Commit 5adeb48e authored by dt's avatar dt
Browse files

ApplicationRC: make exectuable() and co. return expanded values

parent 8cfcb1df
......@@ -132,6 +132,11 @@ ProjectExplorer::LocalApplicationRunConfiguration::RunMode CMakeRunConfiguration
}
QString CMakeRunConfiguration::workingDirectory() const
{
return environment().expandVariables(baseWorkingDirectory());
}
QString CMakeRunConfiguration::baseWorkingDirectory() const
{
if (!m_userWorkingDirectory.isEmpty())
return m_userWorkingDirectory;
......@@ -139,6 +144,11 @@ QString CMakeRunConfiguration::workingDirectory() const
}
QStringList CMakeRunConfiguration::commandLineArguments() const
{
return environment().expandVariables(baseCommandLineArguments());
}
QStringList CMakeRunConfiguration::baseCommandLineArguments() const
{
return Utils::Environment::parseCombinedArgString(m_arguments);
}
......@@ -155,7 +165,7 @@ void CMakeRunConfiguration::setExecutable(const QString &executable)
void CMakeRunConfiguration::setWorkingDirectory(const QString &wd)
{
const QString & oldWorkingDirectory = workingDirectory();
const QString &oldWorkingDirectory = workingDirectory();
m_workingDirectory = wd;
......@@ -326,14 +336,14 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
fl->setMargin(0);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
QLineEdit *argumentsLineEdit = new QLineEdit();
argumentsLineEdit->setText(Utils::Environment::joinArgumentList(cmakeRunConfiguration->commandLineArguments()));
argumentsLineEdit->setText(Utils::Environment::joinArgumentList(cmakeRunConfiguration->baseCommandLineArguments()));
connect(argumentsLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(setArguments(QString)));
fl->addRow(tr("Arguments:"), argumentsLineEdit);
m_workingDirectoryEdit = new Utils::PathChooser();
m_workingDirectoryEdit->setBaseDirectory(m_cmakeRunConfiguration->target()->project()->projectDirectory());
m_workingDirectoryEdit->setPath(m_cmakeRunConfiguration->workingDirectory());
m_workingDirectoryEdit->setPath(m_cmakeRunConfiguration->baseWorkingDirectory());
m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory);
m_workingDirectoryEdit->setPromptDialogTitle(tr("Select Working Directory"));
......
......@@ -104,6 +104,8 @@ protected:
QString defaultDisplayName() const;
private:
QString baseWorkingDirectory() const;
QStringList baseCommandLineArguments() const;
void ctor();
enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
......
......@@ -148,9 +148,9 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
sp.startMode = StartInternal;
sp.environment = rc->environment().toStringList();
sp.workingDirectory = rc->environment().expandVariables(rc->workingDirectory());
sp.executable = rc->environment().searchInPath(rc->executable(), QStringList() << sp.workingDirectory);
sp.processArgs = rc->environment().expandVariables(rc->commandLineArguments());
sp.workingDirectory = rc->workingDirectory();
sp.executable = rc->executable();
sp.processArgs = rc->commandLineArguments();
sp.toolChainType = rc->toolChainType();
sp.useTerminal = rc->runMode() == LocalApplicationRunConfiguration::Console;
sp.dumperLibrary = rc->dumperLibrary();
......
......@@ -95,13 +95,13 @@ LocalApplicationRunControl::LocalApplicationRunControl(LocalApplicationRunConfig
: RunControl(rc, mode)
{
Utils::Environment env = rc->environment();
QString dir = env.expandVariables(rc->workingDirectory());
QString dir = rc->workingDirectory();
m_applicationLauncher.setEnvironment(env.toStringList());
m_applicationLauncher.setWorkingDirectory(dir);
m_executable = env.searchInPath(rc->executable(), QStringList() << dir);
m_executable = rc->executable();
m_runMode = static_cast<ApplicationLauncher::Mode>(rc->runMode());
m_commandLineArguments = env.expandVariables(rc->commandLineArguments());
m_commandLineArguments = rc->commandLineArguments();
connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,bool)),
this, SLOT(slotAppendMessage(QString,bool)));
......
......@@ -281,8 +281,8 @@ void CustomExecutableConfigurationWidget::changed()
if (m_ignoreChange)
return;
m_executableChooser->setPath(executable);
m_commandLineArgumentsLineEdit->setText(Utils::Environment::joinArgumentList(m_runConfiguration->commandLineArguments()));
m_workingDirectory->setPath(m_runConfiguration->workingDirectory());
m_commandLineArgumentsLineEdit->setText(Utils::Environment::joinArgumentList(m_runConfiguration->baseCommandLineArguments()));
m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory());
m_useTerminalCheck->setChecked(m_runConfiguration->runMode() == LocalApplicationRunConfiguration::Console);
}
......@@ -343,7 +343,7 @@ void CustomExecutableRunConfiguration::activeBuildConfigurationChanged()
QString CustomExecutableRunConfiguration::executable() const
{
Utils::Environment env = environment();
QString exec = env.searchInPath(m_executable, QStringList() << env.expandVariables(workingDirectory()));
QString exec = env.searchInPath(m_executable, QStringList() << workingDirectory());
if (exec.isEmpty() || !QFileInfo(exec).exists()) {
// Oh the executable doesn't exists, ask the user.
......@@ -395,11 +395,22 @@ LocalApplicationRunConfiguration::RunMode CustomExecutableRunConfiguration::runM
}
QString CustomExecutableRunConfiguration::workingDirectory() const
{
return environment().expandVariables(baseWorkingDirectory());
}
QString CustomExecutableRunConfiguration::baseWorkingDirectory() const
{
return m_workingDirectory;
}
QStringList CustomExecutableRunConfiguration::commandLineArguments() const
{
return environment().expandVariables(baseCommandLineArguments());
}
QStringList CustomExecutableRunConfiguration::baseCommandLineArguments() const
{
return m_cmdArguments;
}
......
......@@ -124,6 +124,8 @@ private:
void setExecutable(const QString &executable);
void setCommandLineArguments(const QString &commandLineArguments);
QStringList baseCommandLineArguments() const;
QString baseWorkingDirectory() const;
void setWorkingDirectory(const QString &workingDirectory);
void setUserName(const QString &name);
void setRunMode(RunMode runMode);
......
......@@ -201,12 +201,12 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
toplayout->addRow(tr("Executable:"), m_executableLineEdit);
QLabel *argumentsLabel = new QLabel(tr("Arguments:"), this);
m_argumentsLineEdit = new QLineEdit(Utils::Environment::joinArgumentList(qt4RunConfiguration->commandLineArguments()), this);
m_argumentsLineEdit = new QLineEdit(Utils::Environment::joinArgumentList(qt4RunConfiguration->baseCommandLineArguments()), this);
argumentsLabel->setBuddy(m_argumentsLineEdit);
toplayout->addRow(argumentsLabel, m_argumentsLineEdit);
m_workingDirectoryEdit = new Utils::PathChooser(this);
m_workingDirectoryEdit->setPath(m_qt4RunConfiguration->workingDirectory());
m_workingDirectoryEdit->setPath(m_qt4RunConfiguration->baseWorkingDirectory());
m_workingDirectoryEdit->setBaseDirectory(m_qt4RunConfiguration->target()->project()->projectDirectory());
m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory);
m_workingDirectoryEdit->setEnvironment(m_qt4RunConfiguration->environment());
......@@ -442,7 +442,7 @@ void Qt4RunConfigurationWidget::effectiveTargetInformationChanged()
if (m_isShown) {
m_executableLineEdit->setText(QDir::toNativeSeparators(m_qt4RunConfiguration->executable()));
m_ignoreChange = true;
m_workingDirectoryEdit->setPath(QDir::toNativeSeparators(m_qt4RunConfiguration->workingDirectory()));
m_workingDirectoryEdit->setPath(QDir::toNativeSeparators(m_qt4RunConfiguration->baseWorkingDirectory()));
m_ignoreChange = false;
}
}
......@@ -524,6 +524,11 @@ void Qt4RunConfiguration::setUsingDyldImageSuffix(bool state)
}
QString Qt4RunConfiguration::workingDirectory() const
{
return environment().expandVariables(baseWorkingDirectory());
}
QString Qt4RunConfiguration::baseWorkingDirectory() const
{
// if the user overrode us, then return his working directory
if (m_userSetWokingDirectory)
......@@ -537,6 +542,12 @@ QString Qt4RunConfiguration::workingDirectory() const
return ti.workingDir;
}
QStringList Qt4RunConfiguration::baseCommandLineArguments() const
{
return environment().expandVariables(commandLineArguments());
}
QStringList Qt4RunConfiguration::commandLineArguments() const
{
return m_commandLineArguments;
......
......@@ -118,6 +118,8 @@ protected:
virtual bool fromMap(const QVariantMap &map);
private:
QString baseWorkingDirectory() const;
QStringList baseCommandLineArguments() const;
enum BaseEnvironmentBase { CleanEnvironmentBase = 0,
SystemEnvironmentBase = 1,
BuildEnvironmentBase = 2 };
......
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