ProjectExplorer: Remove RunConfigWidget wrapper class

Not really needed, a QWidget does the job, too, and de-emphasizes
then 'Run' bit. The display name is now taken always from the
aspect, but that's what was the practically the case before,
albeit with different implementations.

Change all names to *[cC]onfigWidget* (in line with ISettingsAspect).

Change-Id: Ida0409a2dd0b175dd5ce4202f9b9e94b3f2db421
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
hjk
2018-09-12 13:40:37 +02:00
parent f66770cde1
commit 35b941462e
13 changed files with 29 additions and 55 deletions

View File

@@ -79,11 +79,6 @@ AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurat
chooseSettings(m_aspect->isUsingGlobalSettings() ? 0 : 1);
}
QString AnalyzerRunConfigWidget::displayName() const
{
return m_aspect->displayName();
}
void AnalyzerRunConfigWidget::chooseSettings(int setting)
{
QTC_ASSERT(m_aspect, return);

View File

@@ -39,15 +39,13 @@ namespace Utils { class DetailsWidget; }
namespace Debugger {
class DEBUGGER_EXPORT AnalyzerRunConfigWidget : public ProjectExplorer::RunConfigWidget
class DEBUGGER_EXPORT AnalyzerRunConfigWidget : public QWidget
{
Q_OBJECT
public:
AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurationAspect *aspect);
QString displayName() const override;
private:
void chooseSettings(int setting);
void restoreGlobal();

View File

@@ -63,13 +63,12 @@ namespace Internal {
//
////////////////////////////////////////////////////////////////////////
class DebuggerRunConfigWidget : public RunConfigWidget
class DebuggerRunConfigWidget : public QWidget
{
Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::RunConfigWidget)
public:
explicit DebuggerRunConfigWidget(DebuggerRunConfigurationAspect *aspect);
QString displayName() const override { return tr("Debugger Settings"); }
void showEvent(QShowEvent *event) override;
void update();
@@ -153,7 +152,7 @@ void DebuggerRunConfigWidget::showEvent(QShowEvent *event)
if (!event->spontaneous())
update();
RunConfigWidget::showEvent(event);
QWidget::showEvent(event);
}
void DebuggerRunConfigWidget::update()
@@ -215,7 +214,7 @@ DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(
{
setId("DebuggerAspect");
setDisplayName(tr("Debugger settings"));
setRunConfigWidgetCreator([this] { return new Internal::DebuggerRunConfigWidget(this); });
setConfigWidgetCreator([this] { return new Internal::DebuggerRunConfigWidget(this); });
}
void DebuggerRunConfigurationAspect::setUseQmlDebugger(bool value)

View File

@@ -44,7 +44,7 @@ EnvironmentAspect::EnvironmentAspect(RunConfiguration *runConfig) :
{
setDisplayName(tr("Run Environment"));
setId("EnvironmentAspect");
setRunConfigWidgetCreator([this] { return new EnvironmentAspectWidget(this); });
setConfigWidgetCreator([this] { return new EnvironmentAspectWidget(this); });
}
int EnvironmentAspect::baseEnvironmentBase() const

View File

@@ -42,7 +42,6 @@ namespace ProjectExplorer {
// --------------------------------------------------------------------
EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWidget *additionalWidget) :
RunConfigWidget(),
m_aspect(aspect),
m_additionalWidget(additionalWidget)
{
@@ -98,11 +97,6 @@ EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWid
this, &EnvironmentAspectWidget::environmentChanged);
}
QString EnvironmentAspectWidget::displayName() const
{
return m_aspect->displayName();
}
EnvironmentAspect *EnvironmentAspectWidget::aspect() const
{
return m_aspect;

View File

@@ -45,14 +45,13 @@ namespace ProjectExplorer {
class EnvironmentWidget;
class PROJECTEXPLORER_EXPORT EnvironmentAspectWidget : public RunConfigWidget
class PROJECTEXPLORER_EXPORT EnvironmentAspectWidget : public QWidget
{
Q_OBJECT
public:
explicit EnvironmentAspectWidget(EnvironmentAspect *aspect, QWidget *additionalWidget = nullptr);
QString displayName() const override;
virtual EnvironmentAspect *aspect() const;
QWidget *additionalWidget() const;

View File

@@ -107,9 +107,9 @@ IRunConfigurationAspect::~IRunConfigurationAspect()
transferred to the caller.
*/
RunConfigWidget *IRunConfigurationAspect::createConfigurationWidget() const
QWidget *IRunConfigurationAspect::createConfigWidget() const
{
return m_runConfigWidgetCreator ? m_runConfigWidgetCreator() : nullptr;
return m_configWidgetCreator ? m_configWidgetCreator() : nullptr;
}
void IRunConfigurationAspect::copyFrom(IRunConfigurationAspect *source)
@@ -159,9 +159,9 @@ void IRunConfigurationAspect::addToConfigurationLayout(QFormLayout *layout)
Q_UNUSED(layout);
}
void IRunConfigurationAspect::setRunConfigWidgetCreator(const RunConfigWidgetCreator &runConfigWidgetCreator)
void IRunConfigurationAspect::setConfigWidgetCreator(const ConfigWidgetCreator &runConfigWidgetCreator)
{
m_runConfigWidgetCreator = runConfigWidgetCreator;
m_configWidgetCreator = runConfigWidgetCreator;
}
void IRunConfigurationAspect::resetProjectToGlobalSettings()

View File

@@ -57,7 +57,6 @@ class Node;
class RunConfigurationFactory;
class RunConfiguration;
class RunConfigurationCreationInfo;
class RunConfigWidget;
class RunControl;
class RunWorkerFactory;
class Target;
@@ -111,9 +110,9 @@ public:
explicit IRunConfigurationAspect(RunConfiguration *runConfig);
~IRunConfigurationAspect() override;
using RunConfigWidgetCreator = std::function<RunConfigWidget *()>;
void setRunConfigWidgetCreator(const RunConfigWidgetCreator &runConfigWidgetCreator);
RunConfigWidget *createConfigurationWidget() const;
using ConfigWidgetCreator = std::function<QWidget *()>;
void setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetCreator);
QWidget *createConfigWidget() const;
void copyFrom(IRunConfigurationAspect *other);
void setId(Core::Id id) { m_id = id; }
@@ -154,7 +153,7 @@ private:
RunConfiguration *m_runConfiguration = nullptr;
ISettingsAspect *m_projectSettings = nullptr; // Owned if present.
ISettingsAspect *m_globalSettings = nullptr; // Not owned.
RunConfigWidgetCreator m_runConfigWidgetCreator;
ConfigWidgetCreator m_configWidgetCreator;
};
class PROJECTEXPLORER_EXPORT Runnable
@@ -353,17 +352,6 @@ private:
const bool m_decorateTargetName;
};
class PROJECTEXPLORER_EXPORT RunConfigWidget : public QWidget
{
Q_OBJECT
public:
virtual QString displayName() const = 0;
signals:
void displayNameChanged(const QString &);
};
class PROJECTEXPLORER_EXPORT RunWorker : public QObject
{
Q_OBJECT

View File

@@ -529,19 +529,21 @@ QString RunSettingsWidget::uniqueRCName(const QString &name)
void RunSettingsWidget::addRunControlWidgets()
{
for (IRunConfigurationAspect *aspect : m_runConfiguration->aspects()) {
if (RunConfigWidget *rcw = aspect->createConfigurationWidget())
addSubWidget(rcw);
if (QWidget *rcw = aspect->createConfigWidget()) {
auto label = new QLabel(this);
label->setText(aspect->displayName());
connect(aspect, &IRunConfigurationAspect::changed, label, [label, aspect] {
label->setText(aspect->displayName());
});
addSubWidget(rcw, label);
}
}
}
void RunSettingsWidget::addSubWidget(RunConfigWidget *widget)
void RunSettingsWidget::addSubWidget(QWidget *widget, QLabel *label)
{
widget->setContentsMargins(0, 10, 0, 0);
auto label = new QLabel(this);
label->setText(widget->displayName());
connect(widget, &RunConfigWidget::displayNameChanged,
label, &QLabel::setText);
QFont f = label->font();
f.setBold(true);
f.setPointSizeF(f.pointSizeF() * 1.2);
@@ -558,8 +560,7 @@ void RunSettingsWidget::addSubWidget(RunConfigWidget *widget)
void RunSettingsWidget::removeSubWidgets()
{
// foreach does not like commas in types, it's only a macro after all
foreach (const RunConfigItem &item, m_subWidgets) {
for (const RunConfigItem &item : m_subWidgets) {
delete item.first;
delete item.second;
}

View File

@@ -77,7 +77,7 @@ private:
void setConfigurationWidget(RunConfiguration *rc);
void addRunControlWidgets();
void addSubWidget(RunConfigWidget *subWidget);
void addSubWidget(QWidget *subWidget, QLabel *label);
void removeSubWidgets();
void updateEnabledState();
@@ -94,7 +94,7 @@ private:
QMenu *m_addRunMenu;
QMenu *m_addDeployMenu;
bool m_ignoreChange = false;
typedef QPair<RunConfigWidget *, QLabel *> RunConfigItem;
typedef QPair<QWidget *, QLabel *> RunConfigItem;
QList<RunConfigItem> m_subWidgets;
QGridLayout *m_gridLayout;

View File

@@ -43,7 +43,7 @@ QmlProfilerRunConfigurationAspect::QmlProfilerRunConfigurationAspect(
setDisplayName(QCoreApplication::translate("QmlProfilerRunConfiguration", "QML Profiler Settings"));
setUsingGlobalSettings(true);
resetProjectToGlobalSettings();
setRunConfigWidgetCreator([this] { return new Debugger::AnalyzerRunConfigWidget(this); });
setConfigWidgetCreator([this] { return new Debugger::AnalyzerRunConfigWidget(this); });
}
} // Internal

View File

@@ -53,7 +53,7 @@ RemoteLinuxEnvironmentAspect::RemoteLinuxEnvironmentAspect(ProjectExplorer::RunC
addSupportedBaseEnvironment(CleanBaseEnvironment, tr("Clean Environment"));
addPreferredBaseEnvironment(RemoteBaseEnvironment, tr("System Environment"));
setRunConfigWidgetCreator([this, rc] {
setConfigWidgetCreator([this, rc] {
return new RemoteLinuxEnvironmentAspectWidget(this, rc->target());
});
}

View File

@@ -102,7 +102,7 @@ public:
"Valgrind Settings"));
setUsingGlobalSettings(true);
resetProjectToGlobalSettings();
setRunConfigWidgetCreator([this] { return new Debugger::AnalyzerRunConfigWidget(this); });
setConfigWidgetCreator([this] { return new Debugger::AnalyzerRunConfigWidget(this); });
}
};