forked from qt-creator/qt-creator
ProjectExlorer: Streamline creation of NamedWidgets
Change-Id: I67c1506ea4e2d7722c9ce38738e350418d725a0e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -81,6 +81,7 @@ static QModelIndex mapToSource(const QAbstractItemView *view, const QModelIndex
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) :
|
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) :
|
||||||
|
NamedWidget(tr("CMake")),
|
||||||
m_buildConfiguration(bc),
|
m_buildConfiguration(bc),
|
||||||
m_configModel(new ConfigModel(this)),
|
m_configModel(new ConfigModel(this)),
|
||||||
m_configFilterModel(new Utils::CategorySortFilterModel),
|
m_configFilterModel(new Utils::CategorySortFilterModel),
|
||||||
@@ -88,8 +89,6 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
|||||||
{
|
{
|
||||||
QTC_CHECK(bc);
|
QTC_CHECK(bc);
|
||||||
|
|
||||||
setDisplayName(tr("CMake"));
|
|
||||||
|
|
||||||
auto vbox = new QVBoxLayout(this);
|
auto vbox = new QVBoxLayout(this);
|
||||||
vbox->setContentsMargins(0, 0, 0, 0);
|
vbox->setContentsMargins(0, 0, 0, 0);
|
||||||
auto container = new Utils::DetailsWidget;
|
auto container = new Utils::DetailsWidget;
|
||||||
|
|||||||
@@ -35,25 +35,10 @@
|
|||||||
#include <projectexplorer/buildsystem.h>
|
#include <projectexplorer/buildsystem.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
|
||||||
|
|
||||||
#include <QFuture>
|
|
||||||
#include <QHash>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace CppTools { class CppProjectUpdater; }
|
|
||||||
namespace ProjectExplorer { class FileNode; }
|
|
||||||
|
|
||||||
namespace CMakeProjectManager {
|
namespace CMakeProjectManager {
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
class CMakeBuildConfiguration;
|
|
||||||
class CMakeBuildSettingsWidget;
|
|
||||||
class CMakeProjectNode;
|
|
||||||
} // namespace Internal
|
|
||||||
|
|
||||||
class CMAKE_EXPORT CMakeProject : public ProjectExplorer::Project
|
class CMAKE_EXPORT CMakeProject : public ProjectExplorer::Project
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
IosBuildSettingsWidget::IosBuildSettingsWidget(IosBuildConfiguration *bc)
|
IosBuildSettingsWidget::IosBuildSettingsWidget(IosBuildConfiguration *bc)
|
||||||
: m_bc(bc),
|
: NamedWidget(IosBuildConfiguration::tr("iOS Settings")),
|
||||||
|
m_bc(bc),
|
||||||
m_isDevice(DeviceTypeKitAspect::deviceTypeId(bc->target()->kit())
|
m_isDevice(DeviceTypeKitAspect::deviceTypeId(bc->target()->kit())
|
||||||
== Constants::IOS_DEVICE_TYPE)
|
== Constants::IOS_DEVICE_TYPE)
|
||||||
{
|
{
|
||||||
@@ -166,8 +167,6 @@ IosBuildSettingsWidget::IosBuildSettingsWidget(IosBuildConfiguration *bc)
|
|||||||
detailsWidget->setState(Utils::DetailsWidget::NoSummary);
|
detailsWidget->setState(Utils::DetailsWidget::NoSummary);
|
||||||
detailsWidget->setWidget(container);
|
detailsWidget->setWidget(container);
|
||||||
|
|
||||||
setDisplayName(IosBuildConfiguration::tr("iOS Settings"));
|
|
||||||
|
|
||||||
if (m_isDevice) {
|
if (m_isDevice) {
|
||||||
connect(IosConfigurations::instance(), &IosConfigurations::provisioningDataChanged,
|
connect(IosConfigurations::instance(), &IosConfigurations::provisioningDataChanged,
|
||||||
this, &IosBuildSettingsWidget::populateDevelopmentTeams);
|
this, &IosBuildSettingsWidget::populateDevelopmentTeams);
|
||||||
|
|||||||
@@ -166,8 +166,7 @@ void BuildConfiguration::setBuildDirectory(const Utils::FilePath &dir)
|
|||||||
|
|
||||||
NamedWidget *BuildConfiguration::createConfigWidget()
|
NamedWidget *BuildConfiguration::createConfigWidget()
|
||||||
{
|
{
|
||||||
NamedWidget *named = new NamedWidget;
|
NamedWidget *named = new NamedWidget(d->m_configWidgetDisplayName);
|
||||||
named->setDisplayName(d->m_configWidgetDisplayName);
|
|
||||||
|
|
||||||
QWidget *widget = nullptr;
|
QWidget *widget = nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -33,10 +33,10 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
BuildEnvironmentWidget::BuildEnvironmentWidget(BuildConfiguration *bc) :
|
BuildEnvironmentWidget::BuildEnvironmentWidget(BuildConfiguration *bc)
|
||||||
m_buildConfiguration(nullptr)
|
: NamedWidget(tr("Build Environment")), m_buildConfiguration(bc)
|
||||||
{
|
{
|
||||||
auto vbox = new QVBoxLayout(this);
|
auto vbox = new QVBoxLayout(this);
|
||||||
vbox->setContentsMargins(0, 0, 0, 0);
|
vbox->setContentsMargins(0, 0, 0, 0);
|
||||||
@@ -52,8 +52,6 @@ BuildEnvironmentWidget::BuildEnvironmentWidget(BuildConfiguration *bc) :
|
|||||||
connect(m_clearSystemEnvironmentCheckBox, &QAbstractButton::toggled,
|
connect(m_clearSystemEnvironmentCheckBox, &QAbstractButton::toggled,
|
||||||
this, &BuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked);
|
this, &BuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked);
|
||||||
|
|
||||||
m_buildConfiguration = bc;
|
|
||||||
|
|
||||||
connect(m_buildConfiguration, &BuildConfiguration::environmentChanged,
|
connect(m_buildConfiguration, &BuildConfiguration::environmentChanged,
|
||||||
this, &BuildEnvironmentWidget::environmentChanged);
|
this, &BuildEnvironmentWidget::environmentChanged);
|
||||||
|
|
||||||
@@ -61,8 +59,6 @@ BuildEnvironmentWidget::BuildEnvironmentWidget(BuildConfiguration *bc) :
|
|||||||
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
|
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
|
||||||
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
|
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
|
||||||
m_buildEnvironmentWidget->setUserChanges(m_buildConfiguration->userEnvironmentChanges());
|
m_buildEnvironmentWidget->setUserChanges(m_buildConfiguration->userEnvironmentChanges());
|
||||||
|
|
||||||
setDisplayName(tr("Build Environment"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildEnvironmentWidget::environmentModelUserChangesChanged()
|
void BuildEnvironmentWidget::environmentModelUserChangesChanged()
|
||||||
@@ -82,3 +78,5 @@ void BuildEnvironmentWidget::environmentChanged()
|
|||||||
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
|
m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment());
|
||||||
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
|
m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // ProjectExplorer
|
||||||
|
|||||||
@@ -143,8 +143,6 @@ void BuildSettingsWidget::addSubWidget(NamedWidget *widget)
|
|||||||
|
|
||||||
auto label = new QLabel(this);
|
auto label = new QLabel(this);
|
||||||
label->setText(widget->displayName());
|
label->setText(widget->displayName());
|
||||||
connect(widget, &NamedWidget::displayNameChanged,
|
|
||||||
label, &QLabel::setText);
|
|
||||||
QFont f = label->font();
|
QFont f = label->font();
|
||||||
f.setBold(true);
|
f.setBold(true);
|
||||||
f.setPointSizeF(f.pointSizeF() * 1.2);
|
f.setPointSizeF(f.pointSizeF() * 1.2);
|
||||||
|
|||||||
@@ -192,7 +192,8 @@ BuildStepsWidgetData::~BuildStepsWidgetData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
BuildStepListWidget::BuildStepListWidget(BuildStepList *bsl, QWidget *parent)
|
BuildStepListWidget::BuildStepListWidget(BuildStepList *bsl, QWidget *parent)
|
||||||
: NamedWidget(parent), m_buildStepList(bsl)
|
//: %1 is the name returned by BuildStepList::displayName
|
||||||
|
: NamedWidget(tr("%1 Steps").arg(bsl->displayName()), parent), m_buildStepList(bsl)
|
||||||
{
|
{
|
||||||
setupUi();
|
setupUi();
|
||||||
|
|
||||||
@@ -200,9 +201,6 @@ BuildStepListWidget::BuildStepListWidget(BuildStepList *bsl, QWidget *parent)
|
|||||||
connect(bsl, &BuildStepList::stepRemoved, this, &BuildStepListWidget::removeBuildStep);
|
connect(bsl, &BuildStepList::stepRemoved, this, &BuildStepListWidget::removeBuildStep);
|
||||||
connect(bsl, &BuildStepList::stepMoved, this, &BuildStepListWidget::stepMoved);
|
connect(bsl, &BuildStepList::stepMoved, this, &BuildStepListWidget::stepMoved);
|
||||||
|
|
||||||
//: %1 is the name returned by BuildStepList::displayName
|
|
||||||
setDisplayName(tr("%1 Steps").arg(bsl->displayName()));
|
|
||||||
|
|
||||||
for (int i = 0; i < bsl->count(); ++i) {
|
for (int i = 0; i < bsl->count(); ++i) {
|
||||||
addBuildStep(i);
|
addBuildStep(i);
|
||||||
// addBuilStep expands the config widget by default, which we don't want here
|
// addBuilStep expands the config widget by default, which we don't want here
|
||||||
|
|||||||
@@ -25,24 +25,16 @@
|
|||||||
|
|
||||||
#include "namedwidget.h"
|
#include "namedwidget.h"
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
///
|
NamedWidget::NamedWidget(const QString &displayName, QWidget *parent)
|
||||||
// NamedWidget
|
: QWidget(parent), m_displayName(displayName)
|
||||||
///
|
{
|
||||||
|
}
|
||||||
NamedWidget::NamedWidget(QWidget *parent) : QWidget(parent)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
QString NamedWidget::displayName() const
|
QString NamedWidget::displayName() const
|
||||||
{
|
{
|
||||||
return m_displayName;
|
return m_displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NamedWidget::setDisplayName(const QString &displayName)
|
} // ProjectExplorer
|
||||||
{
|
|
||||||
if (m_displayName == displayName)
|
|
||||||
return;
|
|
||||||
m_displayName = displayName;
|
|
||||||
emit displayNameChanged(m_displayName);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -33,16 +33,10 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT NamedWidget : public QWidget
|
class PROJECTEXPLORER_EXPORT NamedWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NamedWidget(QWidget *parent = nullptr);
|
explicit NamedWidget(const QString &displayName, QWidget *parent = nullptr);
|
||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
void setDisplayName(const QString &displayName);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void displayNameChanged(const QString &);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ class BuildSystem;
|
|||||||
class ContainerNode;
|
class ContainerNode;
|
||||||
class EditorConfiguration;
|
class EditorConfiguration;
|
||||||
class FolderNode;
|
class FolderNode;
|
||||||
class NamedWidget;
|
|
||||||
class Node;
|
class Node;
|
||||||
class ProjectConfiguration;
|
class ProjectConfiguration;
|
||||||
class ProjectImporter;
|
class ProjectImporter;
|
||||||
|
|||||||
@@ -39,9 +39,7 @@ QT_END_NAMESPACE
|
|||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class DeployConfiguration;
|
class DeployConfiguration;
|
||||||
class NamedWidget;
|
|
||||||
class RunConfiguration;
|
class RunConfiguration;
|
||||||
class RunConfigWidget;
|
|
||||||
class Target;
|
class Target;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ static bool isShadowBuild(BuildConfiguration *bc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QmakeProjectConfigWidget::QmakeProjectConfigWidget(QmakeBuildConfiguration *bc)
|
QmakeProjectConfigWidget::QmakeProjectConfigWidget(QmakeBuildConfiguration *bc)
|
||||||
: NamedWidget(),
|
: NamedWidget(tr("General")),
|
||||||
m_buildConfiguration(bc)
|
m_buildConfiguration(bc)
|
||||||
{
|
{
|
||||||
Project *project = bc->target()->project();
|
Project *project = bc->target()->project();
|
||||||
@@ -164,8 +164,6 @@ QmakeProjectConfigWidget::QmakeProjectConfigWidget(QmakeBuildConfiguration *bc)
|
|||||||
connect(m_buildConfiguration, &QmakeBuildConfiguration::qmakeBuildConfigurationChanged,
|
connect(m_buildConfiguration, &QmakeBuildConfiguration::qmakeBuildConfigurationChanged,
|
||||||
this, &QmakeProjectConfigWidget::updateProblemLabel);
|
this, &QmakeProjectConfigWidget::updateProblemLabel);
|
||||||
|
|
||||||
setDisplayName(tr("General"));
|
|
||||||
|
|
||||||
updateDetails();
|
updateDetails();
|
||||||
updateProblemLabel();
|
updateProblemLabel();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user