forked from qt-creator/qt-creator
QtSupport: Use ArgumentsAspect in CustomExecutableRunConfiguration
Change-Id: I739d41d917cd72f7be093ceb5200b8c947d09f4a Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
@@ -228,9 +228,12 @@ QString ArgumentsAspect::unexpandedArguments() const
|
||||
|
||||
void ArgumentsAspect::setArguments(const QString &arguments)
|
||||
{
|
||||
if (arguments != m_arguments) {
|
||||
m_arguments = arguments;
|
||||
if (m_chooser)
|
||||
m_chooser->setText(m_arguments);
|
||||
emit argumentsChanged(arguments);
|
||||
}
|
||||
if (m_chooser->text() != arguments)
|
||||
m_chooser->setText(arguments);
|
||||
}
|
||||
|
||||
void ArgumentsAspect::fromMap(const QVariantMap &map)
|
||||
@@ -258,6 +261,7 @@ void ArgumentsAspect::addToMainConfigurationWidget(QWidget *parent, QFormLayout
|
||||
QTC_CHECK(!m_chooser);
|
||||
m_chooser = new FancyLineEdit(parent);
|
||||
m_chooser->setHistoryCompleter(m_key);
|
||||
m_chooser->setText(m_arguments);
|
||||
|
||||
connect(m_chooser, &QLineEdit::textChanged, this, &ArgumentsAspect::setArguments);
|
||||
|
||||
|
||||
@@ -123,12 +123,15 @@ public:
|
||||
|
||||
void setArguments(const QString &arguments);
|
||||
|
||||
signals:
|
||||
void argumentsChanged(const QString &arguments);
|
||||
|
||||
private:
|
||||
void fromMap(const QVariantMap &map) override;
|
||||
void toMap(QVariantMap &map) const override;
|
||||
|
||||
QString m_arguments;
|
||||
Utils::FancyLineEdit *m_chooser;
|
||||
QPointer<Utils::FancyLineEdit> m_chooser;
|
||||
QString m_key;
|
||||
};
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <utils/detailswidget.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
@@ -52,7 +53,10 @@ namespace QtSupport {
|
||||
namespace Internal {
|
||||
|
||||
CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomExecutableRunConfiguration *rc, ApplyMode mode)
|
||||
: m_ignoreChange(false), m_runConfiguration(rc), m_temporaryTerminalAspect(0)
|
||||
: m_ignoreChange(false),
|
||||
m_runConfiguration(rc),
|
||||
m_temporaryArgumentsAspect(0),
|
||||
m_temporaryTerminalAspect(0)
|
||||
{
|
||||
QFormLayout *layout = new QFormLayout;
|
||||
layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||
@@ -63,9 +67,15 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
|
||||
m_executableChooser->setExpectedKind(Utils::PathChooser::Command);
|
||||
layout->addRow(tr("Executable:"), m_executableChooser);
|
||||
|
||||
m_commandLineArgumentsLineEdit = new QLineEdit(this);
|
||||
m_commandLineArgumentsLineEdit->setMinimumWidth(200); // this shouldn't be fixed here...
|
||||
layout->addRow(tr("Arguments:"), m_commandLineArgumentsLineEdit);
|
||||
ArgumentsAspect *argumentsAspect = rc->extraAspect<ArgumentsAspect>();
|
||||
if (mode == InstantApply) {
|
||||
argumentsAspect->addToMainConfigurationWidget(this, layout);
|
||||
} else {
|
||||
m_temporaryArgumentsAspect = argumentsAspect->clone(rc);
|
||||
m_temporaryArgumentsAspect->addToMainConfigurationWidget(this, layout);
|
||||
connect(m_temporaryArgumentsAspect, &ArgumentsAspect::argumentsChanged,
|
||||
this, &CustomExecutableConfigurationWidget::validChanged);
|
||||
}
|
||||
|
||||
m_workingDirectory = new Utils::PathChooser(this);
|
||||
m_workingDirectory->setHistoryCompleter(QLatin1String("Qt.WorkingDir.History"));
|
||||
@@ -100,15 +110,11 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
|
||||
if (mode == InstantApply) {
|
||||
connect(m_executableChooser, SIGNAL(changed(QString)),
|
||||
this, SLOT(executableEdited()));
|
||||
connect(m_commandLineArgumentsLineEdit, SIGNAL(textEdited(QString)),
|
||||
this, SLOT(argumentsEdited(QString)));
|
||||
connect(m_workingDirectory, SIGNAL(changed(QString)),
|
||||
this, SLOT(workingDirectoryEdited()));
|
||||
} else {
|
||||
connect(m_executableChooser, SIGNAL(changed(QString)),
|
||||
this, SIGNAL(validChanged()));
|
||||
connect(m_commandLineArgumentsLineEdit, SIGNAL(textEdited(QString)),
|
||||
this, SIGNAL(validChanged()));
|
||||
connect(m_workingDirectory, SIGNAL(changed(QString)),
|
||||
this, SIGNAL(validChanged()));
|
||||
}
|
||||
@@ -130,6 +136,7 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE
|
||||
|
||||
CustomExecutableConfigurationWidget::~CustomExecutableConfigurationWidget()
|
||||
{
|
||||
delete m_temporaryArgumentsAspect;
|
||||
delete m_temporaryTerminalAspect;
|
||||
}
|
||||
|
||||
@@ -148,12 +155,7 @@ void CustomExecutableConfigurationWidget::executableEdited()
|
||||
m_runConfiguration->setExecutable(m_executableChooser->rawPath());
|
||||
m_ignoreChange = false;
|
||||
}
|
||||
void CustomExecutableConfigurationWidget::argumentsEdited(const QString &arguments)
|
||||
{
|
||||
m_ignoreChange = true;
|
||||
m_runConfiguration->setCommandLineArguments(arguments);
|
||||
m_ignoreChange = false;
|
||||
}
|
||||
|
||||
void CustomExecutableConfigurationWidget::workingDirectoryEdited()
|
||||
{
|
||||
m_ignoreChange = true;
|
||||
@@ -168,7 +170,6 @@ void CustomExecutableConfigurationWidget::changed()
|
||||
return;
|
||||
|
||||
m_executableChooser->setPath(m_runConfiguration->rawExecutable());
|
||||
m_commandLineArgumentsLineEdit->setText(m_runConfiguration->rawCommandLineArguments());
|
||||
m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory());
|
||||
}
|
||||
|
||||
@@ -176,7 +177,7 @@ void CustomExecutableConfigurationWidget::apply()
|
||||
{
|
||||
m_ignoreChange = true;
|
||||
m_runConfiguration->setExecutable(m_executableChooser->rawPath());
|
||||
m_runConfiguration->setCommandLineArguments(m_commandLineArgumentsLineEdit->text());
|
||||
m_runConfiguration->setCommandLineArguments(m_temporaryArgumentsAspect->unexpandedArguments());
|
||||
m_runConfiguration->setBaseWorkingDirectory(m_workingDirectory->rawPath());
|
||||
m_runConfiguration->setRunMode(m_temporaryTerminalAspect->runMode());
|
||||
m_ignoreChange = false;
|
||||
|
||||
@@ -47,6 +47,7 @@ class PathChooser;
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class ArgumentsAspect;
|
||||
class TerminalAspect;
|
||||
}
|
||||
|
||||
@@ -74,16 +75,15 @@ private slots:
|
||||
void changed();
|
||||
|
||||
void executableEdited();
|
||||
void argumentsEdited(const QString &arguments);
|
||||
void workingDirectoryEdited();
|
||||
void environmentWasChanged();
|
||||
|
||||
private:
|
||||
bool m_ignoreChange;
|
||||
CustomExecutableRunConfiguration *m_runConfiguration;
|
||||
ProjectExplorer::ArgumentsAspect *m_temporaryArgumentsAspect;
|
||||
ProjectExplorer::TerminalAspect *m_temporaryTerminalAspect;
|
||||
Utils::PathChooser *m_executableChooser;
|
||||
QLineEdit *m_commandLineArgumentsLineEdit;
|
||||
Utils::PathChooser *m_workingDirectory;
|
||||
Utils::DetailsWidget *m_detailsContainer;
|
||||
};
|
||||
|
||||
@@ -60,7 +60,6 @@ namespace {
|
||||
const char CUSTOM_EXECUTABLE_ID[] = "ProjectExplorer.CustomExecutableRunConfiguration";
|
||||
|
||||
const char EXECUTABLE_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.Executable";
|
||||
const char ARGUMENTS_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.Arguments";
|
||||
const char WORKING_DIRECTORY_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory";
|
||||
}
|
||||
|
||||
@@ -75,8 +74,8 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *paren
|
||||
m_dialog(0)
|
||||
{
|
||||
addExtraAspect(new LocalEnvironmentAspect(this));
|
||||
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("ProjectExplorer.CustomExecutableRunConfiguration.Arguments")));
|
||||
addExtraAspect(new TerminalAspect(this, QStringLiteral("ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal")));
|
||||
|
||||
if (!parent->activeBuildConfiguration())
|
||||
m_workingDirectory = QLatin1String(Constants::DEFAULT_WORKING_DIR_ALTERNATE);
|
||||
ctor();
|
||||
@@ -87,7 +86,6 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *paren
|
||||
LocalApplicationRunConfiguration(parent, source),
|
||||
m_executable(source->m_executable),
|
||||
m_workingDirectory(source->m_workingDirectory),
|
||||
m_cmdArguments(source->m_cmdArguments),
|
||||
m_dialog(0)
|
||||
{
|
||||
ctor();
|
||||
@@ -264,12 +262,7 @@ QString CustomExecutableRunConfiguration::baseWorkingDirectory() const
|
||||
|
||||
QString CustomExecutableRunConfiguration::commandLineArguments() const
|
||||
{
|
||||
return macroExpander()->expandProcessArgs(m_cmdArguments);
|
||||
}
|
||||
|
||||
QString CustomExecutableRunConfiguration::rawCommandLineArguments() const
|
||||
{
|
||||
return m_cmdArguments;
|
||||
return extraAspect<ArgumentsAspect>()->arguments();
|
||||
}
|
||||
|
||||
QString CustomExecutableRunConfiguration::defaultDisplayName() const
|
||||
@@ -284,7 +277,6 @@ QVariantMap CustomExecutableRunConfiguration::toMap() const
|
||||
{
|
||||
QVariantMap map(LocalApplicationRunConfiguration::toMap());
|
||||
map.insert(QLatin1String(EXECUTABLE_KEY), m_executable);
|
||||
map.insert(QLatin1String(ARGUMENTS_KEY), m_cmdArguments);
|
||||
map.insert(QLatin1String(WORKING_DIRECTORY_KEY), m_workingDirectory);
|
||||
return map;
|
||||
}
|
||||
@@ -292,7 +284,6 @@ QVariantMap CustomExecutableRunConfiguration::toMap() const
|
||||
bool CustomExecutableRunConfiguration::fromMap(const QVariantMap &map)
|
||||
{
|
||||
m_executable = map.value(QLatin1String(EXECUTABLE_KEY)).toString();
|
||||
m_cmdArguments = map.value(QLatin1String(ARGUMENTS_KEY)).toString();
|
||||
m_workingDirectory = map.value(QLatin1String(WORKING_DIRECTORY_KEY)).toString();
|
||||
|
||||
setDefaultDisplayName(defaultDisplayName());
|
||||
@@ -310,7 +301,7 @@ void CustomExecutableRunConfiguration::setExecutable(const QString &executable)
|
||||
|
||||
void CustomExecutableRunConfiguration::setCommandLineArguments(const QString &commandLineArguments)
|
||||
{
|
||||
m_cmdArguments = commandLineArguments;
|
||||
extraAspect<ArgumentsAspect>()->setArguments(commandLineArguments);
|
||||
emit changed();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,6 @@ private:
|
||||
void setExecutable(const QString &executable);
|
||||
QString rawExecutable() const;
|
||||
void setCommandLineArguments(const QString &commandLineArguments);
|
||||
QString rawCommandLineArguments() const;
|
||||
void setBaseWorkingDirectory(const QString &workingDirectory);
|
||||
QString baseWorkingDirectory() const;
|
||||
void setUserName(const QString &name);
|
||||
@@ -103,7 +102,6 @@ private:
|
||||
|
||||
QString m_executable;
|
||||
QString m_workingDirectory;
|
||||
QString m_cmdArguments;
|
||||
ProjectExplorer::ApplicationLauncher::Mode m_runMode;
|
||||
QWidget *m_dialog;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user