forked from qt-creator/qt-creator
CMake: Use ArgumentsAspect in CMakeRunConfiguration
Change-Id: I30fbfc0bcc5e6c997190c3f1a1c279dab06fdbc0 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
#include <coreplugin/helpmanager.h>
|
#include <coreplugin/helpmanager.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
#include <projectexplorer/localenvironmentaspect.h>
|
#include <projectexplorer/localenvironmentaspect.h>
|
||||||
|
#include <projectexplorer/runconfigurationaspects.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
@@ -64,7 +65,6 @@ const char CMAKE_RC_PREFIX[] = "CMakeProjectManager.CMakeRunConfiguration.";
|
|||||||
const char USER_WORKING_DIRECTORY_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory";
|
const char USER_WORKING_DIRECTORY_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory";
|
||||||
const char USE_TERMINAL_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UseTerminal";
|
const char USE_TERMINAL_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UseTerminal";
|
||||||
const char TITLE_KEY[] = "CMakeProjectManager.CMakeRunConfiguation.Title";
|
const char TITLE_KEY[] = "CMakeProjectManager.CMakeRunConfiguation.Title";
|
||||||
const char ARGUMENTS_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.Arguments";
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -78,6 +78,7 @@ CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, Core::Id id, const
|
|||||||
m_enabled(true)
|
m_enabled(true)
|
||||||
{
|
{
|
||||||
addExtraAspect(new LocalEnvironmentAspect(this));
|
addExtraAspect(new LocalEnvironmentAspect(this));
|
||||||
|
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("CMakeProjectManager.CMakeRunConfiguration.Arguments")));
|
||||||
ctor();
|
ctor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +89,6 @@ CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, CMakeRunConfigurati
|
|||||||
m_workingDirectory(source->m_workingDirectory),
|
m_workingDirectory(source->m_workingDirectory),
|
||||||
m_userWorkingDirectory(source->m_userWorkingDirectory),
|
m_userWorkingDirectory(source->m_userWorkingDirectory),
|
||||||
m_title(source->m_title),
|
m_title(source->m_title),
|
||||||
m_arguments(source->m_arguments),
|
|
||||||
m_enabled(source->m_enabled)
|
m_enabled(source->m_enabled)
|
||||||
{
|
{
|
||||||
ctor();
|
ctor();
|
||||||
@@ -135,7 +135,7 @@ QString CMakeRunConfiguration::baseWorkingDirectory() const
|
|||||||
|
|
||||||
QString CMakeRunConfiguration::commandLineArguments() const
|
QString CMakeRunConfiguration::commandLineArguments() const
|
||||||
{
|
{
|
||||||
return macroExpander()->expandProcessArgs(m_arguments);
|
return extraAspect<ArgumentsAspect>()->arguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CMakeRunConfiguration::title() const
|
QString CMakeRunConfiguration::title() const
|
||||||
@@ -177,7 +177,6 @@ QVariantMap CMakeRunConfiguration::toMap() const
|
|||||||
map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEY), m_userWorkingDirectory);
|
map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEY), m_userWorkingDirectory);
|
||||||
map.insert(QLatin1String(USE_TERMINAL_KEY), m_runMode == ApplicationLauncher::Console);
|
map.insert(QLatin1String(USE_TERMINAL_KEY), m_runMode == ApplicationLauncher::Console);
|
||||||
map.insert(QLatin1String(TITLE_KEY), m_title);
|
map.insert(QLatin1String(TITLE_KEY), m_title);
|
||||||
map.insert(QLatin1String(ARGUMENTS_KEY), m_arguments);
|
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@@ -188,7 +187,6 @@ bool CMakeRunConfiguration::fromMap(const QVariantMap &map)
|
|||||||
m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY)).toBool() ? ApplicationLauncher::Console
|
m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY)).toBool() ? ApplicationLauncher::Console
|
||||||
: ApplicationLauncher::Gui;
|
: ApplicationLauncher::Gui;
|
||||||
m_title = map.value(QLatin1String(TITLE_KEY)).toString();
|
m_title = map.value(QLatin1String(TITLE_KEY)).toString();
|
||||||
m_arguments = map.value(QLatin1String(ARGUMENTS_KEY)).toString();
|
|
||||||
|
|
||||||
return RunConfiguration::fromMap(map);
|
return RunConfiguration::fromMap(map);
|
||||||
}
|
}
|
||||||
@@ -210,11 +208,6 @@ QWidget *CMakeRunConfiguration::createConfigurationWidget()
|
|||||||
return new CMakeRunConfigurationWidget(this);
|
return new CMakeRunConfigurationWidget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeRunConfiguration::setCommandLineArguments(const QString &newText)
|
|
||||||
{
|
|
||||||
m_arguments = newText;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMakeRunConfiguration::setEnabled(bool b)
|
void CMakeRunConfiguration::setEnabled(bool b)
|
||||||
{
|
{
|
||||||
if (m_enabled == b)
|
if (m_enabled == b)
|
||||||
@@ -243,10 +236,8 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *
|
|||||||
QFormLayout *fl = new QFormLayout();
|
QFormLayout *fl = new QFormLayout();
|
||||||
fl->setMargin(0);
|
fl->setMargin(0);
|
||||||
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||||
QLineEdit *argumentsLineEdit = new QLineEdit();
|
|
||||||
argumentsLineEdit->setText(cmakeRunConfiguration->commandLineArguments());
|
cmakeRunConfiguration->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, fl);
|
||||||
connect(argumentsLineEdit, &QLineEdit::textChanged, this, &CMakeRunConfigurationWidget::setArguments);
|
|
||||||
fl->addRow(tr("Arguments:"), argumentsLineEdit);
|
|
||||||
|
|
||||||
m_workingDirectoryEdit = new Utils::PathChooser();
|
m_workingDirectoryEdit = new Utils::PathChooser();
|
||||||
m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory);
|
m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory);
|
||||||
@@ -338,10 +329,6 @@ void CMakeRunConfigurationWidget::environmentWasChanged()
|
|||||||
QTC_ASSERT(aspect, return);
|
QTC_ASSERT(aspect, return);
|
||||||
m_workingDirectoryEdit->setEnvironment(aspect->environment());
|
m_workingDirectoryEdit->setEnvironment(aspect->environment());
|
||||||
}
|
}
|
||||||
void CMakeRunConfigurationWidget::setArguments(const QString &args)
|
|
||||||
{
|
|
||||||
m_cmakeRunConfiguration->setCommandLineArguments(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Factory
|
// Factory
|
||||||
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory(QObject *parent) :
|
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory(QObject *parent) :
|
||||||
|
@@ -81,9 +81,6 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void baseWorkingDirectoryChanged(const QString&);
|
void baseWorkingDirectoryChanged(const QString&);
|
||||||
|
|
||||||
private slots:
|
|
||||||
void setCommandLineArguments(const QString &newText);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CMakeRunConfiguration(ProjectExplorer::Target *parent, CMakeRunConfiguration *source);
|
CMakeRunConfiguration(ProjectExplorer::Target *parent, CMakeRunConfiguration *source);
|
||||||
virtual bool fromMap(const QVariantMap &map);
|
virtual bool fromMap(const QVariantMap &map);
|
||||||
@@ -99,7 +96,6 @@ private:
|
|||||||
QString m_workingDirectory;
|
QString m_workingDirectory;
|
||||||
QString m_userWorkingDirectory;
|
QString m_userWorkingDirectory;
|
||||||
QString m_title;
|
QString m_title;
|
||||||
QString m_arguments;
|
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -110,7 +106,6 @@ public:
|
|||||||
explicit CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent = 0);
|
explicit CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent = 0);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setArguments(const QString &args);
|
|
||||||
void setWorkingDirectory();
|
void setWorkingDirectory();
|
||||||
void resetWorkingDirectory();
|
void resetWorkingDirectory();
|
||||||
void runInTerminalToggled(bool toggled);
|
void runInTerminalToggled(bool toggled);
|
||||||
|
Reference in New Issue
Block a user