add "run in terminal" options

This commit is contained in:
Oswald Buddenhagen
2009-02-18 17:04:04 +01:00
parent 40e70a98f9
commit df8ffb09fd
6 changed files with 74 additions and 8 deletions

View File

@@ -39,7 +39,7 @@ using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal; using namespace CMakeProjectManager::Internal;
CMakeRunConfiguration::CMakeRunConfiguration(CMakeProject *pro, const QString &target, const QString &workingDirectory) 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); setName(target);
} }
@@ -60,7 +60,7 @@ QString CMakeRunConfiguration::executable() const
ProjectExplorer::ApplicationRunConfiguration::RunMode CMakeRunConfiguration::runMode() const ProjectExplorer::ApplicationRunConfiguration::RunMode CMakeRunConfiguration::runMode() const
{ {
return ProjectExplorer::ApplicationRunConfiguration::Gui; return m_runMode;
} }
QString CMakeRunConfiguration::workingDirectory() const QString CMakeRunConfiguration::workingDirectory() const
@@ -85,6 +85,7 @@ void CMakeRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writ
ProjectExplorer::ApplicationRunConfiguration::save(writer); ProjectExplorer::ApplicationRunConfiguration::save(writer);
writer.saveValue("CMakeRunConfiguration.Target", m_target); writer.saveValue("CMakeRunConfiguration.Target", m_target);
writer.saveValue("CMakeRunConfiguration.WorkingDirectory", m_workingDirectory); writer.saveValue("CMakeRunConfiguration.WorkingDirectory", m_workingDirectory);
writer.saveValue("CMakeRunConfiguration.UseTerminal", m_runMode == Console);
} }
void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReader &reader) void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReader &reader)
@@ -92,6 +93,7 @@ void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsRea
ProjectExplorer::ApplicationRunConfiguration::restore(reader); ProjectExplorer::ApplicationRunConfiguration::restore(reader);
m_target = reader.restoreValue("CMakeRunConfiguration.Target").toString(); m_target = reader.restoreValue("CMakeRunConfiguration.Target").toString();
m_workingDirectory = reader.restoreValue("CMakeRunConfiguration.WorkingDirectory").toString(); m_workingDirectory = reader.restoreValue("CMakeRunConfiguration.WorkingDirectory").toString();
m_runMode = reader.restoreValue("CMakeRunConfiguration.UseTerminal").toBool() ? Console : Gui;
} }
QWidget *CMakeRunConfiguration::configurationWidget() QWidget *CMakeRunConfiguration::configurationWidget()

View File

@@ -55,6 +55,7 @@ public:
virtual void save(ProjectExplorer::PersistentSettingsWriter &writer) const; virtual void save(ProjectExplorer::PersistentSettingsWriter &writer) const;
virtual void restore(const ProjectExplorer::PersistentSettingsReader &reader); virtual void restore(const ProjectExplorer::PersistentSettingsReader &reader);
private: private:
RunMode m_runMode;
QString m_target; QString m_target;
QString m_workingDirectory; QString m_workingDirectory;
}; };

View File

