Commit fd1f2848 authored by Tobias Hunger's avatar Tobias Hunger

RunConfigurationAspects: Move method to create config widget

Move the method used to create a config widget for a
RunConfigurationAspect from the RunControlFactory into the aspect
itself. This allows for aspects that are not bound to any factory,
which is what I eventually want to use to hold the environment for
run configurations.

Change-Id: Icceb5f44ca9eb63a87b9c7bb6468ff30dab943c2
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 53364429
......@@ -91,12 +91,10 @@ QString AnalyzerRunConfigWidget::displayName() const
return tr("Analyzer Settings");
}
void AnalyzerRunConfigWidget::setRunConfiguration(ProjectExplorer::RunConfiguration *rc)
void AnalyzerRunConfigWidget::setRunConfigurationAspect(AnalyzerRunConfigurationAspect *aspect)
{
QTC_ASSERT(rc, return);
m_aspect = rc->extraAspect<AnalyzerRunConfigurationAspect>();
QTC_ASSERT(m_aspect, return);
QTC_ASSERT(aspect, return);
m_aspect = aspect;
// add config widget for each sub config
foreach (AbstractAnalyzerSubConfig *config, m_aspect->customSubConfigs()) {
......
......@@ -68,7 +68,7 @@ public:
virtual QString displayName() const;
void setRunConfiguration(ProjectExplorer::RunConfiguration *rc);
void setRunConfigurationAspect(AnalyzerRunConfigurationAspect *aspect);
private:
void setDetailEnabled(bool value);
......
......@@ -30,7 +30,6 @@
#include "analyzerruncontrolfactory.h"
#include "analyzersettings.h"
#include "analyzerruncontrol.h"
#include "analyzerrunconfigwidget.h"
#include "analyzermanager.h"
#include "ianalyzertool.h"
#include "analyzerstartparameters.h"
......@@ -87,12 +86,5 @@ IRunConfigurationAspect *AnalyzerRunControlFactory::createRunConfigurationAspect
return new AnalyzerRunConfigurationAspect;
}
RunConfigWidget *AnalyzerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
{
AnalyzerRunConfigWidget *ret = new AnalyzerRunConfigWidget;
ret->setRunConfiguration(runConfiguration);
return ret;
}
} // namespace Internal
} // namespace Analyzer
......@@ -50,8 +50,6 @@ public:
ProjectExplorer::RunMode mode,
QString *errorMessage);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc);
ProjectExplorer::RunConfigWidget *createConfigurationWidget(ProjectExplorer::RunConfiguration *runConfiguration);
};
} // namespace Internal
......
......@@ -31,6 +31,7 @@
#include "analyzersettings.h"
#include "analyzermanager.h"
#include "analyzerrunconfigwidget.h"
#include "ianalyzertool.h"
#include "analyzerplugin.h"
#include "analyzeroptionspage.h"
......@@ -228,4 +229,11 @@ void AnalyzerRunConfigurationAspect::resetCustomToGlobalSettings()
AnalyzerSettings::fromMap(gs->toMap(), &m_customConfigurations);
}
ProjectExplorer::RunConfigWidget *AnalyzerRunConfigurationAspect::createConfigurationWidget()
{
AnalyzerRunConfigWidget *ret = new AnalyzerRunConfigWidget;
ret->setRunConfigurationAspect(this);
return ret;
}
} // namespace Analyzer
......@@ -177,6 +177,7 @@ public:
void resetCustomToGlobalSettings();
QList<AbstractAnalyzerSubConfig *> customSubConfigs() const { return m_customConfigurations; }
ProjectExplorer::RunConfigWidget *createConfigurationWidget();
protected:
virtual void fromMap(const QVariantMap &map);
......
......@@ -32,10 +32,19 @@
#include "debuggerconstants.h"
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/target.h>
#include <QCheckBox>
#include <QSpinBox>
#include <QDebug>
#include <QFormLayout>
#include <QLabel>
static const char USE_CPP_DEBUGGER_KEY[] = "RunConfiguration.UseCppDebugger";
static const char USE_QML_DEBUGGER_KEY[] = "RunConfiguration.UseQmlDebugger";
static const char USE_QML_DEBUGGER_AUTO_KEY[] = "RunConfiguration.UseQmlDebuggerAuto";
......@@ -43,6 +52,142 @@ static const char QML_DEBUG_SERVER_PORT_KEY[] = "RunConfiguration.QmlDebugServer
static const char USE_MULTIPROCESS_KEY[] = "RunConfiguration.UseMultiProcess";
namespace Debugger {
namespace Internal {
////////////////////////////////////////////////////////////////////////
//
// DebuggerRunConfigWidget
//
////////////////////////////////////////////////////////////////////////
class DebuggerRunConfigWidget : public ProjectExplorer::RunConfigWidget
{
Q_OBJECT
public:
explicit DebuggerRunConfigWidget(DebuggerRunConfigurationAspect *aspect);
QString displayName() const { return tr("Debugger Settings"); }
private slots:
void useCppDebuggerToggled(bool on);
void useQmlDebuggerToggled(bool on);
void qmlDebugServerPortChanged(int port);
void useMultiProcessToggled(bool on);
public:
DebuggerRunConfigurationAspect *m_aspect; // not owned
QCheckBox *m_useCppDebugger;
QCheckBox *m_useQmlDebugger;
QSpinBox *m_debugServerPort;
QLabel *m_debugServerPortLabel;
QLabel *m_qmlDebuggerInfoLabel;
QCheckBox *m_useMultiProcess;
};
DebuggerRunConfigWidget::DebuggerRunConfigWidget(DebuggerRunConfigurationAspect *aspect)
{
m_aspect = aspect;
m_useCppDebugger = new QCheckBox(tr("Enable C++"), this);
m_useQmlDebugger = new QCheckBox(tr("Enable QML"), this);
m_debugServerPort = new QSpinBox(this);
m_debugServerPort->setMinimum(1);
m_debugServerPort->setMaximum(65535);
m_debugServerPortLabel = new QLabel(tr("Debug port:"), this);
m_debugServerPortLabel->setBuddy(m_debugServerPort);
m_qmlDebuggerInfoLabel = new QLabel(tr("<a href=\""
"qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html"
"\">What are the prerequisites?</a>"));
m_useCppDebugger->setChecked(m_aspect->useCppDebugger());
m_useQmlDebugger->setChecked(m_aspect->useQmlDebugger());
m_debugServerPort->setValue(m_aspect->qmlDebugServerPort());
static const QByteArray env = qgetenv("QTC_DEBUGGER_MULTIPROCESS");
m_useMultiProcess =
new QCheckBox(tr("Enable Debugging of Subprocesses"), this);
m_useMultiProcess->setChecked(m_aspect->useMultiProcess());
m_useMultiProcess->setVisible(env.toInt());
connect(m_qmlDebuggerInfoLabel, SIGNAL(linkActivated(QString)),
Core::HelpManager::instance(), SLOT(handleHelpRequest(QString)));
connect(m_useQmlDebugger, SIGNAL(toggled(bool)),
SLOT(useQmlDebuggerToggled(bool)));
connect(m_useCppDebugger, SIGNAL(toggled(bool)),
SLOT(useCppDebuggerToggled(bool)));
connect(m_debugServerPort, SIGNAL(valueChanged(int)),
SLOT(qmlDebugServerPortChanged(int)));
connect(m_useMultiProcess, SIGNAL(toggled(bool)),
SLOT(useMultiProcessToggled(bool)));
if (m_aspect->isDisplaySuppressed())
hide();
if (m_aspect->areQmlDebuggingOptionsSuppressed()) {
m_debugServerPortLabel->hide();
m_debugServerPort->hide();
m_useQmlDebugger->hide();
}
if (m_aspect->areCppDebuggingOptionsSuppressed())
m_useCppDebugger->hide();
if (m_aspect->isQmlDebuggingSpinboxSuppressed()) {
m_debugServerPort->hide();
m_debugServerPortLabel->hide();
}
QHBoxLayout *qmlLayout = new QHBoxLayout;
qmlLayout->setMargin(0);
qmlLayout->addWidget(m_useQmlDebugger);
qmlLayout->addWidget(m_debugServerPortLabel);
qmlLayout->addWidget(m_debugServerPort);
qmlLayout->addWidget(m_qmlDebuggerInfoLabel);
qmlLayout->addStretch();
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
layout->addWidget(m_useCppDebugger);
layout->addLayout(qmlLayout);
layout->addWidget(m_useMultiProcess);
setLayout(layout);
}
void DebuggerRunConfigWidget::qmlDebugServerPortChanged(int port)
{
m_aspect->m_qmlDebugServerPort = port;
}
void DebuggerRunConfigWidget::useCppDebuggerToggled(bool on)
{
m_aspect->m_useCppDebugger = on;
if (!on && !m_useQmlDebugger->isChecked())
m_useQmlDebugger->setChecked(true);
}
void DebuggerRunConfigWidget::useQmlDebuggerToggled(bool on)
{
m_debugServerPort->setEnabled(on);
m_debugServerPortLabel->setEnabled(on);
m_aspect->m_useQmlDebugger = on
? DebuggerRunConfigurationAspect::EnableQmlDebugger
: DebuggerRunConfigurationAspect::DisableQmlDebugger;
if (!on && !m_useCppDebugger->isChecked())
m_useCppDebugger->setChecked(true);
}
void DebuggerRunConfigWidget::useMultiProcessToggled(bool on)
{
m_aspect->m_useMultiProcess = on;
}
} // namespace Internal
/*!
\class Debugger::DebuggerRunConfigurationAspect
......@@ -203,6 +348,11 @@ DebuggerRunConfigurationAspect *DebuggerRunConfigurationAspect::clone(
return new DebuggerRunConfigurationAspect(parent, this);
}
ProjectExplorer::RunConfigWidget *DebuggerRunConfigurationAspect::createConfigurationWidget()
{
return new Internal::DebuggerRunConfigWidget(this);
}
void DebuggerRunConfigurationAspect::ctor()
{
connect(this, SIGNAL(debuggersChanged()),
......@@ -210,3 +360,6 @@ void DebuggerRunConfigurationAspect::ctor()
}
} // namespace Debugger
#include "debuggerrunconfigurationaspect.moc"
......@@ -58,6 +58,7 @@ public:
void fromMap(const QVariantMap &map);
DebuggerRunConfigurationAspect *clone(ProjectExplorer::RunConfiguration *parent) const;
ProjectExplorer::RunConfigWidget *createConfigurationWidget();
QString displayName() const;
......
......@@ -71,8 +71,6 @@ public:
private:
QString displayName() const;
ProjectExplorer::RunConfigWidget *createConfigurationWidget(
ProjectExplorer::RunConfiguration *runConfiguration);
};
} // namespace Internal
......
......@@ -50,7 +50,6 @@
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/target.h>
#include <projectexplorer/taskhub.h>
......@@ -59,14 +58,8 @@
#include <utils/portlist.h>
#include <utils/tcpportsgatherer.h>
#include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <QCheckBox>
#include <QSpinBox>
#include <QDebug>
#include <QErrorMessage>
#include <QFormLayout>
#include <QLabel>
using namespace Debugger::Internal;
using namespace ProjectExplorer;
......@@ -113,139 +106,6 @@ static const char *engineTypeName(DebuggerEngineType et)
return "No engine";
}
////////////////////////////////////////////////////////////////////////
//
// DebuggerRunConfigWidget
//
////////////////////////////////////////////////////////////////////////
class DebuggerRunConfigWidget : public RunConfigWidget
{
Q_OBJECT
public:
explicit DebuggerRunConfigWidget(RunConfiguration *runConfiguration);
QString displayName() const { return tr("Debugger Settings"); }
private slots:
void useCppDebuggerToggled(bool on);
void useQmlDebuggerToggled(bool on);
void qmlDebugServerPortChanged(int port);
void useMultiProcessToggled(bool on);
public:
DebuggerRunConfigurationAspect *m_aspect; // not owned
QCheckBox *m_useCppDebugger;
QCheckBox *m_useQmlDebugger;
QSpinBox *m_debugServerPort;
QLabel *m_debugServerPortLabel;
QLabel *m_qmlDebuggerInfoLabel;
QCheckBox *m_useMultiProcess;
};
DebuggerRunConfigWidget::DebuggerRunConfigWidget(RunConfiguration *runConfiguration)
{
m_aspect = runConfiguration->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
m_useCppDebugger = new QCheckBox(tr("Enable C++"), this);
m_useQmlDebugger = new QCheckBox(tr("Enable QML"), this);
m_debugServerPort = new QSpinBox(this);
m_debugServerPort->setMinimum(1);
m_debugServerPort->setMaximum(65535);
m_debugServerPortLabel = new QLabel(tr("Debug port:"), this);
m_debugServerPortLabel->setBuddy(m_debugServerPort);
m_qmlDebuggerInfoLabel = new QLabel(tr("<a href=\""
"qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html"
"\">What are the prerequisites?</a>"));
m_useCppDebugger->setChecked(m_aspect->useCppDebugger());
m_useQmlDebugger->setChecked(m_aspect->useQmlDebugger());
m_debugServerPort->setValue(m_aspect->qmlDebugServerPort());
static const QByteArray env = qgetenv("QTC_DEBUGGER_MULTIPROCESS");
m_useMultiProcess =
new QCheckBox(tr("Enable Debugging of Subprocesses"), this);
m_useMultiProcess->setChecked(m_aspect->useMultiProcess());
m_useMultiProcess->setVisible(env.toInt());
connect(m_qmlDebuggerInfoLabel, SIGNAL(linkActivated(QString)),
Core::HelpManager::instance(), SLOT(handleHelpRequest(QString)));
connect(m_useQmlDebugger, SIGNAL(toggled(bool)),
SLOT(useQmlDebuggerToggled(bool)));
connect(m_useCppDebugger, SIGNAL(toggled(bool)),
SLOT(useCppDebuggerToggled(bool)));
connect(m_debugServerPort, SIGNAL(valueChanged(int)),
SLOT(qmlDebugServerPortChanged(int)));
connect(m_useMultiProcess, SIGNAL(toggled(bool)),
SLOT(useMultiProcessToggled(bool)));
if (m_aspect->isDisplaySuppressed())
hide();
if (m_aspect->areQmlDebuggingOptionsSuppressed()) {
m_debugServerPortLabel->hide();
m_debugServerPort->hide();
m_useQmlDebugger->hide();
}
if (m_aspect->areCppDebuggingOptionsSuppressed())
m_useCppDebugger->hide();
if (m_aspect->isQmlDebuggingSpinboxSuppressed()) {
m_debugServerPort->hide();
m_debugServerPortLabel->hide();
}
QHBoxLayout *qmlLayout = new QHBoxLayout;
qmlLayout->setMargin(0);
qmlLayout->addWidget(m_useQmlDebugger);
qmlLayout->addWidget(m_debugServerPortLabel);
qmlLayout->addWidget(m_debugServerPort);
qmlLayout->addWidget(m_qmlDebuggerInfoLabel);
qmlLayout->addStretch();
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0);
layout->addWidget(m_useCppDebugger);
layout->addLayout(qmlLayout);
layout->addWidget(m_useMultiProcess);
setLayout(layout);
}
void DebuggerRunConfigWidget::qmlDebugServerPortChanged(int port)
{
m_aspect->m_qmlDebugServerPort = port;
}
void DebuggerRunConfigWidget::useCppDebuggerToggled(bool on)
{
m_aspect->m_useCppDebugger = on;
if (!on && !m_useQmlDebugger->isChecked())
m_useQmlDebugger->setChecked(true);
}
void DebuggerRunConfigWidget::useQmlDebuggerToggled(bool on)
{
m_debugServerPort->setEnabled(on);
m_debugServerPortLabel->setEnabled(on);
m_aspect->m_useQmlDebugger = on
? DebuggerRunConfigurationAspect::EnableQmlDebugger
: DebuggerRunConfigurationAspect::DisableQmlDebugger;
if (!on && !m_useCppDebugger->isChecked())
m_useCppDebugger->setChecked(true);
}
void DebuggerRunConfigWidget::useMultiProcessToggled(bool on)
{
m_aspect->m_useMultiProcess = on;
}
////////////////////////////////////////////////////////////////////////
//
// DebuggerRunControlPrivate
......@@ -660,12 +520,6 @@ DebuggerRunControl *DebuggerRunControlFactory::createAndScheduleRun
return rc;
}
RunConfigWidget *DebuggerRunControlFactory::createConfigurationWidget
(RunConfiguration *runConfiguration)
{
return new DebuggerRunConfigWidget(runConfiguration);
}
DebuggerEngine *DebuggerRunControlFactory::createEngine(DebuggerEngineType et,
const DebuggerStartParameters &sp, QString *errorMessage)
{
......@@ -695,5 +549,3 @@ DebuggerEngine *DebuggerRunControlFactory::createEngine(DebuggerEngineType et,
}
} // namespace Debugger
#include "debuggerrunner.moc"
......@@ -104,6 +104,12 @@ bool ProcessHandle::equals(const ProcessHandle &rhs) const
}
RunConfigWidget *IRunConfigurationAspect::createConfigurationWidget()
{
return 0;
}
/*!
\class ProjectExplorer::RunConfiguration
\brief Base class for a run configuration. A run configuration specifies how a
......@@ -396,11 +402,6 @@ IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect(RunCon
return 0;
}
RunConfigWidget *IRunControlFactory::createConfigurationWidget(RunConfiguration *)
{
return 0;
}
/*!
\class ProjectExplorer::RunControl
\brief Each instance of this class represents one item that is run.
......
......@@ -48,6 +48,7 @@ namespace ProjectExplorer {
class Abi;
class BuildConfiguration;
class RunConfiguration;
class RunConfigWidget;
class RunControl;
class Target;
......@@ -79,6 +80,7 @@ public:
virtual QString displayName() const = 0;
virtual IRunConfigurationAspect *clone(RunConfiguration *parent) const = 0;
virtual RunConfigWidget *createConfigurationWidget();
protected:
friend class RunConfiguration;
......@@ -173,8 +175,6 @@ private:
virtual RunConfiguration *doRestore(Target *parent, const QVariantMap &map) = 0;
};
class RunConfigWidget;
class PROJECTEXPLORER_EXPORT IRunControlFactory : public QObject
{
Q_OBJECT
......@@ -188,7 +188,6 @@ public:
virtual QString displayName() const = 0;
virtual IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc);
virtual RunConfigWidget *createConfigurationWidget(RunConfiguration *runConfiguration);
};
class PROJECTEXPLORER_EXPORT RunConfigWidget
......
......@@ -551,9 +551,8 @@ QString RunSettingsWidget::uniqueRCName(const QString &name)
void RunSettingsWidget::addRunControlWidgets()
{
foreach (IRunControlFactory *f, ExtensionSystem::PluginManager::getObjects<IRunControlFactory>()) {
ProjectExplorer::RunConfigWidget *rcw =
f->createConfigurationWidget(m_target->activeRunConfiguration());
foreach (IRunConfigurationAspect *aspect, m_target->activeRunConfiguration()->extraAspects()) {
ProjectExplorer::RunConfigWidget *rcw = aspect->createConfigurationWidget();
if (rcw)
addSubWidget(rcw);
}
......
......@@ -137,9 +137,3 @@ QString QnxRunControlFactory::displayName() const
{
return tr("Run on remote QNX device");
}
RunConfigWidget *QnxRunControlFactory::createConfigurationWidget(RunConfiguration *config)
{
Q_UNUSED(config)
return 0;
}
......@@ -45,7 +45,6 @@ public:
explicit QnxRunControlFactory(QObject *parent = 0);
QString displayName() const;
ProjectExplorer::RunConfigWidget *createConfigurationWidget(ProjectExplorer::RunConfiguration *runConfiguration);
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment