Commit ddef96ec authored by dt's avatar dt
Browse files

Add a working directory line edit to the cmake run configuration

Task-Nr: 254424
parent 884b7af7
......@@ -40,6 +40,7 @@
#include <QtGui/QGroupBox>
#include <QtGui/QLabel>
#include <QtGui/QRadioButton>
#include <QtGui/QToolButton>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
......@@ -82,6 +83,8 @@ ProjectExplorer::ApplicationRunConfiguration::RunMode CMakeRunConfiguration::run
QString CMakeRunConfiguration::workingDirectory() const
{
if (!m_userWorkingDirectory.isEmpty())
return m_userWorkingDirectory;
return m_workingDirectory;
}
......@@ -100,9 +103,26 @@ void CMakeRunConfiguration::setExecutable(const QString &executable)
m_target = executable;
}
void CMakeRunConfiguration::setWorkingDirectory(const QString &workingDirectory)
void CMakeRunConfiguration::setWorkingDirectory(const QString &wd)
{
m_workingDirectory = workingDirectory;
const QString & oldWorkingDirectory = workingDirectory();
m_workingDirectory = wd;
const QString &newWorkingDirectory = workingDirectory();
if (oldWorkingDirectory != newWorkingDirectory)
emit workingDirectoryChanged(newWorkingDirectory);
}
void CMakeRunConfiguration::setUserWorkingDirectory(const QString &wd)
{
const QString & oldWorkingDirectory = workingDirectory();
m_userWorkingDirectory = wd;
const QString &newWorkingDirectory = workingDirectory();
if (oldWorkingDirectory != newWorkingDirectory)
emit workingDirectoryChanged(newWorkingDirectory);
}
void CMakeRunConfiguration::save(ProjectExplorer::PersistentSettingsWriter &writer) const
......@@ -110,11 +130,13 @@ 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.UserWorkingDirectory", m_userWorkingDirectory);
writer.saveValue("CMakeRunConfiguration.UseTerminal", m_runMode == Console);
writer.saveValue("CMakeRunConfiguation.Title", m_title);
writer.saveValue("CMakeRunConfiguration.Arguments", m_arguments);
writer.saveValue("CMakeRunConfiguration.UserEnvironmentChanges", ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges));
writer.saveValue("BaseEnvironmentBase", m_baseEnvironmentBase);
}
void CMakeRunConfiguration::restore(const ProjectExplorer::PersistentSettingsReader &reader)
......@@ -122,6 +144,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_userWorkingDirectory = reader.restoreValue("CMakeRunConfiguration.UserWorkingDirectory").toString();
m_runMode = reader.restoreValue("CMakeRunConfiguration.UseTerminal").toBool() ? Console : Gui;
m_title = reader.restoreValue("CMakeRunConfiguation.Title").toString();
m_arguments = reader.restoreValue("CMakeRunConfiguration.Arguments").toString();
......@@ -208,6 +231,21 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
this, SLOT(setArguments(QString)));
fl->addRow(tr("Arguments:"), argumentsLineEdit);
m_workingDirectoryEdit = new Core::Utils::PathChooser();
m_workingDirectoryEdit->setPath(m_cmakeRunConfiguration->workingDirectory());
m_workingDirectoryEdit->setExpectedKind(Core::Utils::PathChooser::Directory);
m_workingDirectoryEdit->setPromptDialogTitle(tr("Select the working directory"));
QToolButton *resetButton = new QToolButton();
resetButton->setToolTip(tr("Reset to default"));
resetButton->setIcon(QIcon(":/core/images/reset.png"));
QHBoxLayout *boxlayout = new QHBoxLayout();
boxlayout->addWidget(m_workingDirectoryEdit);
boxlayout->addWidget(resetButton);
fl->addRow(tr("Working Directory:"), boxlayout);
QGroupBox *box = new QGroupBox(tr("Environment"),this);
QVBoxLayout *boxLayout = new QVBoxLayout();
box->setLayout(boxLayout);
......@@ -223,6 +261,13 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
boxLayout->addWidget(m_systemEnvironmentRadioButton);
boxLayout->addWidget(m_buildEnvironmentRadioButton);
connect(m_workingDirectoryEdit, SIGNAL(changed()),
this, SLOT(setWorkingDirectory()));
connect(resetButton, SIGNAL(clicked()),
this, SLOT(resetWorkingDirectory()));
if (cmakeRunConfiguration->baseEnvironmentBase() == CMakeRunConfiguration::CleanEnvironmentBase)
m_cleanEnvironmentRadioButton->setChecked(true);
else if (cmakeRunConfiguration->baseEnvironmentBase() == CMakeRunConfiguration::SystemEnvironmentBase)
......@@ -250,10 +295,35 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
connect(m_environmentWidget, SIGNAL(userChangesUpdated()),
this, SLOT(userChangesUpdated()));
connect(m_cmakeRunConfiguration, SIGNAL(workingDirectoryChanged(QString)),
this, SLOT(workingDirectoryChanged(QString)));
connect(m_cmakeRunConfiguration, SIGNAL(baseEnvironmentChanged()),
this, SLOT(baseEnvironmentChanged()));
connect(m_cmakeRunConfiguration, SIGNAL(userEnvironmentChangesChanged(QList<ProjectExplorer::EnvironmentItem>)),
this, SLOT(userEnvironmentChangesChanged()));
}
void CMakeRunConfigurationWidget::setWorkingDirectory()
{
if (m_ignoreChange)
return;
m_ignoreChange = true;
m_cmakeRunConfiguration->setUserWorkingDirectory(m_workingDirectoryEdit->path());
m_ignoreChange = false;
}
void CMakeRunConfigurationWidget::workingDirectoryChanged(const QString &workingDirectory)
{
if (!m_ignoreChange)
m_workingDirectoryEdit->setPath(workingDirectory);
}
void CMakeRunConfigurationWidget::resetWorkingDirectory()
{
// This emits a signal connected to workingDirectoryChanged()
// that sets the m_workingDirectoryEdit
m_cmakeRunConfiguration->setUserWorkingDirectory("");
}
void CMakeRunConfigurationWidget::userChangesUpdated()
......
......@@ -34,6 +34,7 @@
#include <projectexplorer/environment.h>
#include <projectexplorer/persistentsettings.h>
#include <projectexplorer/environmenteditmodel.h>
#include <utils/pathchooser.h>
QT_BEGIN_NAMESPACE
class QRadioButton;
......@@ -62,6 +63,8 @@ public:
void setExecutable(const QString &executable);
void setWorkingDirectory(const QString &workingDirectory);
void setUserWorkingDirectory(const QString &workingDirectory);
QString title() const;
virtual void save(ProjectExplorer::PersistentSettingsWriter &writer) const;
......@@ -71,6 +74,7 @@ public:
signals:
void baseEnvironmentChanged();
void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &diff);
void workingDirectoryChanged(const QString&);
private slots:
void setArguments(const QString &newText);
......@@ -85,6 +89,7 @@ private:
RunMode m_runMode;
QString m_target;
QString m_workingDirectory;
QString m_userWorkingDirectory;
QString m_title;
QString m_arguments;
QList<ProjectExplorer::EnvironmentItem> m_userEnvironmentChanges;
......@@ -101,11 +106,15 @@ private slots:
void baseEnvironmentChanged();
void userEnvironmentChangesChanged();
void userChangesUpdated();
void setWorkingDirectory();
void resetWorkingDirectory();
private slots:
void baseEnvironmentRadioButtonChanged();
void workingDirectoryChanged(const QString &workingDirectory);
private:
bool m_ignoreChange;
CMakeRunConfiguration *m_cmakeRunConfiguration;
Core::Utils::PathChooser *m_workingDirectoryEdit;
ProjectExplorer::EnvironmentWidget *m_environmentWidget;
QRadioButton *m_cleanEnvironmentRadioButton;
QRadioButton *m_systemEnvironmentRadioButton;
......
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