@@ -31,6 +31,7 @@
#include "environment.h" #include "environment.h"
#include "project.h" #include "project.h"
#include <QtGui/QCheckBox>
#include <QtGui/QFormLayout> #include <QtGui/QFormLayout>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QLabel> #include <QtGui/QLabel>
@@ -61,6 +62,9 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
m_workingDirectory = new Core::Utils::PathChooser(); m_workingDirectory = new Core::Utils::PathChooser();
layout->addRow("Working Directory:", m_workingDirectory); layout->addRow("Working Directory:", m_workingDirectory);
m_useTerminalCheck = new QCheckBox(tr("Run in &Terminal"));
layout->addRow(QString(), m_useTerminalCheck);
setLayout(layout); setLayout(layout);
changed(); changed();
@@ -70,7 +74,9 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
this, SLOT(setCommandLineArguments(const QString&))); this, SLOT(setCommandLineArguments(const QString&)));
connect(m_workingDirectory, SIGNAL(changed()), connect(m_workingDirectory, SIGNAL(changed()),
this, SLOT(setWorkingDirectory())); this, SLOT(setWorkingDirectory()));
connect(m_useTerminalCheck, SIGNAL(toggled(bool)),
this, SLOT(termToggled(bool)));
connect(m_runConfiguration, SIGNAL(changed()), this, SLOT(changed())); connect(m_runConfiguration, SIGNAL(changed()), this, SLOT(changed()));
} }
@@ -93,6 +99,14 @@ void CustomExecutableConfigurationWidget::setWorkingDirectory()
m_ignoreChange = false; 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() void CustomExecutableConfigurationWidget::changed()
{ {
// We triggered the change, don't update us // We triggered the change, don't update us
@@ -101,6 +115,7 @@ void CustomExecutableConfigurationWidget::changed()
m_executableChooser->setPath(m_runConfiguration->baseExecutable()); m_executableChooser->setPath(m_runConfiguration->baseExecutable());
m_commandLineArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(m_runConfiguration->commandLineArguments())); m_commandLineArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(m_runConfiguration->commandLineArguments()));
m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory()); m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory());
m_useTerminalCheck->setChecked(m_runConfiguration->runMode() == ApplicationRunConfiguration::Console);
} }
CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Project *pro) CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Project *pro)
@@ -166,7 +181,7 @@ QString CustomExecutableRunConfiguration::executable() const
ApplicationRunConfiguration::RunMode CustomExecutableRunConfiguration::runMode() const ApplicationRunConfiguration::RunMode CustomExecutableRunConfiguration::runMode() const
{ {
return ApplicationRunConfiguration::Gui; return m_runMode;
} }
QString CustomExecutableRunConfiguration::baseWorkingDirectory() const QString CustomExecutableRunConfiguration::baseWorkingDirectory() const
@@ -197,6 +212,7 @@ void CustomExecutableRunConfiguration::save(PersistentSettingsWriter &writer) co
writer.saveValue("Executable", m_executable); writer.saveValue("Executable", m_executable);
writer.saveValue("Arguments", m_cmdArguments); writer.saveValue("Arguments", m_cmdArguments);
writer.saveValue("WorkingDirectory", m_workingDirectory); writer.saveValue("WorkingDirectory", m_workingDirectory);
writer.saveValue("UseTerminal", m_runMode == Console);
ApplicationRunConfiguration::save(writer); ApplicationRunConfiguration::save(writer);
} }
@@ -205,6 +221,7 @@ void CustomExecutableRunConfiguration::restore(const PersistentSettingsReader &r
m_executable = reader.restoreValue("Executable").toString(); m_executable = reader.restoreValue("Executable").toString();
m_cmdArguments = reader.restoreValue("Arguments").toStringList(); m_cmdArguments = reader.restoreValue("Arguments").toStringList();
m_workingDirectory = reader.restoreValue("WorkingDirectory").toString(); m_workingDirectory = reader.restoreValue("WorkingDirectory").toString();
m_runMode = reader.restoreValue("UseTerminal").toBool() ? Console : Gui;
ApplicationRunConfiguration::restore(reader); ApplicationRunConfiguration::restore(reader);
} }
@@ -227,6 +244,12 @@ void CustomExecutableRunConfiguration::setWorkingDirectory(const QString &workin
emit changed(); emit changed();
} }
void CustomExecutableRunConfiguration::setRunMode(RunMode runMode)
{
m_runMode = runMode;
emit changed();
}
QWidget *CustomExecutableRunConfiguration::configurationWidget() QWidget *CustomExecutableRunConfiguration::configurationWidget()
{ {
return new CustomExecutableConfigurationWidget(this); return new CustomExecutableConfigurationWidget(this);

View File

@@ -37,6 +37,7 @@
#include <QtGui/QToolButton> #include <QtGui/QToolButton>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QCheckBox;
class QLineEdit; class QLineEdit;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -75,14 +76,15 @@ public:
virtual QWidget *configurationWidget(); virtual QWidget *configurationWidget();
signals: signals:
void changed(); void changed();
private slots: private:
void setExecutable(const QString &executable); void setExecutable(const QString &executable);
void setCommandLineArguments(const QString &commandLineArguments); void setCommandLineArguments(const QString &commandLineArguments);
void setWorkingDirectory(const QString &workingDirectory); void setWorkingDirectory(const QString &workingDirectory);
private: void setRunMode(RunMode runMode);
QString m_executable; QString m_executable;
QString m_workingDirectory; QString m_workingDirectory;
QStringList m_cmdArguments; QStringList m_cmdArguments;
RunMode m_runMode;
}; };
class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory class CustomExecutableRunConfigurationFactory : public IRunConfigurationFactory
@@ -110,12 +112,14 @@ private slots:
void setExecutable(); void setExecutable();
void setCommandLineArguments(const QString &commandLineArguments); void setCommandLineArguments(const QString &commandLineArguments);
void setWorkingDirectory(); void setWorkingDirectory();
void termToggled(bool);
private: private:
bool m_ignoreChange; bool m_ignoreChange;
CustomExecutableRunConfiguration *m_runConfiguration; CustomExecutableRunConfiguration *m_runConfiguration;
Core::Utils::PathChooser *m_executableChooser; Core::Utils::PathChooser *m_executableChooser;
QLineEdit *m_commandLineArgumentsLineEdit; QLineEdit *m_commandLineArgumentsLineEdit;
Core::Utils::PathChooser *m_workingDirectory; Core::Utils::PathChooser *m_workingDirectory;
QCheckBox *m_useTerminalCheck;
}; };
} }
} }

