diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp index 42c183a9f0a792233ff30ab275fdc0364e6d389c..73007ad7d16eebd4d6e7278a815ca1efd02fc591 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp @@ -39,7 +39,7 @@ using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &target, const QString &workingDirectory) - : ProjectExplorer::ApplicationRunConfiguration(pro), m_target(target), m_workingDirectory(workingDirectory) + : ProjectExplorer::ApplicationRunConfiguration(pro), m_runMode(Gui), m_target(target), m_workingDirectory(workingDirectory) { setName(target); } @@ -60,7 +60,7 @@ QString CMakeRunConfiguration::executable() const ProjectExplorer::ApplicationRunConfiguration::RunMode CMakeRunConfiguration::runMode() const { - return ProjectExplorer::ApplicationRunConfiguration::Gui; + return m_runMode; } QString CMakeRunConfiguration::workingDirectory() const @@ -85,6 +85,7 @@ void CMakeRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writ ProjectExplorer::ApplicationRunConfiguration::save(writer); writer.saveValue("CMakeRunConfiguration.Target", m_target); writer.saveValue("CMakeRunConfiguration.WorkingDirectory", m_workingDirectory); + writer.saveValue("CMakeRunConfiguration.UseTerminal", m_runMode == Console); } void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReader &reader) @@ -92,6 +93,7 @@ void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsRea ProjectExplorer::ApplicationRunConfiguration::restore(reader); m_target = reader.restoreValue("CMakeRunConfiguration.Target").toString(); m_workingDirectory = reader.restoreValue("CMakeRunConfiguration.WorkingDirectory").toString(); + m_runMode = reader.restoreValue("CMakeRunConfiguration.UseTerminal").toBool() ? Console : Gui; } QWidget *CMakeRunConfiguration::configurationWidget() diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h index 098b86863e2adab9fe168226aa92d3cbd7e03941..77bbbc7b92090267e04a675e40de54bef9625a6e 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h @@ -55,6 +55,7 @@ public: virtual void save(ProjectExplorer::PersistentSettingsWriter &writer) const; virtual void restore(const ProjectExplorer::PersistentSettingsReader &reader); private: + RunMode m_runMode; QString m_target; QString m_workingDirectory; }; diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index a8634d586565d9a89ca6f94016f7364521da68b5..caf65f74999229443dbedb7ec5dc1e4b37435efb 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -31,6 +31,7 @@ #include "environment.h" #include "project.h" +#include <QtGui/QCheckBox> #include <QtGui/QFormLayout> #include <QtGui/QLineEdit> #include <QtGui/QLabel> @@ -61,6 +62,9 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE m_workingDirectory = new Core::Utils::PathChooser(); layout->addRow("Working Directory:", m_workingDirectory); + m_useTerminalCheck = new QCheckBox(tr("Run in &Terminal")); + layout->addRow(QString(), m_useTerminalCheck); + setLayout(layout); changed(); @@ -70,7 +74,9 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE this, SLOT(setCommandLineArguments(const QString&))); connect(m_workingDirectory, SIGNAL(changed()), this, SLOT(setWorkingDirectory())); - + connect(m_useTerminalCheck, SIGNAL(toggled(bool)), + this, SLOT(termToggled(bool))); + connect(m_runConfiguration, SIGNAL(changed()), this, SLOT(changed())); } @@ -93,6 +99,14 @@ void CustomExecutableConfigurationWidget::setWorkingDirectory() m_ignoreChange = false; } +void CustomExecutableConfigurationWidget::termToggled(bool on) +{ + m_ignoreChange = true; + m_runConfiguration->setRunMode(on ? ApplicationRunConfiguration::Console + : ApplicationRunConfiguration::Gui); + m_ignoreChange = false; +} + void CustomExecutableConfigurationWidget::changed() { // We triggered the change, don't update us @@ -101,6 +115,7 @@ void CustomExecutableConfigurationWidget::changed() m_executableChooser->setPath(m_runConfiguration->baseExecutable()); m_commandLineArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(m_runConfiguration->commandLineArguments())); m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory()); + m_useTerminalCheck->setChecked(m_runConfiguration->runMode() == ApplicationRunConfiguration::Console); } CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Project *pro) @@ -166,7 +181,7 @@ QString CustomExecutableRunConfiguration::executable() const ApplicationRunConfiguration::RunMode CustomExecutableRunConfiguration::runMode() const { - return ApplicationRunConfiguration::Gui; + return m_runMode; } QString CustomExecutableRunConfiguration::baseWorkingDirectory() const @@ -197,6 +212,7 @@ void CustomExecutableRunConfiguration::save(PersistentSettingsWriter &writer) co writer.saveValue("Executable", m_executable); writer.saveValue("Arguments", m_cmdArguments); writer.saveValue("WorkingDirectory", m_workingDirectory); + writer.saveValue("UseTerminal", m_runMode == Console); ApplicationRunConfiguration::save(writer); } @@ -205,6 +221,7 @@ void CustomExecutableRunConfiguration::restore(const PersistentSettingsReader &r m_executable = reader.restoreValue("Executable").toString(); m_cmdArguments = reader.restoreValue("Arguments").toStringList(); m_workingDirectory = reader.restoreValue("WorkingDirectory").toString(); + m_runMode = reader.restoreValue("UseTerminal").toBool() ? Console : Gui; ApplicationRunConfiguration::restore(reader); } @@ -227,6 +244,12 @@ void CustomExecutableRunConfiguration::setWorkingDirectory(const QString &workin emit changed(); } +void CustomExecutableRunConfiguration::setRunMode(RunMode runMode) +{ + m_runMode = runMode; + emit changed(); +} + QWidget *CustomExecutableRunConfiguration::configurationWidget() { return new CustomExecutableConfigurationWidget(this); diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.h b/src/plugins/projectexplorer/customexecutablerunconfiguration.h index 1873399ba8e3e3a3113e60c61f3fcc20d9242160..400feb0e4160c8f2d91e5a2a0bb4026b82b23b94 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.h +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.h @@ -37,6 +37,7 @@ #include <QtGui/QToolButton> QT_BEGIN_NAMESPACE +class QCheckBox; class QLineEdit; QT_END_NAMESPACE @@ -75,14 +76,15 @@ public: virtual QWidget *configurationWidget(); signals: void changed(); -private slots: +private: void setExecutable(const QString &executable); void setCommandLineArguments(const QString &commandLineArguments); void setWorkingDirectory(const QString &workingDirectory); -private: + void setRunMode(RunMode runMode); QString m_executable; QString m_workingDirectory; QStringList m_cmdArguments; + RunMode m_runMode; }; class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory @@ -110,12 +112,14 @@ private slots: void setExecutable(); void setCommandLineArguments(const QString &commandLineArguments); void setWorkingDirectory(); + void termToggled(bool); private: bool m_ignoreChange; CustomExecutableRunConfiguration *m_runConfiguration; Core::Utils::PathChooser *m_executableChooser; QLineEdit *m_commandLineArgumentsLineEdit; Core::Utils::PathChooser *m_workingDirectory; + QCheckBox *m_useTerminalCheck; }; } } diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp index c722c726f7cff6e681e410d8c8be29e5d7c224ac..483ea16ff35e3986f6d03f312c63c4a0b2ed1544 100644 --- a/src/plugins/qt4projectmanager/qt4runconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt4runconfiguration.cpp @@ -43,6 +43,7 @@ #include <QtGui/QFormLayout> #include <QtGui/QInputDialog> #include <QtGui/QLabel> +#include <QtGui/QCheckBox> using namespace Qt4ProjectManager::Internal; using namespace Qt4ProjectManager; @@ -106,16 +107,25 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run argumentsLabel->setBuddy(m_argumentsLineEdit); toplayout->addRow(argumentsLabel, m_argumentsLineEdit); + m_useTerminalCheck = new QCheckBox(tr("Run in &Terminal")); + m_useTerminalCheck->setChecked(m_qt4RunConfiguration->runMode() == ProjectExplorer::ApplicationRunConfiguration::Console); + toplayout->addRow(QString(), m_useTerminalCheck); + connect(m_argumentsLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(setCommandLineArguments(const QString&))); connect(m_nameLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(nameEdited(const QString&))); + connect(m_useTerminalCheck, SIGNAL(toggled(bool)), + this, SLOT(termToggled(bool))); + connect(qt4RunConfiguration, SIGNAL(commandLineArgumentsChanged(QString)), this, SLOT(commandLineArgumentsChanged(QString))); connect(qt4RunConfiguration, SIGNAL(nameChanged(QString)), this, SLOT(nameChanged(QString))); + connect(qt4RunConfiguration, SIGNAL(runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode)), + this, SLOT(runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode))); connect(qt4RunConfiguration, SIGNAL(effectiveExecutableChanged()), this, SLOT(effectiveExecutableChanged())); @@ -138,6 +148,14 @@ void Qt4RunConfigurationWidget::nameEdited(const QString &name) m_ignoreChange = false; } +void Qt4RunConfigurationWidget::termToggled(bool on) +{ + m_ignoreChange = true; + m_qt4RunConfiguration->setRunMode(on ? ApplicationRunConfiguration::Console + : ApplicationRunConfiguration::Gui); + m_ignoreChange = false; +} + void Qt4RunConfigurationWidget::commandLineArgumentsChanged(const QString &args) { if (!m_ignoreChange) @@ -150,6 +168,12 @@ void Qt4RunConfigurationWidget::nameChanged(const QString &name) m_nameLineEdit->setText(name); } +void Qt4RunConfigurationWidget::runModeChanged(ApplicationRunConfiguration::RunMode runMode) +{ + if (!m_ignoreChange) + m_useTerminalCheck->setChecked(runMode == ApplicationRunConfiguration::Console); +} + void Qt4RunConfigurationWidget::effectiveExecutableChanged() { m_executableLabel->setText(m_qt4RunConfiguration->executable()); @@ -172,6 +196,7 @@ void Qt4RunConfiguration::save(PersistentSettingsWriter &writer) const writer.saveValue("CommandLineArguments", m_commandLineArguments); writer.saveValue("ProFile", m_proFilePath); writer.saveValue("UserSetName", m_userSetName); + writer.saveValue("UseTerminal", m_runMode == Console); ApplicationRunConfiguration::save(writer); } @@ -181,6 +206,7 @@ void Qt4RunConfiguration::restore(const PersistentSettingsReader &reader) m_commandLineArguments = reader.restoreValue("CommandLineArguments").toStringList(); m_proFilePath = reader.restoreValue("ProFile").toString(); m_userSetName = reader.restoreValue("UserSetName").toBool(); + m_runMode = reader.restoreValue("UseTerminal").toBool() ? Console : Gui; if (!m_proFilePath.isEmpty()) { updateCachedValues(); if (!m_userSetName) @@ -221,6 +247,12 @@ void Qt4RunConfiguration::setCommandLineArguments(const QString &argumentsString emit commandLineArgumentsChanged(argumentsString); } +void Qt4RunConfiguration::setRunMode(RunMode runMode) +{ + m_runMode = runMode; + emit runModeChanged(runMode); +} + void Qt4RunConfiguration::nameEdited(const QString &name) { if (name == "") { @@ -283,8 +315,6 @@ void Qt4RunConfiguration::updateCachedValues() m_targets = reader->values(QLatin1String("TARGET")); m_srcDir = QFileInfo(m_proFilePath).path(); - const QStringList config = reader->values(QLatin1String("CONFIG")); - m_runMode = ProjectExplorer::ApplicationRunConfiguration::Gui; delete reader; diff --git a/src/plugins/qt4projectmanager/qt4runconfiguration.h b/src/plugins/qt4projectmanager/qt4runconfiguration.h index 299a21e309aca047a4cdfafd80342ade0e448170..d848531d013b0e57220933eeb0596061303a5d7b 100644 --- a/src/plugins/qt4projectmanager/qt4runconfiguration.h +++ b/src/plugins/qt4projectmanager/qt4runconfiguration.h @@ -36,6 +36,7 @@ QT_BEGIN_NAMESPACE class QWidget; +class QCheckBox; class QLabel; class QLineEdit; QT_END_NAMESPACE @@ -78,6 +79,7 @@ public: signals: void nameChanged(const QString&); void commandLineArgumentsChanged(const QString&); + void runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode runMode); // note those signals might not emited for every change void effectiveExecutableChanged(); @@ -86,6 +88,7 @@ signals: private slots: void setCommandLineArguments(const QString &argumentsString); void nameEdited(const QString&); + void setRunMode(RunMode runMode); private: void detectQtShadowBuild(const QString &buildConfig) const; @@ -119,8 +122,10 @@ private slots: // TODO connect to signals from qt4runconfiguration for changed arguments and names void commandLineArgumentsChanged(const QString &args); void nameChanged(const QString &name); + void runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode runMode); void effectiveExecutableChanged(); void effectiveWorkingDirectoryChanged(); + void termToggled(bool); private: Qt4RunConfiguration *m_qt4RunConfiguration; bool m_ignoreChange; @@ -128,6 +133,7 @@ private: QLabel *m_workingDirectoryLabel; QLineEdit *m_nameLineEdit; QLineEdit *m_argumentsLineEdit; + QCheckBox *m_useTerminalCheck; }; class Qt4RunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory