diff --git a/src/plugins/projectexplorer/customexecutableconfigurationwidget.cpp b/src/plugins/projectexplorer/customexecutableconfigurationwidget.cpp index 3a2446e25e3..a32d7c71805 100644 --- a/src/plugins/projectexplorer/customexecutableconfigurationwidget.cpp +++ b/src/plugins/projectexplorer/customexecutableconfigurationwidget.cpp @@ -60,26 +60,23 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE layout->addRow(tr("Executable:"), m_executableChooser); auto argumentsAspect = rc->extraAspect(); + auto workingDirectoryAspect = rc->extraAspect(); + auto terminalAspect = rc->extraAspect(); if (mode == InstantApply) { argumentsAspect->addToMainConfigurationWidget(this, layout); + workingDirectoryAspect->addToMainConfigurationWidget(this, layout); + terminalAspect->addToMainConfigurationWidget(this, layout); } else { m_temporaryArgumentsAspect = new ArgumentsAspect(rc, QString()); m_temporaryArgumentsAspect->copyFrom(argumentsAspect); m_temporaryArgumentsAspect->addToMainConfigurationWidget(this, layout); connect(m_temporaryArgumentsAspect, &ArgumentsAspect::argumentsChanged, this, &CustomExecutableConfigurationWidget::validChanged); - } - m_workingDirectory = new PathChooser(this); - m_workingDirectory->setHistoryCompleter(QLatin1String("Qt.WorkingDir.History")); - m_workingDirectory->setExpectedKind(PathChooser::Directory); + m_temporaryWorkingDirectoryAspect = new WorkingDirectoryAspect(rc, QString()); + m_temporaryWorkingDirectoryAspect->copyFrom(workingDirectoryAspect); + m_temporaryArgumentsAspect->addToMainConfigurationWidget(this, layout); - layout->addRow(tr("Working directory:"), m_workingDirectory); - - auto terminalAspect = rc->extraAspect(); - if (mode == InstantApply) { - terminalAspect->addToMainConfigurationWidget(this, layout); - } else { m_temporaryTerminalAspect = new TerminalAspect(rc, QString()); m_temporaryTerminalAspect->copyFrom(terminalAspect); m_temporaryTerminalAspect->addToMainConfigurationWidget(this, layout); @@ -103,13 +100,9 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE if (mode == InstantApply) { connect(m_executableChooser, &PathChooser::rawPathChanged, this, &CustomExecutableConfigurationWidget::executableEdited); - connect(m_workingDirectory, &PathChooser::rawPathChanged, - this, &CustomExecutableConfigurationWidget::workingDirectoryEdited); } else { connect(m_executableChooser, &PathChooser::rawPathChanged, this, &CustomExecutableConfigurationWidget::validChanged); - connect(m_workingDirectory, &PathChooser::rawPathChanged, - this, &CustomExecutableConfigurationWidget::validChanged); } auto enviromentAspect = rc->extraAspect(); @@ -132,13 +125,13 @@ CustomExecutableConfigurationWidget::~CustomExecutableConfigurationWidget() { delete m_temporaryArgumentsAspect; delete m_temporaryTerminalAspect; + delete m_temporaryWorkingDirectoryAspect; } void CustomExecutableConfigurationWidget::environmentWasChanged() { auto aspect = m_runConfiguration->extraAspect(); QTC_ASSERT(aspect, return); - m_workingDirectory->setEnvironment(aspect->environment()); m_executableChooser->setEnvironment(aspect->environment()); } @@ -149,13 +142,6 @@ void CustomExecutableConfigurationWidget::executableEdited() m_ignoreChange = false; } -void CustomExecutableConfigurationWidget::workingDirectoryEdited() -{ - m_ignoreChange = true; - m_runConfiguration->setBaseWorkingDirectory(m_workingDirectory->rawPath()); - m_ignoreChange = false; -} - void CustomExecutableConfigurationWidget::changed() { // We triggered the change, don't update us @@ -163,16 +149,16 @@ void CustomExecutableConfigurationWidget::changed() return; m_executableChooser->setPath(m_runConfiguration->rawExecutable()); - m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory()); } void CustomExecutableConfigurationWidget::apply() { m_ignoreChange = true; m_runConfiguration->setExecutable(m_executableChooser->rawPath()); - m_runConfiguration->setCommandLineArguments(m_temporaryArgumentsAspect->unexpandedArguments()); - m_runConfiguration->setBaseWorkingDirectory(m_workingDirectory->rawPath()); - m_runConfiguration->setRunMode(m_temporaryTerminalAspect->runMode()); + m_runConfiguration->extraAspect() + ->copyFrom(m_temporaryWorkingDirectoryAspect); + m_runConfiguration->extraAspect()->copyFrom(m_temporaryArgumentsAspect); + m_runConfiguration->extraAspect()->copyFrom(m_temporaryTerminalAspect); m_ignoreChange = false; } diff --git a/src/plugins/projectexplorer/customexecutableconfigurationwidget.h b/src/plugins/projectexplorer/customexecutableconfigurationwidget.h index 463990d0fe9..5b1f01ba0bd 100644 --- a/src/plugins/projectexplorer/customexecutableconfigurationwidget.h +++ b/src/plugins/projectexplorer/customexecutableconfigurationwidget.h @@ -44,6 +44,7 @@ namespace ProjectExplorer { class ArgumentsAspect; class TerminalAspect; +class WorkingDirectoryAspect; class CustomExecutableRunConfiguration; namespace Internal { @@ -66,15 +67,14 @@ signals: private: void changed(); void executableEdited(); - void workingDirectoryEdited(); void environmentWasChanged(); bool m_ignoreChange = false; CustomExecutableRunConfiguration *m_runConfiguration = 0; ProjectExplorer::ArgumentsAspect *m_temporaryArgumentsAspect = 0; ProjectExplorer::TerminalAspect *m_temporaryTerminalAspect = 0; + ProjectExplorer::WorkingDirectoryAspect *m_temporaryWorkingDirectoryAspect = 0; Utils::PathChooser *m_executableChooser = 0; - Utils::PathChooser *m_workingDirectory = 0; Utils::DetailsWidget *m_detailsContainer = 0; }; diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index c058f19bb63..7e584a46f32 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -53,7 +53,6 @@ namespace ProjectExplorer { const char CUSTOM_EXECUTABLE_ID[] = "ProjectExplorer.CustomExecutableRunConfiguration"; const char EXECUTABLE_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.Executable"; -const char WORKING_DIRECTORY_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory"; // Dialog embedding the CustomExecutableConfigurationWidget // prompting the user to complete the configuration. @@ -88,6 +87,7 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier())); addExtraAspect(new ArgumentsAspect(this, "ProjectExplorer.CustomExecutableRunConfiguration.Arguments")); addExtraAspect(new TerminalAspect(this, "ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal")); + addExtraAspect(new WorkingDirectoryAspect(this, "ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory")); setDefaultDisplayName(defaultDisplayName()); } @@ -184,7 +184,7 @@ bool CustomExecutableRunConfiguration::validateExecutable(QString *executable, Q if (aspect) env = aspect->environment(); const Utils::FileName exec = env.searchInPath(macroExpander()->expand(m_executable), - {Utils::FileName::fromString(workingDirectory())}); + {extraAspect()->workingDirectory()}); if (exec.isEmpty()) { if (errorMessage) *errorMessage = tr("The executable\n%1\ncannot be found in the path."). @@ -213,31 +213,17 @@ bool CustomExecutableRunConfiguration::isConfigured() const return !m_executable.isEmpty(); } -QString CustomExecutableRunConfiguration::workingDirectory() const -{ - EnvironmentAspect *aspect = extraAspect(); - QTC_ASSERT(aspect, return baseWorkingDirectory()); - return QDir::cleanPath(aspect->environment().expandVariables( - macroExpander()->expand(baseWorkingDirectory()))); -} - Runnable CustomExecutableRunConfiguration::runnable() const { StandardRunnable r; r.executable = executable(); r.commandLineArguments = extraAspect()->arguments(); - r.workingDirectory = workingDirectory(); r.environment = extraAspect()->environment(); r.runMode = extraAspect()->runMode(); r.device = DeviceManager::instance()->defaultDevice(Constants::DESKTOP_DEVICE_TYPE); return r; } -QString CustomExecutableRunConfiguration::baseWorkingDirectory() const -{ - return m_workingDirectory; -} - QString CustomExecutableRunConfiguration::defaultDisplayName() const { if (m_executable.isEmpty()) @@ -250,15 +236,12 @@ QVariantMap CustomExecutableRunConfiguration::toMap() const { QVariantMap map(RunConfiguration::toMap()); map.insert(QLatin1String(EXECUTABLE_KEY), m_executable); - map.insert(QLatin1String(WORKING_DIRECTORY_KEY), m_workingDirectory); return map; } bool CustomExecutableRunConfiguration::fromMap(const QVariantMap &map) { m_executable = map.value(QLatin1String(EXECUTABLE_KEY)).toString(); - m_workingDirectory = map.value(QLatin1String(WORKING_DIRECTORY_KEY)).toString(); - setDefaultDisplayName(defaultDisplayName()); return RunConfiguration::fromMap(map); } @@ -272,24 +255,6 @@ void CustomExecutableRunConfiguration::setExecutable(const QString &executable) emit changed(); } -void CustomExecutableRunConfiguration::setCommandLineArguments(const QString &commandLineArguments) -{ - extraAspect()->setArguments(commandLineArguments); - emit changed(); -} - -void CustomExecutableRunConfiguration::setBaseWorkingDirectory(const QString &workingDirectory) -{ - m_workingDirectory = workingDirectory; - emit changed(); -} - -void CustomExecutableRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode) -{ - extraAspect()->setRunMode(runMode); - emit changed(); -} - QWidget *CustomExecutableRunConfiguration::createConfigurationWidget() { return new CustomExecutableConfigurationWidget(this, CustomExecutableConfigurationWidget::InstantApply); diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.h b/src/plugins/projectexplorer/customexecutablerunconfiguration.h index 63ec8151507..22cbdc6e609 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.h +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.h @@ -51,7 +51,6 @@ public: * ask the user if none is specified */ QString executable() const; - QString workingDirectory() const; Runnable runnable() const override; /** Returns whether this runconfiguration ever was configured with an executable @@ -72,11 +71,7 @@ private: void configurationDialogFinished(); void setExecutable(const QString &executable); QString rawExecutable() const; - void setCommandLineArguments(const QString &commandLineArguments); - void setBaseWorkingDirectory(const QString &workingDirectory); - QString baseWorkingDirectory() const; void setUserName(const QString &name); - void setRunMode(ApplicationLauncher::Mode runMode); bool validateExecutable(QString *executable = 0, QString *errorMessage = 0) const; QString m_executable;