forked from qt-creator/qt-creator
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:
@@ -79,11 +79,6 @@ AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurat
|
|||||||
chooseSettings(m_aspect->isUsingGlobalSettings() ? 0 : 1);
|
chooseSettings(m_aspect->isUsingGlobalSettings() ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AnalyzerRunConfigWidget::displayName() const
|
|
||||||
{
|
|
||||||
return m_aspect->displayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnalyzerRunConfigWidget::chooseSettings(int setting)
|
void AnalyzerRunConfigWidget::chooseSettings(int setting)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_aspect, return);
|
QTC_ASSERT(m_aspect, return);
|
||||||
|
|||||||
@@ -39,15 +39,13 @@ namespace Utils { class DetailsWidget; }
|
|||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|
||||||
class DEBUGGER_EXPORT AnalyzerRunConfigWidget : public ProjectExplorer::RunConfigWidget
|
class DEBUGGER_EXPORT AnalyzerRunConfigWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurationAspect *aspect);
|
AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurationAspect *aspect);
|
||||||
|
|
||||||
QString displayName() const override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void chooseSettings(int setting);
|
void chooseSettings(int setting);
|
||||||
void restoreGlobal();
|
void restoreGlobal();
|
||||||
|
|||||||
@@ -63,13 +63,12 @@ namespace Internal {
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class DebuggerRunConfigWidget : public RunConfigWidget
|
class DebuggerRunConfigWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::RunConfigWidget)
|
Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::RunConfigWidget)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DebuggerRunConfigWidget(DebuggerRunConfigurationAspect *aspect);
|
explicit DebuggerRunConfigWidget(DebuggerRunConfigurationAspect *aspect);
|
||||||
QString displayName() const override { return tr("Debugger Settings"); }
|
|
||||||
|
|
||||||
void showEvent(QShowEvent *event) override;
|
void showEvent(QShowEvent *event) override;
|
||||||
void update();
|
void update();
|
||||||
@@ -153,7 +152,7 @@ void DebuggerRunConfigWidget::showEvent(QShowEvent *event)
|
|||||||
if (!event->spontaneous())
|
if (!event->spontaneous())
|
||||||
update();
|
update();
|
||||||
|
|
||||||
RunConfigWidget::showEvent(event);
|
QWidget::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunConfigWidget::update()
|
void DebuggerRunConfigWidget::update()
|
||||||
@@ -215,7 +214,7 @@ DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(
|
|||||||
{
|
{
|
||||||
setId("DebuggerAspect");
|
setId("DebuggerAspect");
|
||||||
setDisplayName(tr("Debugger settings"));
|
setDisplayName(tr("Debugger settings"));
|
||||||
setRunConfigWidgetCreator([this] { return new Internal::DebuggerRunConfigWidget(this); });
|
setConfigWidgetCreator([this] { return new Internal::DebuggerRunConfigWidget(this); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerRunConfigurationAspect::setUseQmlDebugger(bool value)
|
void DebuggerRunConfigurationAspect::setUseQmlDebugger(bool value)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ EnvironmentAspect::EnvironmentAspect(RunConfiguration *runConfig) :
|
|||||||
{
|
{
|
||||||
setDisplayName(tr("Run Environment"));
|
setDisplayName(tr("Run Environment"));
|
||||||
setId("EnvironmentAspect");
|
setId("EnvironmentAspect");
|
||||||
setRunConfigWidgetCreator([this] { return new EnvironmentAspectWidget(this); });
|
setConfigWidgetCreator([this] { return new EnvironmentAspectWidget(this); });
|
||||||
}
|
}
|
||||||
|
|
||||||
int EnvironmentAspect::baseEnvironmentBase() const
|
int EnvironmentAspect::baseEnvironmentBase() const
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ namespace ProjectExplorer {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWidget *additionalWidget) :
|
EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWidget *additionalWidget) :
|
||||||
RunConfigWidget(),
|
|
||||||
m_aspect(aspect),
|
m_aspect(aspect),
|
||||||
m_additionalWidget(additionalWidget)
|
m_additionalWidget(additionalWidget)
|
||||||
{
|
{
|
||||||
@@ -98,11 +97,6 @@ EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWid
|
|||||||
this, &EnvironmentAspectWidget::environmentChanged);
|
this, &EnvironmentAspectWidget::environmentChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString EnvironmentAspectWidget::displayName() const
|
|
||||||
{
|
|
||||||
return m_aspect->displayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
EnvironmentAspect *EnvironmentAspectWidget::aspect() const
|
EnvironmentAspect *EnvironmentAspectWidget::aspect() const
|
||||||
{
|
{
|
||||||
return m_aspect;
|
return m_aspect;
|
||||||
|
|||||||
@@ -45,14 +45,13 @@ namespace ProjectExplorer {
|
|||||||
|
|
||||||
class EnvironmentWidget;
|
class EnvironmentWidget;
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT EnvironmentAspectWidget : public RunConfigWidget
|
class PROJECTEXPLORER_EXPORT EnvironmentAspectWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EnvironmentAspectWidget(EnvironmentAspect *aspect, QWidget *additionalWidget = nullptr);
|
explicit EnvironmentAspectWidget(EnvironmentAspect *aspect, QWidget *additionalWidget = nullptr);
|
||||||
|
|
||||||
QString displayName() const override;
|
|
||||||
virtual EnvironmentAspect *aspect() const;
|
virtual EnvironmentAspect *aspect() const;
|
||||||
|
|
||||||
QWidget *additionalWidget() const;
|
QWidget *additionalWidget() const;
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ IRunConfigurationAspect::~IRunConfigurationAspect()
|
|||||||
transferred to the caller.
|
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)
|
void IRunConfigurationAspect::copyFrom(IRunConfigurationAspect *source)
|
||||||
@@ -159,9 +159,9 @@ void IRunConfigurationAspect::addToConfigurationLayout(QFormLayout *layout)
|
|||||||
Q_UNUSED(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()
|
void IRunConfigurationAspect::resetProjectToGlobalSettings()
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ class Node;
|
|||||||
class RunConfigurationFactory;
|
class RunConfigurationFactory;
|
||||||
class RunConfiguration;
|
class RunConfiguration;
|
||||||
class RunConfigurationCreationInfo;
|
class RunConfigurationCreationInfo;
|
||||||
class RunConfigWidget;
|
|
||||||
class RunControl;
|
class RunControl;
|
||||||
class RunWorkerFactory;
|
class RunWorkerFactory;
|
||||||
class Target;
|
class Target;
|
||||||
@@ -111,9 +110,9 @@ public:
|
|||||||
explicit IRunConfigurationAspect(RunConfiguration *runConfig);
|
explicit IRunConfigurationAspect(RunConfiguration *runConfig);
|
||||||
~IRunConfigurationAspect() override;
|
~IRunConfigurationAspect() override;
|
||||||
|
|
||||||
using RunConfigWidgetCreator = std::function<RunConfigWidget *()>;
|
using ConfigWidgetCreator = std::function<QWidget *()>;
|
||||||
void setRunConfigWidgetCreator(const RunConfigWidgetCreator &runConfigWidgetCreator);
|
void setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetCreator);
|
||||||
RunConfigWidget *createConfigurationWidget() const;
|
QWidget *createConfigWidget() const;
|
||||||
void copyFrom(IRunConfigurationAspect *other);
|
void copyFrom(IRunConfigurationAspect *other);
|
||||||
|
|
||||||
void setId(Core::Id id) { m_id = id; }
|
void setId(Core::Id id) { m_id = id; }
|
||||||
@@ -154,7 +153,7 @@ private:
|
|||||||
RunConfiguration *m_runConfiguration = nullptr;
|
RunConfiguration *m_runConfiguration = nullptr;
|
||||||
ISettingsAspect *m_projectSettings = nullptr; // Owned if present.
|
ISettingsAspect *m_projectSettings = nullptr; // Owned if present.
|
||||||
ISettingsAspect *m_globalSettings = nullptr; // Not owned.
|
ISettingsAspect *m_globalSettings = nullptr; // Not owned.
|
||||||
RunConfigWidgetCreator m_runConfigWidgetCreator;
|
ConfigWidgetCreator m_configWidgetCreator;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT Runnable
|
class PROJECTEXPLORER_EXPORT Runnable
|
||||||
@@ -353,17 +352,6 @@ private:
|
|||||||
const bool m_decorateTargetName;
|
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
|
class PROJECTEXPLORER_EXPORT RunWorker : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -529,19 +529,21 @@ QString RunSettingsWidget::uniqueRCName(const QString &name)
|
|||||||
void RunSettingsWidget::addRunControlWidgets()
|
void RunSettingsWidget::addRunControlWidgets()
|
||||||
{
|
{
|
||||||
for (IRunConfigurationAspect *aspect : m_runConfiguration->aspects()) {
|
for (IRunConfigurationAspect *aspect : m_runConfiguration->aspects()) {
|
||||||
if (RunConfigWidget *rcw = aspect->createConfigurationWidget())
|
if (QWidget *rcw = aspect->createConfigWidget()) {
|
||||||
addSubWidget(rcw);
|
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);
|
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();
|
QFont f = label->font();
|
||||||
f.setBold(true);
|
f.setBold(true);
|
||||||
f.setPointSizeF(f.pointSizeF() * 1.2);
|
f.setPointSizeF(f.pointSizeF() * 1.2);
|
||||||
@@ -558,8 +560,7 @@ void RunSettingsWidget::addSubWidget(RunConfigWidget *widget)
|
|||||||
|
|
||||||
void RunSettingsWidget::removeSubWidgets()
|
void RunSettingsWidget::removeSubWidgets()
|
||||||
{
|
{
|
||||||
// foreach does not like commas in types, it's only a macro after all
|
for (const RunConfigItem &item : m_subWidgets) {
|
||||||
foreach (const RunConfigItem &item, m_subWidgets) {
|
|
||||||
delete item.first;
|
delete item.first;
|
||||||
delete item.second;
|
delete item.second;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ private:
|
|||||||
void setConfigurationWidget(RunConfiguration *rc);
|
void setConfigurationWidget(RunConfiguration *rc);
|
||||||
|
|
||||||
void addRunControlWidgets();
|
void addRunControlWidgets();
|
||||||
void addSubWidget(RunConfigWidget *subWidget);
|
void addSubWidget(QWidget *subWidget, QLabel *label);
|
||||||
void removeSubWidgets();
|
void removeSubWidgets();
|
||||||
|
|
||||||
void updateEnabledState();
|
void updateEnabledState();
|
||||||
@@ -94,7 +94,7 @@ private:
|
|||||||
QMenu *m_addRunMenu;
|
QMenu *m_addRunMenu;
|
||||||
QMenu *m_addDeployMenu;
|
QMenu *m_addDeployMenu;
|
||||||
bool m_ignoreChange = false;
|
bool m_ignoreChange = false;
|
||||||
typedef QPair<RunConfigWidget *, QLabel *> RunConfigItem;
|
typedef QPair<QWidget *, QLabel *> RunConfigItem;
|
||||||
QList<RunConfigItem> m_subWidgets;
|
QList<RunConfigItem> m_subWidgets;
|
||||||
|
|
||||||
QGridLayout *m_gridLayout;
|
QGridLayout *m_gridLayout;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ QmlProfilerRunConfigurationAspect::QmlProfilerRunConfigurationAspect(
|
|||||||
setDisplayName(QCoreApplication::translate("QmlProfilerRunConfiguration", "QML Profiler Settings"));
|
setDisplayName(QCoreApplication::translate("QmlProfilerRunConfiguration", "QML Profiler Settings"));
|
||||||
setUsingGlobalSettings(true);
|
setUsingGlobalSettings(true);
|
||||||
resetProjectToGlobalSettings();
|
resetProjectToGlobalSettings();
|
||||||
setRunConfigWidgetCreator([this] { return new Debugger::AnalyzerRunConfigWidget(this); });
|
setConfigWidgetCreator([this] { return new Debugger::AnalyzerRunConfigWidget(this); });
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ RemoteLinuxEnvironmentAspect::RemoteLinuxEnvironmentAspect(ProjectExplorer::RunC
|
|||||||
addSupportedBaseEnvironment(CleanBaseEnvironment, tr("Clean Environment"));
|
addSupportedBaseEnvironment(CleanBaseEnvironment, tr("Clean Environment"));
|
||||||
addPreferredBaseEnvironment(RemoteBaseEnvironment, tr("System Environment"));
|
addPreferredBaseEnvironment(RemoteBaseEnvironment, tr("System Environment"));
|
||||||
|
|
||||||
setRunConfigWidgetCreator([this, rc] {
|
setConfigWidgetCreator([this, rc] {
|
||||||
return new RemoteLinuxEnvironmentAspectWidget(this, rc->target());
|
return new RemoteLinuxEnvironmentAspectWidget(this, rc->target());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
"Valgrind Settings"));
|
"Valgrind Settings"));
|
||||||
setUsingGlobalSettings(true);
|
setUsingGlobalSettings(true);
|
||||||
resetProjectToGlobalSettings();
|
resetProjectToGlobalSettings();
|
||||||
setRunConfigWidgetCreator([this] { return new Debugger::AnalyzerRunConfigWidget(this); });
|
setConfigWidgetCreator([this] { return new Debugger::AnalyzerRunConfigWidget(this); });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user