diff options
author | Tobias Hunger <[email protected]> | 2013-03-27 17:17:24 +0100 |
---|---|---|
committer | Tobias Hunger <[email protected]> | 2013-04-05 14:56:35 +0200 |
commit | fd1f2848922254179120a7d48472af55bd5e6eae (patch) | |
tree | 3a7fb1e1b469418eb12e7b8657577f36856fc95a /src/plugins/debugger/debuggerrunconfigurationaspect.cpp | |
parent | 533644290fb5c0f511085eb9a9648f38c8497635 (diff) |
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: Tobias Hunger <[email protected]>
Diffstat (limited to 'src/plugins/debugger/debuggerrunconfigurationaspect.cpp')
-rw-r--r-- | src/plugins/debugger/debuggerrunconfigurationaspect.cpp | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp index cba05009f31..1aee092d952 100644 --- a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp +++ b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp @@ -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" |