forked from qt-creator/qt-creator
ProjectExplorer: Split IRunConfigurationAspect
... into items that can be used generically in project configurations (ProjectConfigurationAspect) and items that have a choice between global and project settings (GlobalOrProjectAspect) Change-Id: I94831237bdbb18c339eb76eba131bf7f928933d6 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
namespace Android {
|
namespace Android {
|
||||||
|
|
||||||
class BaseStringListAspect : public ProjectExplorer::IRunConfigurationAspect
|
class BaseStringListAspect : public ProjectExplorer::ProjectConfigurationAspect
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
|
||||||
AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurationAspect *aspect)
|
AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::GlobalOrProjectAspect *aspect)
|
||||||
{
|
{
|
||||||
m_aspect = aspect;
|
m_aspect = aspect;
|
||||||
|
|
||||||
|
|||||||
@@ -44,14 +44,14 @@ class DEBUGGER_EXPORT AnalyzerRunConfigWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurationAspect *aspect);
|
AnalyzerRunConfigWidget(ProjectExplorer::GlobalOrProjectAspect *aspect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void chooseSettings(int setting);
|
void chooseSettings(int setting);
|
||||||
void restoreGlobal();
|
void restoreGlobal();
|
||||||
|
|
||||||
QWidget *m_configWidget;
|
QWidget *m_configWidget;
|
||||||
ProjectExplorer::IRunConfigurationAspect *m_aspect;
|
ProjectExplorer::GlobalOrProjectAspect *m_aspect;
|
||||||
QComboBox *m_settingsCombo;
|
QComboBox *m_settingsCombo;
|
||||||
QPushButton *m_restoreButton;
|
QPushButton *m_restoreButton;
|
||||||
Utils::DetailsWidget *m_details;
|
Utils::DetailsWidget *m_details;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class DEBUGGER_EXPORT DebuggerRunConfigurationAspect
|
class DEBUGGER_EXPORT DebuggerRunConfigurationAspect
|
||||||
: public ProjectExplorer::IRunConfigurationAspect
|
: public ProjectExplorer::GlobalOrProjectAspect
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,13 @@ const char CUSTOM_EXECUTABLE_ID[] = "ProjectExplorer.CustomExecutableRunConfigur
|
|||||||
|
|
||||||
// Dialog prompting the user to complete the configuration.
|
// Dialog prompting the user to complete the configuration.
|
||||||
|
|
||||||
|
static void copyAspect(ProjectConfigurationAspect *source, ProjectConfigurationAspect *target)
|
||||||
|
{
|
||||||
|
QVariantMap data;
|
||||||
|
source->toMap(data);
|
||||||
|
target->fromMap(data);
|
||||||
|
}
|
||||||
|
|
||||||
class CustomExecutableDialog : public QDialog
|
class CustomExecutableDialog : public QDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -119,13 +126,13 @@ CustomExecutableDialog::CustomExecutableDialog(RunConfiguration *rc)
|
|||||||
connect(m_executableChooser, &PathChooser::rawPathChanged,
|
connect(m_executableChooser, &PathChooser::rawPathChanged,
|
||||||
this, &CustomExecutableDialog::changed);
|
this, &CustomExecutableDialog::changed);
|
||||||
|
|
||||||
m_arguments.copyFrom(rc->extraAspect<ArgumentsAspect>());
|
copyAspect(rc->extraAspect<ArgumentsAspect>(), &m_arguments);
|
||||||
m_arguments.addToConfigurationLayout(layout);
|
m_arguments.addToConfigurationLayout(layout);
|
||||||
|
|
||||||
m_workingDirectory.copyFrom(rc->extraAspect<WorkingDirectoryAspect>());
|
copyAspect(rc->extraAspect<WorkingDirectoryAspect>(), &m_workingDirectory);
|
||||||
m_workingDirectory.addToConfigurationLayout(layout);
|
m_workingDirectory.addToConfigurationLayout(layout);
|
||||||
|
|
||||||
m_terminal.copyFrom(rc->extraAspect<TerminalAspect>());
|
copyAspect(rc->extraAspect<TerminalAspect>(), &m_terminal);
|
||||||
m_terminal.addToConfigurationLayout(layout);
|
m_terminal.addToConfigurationLayout(layout);
|
||||||
|
|
||||||
auto enviromentAspect = rc->extraAspect<EnvironmentAspect>();
|
auto enviromentAspect = rc->extraAspect<EnvironmentAspect>();
|
||||||
@@ -140,9 +147,9 @@ void CustomExecutableDialog::accept()
|
|||||||
{
|
{
|
||||||
auto executable = FileName::fromString(m_executableChooser->path());
|
auto executable = FileName::fromString(m_executableChooser->path());
|
||||||
m_rc->extraAspect<ExecutableAspect>()->setExecutable(executable);
|
m_rc->extraAspect<ExecutableAspect>()->setExecutable(executable);
|
||||||
m_rc->extraAspect<ArgumentsAspect>()->copyFrom(&m_arguments);
|
copyAspect(&m_arguments, m_rc->extraAspect<ArgumentsAspect>());
|
||||||
m_rc->extraAspect<WorkingDirectoryAspect>()->copyFrom(&m_workingDirectory);
|
copyAspect(&m_workingDirectory, m_rc->extraAspect<WorkingDirectoryAspect>());
|
||||||
m_rc->extraAspect<TerminalAspect>()->copyFrom(&m_terminal);
|
copyAspect(&m_terminal, m_rc->extraAspect<TerminalAspect>());
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT EnvironmentAspect : public IRunConfigurationAspect
|
class PROJECTEXPLORER_EXPORT EnvironmentAspect : public ProjectConfigurationAspect
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "projectconfiguration.h"
|
#include "projectconfiguration.h"
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
@@ -33,6 +34,26 @@ const char CONFIGURATION_ID_KEY[] = "ProjectExplorer.ProjectConfiguration.Id";
|
|||||||
const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayName";
|
const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayName";
|
||||||
const char DEFAULT_DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName";
|
const char DEFAULT_DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName";
|
||||||
|
|
||||||
|
// ProjectConfigurationAspect
|
||||||
|
|
||||||
|
ProjectConfigurationAspect::ProjectConfigurationAspect() = default;
|
||||||
|
|
||||||
|
ProjectConfigurationAspect::~ProjectConfigurationAspect() = default;
|
||||||
|
|
||||||
|
void ProjectConfigurationAspect::setConfigWidgetCreator
|
||||||
|
(const ConfigWidgetCreator &configWidgetCreator)
|
||||||
|
{
|
||||||
|
m_configWidgetCreator = configWidgetCreator;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *ProjectConfigurationAspect::createConfigWidget() const
|
||||||
|
{
|
||||||
|
return m_configWidgetCreator ? m_configWidgetCreator() : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ProjectConfiguration
|
||||||
|
|
||||||
ProjectConfiguration::ProjectConfiguration(QObject *parent, Core::Id id)
|
ProjectConfiguration::ProjectConfiguration(QObject *parent, Core::Id id)
|
||||||
: QObject(parent), m_id(id)
|
: QObject(parent), m_id(id)
|
||||||
{
|
{
|
||||||
@@ -40,6 +61,11 @@ ProjectConfiguration::ProjectConfiguration(QObject *parent, Core::Id id)
|
|||||||
setObjectName(id.toString());
|
setObjectName(id.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProjectConfiguration::~ProjectConfiguration()
|
||||||
|
{
|
||||||
|
qDeleteAll(m_aspects);
|
||||||
|
}
|
||||||
|
|
||||||
Core::Id ProjectConfiguration::id() const
|
Core::Id ProjectConfiguration::id() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
@@ -103,6 +129,10 @@ QVariantMap ProjectConfiguration::toMap() const
|
|||||||
map.insert(QLatin1String(CONFIGURATION_ID_KEY), m_id.toSetting());
|
map.insert(QLatin1String(CONFIGURATION_ID_KEY), m_id.toSetting());
|
||||||
map.insert(QLatin1String(DISPLAY_NAME_KEY), m_displayName);
|
map.insert(QLatin1String(DISPLAY_NAME_KEY), m_displayName);
|
||||||
map.insert(QLatin1String(DEFAULT_DISPLAY_NAME_KEY), m_defaultDisplayName);
|
map.insert(QLatin1String(DEFAULT_DISPLAY_NAME_KEY), m_defaultDisplayName);
|
||||||
|
|
||||||
|
for (const auto &aspect : m_aspects)
|
||||||
|
aspect->toMap(map);
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,14 +147,25 @@ bool ProjectConfiguration::fromMap(const QVariantMap &map)
|
|||||||
m_defaultDisplayName = map.value(QLatin1String(DEFAULT_DISPLAY_NAME_KEY),
|
m_defaultDisplayName = map.value(QLatin1String(DEFAULT_DISPLAY_NAME_KEY),
|
||||||
m_defaultDisplayName.isEmpty() ?
|
m_defaultDisplayName.isEmpty() ?
|
||||||
m_displayName : m_defaultDisplayName).toString();
|
m_displayName : m_defaultDisplayName).toString();
|
||||||
|
|
||||||
|
for (const auto &aspect : qAsConst(m_aspects))
|
||||||
|
aspect->fromMap(map);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProjectConfigurationAspect *ProjectConfiguration::extraAspect(Core::Id id) const
|
||||||
|
{
|
||||||
|
return Utils::findOrDefault(m_aspects, Utils::equal(&ProjectConfigurationAspect::id, id));
|
||||||
|
}
|
||||||
|
|
||||||
Core::Id ProjectExplorer::idFromMap(const QVariantMap &map)
|
Core::Id ProjectExplorer::idFromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
return Core::Id::fromSetting(map.value(QLatin1String(CONFIGURATION_ID_KEY)));
|
return Core::Id::fromSetting(map.value(QLatin1String(CONFIGURATION_ID_KEY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StatefulProjectConfiguration
|
||||||
|
|
||||||
bool StatefulProjectConfiguration::isEnabled() const
|
bool StatefulProjectConfiguration::isEnabled() const
|
||||||
{
|
{
|
||||||
return m_isEnabled;
|
return m_isEnabled;
|
||||||
|
|||||||
@@ -34,10 +34,52 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QFormLayout;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class Project;
|
class Project;
|
||||||
|
|
||||||
|
class PROJECTEXPLORER_EXPORT ProjectConfigurationAspect : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ProjectConfigurationAspect();
|
||||||
|
~ProjectConfigurationAspect() override;
|
||||||
|
|
||||||
|
void setId(Core::Id id) { m_id = id; }
|
||||||
|
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
||||||
|
void setSettingsKey(const QString &settingsKey) { m_settingsKey = settingsKey; }
|
||||||
|
|
||||||
|
Core::Id id() const { return m_id; }
|
||||||
|
QString displayName() const { return m_displayName; }
|
||||||
|
QString settingsKey() const { return m_settingsKey; }
|
||||||
|
|
||||||
|
bool isVisible() const { return m_visible; }
|
||||||
|
void setVisible(bool visible) { m_visible = visible; }
|
||||||
|
|
||||||
|
using ConfigWidgetCreator = std::function<QWidget *()>;
|
||||||
|
void setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetCreator);
|
||||||
|
QWidget *createConfigWidget() const;
|
||||||
|
|
||||||
|
virtual void fromMap(const QVariantMap &) {}
|
||||||
|
virtual void toMap(QVariantMap &) const {}
|
||||||
|
virtual void addToConfigurationLayout(QFormLayout *) {}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void changed();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Core::Id m_id;
|
||||||
|
QString m_displayName;
|
||||||
|
QString m_settingsKey; // Name of data in settings.
|
||||||
|
bool m_visible = true;
|
||||||
|
ConfigWidgetCreator m_configWidgetCreator;
|
||||||
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT ProjectConfiguration : public QObject
|
class PROJECTEXPLORER_EXPORT ProjectConfiguration : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -46,7 +88,7 @@ protected:
|
|||||||
explicit ProjectConfiguration(QObject *parent, Core::Id id);
|
explicit ProjectConfiguration(QObject *parent, Core::Id id);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~ProjectConfiguration() override = default;
|
~ProjectConfiguration() override;
|
||||||
|
|
||||||
Core::Id id() const;
|
Core::Id id() const;
|
||||||
|
|
||||||
@@ -74,10 +116,33 @@ public:
|
|||||||
|
|
||||||
static QString settingsIdKey();
|
static QString settingsIdKey();
|
||||||
|
|
||||||
|
template<class Aspect, typename ...Args>
|
||||||
|
Aspect *addAspect(Args && ...args)
|
||||||
|
{
|
||||||
|
auto aspect = new Aspect(args...);
|
||||||
|
m_aspects.append(aspect);
|
||||||
|
return aspect;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<ProjectConfigurationAspect *> aspects() const { return m_aspects; }
|
||||||
|
|
||||||
|
ProjectConfigurationAspect *extraAspect(Core::Id id) const;
|
||||||
|
|
||||||
|
template <typename T> T *extraAspect() const
|
||||||
|
{
|
||||||
|
for (ProjectConfigurationAspect *aspect : m_aspects)
|
||||||
|
if (T *result = qobject_cast<T *>(aspect))
|
||||||
|
return result;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void displayNameChanged();
|
void displayNameChanged();
|
||||||
void toolTipChanged();
|
void toolTipChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QList<ProjectConfigurationAspect *> m_aspects;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Core::Id m_id;
|
const Core::Id m_id;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
|
|||||||
@@ -93,76 +93,48 @@ QWidget *ISettingsAspect::createConfigWidget() const
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
IRunConfigurationAspect::IRunConfigurationAspect() = default;
|
GlobalOrProjectAspect::GlobalOrProjectAspect() = default;
|
||||||
|
|
||||||
IRunConfigurationAspect::~IRunConfigurationAspect()
|
GlobalOrProjectAspect::~GlobalOrProjectAspect()
|
||||||
{
|
{
|
||||||
delete m_projectSettings;
|
delete m_projectSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
void GlobalOrProjectAspect::setProjectSettings(ISettingsAspect *settings)
|
||||||
Returns the widget used to configure this run configuration. Ownership is
|
|
||||||
transferred to the caller.
|
|
||||||
*/
|
|
||||||
|
|
||||||
QWidget *IRunConfigurationAspect::createConfigWidget() const
|
|
||||||
{
|
|
||||||
return m_configWidgetCreator ? m_configWidgetCreator() : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IRunConfigurationAspect::copyFrom(IRunConfigurationAspect *source)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(source, return);
|
|
||||||
QVariantMap data;
|
|
||||||
source->toMap(data);
|
|
||||||
fromMap(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IRunConfigurationAspect::setProjectSettings(ISettingsAspect *settings)
|
|
||||||
{
|
{
|
||||||
m_projectSettings = settings;
|
m_projectSettings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRunConfigurationAspect::setGlobalSettings(ISettingsAspect *settings)
|
void GlobalOrProjectAspect::setGlobalSettings(ISettingsAspect *settings)
|
||||||
{
|
{
|
||||||
m_globalSettings = settings;
|
m_globalSettings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRunConfigurationAspect::setUsingGlobalSettings(bool value)
|
void GlobalOrProjectAspect::setUsingGlobalSettings(bool value)
|
||||||
{
|
{
|
||||||
m_useGlobalSettings = value;
|
m_useGlobalSettings = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISettingsAspect *IRunConfigurationAspect::currentSettings() const
|
ISettingsAspect *GlobalOrProjectAspect::currentSettings() const
|
||||||
{
|
{
|
||||||
return m_useGlobalSettings ? m_globalSettings : m_projectSettings;
|
return m_useGlobalSettings ? m_globalSettings : m_projectSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRunConfigurationAspect::fromMap(const QVariantMap &map)
|
void GlobalOrProjectAspect::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
if (m_projectSettings)
|
if (m_projectSettings)
|
||||||
m_projectSettings->fromMap(map);
|
m_projectSettings->fromMap(map);
|
||||||
m_useGlobalSettings = map.value(m_id.toString() + QLatin1String(".UseGlobalSettings"), true).toBool();
|
m_useGlobalSettings = map.value(m_id.toString() + QLatin1String(".UseGlobalSettings"), true).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRunConfigurationAspect::toMap(QVariantMap &map) const
|
void GlobalOrProjectAspect::toMap(QVariantMap &map) const
|
||||||
{
|
{
|
||||||
if (m_projectSettings)
|
if (m_projectSettings)
|
||||||
m_projectSettings->toMap(map);
|
m_projectSettings->toMap(map);
|
||||||
map.insert(m_id.toString() + QLatin1String(".UseGlobalSettings"), m_useGlobalSettings);
|
map.insert(m_id.toString() + QLatin1String(".UseGlobalSettings"), m_useGlobalSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRunConfigurationAspect::addToConfigurationLayout(QFormLayout *layout)
|
void GlobalOrProjectAspect::resetProjectToGlobalSettings()
|
||||||
{
|
|
||||||
Q_UNUSED(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IRunConfigurationAspect::setConfigWidgetCreator(const ConfigWidgetCreator &runConfigWidgetCreator)
|
|
||||||
{
|
|
||||||
m_configWidgetCreator = runConfigWidgetCreator;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IRunConfigurationAspect::resetProjectToGlobalSettings()
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_globalSettings, return);
|
QTC_ASSERT(m_globalSettings, return);
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
@@ -232,10 +204,7 @@ RunConfiguration::RunConfiguration(Target *target, Core::Id id)
|
|||||||
m_aspects.append(factory(target));
|
m_aspects.append(factory(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
RunConfiguration::~RunConfiguration()
|
RunConfiguration::~RunConfiguration() = default;
|
||||||
{
|
|
||||||
qDeleteAll(m_aspects);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RunConfiguration::isActive() const
|
bool RunConfiguration::isActive() const
|
||||||
{
|
{
|
||||||
@@ -256,8 +225,8 @@ QWidget *RunConfiguration::createConfigurationWidget()
|
|||||||
auto widget = new QWidget;
|
auto widget = new QWidget;
|
||||||
auto formLayout = new QFormLayout(widget);
|
auto formLayout = new QFormLayout(widget);
|
||||||
|
|
||||||
for (IRunConfigurationAspect *aspect : m_aspects) {
|
for (ProjectConfigurationAspect *aspect : m_aspects) {
|
||||||
if (aspect->m_visible)
|
if (aspect->isVisible())
|
||||||
aspect->addToConfigurationLayout(formLayout);
|
aspect->addToConfigurationLayout(formLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,8 +313,6 @@ QVariantMap RunConfiguration::toMap() const
|
|||||||
const Core::Id mangled = id().withSuffix(m_buildKey);
|
const Core::Id mangled = id().withSuffix(m_buildKey);
|
||||||
map.insert(settingsIdKey(), mangled.toSetting());
|
map.insert(settingsIdKey(), mangled.toSetting());
|
||||||
}
|
}
|
||||||
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
|
||||||
aspect->toMap(map);
|
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@@ -375,9 +342,6 @@ bool RunConfiguration::fromMap(const QVariantMap &map)
|
|||||||
const Core::Id mangledId = Core::Id::fromSetting(map.value(settingsIdKey()));
|
const Core::Id mangledId = Core::Id::fromSetting(map.value(settingsIdKey()));
|
||||||
m_buildKey = mangledId.suffixAfter(id());
|
m_buildKey = mangledId.suffixAfter(id());
|
||||||
|
|
||||||
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
|
||||||
aspect->fromMap(map);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,22 +357,6 @@ bool RunConfiguration::fromMap(const QVariantMap &map)
|
|||||||
the need to add all options to the base class.
|
the need to add all options to the base class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
Returns extra aspects.
|
|
||||||
|
|
||||||
\sa ProjectExplorer::IRunConfigurationAspect
|
|
||||||
*/
|
|
||||||
|
|
||||||
const QList<IRunConfigurationAspect *> RunConfiguration::aspects() const
|
|
||||||
{
|
|
||||||
return m_aspects;
|
|
||||||
}
|
|
||||||
|
|
||||||
IRunConfigurationAspect *RunConfiguration::extraAspect(Core::Id id) const
|
|
||||||
{
|
|
||||||
return Utils::findOrDefault(m_aspects, Utils::equal(&IRunConfigurationAspect::id, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
|
|
||||||
|
|||||||
@@ -43,16 +43,12 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QFormLayout;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Utils { class OutputFormatter; }
|
namespace Utils { class OutputFormatter; }
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class Abi;
|
class Abi;
|
||||||
class BuildConfiguration;
|
class BuildConfiguration;
|
||||||
class IRunConfigurationAspect;
|
class GlobalOrProjectAspect;
|
||||||
class Node;
|
class Node;
|
||||||
class RunConfigurationFactory;
|
class RunConfigurationFactory;
|
||||||
class RunConfiguration;
|
class RunConfiguration;
|
||||||
@@ -86,7 +82,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
friend class IRunConfigurationAspect;
|
friend class GlobalOrProjectAspect;
|
||||||
/// Converts current object into map for storage.
|
/// Converts current object into map for storage.
|
||||||
virtual void toMap(QVariantMap &map) const = 0;
|
virtual void toMap(QVariantMap &map) const = 0;
|
||||||
/// Read object state from @p map.
|
/// Read object state from @p map.
|
||||||
@@ -102,56 +98,34 @@ protected:
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT IRunConfigurationAspect : public QObject
|
class PROJECTEXPLORER_EXPORT GlobalOrProjectAspect : public ProjectConfigurationAspect
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IRunConfigurationAspect();
|
GlobalOrProjectAspect();
|
||||||
~IRunConfigurationAspect() override;
|
~GlobalOrProjectAspect() override;
|
||||||
|
|
||||||
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; }
|
|
||||||
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
|
||||||
void setSettingsKey(const QString &settingsKey) { m_settingsKey = settingsKey; }
|
|
||||||
void setProjectSettings(ISettingsAspect *settings);
|
void setProjectSettings(ISettingsAspect *settings);
|
||||||
void setGlobalSettings(ISettingsAspect *settings);
|
void setGlobalSettings(ISettingsAspect *settings);
|
||||||
|
|
||||||
Core::Id id() const { return m_id; }
|
|
||||||
QString displayName() const { return m_displayName; }
|
|
||||||
QString settingsKey() const { return m_settingsKey; }
|
|
||||||
bool isUsingGlobalSettings() const { return m_useGlobalSettings; }
|
bool isUsingGlobalSettings() const { return m_useGlobalSettings; }
|
||||||
void setUsingGlobalSettings(bool value);
|
void setUsingGlobalSettings(bool value);
|
||||||
void setVisible(bool visible) { m_visible = visible; }
|
|
||||||
void resetProjectToGlobalSettings();
|
void resetProjectToGlobalSettings();
|
||||||
|
|
||||||
ISettingsAspect *projectSettings() const { return m_projectSettings; }
|
ISettingsAspect *projectSettings() const { return m_projectSettings; }
|
||||||
ISettingsAspect *globalSettings() const { return m_globalSettings; }
|
ISettingsAspect *globalSettings() const { return m_globalSettings; }
|
||||||
ISettingsAspect *currentSettings() const;
|
ISettingsAspect *currentSettings() const;
|
||||||
|
|
||||||
virtual void addToConfigurationLayout(QFormLayout *layout);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void changed();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class RunConfiguration;
|
friend class RunConfiguration;
|
||||||
virtual void fromMap(const QVariantMap &map);
|
void fromMap(const QVariantMap &map) override;
|
||||||
virtual void toMap(QVariantMap &data) const;
|
void toMap(QVariantMap &data) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::Id m_id;
|
|
||||||
QString m_displayName;
|
|
||||||
QString m_settingsKey; // Name of data in settings.
|
|
||||||
bool m_useGlobalSettings = false;
|
bool m_useGlobalSettings = false;
|
||||||
bool m_visible = true;
|
|
||||||
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.
|
||||||
ConfigWidgetCreator m_configWidgetCreator;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT Runnable
|
class PROJECTEXPLORER_EXPORT Runnable
|
||||||
@@ -197,17 +171,6 @@ public:
|
|||||||
bool fromMap(const QVariantMap &map) override;
|
bool fromMap(const QVariantMap &map) override;
|
||||||
QVariantMap toMap() const override;
|
QVariantMap toMap() const override;
|
||||||
|
|
||||||
const QList<IRunConfigurationAspect *> aspects() const;
|
|
||||||
IRunConfigurationAspect *extraAspect(Core::Id id) const;
|
|
||||||
|
|
||||||
template <typename T> T *extraAspect() const
|
|
||||||
{
|
|
||||||
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
|
||||||
if (T *result = qobject_cast<T *>(aspect))
|
|
||||||
return result;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Runnable runnable() const;
|
virtual Runnable runnable() const;
|
||||||
virtual Abi abi() const;
|
virtual Abi abi() const;
|
||||||
|
|
||||||
@@ -217,18 +180,17 @@ public:
|
|||||||
// The BuildTargetInfo corresponding to the buildKey.
|
// The BuildTargetInfo corresponding to the buildKey.
|
||||||
BuildTargetInfo buildTargetInfo() const;
|
BuildTargetInfo buildTargetInfo() const;
|
||||||
|
|
||||||
template<class Aspect, typename ...Args>
|
|
||||||
Aspect *addAspect(Args && ...args)
|
|
||||||
{
|
|
||||||
auto aspect = new Aspect(args...);
|
|
||||||
m_aspects.append(aspect);
|
|
||||||
return aspect;
|
|
||||||
}
|
|
||||||
|
|
||||||
static RunConfiguration *startupRunConfiguration();
|
static RunConfiguration *startupRunConfiguration();
|
||||||
virtual bool canRunForNode(const ProjectExplorer::Node *) const { return false; }
|
virtual bool canRunForNode(const ProjectExplorer::Node *) const { return false; }
|
||||||
|
|
||||||
using AspectFactory = std::function<IRunConfigurationAspect *(Target *)>;
|
template <class T = ISettingsAspect> T *currentSettings(Core::Id id) const
|
||||||
|
{
|
||||||
|
if (auto aspect = qobject_cast<GlobalOrProjectAspect *>(extraAspect(id)))
|
||||||
|
return qobject_cast<T *>(aspect->currentSettings());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
using AspectFactory = std::function<ProjectConfigurationAspect *(Target *)>;
|
||||||
template <class T> static void registerAspect()
|
template <class T> static void registerAspect()
|
||||||
{
|
{
|
||||||
addAspectFactory([](Target *target) { return new T(target); });
|
addAspectFactory([](Target *target) { return new T(target); });
|
||||||
@@ -258,7 +220,6 @@ private:
|
|||||||
|
|
||||||
friend class RunConfigurationCreationInfo;
|
friend class RunConfigurationCreationInfo;
|
||||||
|
|
||||||
QList<IRunConfigurationAspect *> m_aspects;
|
|
||||||
QString m_buildKey;
|
QString m_buildKey;
|
||||||
std::function<Utils::OutputFormatter *(Project *)> m_outputFormatterCreator;
|
std::function<Utils::OutputFormatter *(Project *)> m_outputFormatterCreator;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -589,7 +589,7 @@ void ExecutableAspect::setExecutable(const FileName &executable)
|
|||||||
|
|
||||||
void ExecutableAspect::setSettingsKey(const QString &key)
|
void ExecutableAspect::setSettingsKey(const QString &key)
|
||||||
{
|
{
|
||||||
IRunConfigurationAspect::setSettingsKey(key);
|
ProjectConfigurationAspect::setSettingsKey(key);
|
||||||
m_executable.setSettingsKey(key);
|
m_executable.setSettingsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT TerminalAspect : public IRunConfigurationAspect
|
class PROJECTEXPLORER_EXPORT TerminalAspect : public ProjectConfigurationAspect
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ private:
|
|||||||
QPointer<QCheckBox> m_checkBox; // Owned by RunConfigWidget
|
QPointer<QCheckBox> m_checkBox; // Owned by RunConfigWidget
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT WorkingDirectoryAspect : public IRunConfigurationAspect
|
class PROJECTEXPLORER_EXPORT WorkingDirectoryAspect : public ProjectConfigurationAspect
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ private:
|
|||||||
QPointer<QToolButton> m_resetButton;
|
QPointer<QToolButton> m_resetButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT ArgumentsAspect : public IRunConfigurationAspect
|
class PROJECTEXPLORER_EXPORT ArgumentsAspect : public ProjectConfigurationAspect
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ private:
|
|||||||
QPointer<Utils::FancyLineEdit> m_chooser;
|
QPointer<Utils::FancyLineEdit> m_chooser;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT BaseBoolAspect : public IRunConfigurationAspect
|
class PROJECTEXPLORER_EXPORT BaseBoolAspect : public ProjectConfigurationAspect
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ private:
|
|||||||
bool m_value = false;
|
bool m_value = false;
|
||||||
bool m_defaultValue = false;
|
bool m_defaultValue = false;
|
||||||
QString m_label;
|
QString m_label;
|
||||||
QPointer<QCheckBox> m_checkBox; // Owned by RunConfigWidget
|
QPointer<QCheckBox> m_checkBox; // Owned by configuration widget
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT UseLibraryPathsAspect : public BaseBoolAspect
|
class PROJECTEXPLORER_EXPORT UseLibraryPathsAspect : public BaseBoolAspect
|
||||||
@@ -164,7 +164,7 @@ public:
|
|||||||
UseDyldSuffixAspect();
|
UseDyldSuffixAspect();
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT BaseStringAspect : public IRunConfigurationAspect
|
class PROJECTEXPLORER_EXPORT BaseStringAspect : public ProjectConfigurationAspect
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ private:
|
|||||||
QPixmap m_labelPixmap;
|
QPixmap m_labelPixmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT ExecutableAspect : public IRunConfigurationAspect
|
class PROJECTEXPLORER_EXPORT ExecutableAspect : public ProjectConfigurationAspect
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
@@ -528,11 +528,11 @@ QString RunSettingsWidget::uniqueRCName(const QString &name)
|
|||||||
|
|
||||||
void RunSettingsWidget::addRunControlWidgets()
|
void RunSettingsWidget::addRunControlWidgets()
|
||||||
{
|
{
|
||||||
for (IRunConfigurationAspect *aspect : m_runConfiguration->aspects()) {
|
for (ProjectConfigurationAspect *aspect : m_runConfiguration->aspects()) {
|
||||||
if (QWidget *rcw = aspect->createConfigWidget()) {
|
if (QWidget *rcw = aspect->createConfigWidget()) {
|
||||||
auto label = new QLabel(this);
|
auto label = new QLabel(this);
|
||||||
label->setText(aspect->displayName());
|
label->setText(aspect->displayName());
|
||||||
connect(aspect, &IRunConfigurationAspect::changed, label, [label, aspect] {
|
connect(aspect, &GlobalOrProjectAspect::changed, label, [label, aspect] {
|
||||||
label->setText(aspect->displayName());
|
label->setText(aspect->displayName());
|
||||||
});
|
});
|
||||||
addSubWidget(rcw, label);
|
addSubWidget(rcw, label);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class QmlProfilerRunConfigurationAspect : public ProjectExplorer::IRunConfigurationAspect
|
class QmlProfilerRunConfigurationAspect : public ProjectExplorer::GlobalOrProjectAspect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlProfilerRunConfigurationAspect(ProjectExplorer::Target *);
|
QmlProfilerRunConfigurationAspect(ProjectExplorer::Target *);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ static bool caseInsensitiveLessThan(const QString &s1, const QString &s2)
|
|||||||
|
|
||||||
// MainQmlFileAspect
|
// MainQmlFileAspect
|
||||||
|
|
||||||
class MainQmlFileAspect : public IRunConfigurationAspect
|
class MainQmlFileAspect : public ProjectConfigurationAspect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit MainQmlFileAspect(QmlProject *project);
|
explicit MainQmlFileAspect(QmlProject *project);
|
||||||
|
|||||||
@@ -766,12 +766,11 @@ void CallgrindTool::setupRunner(CallgrindToolRunner *toolRunner)
|
|||||||
QTC_ASSERT(m_visualization, return);
|
QTC_ASSERT(m_visualization, return);
|
||||||
|
|
||||||
// apply project settings
|
// apply project settings
|
||||||
if (IRunConfigurationAspect *analyzerAspect = runControl->runConfiguration()->extraAspect(ANALYZER_VALGRIND_SETTINGS)) {
|
if (auto settings = runControl->runConfiguration()
|
||||||
if (const ValgrindBaseSettings *settings = qobject_cast<ValgrindBaseSettings *>(analyzerAspect->currentSettings())) {
|
->currentSettings<ValgrindBaseSettings>(ANALYZER_VALGRIND_SETTINGS)) {
|
||||||
m_visualization->setMinimumInclusiveCostRatio(settings->visualisationMinimumInclusiveCostRatio() / 100.0);
|
m_visualization->setMinimumInclusiveCostRatio(settings->visualisationMinimumInclusiveCostRatio() / 100.0);
|
||||||
m_proxyModel.setMinimumInclusiveCostRatio(settings->minimumInclusiveCostRatio() / 100.0);
|
m_proxyModel.setMinimumInclusiveCostRatio(settings->minimumInclusiveCostRatio() / 100.0);
|
||||||
m_dataModel.setVerboseToolTipsEnabled(settings->enableEventToolTips());
|
m_dataModel.setVerboseToolTipsEnabled(settings->enableEventToolTips());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_toolBusy = true;
|
m_toolBusy = true;
|
||||||
|
|||||||
@@ -914,8 +914,7 @@ void MemcheckTool::maybeActiveRunConfigurationChanged()
|
|||||||
if (Project *project = SessionManager::startupProject())
|
if (Project *project = SessionManager::startupProject())
|
||||||
if (Target *target = project->activeTarget())
|
if (Target *target = project->activeTarget())
|
||||||
if (RunConfiguration *rc = target->activeRunConfiguration())
|
if (RunConfiguration *rc = target->activeRunConfiguration())
|
||||||
if (IRunConfigurationAspect *aspect = rc->extraAspect(ANALYZER_VALGRIND_SETTINGS))
|
settings = rc->currentSettings<ValgrindBaseSettings>(ANALYZER_VALGRIND_SETTINGS);
|
||||||
settings = qobject_cast<ValgrindBaseSettings *>(aspect->currentSettings());
|
|
||||||
|
|
||||||
if (!settings) // fallback to global settings
|
if (!settings) // fallback to global settings
|
||||||
settings = ValgrindPlugin::globalSettings();
|
settings = ValgrindPlugin::globalSettings();
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ ValgrindToolRunner::ValgrindToolRunner(RunControl *runControl)
|
|||||||
runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR);
|
runControl->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL_TOOLBAR);
|
||||||
setSupportsReRunning(false);
|
setSupportsReRunning(false);
|
||||||
|
|
||||||
if (IRunConfigurationAspect *aspect = runControl->runConfiguration()->extraAspect(ANALYZER_VALGRIND_SETTINGS))
|
m_settings = runControl->runConfiguration()
|
||||||
m_settings = qobject_cast<ValgrindBaseSettings *>(aspect->currentSettings());
|
->currentSettings<ValgrindBaseSettings>(ANALYZER_VALGRIND_SETTINGS);
|
||||||
|
|
||||||
if (!m_settings)
|
if (!m_settings)
|
||||||
m_settings = ValgrindPlugin::globalSettings();
|
m_settings = ValgrindPlugin::globalSettings();
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ private:
|
|||||||
QPointer<QWidget> m_widget;
|
QPointer<QWidget> m_widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ValgrindRunConfigurationAspect : public IRunConfigurationAspect
|
class ValgrindRunConfigurationAspect : public GlobalOrProjectAspect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ValgrindRunConfigurationAspect(Target *)
|
ValgrindRunConfigurationAspect(Target *)
|
||||||
|
|||||||
Reference in New Issue
Block a user