diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index 09ffd3426fd..19167c73103 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -80,7 +80,8 @@ void TerminalAspect::addToMainConfigurationWidget(QWidget *parent, QFormLayout * layout->addRow(QString(), m_checkBox); connect(m_checkBox.data(), &QAbstractButton::clicked, this, [this] { m_userSet = true; - setUseTerminal(true); + m_useTerminal = m_checkBox->isChecked(); + emit useTerminalChanged(m_useTerminal); }); } @@ -121,6 +122,8 @@ ApplicationLauncher::Mode TerminalAspect::runMode() const void TerminalAspect::setRunMode(ApplicationLauncher::Mode runMode) { setUseTerminal(runMode == ApplicationLauncher::Console); + if (m_checkBox) + m_checkBox->setChecked(m_useTerminal); } /*! diff --git a/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp b/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp index 1f105805a72..c98c684c980 100644 --- a/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp +++ b/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -45,12 +46,13 @@ #include #include +using namespace ProjectExplorer; namespace QtSupport { namespace Internal { CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomExecutableRunConfiguration *rc, ApplyMode mode) - : m_ignoreChange(false), m_runConfiguration(rc) + : m_ignoreChange(false), m_runConfiguration(rc), m_temporaryTerminalAspect(0) { QFormLayout *layout = new QFormLayout; layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); @@ -72,8 +74,15 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE layout->addRow(tr("Working directory:"), m_workingDirectory); - m_useTerminalCheck = new QCheckBox(tr("Run in &terminal"), this); - layout->addRow(QString(), m_useTerminalCheck); + TerminalAspect *terminalAspect = rc->extraAspect(); + if (mode == InstantApply) { + terminalAspect->addToMainConfigurationWidget(this, layout); + } else { + m_temporaryTerminalAspect = terminalAspect->clone(rc); + m_temporaryTerminalAspect->addToMainConfigurationWidget(this, layout); + connect(m_temporaryTerminalAspect, &TerminalAspect::useTerminalChanged, + this, &CustomExecutableConfigurationWidget::validChanged); + } QVBoxLayout *vbox = new QVBoxLayout(this); vbox->setMargin(0); @@ -95,8 +104,6 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE this, SLOT(argumentsEdited(QString))); connect(m_workingDirectory, SIGNAL(changed(QString)), this, SLOT(workingDirectoryEdited())); - connect(m_useTerminalCheck, SIGNAL(toggled(bool)), - this, SLOT(termToggled(bool))); } else { connect(m_executableChooser, SIGNAL(changed(QString)), this, SIGNAL(validChanged())); @@ -104,8 +111,6 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE this, SIGNAL(validChanged())); connect(m_workingDirectory, SIGNAL(changed(QString)), this, SIGNAL(validChanged())); - connect(m_useTerminalCheck, SIGNAL(toggled(bool)), - this, SIGNAL(validChanged())); } ProjectExplorer::EnvironmentAspect *aspect = rc->extraAspect(); @@ -123,6 +128,11 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE Core::VariableChooser::addSupportForChildWidgets(this, m_runConfiguration->macroExpander()); } +CustomExecutableConfigurationWidget::~CustomExecutableConfigurationWidget() +{ + delete m_temporaryTerminalAspect; +} + void CustomExecutableConfigurationWidget::environmentWasChanged() { ProjectExplorer::EnvironmentAspect *aspect @@ -151,14 +161,6 @@ void CustomExecutableConfigurationWidget::workingDirectoryEdited() m_ignoreChange = false; } -void CustomExecutableConfigurationWidget::termToggled(bool on) -{ - m_ignoreChange = true; - m_runConfiguration->setRunMode(on ? ProjectExplorer::ApplicationLauncher::Console - : ProjectExplorer::ApplicationLauncher::Gui); - m_ignoreChange = false; -} - void CustomExecutableConfigurationWidget::changed() { // We triggered the change, don't update us @@ -168,8 +170,6 @@ void CustomExecutableConfigurationWidget::changed() m_executableChooser->setPath(m_runConfiguration->rawExecutable()); m_commandLineArgumentsLineEdit->setText(m_runConfiguration->rawCommandLineArguments()); m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory()); - m_useTerminalCheck->setChecked(m_runConfiguration->runMode() - == ProjectExplorer::ApplicationLauncher::Console); } void CustomExecutableConfigurationWidget::apply() @@ -178,8 +178,7 @@ void CustomExecutableConfigurationWidget::apply() m_runConfiguration->setExecutable(m_executableChooser->rawPath()); m_runConfiguration->setCommandLineArguments(m_commandLineArgumentsLineEdit->text()); m_runConfiguration->setBaseWorkingDirectory(m_workingDirectory->rawPath()); - m_runConfiguration->setRunMode(m_useTerminalCheck->isChecked() ? ProjectExplorer::ApplicationLauncher::Console - : ProjectExplorer::ApplicationLauncher::Gui); + m_runConfiguration->setRunMode(m_temporaryTerminalAspect->runMode()); m_ignoreChange = false; } diff --git a/src/plugins/qtsupport/customexecutableconfigurationwidget.h b/src/plugins/qtsupport/customexecutableconfigurationwidget.h index e31664404a0..993567d3fa4 100644 --- a/src/plugins/qtsupport/customexecutableconfigurationwidget.h +++ b/src/plugins/qtsupport/customexecutableconfigurationwidget.h @@ -46,6 +46,10 @@ class DetailsWidget; class PathChooser; } +namespace ProjectExplorer { +class TerminalAspect; +} + namespace QtSupport { class CustomExecutableRunConfiguration; @@ -58,6 +62,8 @@ class CustomExecutableConfigurationWidget : public QWidget public: enum ApplyMode { InstantApply, DelayedApply}; CustomExecutableConfigurationWidget(CustomExecutableRunConfiguration *rc, ApplyMode mode); + ~CustomExecutableConfigurationWidget(); + void apply(); // only used for DelayedApply bool isValid() const; @@ -70,16 +76,15 @@ private slots: void executableEdited(); void argumentsEdited(const QString &arguments); void workingDirectoryEdited(); - void termToggled(bool); void environmentWasChanged(); private: bool m_ignoreChange; CustomExecutableRunConfiguration *m_runConfiguration; + ProjectExplorer::TerminalAspect *m_temporaryTerminalAspect; Utils::PathChooser *m_executableChooser; QLineEdit *m_commandLineArgumentsLineEdit; Utils::PathChooser *m_workingDirectory; - QCheckBox *m_useTerminalCheck; Utils::DetailsWidget *m_detailsContainer; }; diff --git a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp index 229751b5d93..481c5fe937e 100644 --- a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp +++ b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -61,7 +62,6 @@ const char CUSTOM_EXECUTABLE_ID[] = "ProjectExplorer.CustomExecutableRunConfigur const char EXECUTABLE_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.Executable"; const char ARGUMENTS_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.Arguments"; const char WORKING_DIRECTORY_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory"; -const char USE_TERMINAL_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal"; } void CustomExecutableRunConfiguration::ctor() @@ -72,10 +72,10 @@ void CustomExecutableRunConfiguration::ctor() CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *parent) : LocalApplicationRunConfiguration(parent, Core::Id(CUSTOM_EXECUTABLE_ID)), m_workingDirectory(QLatin1String(Constants::DEFAULT_WORKING_DIR)), - m_runMode(ProjectExplorer::ApplicationLauncher::Gui), m_dialog(0) { addExtraAspect(new LocalEnvironmentAspect(this)); + addExtraAspect(new TerminalAspect(this, QStringLiteral("ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal"))); if (!parent->activeBuildConfiguration()) m_workingDirectory = QLatin1String(Constants::DEFAULT_WORKING_DIR_ALTERNATE); @@ -88,7 +88,6 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *paren m_executable(source->m_executable), m_workingDirectory(source->m_workingDirectory), m_cmdArguments(source->m_cmdArguments), - m_runMode(source->m_runMode), m_dialog(0) { ctor(); @@ -246,7 +245,7 @@ bool CustomExecutableRunConfiguration::isConfigured() const ApplicationLauncher::Mode CustomExecutableRunConfiguration::runMode() const { - return m_runMode; + return extraAspect()->runMode(); } QString CustomExecutableRunConfiguration::workingDirectory() const @@ -287,8 +286,6 @@ QVariantMap CustomExecutableRunConfiguration::toMap() const map.insert(QLatin1String(EXECUTABLE_KEY), m_executable); map.insert(QLatin1String(ARGUMENTS_KEY), m_cmdArguments); map.insert(QLatin1String(WORKING_DIRECTORY_KEY), m_workingDirectory); - map.insert(QLatin1String(USE_TERMINAL_KEY), - m_runMode == ProjectExplorer::ApplicationLauncher::Console); return map; } @@ -297,9 +294,6 @@ 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(); - m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY)).toBool() - ? ProjectExplorer::ApplicationLauncher::Console - : ProjectExplorer::ApplicationLauncher::Gui; setDefaultDisplayName(defaultDisplayName()); return LocalApplicationRunConfiguration::fromMap(map); @@ -328,7 +322,7 @@ void CustomExecutableRunConfiguration::setBaseWorkingDirectory(const QString &wo void CustomExecutableRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode) { - m_runMode = runMode; + extraAspect()->setRunMode(runMode); emit changed(); }