View File

@@ -43,6 +43,7 @@
#include <QtGui/QFormLayout> #include <QtGui/QFormLayout>
#include <QtGui/QInputDialog> #include <QtGui/QInputDialog>
#include <QtGui/QLabel> #include <QtGui/QLabel>
#include <QtGui/QCheckBox>
using namespace Qt4ProjectManager::Internal; using namespace Qt4ProjectManager::Internal;
using namespace Qt4ProjectManager; using namespace Qt4ProjectManager;
@@ -106,16 +107,25 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
argumentsLabel->setBuddy(m_argumentsLineEdit); argumentsLabel->setBuddy(m_argumentsLineEdit);
toplayout->addRow(argumentsLabel, 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&)), connect(m_argumentsLineEdit, SIGNAL(textEdited(const QString&)),
this, SLOT(setCommandLineArguments(const QString&))); this, SLOT(setCommandLineArguments(const QString&)));
connect(m_nameLineEdit, SIGNAL(textEdited(const QString&)), connect(m_nameLineEdit, SIGNAL(textEdited(const QString&)),
this, SLOT(nameEdited(const QString&))); this, SLOT(nameEdited(const QString&)));
connect(m_useTerminalCheck, SIGNAL(toggled(bool)),
this, SLOT(termToggled(bool)));
connect(qt4RunConfiguration, SIGNAL(commandLineArgumentsChanged(QString)), connect(qt4RunConfiguration, SIGNAL(commandLineArgumentsChanged(QString)),
this, SLOT(commandLineArgumentsChanged(QString))); this, SLOT(commandLineArgumentsChanged(QString)));
connect(qt4RunConfiguration, SIGNAL(nameChanged(QString)), connect(qt4RunConfiguration, SIGNAL(nameChanged(QString)),
this, SLOT(nameChanged(QString))); this, SLOT(nameChanged(QString)));
connect(qt4RunConfiguration, SIGNAL(runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode)),
this, SLOT(runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode)));
connect(qt4RunConfiguration, SIGNAL(effectiveExecutableChanged()), connect(qt4RunConfiguration, SIGNAL(effectiveExecutableChanged()),
this, SLOT(effectiveExecutableChanged())); this, SLOT(effectiveExecutableChanged()));
@@ -138,6 +148,14 @@ void Qt4RunConfigurationWidget::nameEdited(const QString &name)
m_ignoreChange = false; 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) void Qt4RunConfigurationWidget::commandLineArgumentsChanged(const QString &args)
{ {
if (!m_ignoreChange) if (!m_ignoreChange)
@@ -150,6 +168,12 @@ void Qt4RunConfigurationWidget::nameChanged(const QString &name)
m_nameLineEdit->setText(name); m_nameLineEdit->setText(name);
} }
void Qt4RunConfigurationWidget::runModeChanged(ApplicationRunConfiguration::RunMode runMode)
{
if (!m_ignoreChange)
m_useTerminalCheck->setChecked(runMode == ApplicationRunConfiguration::Console);
}
void Qt4RunConfigurationWidget::effectiveExecutableChanged() void Qt4RunConfigurationWidget::effectiveExecutableChanged()
{ {
m_executableLabel->setText(m_qt4RunConfiguration->executable()); m_executableLabel->setText(m_qt4RunConfiguration->executable());
@@ -172,6 +196,7 @@ void Qt4RunConfiguration::save(PersistentSettingsWriter &writer) const
writer.saveValue("CommandLineArguments", m_commandLineArguments); writer.saveValue("CommandLineArguments", m_commandLineArguments);
writer.saveValue("ProFile", m_proFilePath); writer.saveValue("ProFile", m_proFilePath);
writer.saveValue("UserSetName", m_userSetName); writer.saveValue("UserSetName", m_userSetName);
writer.saveValue("UseTerminal", m_runMode == Console);
ApplicationRunConfiguration::save(writer); ApplicationRunConfiguration::save(writer);
} }
@@ -181,6 +206,7 @@ void Qt4RunConfiguration::restore(const PersistentSettingsReader &reader)
m_commandLineArguments = reader.restoreValue("CommandLineArguments").toStringList(); m_commandLineArguments = reader.restoreValue("CommandLineArguments").toStringList();
m_proFilePath = reader.restoreValue("ProFile").toString(); m_proFilePath = reader.restoreValue("ProFile").toString();
m_userSetName = reader.restoreValue("UserSetName").toBool(); m_userSetName = reader.restoreValue("UserSetName").toBool();
m_runMode = reader.restoreValue("UseTerminal").toBool() ? Console : Gui;
if (!m_proFilePath.isEmpty()) { if (!m_proFilePath.isEmpty()) {
updateCachedValues(); updateCachedValues();
if (!m_userSetName) if (!m_userSetName)
@@ -221,6 +247,12 @@ void Qt4RunConfiguration::setCommandLineArguments(const QString &argumentsString
emit commandLineArgumentsChanged(argumentsString); emit commandLineArgumentsChanged(argumentsString);
} }
void Qt4RunConfiguration::setRunMode(RunMode runMode)
{
m_runMode = runMode;
emit runModeChanged(runMode);
}
void Qt4RunConfiguration::nameEdited(const QString &name) void Qt4RunConfiguration::nameEdited(const QString &name)
{ {
if (name == "") { if (name == "") {
@@ -283,8 +315,6 @@ void Qt4RunConfiguration::updateCachedValues()
m_targets = reader->values(QLatin1String("TARGET")); m_targets = reader->values(QLatin1String("TARGET"));
m_srcDir = QFileInfo(m_proFilePath).path(); m_srcDir = QFileInfo(m_proFilePath).path();
const QStringList config = reader->values(QLatin1String("CONFIG"));
m_runMode = ProjectExplorer::ApplicationRunConfiguration::Gui;
delete reader; delete reader;

View File

@@ -36,6 +36,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QWidget; class QWidget;
class QCheckBox;
class QLabel; class QLabel;
class QLineEdit; class QLineEdit;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -78,6 +79,7 @@ public:
signals: signals:
void nameChanged(const QString&); void nameChanged(const QString&);
void commandLineArgumentsChanged(const QString&); void commandLineArgumentsChanged(const QString&);
void runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode runMode);
// note those signals might not emited for every change // note those signals might not emited for every change
void effectiveExecutableChanged(); void effectiveExecutableChanged();
@@ -86,6 +88,7 @@ signals:
private slots: private slots:
void setCommandLineArguments(const QString &argumentsString); void setCommandLineArguments(const QString &argumentsString);
void nameEdited(const QString&); void nameEdited(const QString&);
void setRunMode(RunMode runMode);
private: private:
void detectQtShadowBuild(const QString &buildConfig) const; void detectQtShadowBuild(const QString &buildConfig) const;
@@ -119,8 +122,10 @@ private slots:
// TODO connect to signals from qt4runconfiguration for changed arguments and names // TODO connect to signals from qt4runconfiguration for changed arguments and names
void commandLineArgumentsChanged(const QString &args); void commandLineArgumentsChanged(const QString &args);
void nameChanged(const QString &name); void nameChanged(const QString &name);
void runModeChanged(ProjectExplorer::ApplicationRunConfiguration::RunMode runMode);
void effectiveExecutableChanged(); void effectiveExecutableChanged();
void effectiveWorkingDirectoryChanged(); void effectiveWorkingDirectoryChanged();
void termToggled(bool);
private: private:
Qt4RunConfiguration *m_qt4RunConfiguration; Qt4RunConfiguration *m_qt4RunConfiguration;
bool m_ignoreChange; bool m_ignoreChange;
@@ -128,6 +133,7 @@ private:
QLabel *m_workingDirectoryLabel; QLabel *m_workingDirectoryLabel;
QLineEdit *m_nameLineEdit; QLineEdit *m_nameLineEdit;
QLineEdit *m_argumentsLineEdit; QLineEdit *m_argumentsLineEdit;
QCheckBox *m_useTerminalCheck;
}; };
class Qt4RunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory class Qt4RunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory