Commit 503c6e26 authored by hjk's avatar hjk Committed by hjk

projectexplorer: Make the debugger language chooser a (hardcoded) "aspect"

This is the first step of a larger refactoring. The plan is to make
debuggersettings more orthogonal to individual runconfiguration
implementation. This patch alone already pushes the settings handling
to the debugger plugin and removes code duplication in the
runconfiguration implementation.

Change-Id: I4c78d1658ea462d3df14b873f8f41cc918a23f1a
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent d39bd871
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "debuggerlanguagechooser.h"
#include <QHBoxLayout>
#include <QCheckBox>
#include <QSpinBox>
#include <QLabel>
namespace Utils {
DebuggerLanguageChooser::DebuggerLanguageChooser(QWidget *parent) :
QWidget(parent)
{
m_useCppDebugger = new QCheckBox(tr("C++"), this);
m_useQmlDebugger = new QCheckBox(tr("QML"), this);
connect(m_useCppDebugger, SIGNAL(toggled(bool)),
this, SLOT(useCppDebuggerToggled(bool)));
connect(m_useQmlDebugger, SIGNAL(toggled(bool)),
this, SLOT(useQmlDebuggerToggled(bool)));
m_debugServerPortLabel = new QLabel(tr("Debug port:"), this);
m_debugServerPort = new QSpinBox(this);
m_debugServerPort->setMinimum(1);
m_debugServerPort->setMaximum(65535);
m_debugServerPortLabel->setBuddy(m_debugServerPort);
m_qmlDebuggerInfoLabel = new QLabel(tr("<a href=\"qthelp://com.nokia.qtcreator/doc/creator-debugging-qml.html\">What are the prerequisites?</a>"));
connect(m_qmlDebuggerInfoLabel, SIGNAL(linkActivated(QString)),
this, SIGNAL(openHelpUrl(QString)));
connect(m_useQmlDebugger, SIGNAL(toggled(bool)), m_debugServerPort, SLOT(setEnabled(bool)));
connect(m_useQmlDebugger, SIGNAL(toggled(bool)), m_debugServerPortLabel, SLOT(setEnabled(bool)));
connect(m_debugServerPort, SIGNAL(valueChanged(int)), this, SLOT(onDebugServerPortChanged(int)));
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);
setLayout(layout);
}
bool DebuggerLanguageChooser::cppChecked() const
{
return m_useCppDebugger->isChecked();
}
bool DebuggerLanguageChooser::qmlChecked() const
{
return m_useQmlDebugger->isChecked();
}
uint DebuggerLanguageChooser::qmlDebugServerPort() const
{
return m_debugServerPort->value();
}
void DebuggerLanguageChooser::setCppChecked(bool value)
{
m_useCppDebugger->setChecked(value);
}
void DebuggerLanguageChooser::setQmlChecked(bool value)
{
m_useQmlDebugger->setChecked(value);
m_debugServerPortLabel->setEnabled(value);
m_debugServerPort->setEnabled(value);
}
void DebuggerLanguageChooser::setQmlDebugServerPort(uint port)
{
m_debugServerPort->setValue(port);
}
void DebuggerLanguageChooser::useCppDebuggerToggled(bool toggled)
{
emit cppLanguageToggled(toggled);
if (!toggled && !m_useQmlDebugger->isChecked())
m_useQmlDebugger->setChecked(true);
}
void DebuggerLanguageChooser::useQmlDebuggerToggled(bool toggled)
{
emit qmlLanguageToggled(toggled);
if (!toggled && !m_useCppDebugger->isChecked())
m_useCppDebugger->setChecked(true);
}
void DebuggerLanguageChooser::onDebugServerPortChanged(int port)
{
emit qmlDebugServerPortChanged((uint)port);
}
} // namespace Utils
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef DEBUGGERLANGUAGECHOOSER_H
#define DEBUGGERLANGUAGECHOOSER_H
#include "utils_global.h"
#include <QWidget>
QT_FORWARD_DECLARE_CLASS(QCheckBox)
QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QSpinBox)
namespace Utils {
class QTCREATOR_UTILS_EXPORT DebuggerLanguageChooser : public QWidget
{
Q_OBJECT
public:
explicit DebuggerLanguageChooser(QWidget *parent = 0);
bool cppChecked() const;
bool qmlChecked() const;
uint qmlDebugServerPort() const;
void setCppChecked(bool value);
void setQmlChecked(bool value);
void setQmlDebugServerPort(uint port);
signals:
void cppLanguageToggled(bool value);
void qmlLanguageToggled(bool value);
void qmlDebugServerPortChanged(uint port);
void openHelpUrl(const QString &url);
private slots:
void useCppDebuggerToggled(bool toggled);
void useQmlDebuggerToggled(bool toggled);
void onDebugServerPortChanged(int port);
private:
QCheckBox *m_useCppDebugger;
QCheckBox *m_useQmlDebugger;
QSpinBox *m_debugServerPort;
QLabel *m_debugServerPortLabel;
QLabel *m_qmlDebuggerInfoLabel;
};
} // namespace Utils
#endif // DEBUGGERLANGUAGECHOOSER_H
......@@ -59,7 +59,6 @@ SOURCES += $$PWD/environment.cpp \
$$PWD/htmldocextractor.cpp \
$$PWD/navigationtreeview.cpp \
$$PWD/crumblepath.cpp \
$$PWD/debuggerlanguagechooser.cpp \
$$PWD/historycompleter.cpp \
$$PWD/buildablehelperlibrary.cpp \
$$PWD/annotateditemdelegate.cpp \
......@@ -160,7 +159,6 @@ HEADERS += \
$$PWD/htmldocextractor.h \
$$PWD/navigationtreeview.h \
$$PWD/crumblepath.h \
$$PWD/debuggerlanguagechooser.h \
$$PWD/historycompleter.h \
$$PWD/buildablehelperlibrary.h \
$$PWD/annotateditemdelegate.h \
......
......@@ -44,8 +44,6 @@ DynamicLibrary {
"consoleprocess.h",
"consoleprocess_p.h",
"crumblepath.h",
"debuggerlanguagechooser.cpp",
"debuggerlanguagechooser.h",
"detailsbutton.cpp",
"detailsbutton.h",
"detailswidget.cpp",
......
......@@ -45,7 +45,6 @@
#include <utils/pathchooser.h>
#include <utils/detailswidget.h>
#include <utils/qtcassert.h>
#include <utils/debuggerlanguagechooser.h>
#include <utils/qtcprocess.h>
#include <utils/stringutils.h>
......@@ -365,16 +364,6 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
QCheckBox *runInTerminal = new QCheckBox;
fl->addRow(tr("Run in Terminal"), runInTerminal);
QLabel *debuggerLabel = new QLabel(tr("Debugger:"), this);
debuggerLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
m_debuggerLanguageChooser = new Utils::DebuggerLanguageChooser(this);
fl->addRow(debuggerLabel, m_debuggerLanguageChooser);
m_debuggerLanguageChooser->setCppChecked(m_cmakeRunConfiguration->useCppDebugger());
m_debuggerLanguageChooser->setQmlChecked(m_cmakeRunConfiguration->useQmlDebugger());
m_debuggerLanguageChooser->setQmlDebugServerPort(m_cmakeRunConfiguration->qmlDebugServerPort());
m_detailsContainer = new Utils::DetailsWidget(this);
m_detailsContainer->setState(Utils::DetailsWidget::NoSummary);
......@@ -426,15 +415,6 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
connect(runInTerminal, SIGNAL(toggled(bool)),
this, SLOT(runInTerminalToggled(bool)));
connect(m_debuggerLanguageChooser, SIGNAL(cppLanguageToggled(bool)),
this, SLOT(useCppDebuggerToggled(bool)));
connect(m_debuggerLanguageChooser, SIGNAL(qmlLanguageToggled(bool)),
this, SLOT(useQmlDebuggerToggled(bool)));
connect(m_debuggerLanguageChooser, SIGNAL(qmlDebugServerPortChanged(uint)),
this, SLOT(qmlDebugServerPortChanged(uint)));
connect(m_debuggerLanguageChooser, SIGNAL(openHelpUrl(QString)),
Core::HelpManager::instance(), SLOT(handleHelpRequest(QString)));
connect(m_environmentWidget, SIGNAL(userChangesChanged()),
this, SLOT(userChangesChanged()));
......@@ -476,21 +456,6 @@ void CMakeRunConfigurationWidget::runInTerminalToggled(bool toggled)
: ProjectExplorer::LocalApplicationRunConfiguration::Gui);
}
void CMakeRunConfigurationWidget::useCppDebuggerToggled(bool toggled)
{
m_cmakeRunConfiguration->setUseCppDebugger(toggled);
}
void CMakeRunConfigurationWidget::useQmlDebuggerToggled(bool toggled)
{
m_cmakeRunConfiguration->setUseQmlDebugger(toggled);
}
void CMakeRunConfigurationWidget::qmlDebugServerPortChanged(uint port)
{
m_cmakeRunConfiguration->setQmlDebugServerPort(port);
}
void CMakeRunConfigurationWidget::userChangesChanged()
{
m_cmakeRunConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
......
......@@ -41,7 +41,6 @@ class QComboBox;
QT_END_NAMESPACE
namespace Utils {
class DebuggerLanguageChooser;
class PathChooser;
class DetailsWidget;
}
......@@ -147,9 +146,6 @@ private slots:
void setWorkingDirectory();
void resetWorkingDirectory();
void runInTerminalToggled(bool toggled);
void useCppDebuggerToggled(bool toggled);
void useQmlDebuggerToggled(bool toggled);
void qmlDebugServerPortChanged(uint port);
void baseEnvironmentComboBoxChanged(int index);
void workingDirectoryChanged(const QString &workingDirectory);
......@@ -160,7 +156,6 @@ private:
CMakeRunConfiguration *m_cmakeRunConfiguration;
Utils::PathChooser *m_workingDirectoryEdit;
QComboBox *m_baseEnvironmentComboBox;
Utils::DebuggerLanguageChooser *m_debuggerLanguageChooser;
ProjectExplorer::EnvironmentWidget *m_environmentWidget;
Utils::DetailsWidget *m_detailsContainer;
};
......
......@@ -229,9 +229,9 @@ void DebuggerMainWindowPrivate::updateActiveLanguages()
newLanguages = m_engineDebugLanguages;
else {
if (m_previousRunConfiguration) {
if (m_previousRunConfiguration->useCppDebugger())
if (m_previousRunConfiguration->debuggerAspect()->useCppDebugger())
newLanguages |= CppLanguage;
if (m_previousRunConfiguration->useQmlDebugger())
if (m_previousRunConfiguration->debuggerAspect()->useQmlDebugger())
newLanguages |= QmlLanguage;
}
}
......
......@@ -526,7 +526,7 @@ bool DummyEngine::hasCapability(unsigned cap) const
QTC_ASSERT(activeRc, return 0);
// This is a non-started Cdb or Gdb engine:
if (activeRc->useCppDebugger())
if (activeRc->debuggerAspect()->useCppDebugger())
return cap & (WatchpointByAddressCapability
| BreakConditionCapability
| TracePointCapability
......
......@@ -65,12 +65,17 @@
#include <utils/fancymainwindow.h>
#include <utils/qtcprocess.h>
#include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <utils/buildablehelperlibrary.h>
#include <QDir>
#include <QCheckBox>
#include <QSpinBox>
#include <QDebug>
#include <QMessageBox>
#include <QErrorMessage>
#include <QFormLayout>
#include <QLabel>
#include <QMessageBox>
using namespace ProjectExplorer;
using namespace Debugger::Internal;
......@@ -147,6 +152,203 @@ static inline QString msgEngineNotAvailable(DebuggerEngineType et)
return msgEngineNotAvailable(engineTypeName(et));
}
////////////////////////////////////////////////////////////////////////
//
// DebuggerRunConfigWidget
//
////////////////////////////////////////////////////////////////////////
class DebuggerLanguageChooser : public QWidget
{
Q_OBJECT
public:
explicit DebuggerLanguageChooser(QWidget *parent = 0);
bool cppChecked() const;
bool qmlChecked() const;
uint qmlDebugServerPort() const;
void setCppChecked(bool value);
void setQmlChecked(bool value);
void setQmlDebugServerPort(uint port);
signals:
void cppLanguageToggled(bool value);
void qmlLanguageToggled(bool value);
void qmlDebugServerPortChanged(uint port);
void openHelpUrl(const QString &url);
private slots:
void useCppDebuggerToggled(bool toggled);
void useQmlDebuggerToggled(bool toggled);
void onDebugServerPortChanged(int port);
private:
QCheckBox *m_useCppDebugger;
QCheckBox *m_useQmlDebugger;
QSpinBox *m_debugServerPort;
QLabel *m_debugServerPortLabel;
QLabel *m_qmlDebuggerInfoLabel;
};
DebuggerLanguageChooser::DebuggerLanguageChooser(QWidget *parent)
: QWidget(parent)
{
m_useCppDebugger = new QCheckBox(tr("C++"), this);
m_useQmlDebugger = new QCheckBox(tr("QML"), this);
connect(m_useCppDebugger, SIGNAL(toggled(bool)),
this, SLOT(useCppDebuggerToggled(bool)));
connect(m_useQmlDebugger, SIGNAL(toggled(bool)),
this, SLOT(useQmlDebuggerToggled(bool)));
m_debugServerPortLabel = new QLabel(tr("Debug port:"), this);
m_debugServerPort = new QSpinBox(this);
m_debugServerPort->setMinimum(1);
m_debugServerPort->setMaximum(65535);
m_debugServerPortLabel->setBuddy(m_debugServerPort);
m_qmlDebuggerInfoLabel = new QLabel(tr("<a href=\""
"qthelp://com.nokia.qtcreator/doc/creator-debugging-qml.html"
"\">What are the prerequisites?</a>"));
connect(m_qmlDebuggerInfoLabel, SIGNAL(linkActivated(QString)),
this, SIGNAL(openHelpUrl(QString)));
connect(m_useQmlDebugger, SIGNAL(toggled(bool)),
m_debugServerPort, SLOT(setEnabled(bool)));
connect(m_useQmlDebugger, SIGNAL(toggled(bool)),
m_debugServerPortLabel, SLOT(setEnabled(bool)));
connect(m_debugServerPort, SIGNAL(valueChanged(int)),
this, SLOT(onDebugServerPortChanged(int)));
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);
setLayout(layout);
}
bool DebuggerLanguageChooser::cppChecked() const
{
return m_useCppDebugger->isChecked();
}
bool DebuggerLanguageChooser::qmlChecked() const
{
return m_useQmlDebugger->isChecked();
}
uint DebuggerLanguageChooser::qmlDebugServerPort() const
{
return m_debugServerPort->value();
}
void DebuggerLanguageChooser::setCppChecked(bool value)
{
m_useCppDebugger->setChecked(value);
}
void DebuggerLanguageChooser::setQmlChecked(bool value)
{
m_useQmlDebugger->setChecked(value);
m_debugServerPortLabel->setEnabled(value);
m_debugServerPort->setEnabled(value);
}
void DebuggerLanguageChooser::setQmlDebugServerPort(uint port)
{
m_debugServerPort->setValue(port);
}
void DebuggerLanguageChooser::useCppDebuggerToggled(bool toggled)
{
emit cppLanguageToggled(toggled);
if (!toggled && !m_useQmlDebugger->isChecked())
m_useQmlDebugger->setChecked(true);
}
void DebuggerLanguageChooser::useQmlDebuggerToggled(bool toggled)
{
emit qmlLanguageToggled(toggled);
if (!toggled && !m_useCppDebugger->isChecked())
m_useCppDebugger->setChecked(true);
}
void DebuggerLanguageChooser::onDebugServerPortChanged(int port)
{
emit qmlDebugServerPortChanged((uint)port);
}
class DebuggerRunConfigWidget : public ProjectExplorer::RunConfigWidget
{
Q_OBJECT
public:
explicit DebuggerRunConfigWidget(RunConfiguration *runConfiguration)
{
m_settings = runConfiguration->debuggerAspect();
QLabel *debuggerLabel = new QLabel(tr("Languages:"), this);
debuggerLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
m_debuggerLanguageChooser = new DebuggerLanguageChooser(this);
m_debuggerLanguageChooser->setCppChecked(m_settings->useCppDebugger());
m_debuggerLanguageChooser->setQmlChecked(runConfiguration->useQmlDebugger());
m_debuggerLanguageChooser->setQmlDebugServerPort(m_settings->qmlDebugServerPort());
QFormLayout *layout = new QFormLayout(this);
layout->addRow(debuggerLabel, m_debuggerLanguageChooser);
setLayout(layout);
connect(m_debuggerLanguageChooser, SIGNAL(cppLanguageToggled(bool)),
this, SLOT(useCppDebuggerToggled(bool)));
connect(m_debuggerLanguageChooser, SIGNAL(qmlLanguageToggled(bool)),
this, SLOT(useQmlDebuggerToggled(bool)));
connect(m_debuggerLanguageChooser, SIGNAL(qmlDebugServerPortChanged(uint)),
this, SLOT(qmlDebugServerPortChanged(uint)));
connect(m_debuggerLanguageChooser, SIGNAL(openHelpUrl(QString)),
Core::HelpManager::instance(), SLOT(handleHelpRequest(QString)));
}
QString displayName() const
{
return tr("Debugger Settings");
}
public slots:
void useCppDebuggerToggled(bool toggled)
{
m_settings->m_useCppDebugger = toggled;
}
void useQmlDebuggerToggled(bool toggled)
{
m_settings->m_useQmlDebugger = toggled
? DebuggerProjectSettings::EnableQmlDebugger
: DebuggerProjectSettings::DisableQmlDebugger;
}
void qmlDebugServerPortChanged(uint port)
{
m_settings->m_qmlDebugServerPort = port;
}
public:
DebuggerProjectSettings *m_settings; // not owned
DebuggerLanguageChooser *m_debuggerLanguageChooser; // owned
};
////////////////////////////////////////////////////////////////////////
//
// DebuggerRunControlPrivate
......@@ -777,12 +979,12 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
}
}
if (runConfiguration->useCppDebugger())
if (runConfiguration->debuggerAspect()->useCppDebugger())
sp.languages |= CppLanguage;
if (runConfiguration->useQmlDebugger()) {
sp.qmlServerAddress = _("127.0.0.1");
sp.qmlServerPort = runConfiguration->qmlDebugServerPort();
sp.qmlServerPort = runConfiguration->debuggerAspect()->qmlDebugServerPort();
sp.languages |= QmlLanguage;
// Makes sure that all bindings go through the JavaScript engine, so that
......@@ -820,9 +1022,7 @@ RunControl *DebuggerRunControlFactory::create
RunConfigWidget *DebuggerRunControlFactory::createConfigurationWidget
(RunConfiguration *runConfiguration)
{
// NBS TODO: Add GDB-specific configuration widget
Q_UNUSED(runConfiguration)
return 0;
return new DebuggerRunConfigWidget(runConfiguration);
}
DebuggerRunControl *DebuggerRunControlFactory::create
......@@ -867,5 +1067,6 @@ DebuggerEngine *DebuggerRunControlFactory::createEngine
return 0;
}
} // namespace Debugger
#include "debuggerrunner.moc"
......@@ -80,7 +80,7 @@ void MaemoRunConfiguration::init()
connect(m_remoteMounts, SIGNAL(modelReset()), SLOT(handleRemoteMountsChanged()));
if (!maemoTarget()->allowsQmlDebugging())
setUseQmlDebugger(false);
debuggerAspect()->setUseQmlDebugger(false);
}
bool MaemoRunConfiguration::isEnabled() const
......
......@@ -40,7 +40,6 @@
#include <utils/detailswidget.h>
#include <utils/environment.h>