Commit 8c394710 authored by Lasse Holmstedt's avatar Lasse Holmstedt

Debugger languages are now runconfiguration dependent

There's a UI in qml/customexec/cmake/qmake run configs for choosing the
debugger languages (C++ and QML). The default for all except .qmlproject
is only C++, so default debugging behavior is the same. However, if the
user wants to do simultaneous debugging with two languages, or only
debug QML, they can select the languages from Run Settings and it will
be remembered.

Reviewed-by: hunger
parent 3db7e514
#include "debuggerlanguagechooser.h"
#include <QHBoxLayout>
#include <QCheckBox>
namespace Utils {
DebuggerLanguageChooser::DebuggerLanguageChooser(QWidget *parent) :
QWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout(this);
setLayout(layout);
m_useCppDebugger = new QCheckBox(tr("C++"), this);
m_useQmlDebugger = new QCheckBox(tr("QML"), this);
layout->setMargin(0);
layout->addWidget(m_useCppDebugger);
layout->addWidget(m_useQmlDebugger);
connect(m_useCppDebugger, SIGNAL(toggled(bool)),
this, SLOT(useCppDebuggerToggled(bool)));
connect(m_useQmlDebugger, SIGNAL(toggled(bool)),
this, SLOT(useQmlDebuggerToggled(bool)));
}
void DebuggerLanguageChooser::setCppChecked(bool value)
{
m_useCppDebugger->setChecked(value);
}
void DebuggerLanguageChooser::setQmlChecked(bool value)
{
m_useQmlDebugger->setChecked(value);
}
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);
}
} // namespace Utils
#ifndef DEBUGGERLANGUAGECHOOSER_H
#define DEBUGGERLANGUAGECHOOSER_H
#include <QWidget>
#include "utils_global.h"
QT_FORWARD_DECLARE_CLASS(QCheckBox);
namespace Utils {
class QTCREATOR_UTILS_EXPORT DebuggerLanguageChooser : public QWidget
{
Q_OBJECT
public:
explicit DebuggerLanguageChooser(QWidget *parent = 0);
void setCppChecked(bool value);
void setQmlChecked(bool value);
signals:
void cppLanguageToggled(bool value);
void qmlLanguageToggled(bool value);
private slots:
void useCppDebuggerToggled(bool toggled);
void useQmlDebuggerToggled(bool toggled);
private:
QCheckBox *m_useCppDebugger;
QCheckBox *m_useQmlDebugger;
};
} // namespace Utils
#endif // DEBUGGERLANGUAGECHOOSER_H
......@@ -45,7 +45,9 @@ SOURCES += $$PWD/reloadpromptutils.cpp \
$$PWD/faketooltip.cpp \
$$PWD/htmldocextractor.cpp \
$$PWD/navigationtreeview.cpp \
$$PWD/crumblepath.cpp
$$PWD/crumblepath.cpp \
$$PWD/debuggerlanguagechooser.cpp
win32 {
SOURCES += $$PWD/abstractprocess_win.cpp \
$$PWD/consoleprocess_win.cpp \
......@@ -101,7 +103,9 @@ HEADERS += $$PWD/utils_global.h \
$$PWD/faketooltip.h \
$$PWD/htmldocextractor.h \
$$PWD/navigationtreeview.h \
$$PWD/crumblepath.h
$$PWD/crumblepath.h \
$$PWD/debuggerlanguagechooser.h
FORMS += $$PWD/filewizardpage.ui \
$$PWD/projectintropage.ui \
$$PWD/newclasswidget.ui \
......
......@@ -38,6 +38,7 @@
#include <projectexplorer/environment.h>
#include <projectexplorer/debugginghelper.h>
#include <utils/qtcassert.h>
#include <utils/debuggerlanguagechooser.h>
#include <QtGui/QFormLayout>
#include <QtGui/QLineEdit>
#include <QtGui/QGroupBox>
......@@ -346,6 +347,13 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
fl->addRow(tr("Working Directory:"), boxlayout);
QLabel *debuggerLabel = new QLabel(tr("Debugger:"), this);
m_debuggerLanguageChooser = new Utils::DebuggerLanguageChooser(this);
fl->addRow(debuggerLabel, m_debuggerLanguageChooser);
m_debuggerLanguageChooser->setCppChecked(m_cmakeRunConfiguration->useCppDebugger());
m_debuggerLanguageChooser->setQmlChecked(m_cmakeRunConfiguration->useQmlDebugger());
m_detailsContainer = new Utils::DetailsWidget(this);
m_detailsContainer->setState(Utils::DetailsWidget::NoSummary);
......@@ -394,6 +402,11 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
connect(resetButton, SIGNAL(clicked()),
this, SLOT(resetWorkingDirectory()));
connect(m_debuggerLanguageChooser, SIGNAL(cppLanguageToggled(bool)),
this, SLOT(useCppDebuggerToggled(bool)));
connect(m_debuggerLanguageChooser, SIGNAL(qmlLanguageToggled(bool)),
this, SLOT(useQmlDebuggerToggled(bool)));
connect(m_environmentWidget, SIGNAL(userChangesChanged()),
this, SLOT(userChangesChanged()));
......@@ -428,6 +441,16 @@ void CMakeRunConfigurationWidget::resetWorkingDirectory()
m_cmakeRunConfiguration->setUserWorkingDirectory("");
}
void CMakeRunConfigurationWidget::useCppDebuggerToggled(bool toggled)
{
m_cmakeRunConfiguration->setUseCppDebugger(toggled);
}
void CMakeRunConfigurationWidget::useQmlDebuggerToggled(bool toggled)
{
m_cmakeRunConfiguration->setUseQmlDebugger(toggled);
}
void CMakeRunConfigurationWidget::userChangesChanged()
{
m_cmakeRunConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
......
......@@ -41,6 +41,10 @@ QT_BEGIN_NAMESPACE
class QComboBox;
QT_END_NAMESPACE
namespace Utils {
class DebuggerLanguageChooser;
}
namespace CMakeProjectManager {
namespace Internal {
......@@ -93,6 +97,8 @@ signals:
private slots:
void setArguments(const QString &newText);
void useCppDebuggerToggled(bool toggled);
void useQmlDebuggerToggled(bool toggled);
protected:
CMakeRunConfiguration(CMakeTarget *parent, CMakeRunConfiguration *source);
......@@ -137,6 +143,8 @@ private slots:
void userChangesChanged();
void setWorkingDirectory();
void resetWorkingDirectory();
void useCppDebuggerToggled(bool toggled);
void useQmlDebuggerToggled(bool toggled);
private slots:
void baseEnvironmentComboBoxChanged(int index);
......@@ -148,6 +156,7 @@ private:
CMakeRunConfiguration *m_cmakeRunConfiguration;
Utils::PathChooser *m_workingDirectoryEdit;
QComboBox *m_baseEnvironmentComboBox;
Utils::DebuggerLanguageChooser *m_debuggerLanguageChooser;
ProjectExplorer::EnvironmentWidget *m_environmentWidget;
Utils::DetailsWidget *m_detailsContainer;
};
......
......@@ -134,6 +134,7 @@ struct DebuggerUISwitcherPrivate
QWeakPointer<ProjectExplorer::Project> m_previousProject;
QWeakPointer<ProjectExplorer::Target> m_previousTarget;
QWeakPointer<ProjectExplorer::RunConfiguration> m_previousRunConfiguration;
bool m_initialized;
......@@ -221,7 +222,8 @@ void DebuggerUISwitcher::updateUiForTarget(ProjectExplorer::Target *target)
return;
if (d->m_previousTarget) {
disconnect(target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
disconnect(d->m_previousTarget.data(),
SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
this, SLOT(updateUiForRunConfiguration(ProjectExplorer::RunConfiguration*)));
}
d->m_previousTarget = target;
......@@ -230,33 +232,33 @@ void DebuggerUISwitcher::updateUiForTarget(ProjectExplorer::Target *target)
updateUiForRunConfiguration(target->activeRunConfiguration());
}
static bool isQmlProjectType(ProjectExplorer::RunConfiguration *rc)
{
if (rc && rc->target() && rc->target()->project()) {
return (rc->target()->project()->id() == QLatin1String("QmlProjectManager.QmlProject"));
}
return false;
}
// updates default debug language settings per run config.
void DebuggerUISwitcher::updateUiForRunConfiguration(ProjectExplorer::RunConfiguration *rc)
{
bool isDotQmlProjectType = isQmlProjectType(rc);
if (rc) {
d->m_languageActionGroup->setDisabled(false);
if (d->m_qmlEnabled) {
d->m_activateCppAction->setChecked(!isDotQmlProjectType);
d->m_activateQmlAction->setChecked(isDotQmlProjectType);
} else {
if (d->m_activateQmlAction)
d->m_activateQmlAction->setChecked(false);
if (d->m_previousRunConfiguration) {
disconnect(d->m_previousRunConfiguration.data(),
SIGNAL(debuggersChanged()),
this, SLOT(updateUiForCurrentRunConfiguration()));
}
} else {
d->m_previousRunConfiguration = rc;
connect(d->m_previousRunConfiguration.data(),
SIGNAL(debuggersChanged()),
this, SLOT(updateUiForCurrentRunConfiguration()));
updateUiForCurrentRunConfiguration();
}
}
void DebuggerUISwitcher::updateUiForCurrentRunConfiguration()
{
if (d->m_previousRunConfiguration) {
ProjectExplorer::RunConfiguration *rc = d->m_previousRunConfiguration.data();
if (d->m_activateCppAction)
d->m_activateCppAction->setChecked(true);
d->m_activateCppAction->setChecked(rc->useCppDebugger());
if (d->m_activateQmlAction)
d->m_activateQmlAction->setChecked(false);
d->m_languageActionGroup->setDisabled(true);
d->m_activateQmlAction->setChecked(rc->useQmlDebugger());
}
updateActiveLanguages();
......
......@@ -132,6 +132,7 @@ private slots:
void updateUiForProject(ProjectExplorer::Project *project);
void updateUiForTarget(ProjectExplorer::Target *target);
void updateUiForRunConfiguration(ProjectExplorer::RunConfiguration *rc);
void updateUiForCurrentRunConfiguration();
void updateUiOnFileListChange();
void updateActiveLanguages();
......
......@@ -37,6 +37,7 @@
#include <projectexplorer/target.h>
#include <utils/detailswidget.h>
#include <utils/pathchooser.h>
#include <utils/debuggerlanguagechooser.h>
#include <QtCore/QDir>
#include <QtGui/QCheckBox>
......@@ -102,6 +103,13 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
m_useTerminalCheck = new QCheckBox(tr("Run in &Terminal"), this);
layout->addRow(QString(), m_useTerminalCheck);
QLabel *debuggerLabel = new QLabel(tr("Debugger:"), this);
m_debuggerLanguageChooser = new Utils::DebuggerLanguageChooser(this);
layout->addRow(debuggerLabel, m_debuggerLanguageChooser);
m_debuggerLanguageChooser->setCppChecked(m_runConfiguration->useCppDebugger());
m_debuggerLanguageChooser->setQmlChecked(m_runConfiguration->useQmlDebugger());
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0);
......@@ -154,6 +162,11 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
connect(m_useTerminalCheck, SIGNAL(toggled(bool)),
this, SLOT(termToggled(bool)));
connect(m_debuggerLanguageChooser, SIGNAL(cppLanguageToggled(bool)),
this, SLOT(useCppDebuggerToggled(bool)));
connect(m_debuggerLanguageChooser, SIGNAL(qmlLanguageToggled(bool)),
this, SLOT(useQmlDebuggerToggled(bool)));
connect(m_runConfiguration, SIGNAL(changed()), this, SLOT(changed()));
connect(m_environmentWidget, SIGNAL(userChangesChanged()),
......@@ -180,6 +193,16 @@ void CustomExecutableConfigurationWidget::baseEnvironmentSelected(int index)
m_ignoreChange = false;
}
void CustomExecutableConfigurationWidget::useCppDebuggerToggled(bool toggled)
{
m_runConfiguration->setUseCppDebugger(toggled);
}
void CustomExecutableConfigurationWidget::useQmlDebuggerToggled(bool toggled)
{
m_runConfiguration->setUseQmlDebugger(toggled);
}
void CustomExecutableConfigurationWidget::baseEnvironmentChanged()
{
if (m_ignoreChange)
......@@ -279,6 +302,7 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *paren
ctor();
}
// Note: Qt4Project deletes all empty customexecrunconfigs for which isConfigured() == false.
CustomExecutableRunConfiguration::~CustomExecutableRunConfiguration()
{
}
......@@ -466,7 +490,7 @@ bool CustomExecutableRunConfiguration::fromMap(const QVariantMap &map)
m_baseEnvironmentBase = static_cast<BaseEnvironmentBase>(map.value(QLatin1String(BASE_ENVIRONMENT_BASE_KEY), static_cast<int>(CustomExecutableRunConfiguration::BuildEnvironmentBase)).toInt());
setDefaultDisplayName(defaultDisplayName());
return RunConfiguration::fromMap(map);
return LocalApplicationRunConfiguration::fromMap(map);
}
void CustomExecutableRunConfiguration::setExecutable(const QString &executable)
......
......@@ -46,6 +46,7 @@ QT_END_NAMESPACE
namespace Utils {
class DetailsWidget;
class PathChooser;
class DebuggerLanguageChooser;
}
namespace ProjectExplorer {
......@@ -184,6 +185,9 @@ private slots:
void baseEnvironmentChanged();
void userEnvironmentChangesChanged();
void baseEnvironmentSelected(int index);
void useCppDebuggerToggled(bool toggled);
void useQmlDebuggerToggled(bool toggled);
private:
bool m_ignoreChange;
CustomExecutableRunConfiguration *m_runConfiguration;
......@@ -195,6 +199,7 @@ private:
ProjectExplorer::EnvironmentWidget *m_environmentWidget;
QComboBox *m_baseEnvironmentComboBox;
Utils::DetailsWidget *m_detailsContainer;
Utils::DebuggerLanguageChooser *m_debuggerLanguageChooser;
};
} // namespace Internal
......
......@@ -52,6 +52,9 @@ using namespace ProjectExplorer;
namespace {
// Function objects:
const char * const USE_CPP_DEBUGGER_KEY("RunConfiguration.UseCppDebugger");
const char * const USE_QML_DEBUGGER_KEY("RunConfiguration.UseQmlDebugger");
class RunConfigurationFactoryMatcher
{
public:
......@@ -141,7 +144,9 @@ IRunConfigurationFactory * findRunConfigurationFactory(RunConfigurationFactoryMa
// RunConfiguration
RunConfiguration::RunConfiguration(Target *target, const QString &id) :
ProjectConfiguration(target, id)
ProjectConfiguration(target, id),
m_useCppDebugger(true),
m_useQmlDebugger(false)
{
Q_ASSERT(target);
}
......@@ -182,6 +187,43 @@ Target *RunConfiguration::target() const
return static_cast<Target *>(parent());
}
void RunConfiguration::setUseQmlDebugger(bool value)
{
m_useQmlDebugger = value;
emit debuggersChanged();
}
void RunConfiguration::setUseCppDebugger(bool value)
{
m_useCppDebugger = value;
emit debuggersChanged();
}
bool RunConfiguration::useCppDebugger() const
{
return m_useCppDebugger;
}
bool RunConfiguration::useQmlDebugger() const
{
return m_useQmlDebugger;
}
QVariantMap RunConfiguration::toMap() const
{
QVariantMap map(ProjectConfiguration::toMap());
map.insert(QLatin1String(USE_CPP_DEBUGGER_KEY), m_useCppDebugger);
map.insert(QLatin1String(USE_QML_DEBUGGER_KEY), m_useQmlDebugger);
return map;
}
bool RunConfiguration::fromMap(const QVariantMap &map)
{
m_useCppDebugger = map.value(QLatin1String(USE_CPP_DEBUGGER_KEY), true).toBool();
m_useQmlDebugger = map.value(QLatin1String(USE_QML_DEBUGGER_KEY), false).toBool();
return ProjectConfiguration::fromMap(map);
}
ProjectExplorer::OutputFormatter *RunConfiguration::createOutputFormatter() const
{
return new OutputFormatter();
......
......@@ -87,8 +87,15 @@ public:
virtual ProjectExplorer::OutputFormatter *createOutputFormatter() const;
void setUseQmlDebugger(bool value);
void setUseCppDebugger(bool value);
bool useQmlDebugger() const;
bool useCppDebugger() const;
virtual QVariantMap toMap() const;
signals:
void isEnabledChanged(bool value);
void debuggersChanged();
protected:
RunConfiguration(Target *parent, const QString &id);
......@@ -96,6 +103,12 @@ protected:
/// convenience method to get current build configuration.
BuildConfiguration *activeBuildConfiguration() const;
virtual bool fromMap(const QVariantMap &map);
private:
bool m_useCppDebugger;
bool m_useQmlDebugger;
};
/**
......
......@@ -41,6 +41,7 @@
#include <coreplugin/ifile.h>
#include <utils/synchronousprocess.h>
#include <utils/pathchooser.h>
#include <utils/debuggerlanguagechooser.h>
#include <qt4projectmanager/qtversionmanager.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
......@@ -92,6 +93,10 @@ bool QmlProjectRunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration *
void QmlProjectRunConfiguration::ctor()
{
// reset default settings in constructor
setUseCppDebugger(false);
setUseQmlDebugger(true);
Core::EditorManager *em = Core::EditorManager::instance();
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(changeCurrentFile(Core::IEditor*)));
......@@ -202,7 +207,19 @@ QWidget *QmlProjectRunConfiguration::createConfigurationWidget()
form->addRow(tr("Debugging Address:"), debugServer);
form->addRow(tr("Debugging Port:"), debugPort);
QLabel *debuggerLabel = new QLabel(tr("Debugger:"), config);
Utils::DebuggerLanguageChooser *debuggerLanguageChooser = new Utils::DebuggerLanguageChooser(config);
form->addRow(tr("Main QML File:"), m_fileListCombo.data());
form->addRow(debuggerLabel, debuggerLanguageChooser);
debuggerLanguageChooser->setCppChecked(useCppDebugger());
debuggerLanguageChooser->setQmlChecked(useQmlDebugger());
connect(debuggerLanguageChooser, SIGNAL(cppLanguageToggled(bool)),
this, SLOT(useCppDebuggerToggled(bool)));
connect(debuggerLanguageChooser, SIGNAL(qmlLanguageToggled(bool)),
this, SLOT(useQmlDebuggerToggled(bool)));
return config;
}
......@@ -298,6 +315,17 @@ void QmlProjectRunConfiguration::onDebugServerPortChanged()
}
}
void QmlProjectRunConfiguration::useCppDebuggerToggled(bool toggled)
{
setUseCppDebugger(toggled);
}
void QmlProjectRunConfiguration::useQmlDebuggerToggled(bool toggled)
{
setUseQmlDebugger(toggled);
}
QVariantMap QmlProjectRunConfiguration::toMap() const
{
QVariantMap map(ProjectExplorer::RunConfiguration::toMap());
......
......@@ -99,6 +99,8 @@ private slots:
void onViewerArgsChanged();
void onDebugServerAddressChanged();
void onDebugServerPortChanged();
void useCppDebuggerToggled(bool toggled);
void useQmlDebuggerToggled(bool toggled);
protected:
QString viewerDefaultPath() const;
......
......@@ -49,6 +49,7 @@
#include <utils/qtcassert.h>
#include <utils/pathchooser.h>
#include <utils/detailswidget.h>
#include <utils/debuggerlanguagechooser.h>
#include <QtGui/QFormLayout>
#include <QtGui/QInputDialog>
......@@ -223,6 +224,13 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
m_useTerminalCheck->setChecked(m_qt4RunConfiguration->runMode() == ProjectExplorer::LocalApplicationRunConfiguration::Console);
toplayout->addRow(QString(), m_useTerminalCheck);
QLabel *debuggerLabel = new QLabel(tr("Debugger:"), this);
m_debuggerLanguageChooser = new Utils::DebuggerLanguageChooser(this);
toplayout->addRow(debuggerLabel, m_debuggerLanguageChooser);
m_debuggerLanguageChooser->setCppChecked(m_qt4RunConfiguration->useCppDebugger());
m_debuggerLanguageChooser->setQmlChecked(m_qt4RunConfiguration->useQmlDebugger());
#ifdef Q_OS_MAC
m_usingDyldImageSuffix = new QCheckBox(tr("Use debug version of frameworks (DYLD_IMAGE_SUFFIX=_debug)"), this);
m_usingDyldImageSuffix->setChecked(m_qt4RunConfiguration->isUsingDyldImageSuffix());
......@@ -273,6 +281,11 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
connect(m_useTerminalCheck, SIGNAL(toggled(bool)),
this, SLOT(termToggled(bool)));
connect(m_debuggerLanguageChooser, SIGNAL(cppLanguageToggled(bool)),
this, SLOT(useCppDebuggerToggled(bool)));
connect(m_debuggerLanguageChooser, SIGNAL(qmlLanguageToggled(bool)),
this, SLOT(useQmlDebuggerToggled(bool)));
connect(m_environmentWidget, SIGNAL(userChangesChanged()),
this, SLOT(userChangesEdited()));
......@@ -299,6 +312,16 @@ Qt4RunConfigurationWidget::~Qt4RunConfigurationWidget()
{
}
void Qt4RunConfigurationWidget::useCppDebuggerToggled(bool toggled)
{
m_qt4RunConfiguration->setUseCppDebugger(toggled);
}
void Qt4RunConfigurationWidget::useQmlDebuggerToggled(bool toggled)
{
m_qt4RunConfiguration->setUseQmlDebugger(toggled);
}
void Qt4RunConfigurationWidget::baseEnvironmentSelected(int index)
{
m_ignoreChange = true;
......
......@@ -43,6 +43,7 @@ QT_END_NAMESPACE
namespace Utils {
class PathChooser;
class DebuggerLanguageChooser;
class DetailsWidget;
}
......@@ -172,6 +173,8 @@ private slots:
void usingDyldImageSuffixToggled(bool);
void usingDyldImageSuffixChanged(bool);
void baseEnvironmentSelected(int index);
void useCppDebuggerToggled(bool toggled);
void useQmlDebuggerToggled(bool toggled);
private:
Qt4RunConfiguration *m_qt4RunConfiguration;
......@@ -184,7 +187,7 @@ private:
QComboBox *m_baseEnvironmentComboBox;
Utils::DetailsWidget *m_detailsContainer;
Utils::DebuggerLanguageChooser *m_debuggerLanguageChooser;
ProjectExplorer::EnvironmentWidget *m_environmentWidget;
bool m_isShown;
};
......
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