diff --git a/interfaces/iruncontroller.h b/interfaces/iruncontroller.h --- a/interfaces/iruncontroller.h +++ b/interfaces/iruncontroller.h @@ -139,6 +139,9 @@ KDevelop::IProject* project = nullptr, const QString& name = QString() ) = 0; + /// Opens a dialog to setup new launch configurations, or to change the existing ones. + virtual void showConfigurationDialog() const = 0; + public Q_SLOTS: /** * Request for all running processes to be killed. diff --git a/shell/debugcontroller.cpp b/shell/debugcontroller.cpp --- a/shell/debugcontroller.cpp +++ b/shell/debugcontroller.cpp @@ -51,8 +51,6 @@ #include "debug.h" #include "uicontroller.h" #include "iruncontroller.h" -#include "launchconfigurationdialog.h" - namespace KDevelop { @@ -493,11 +491,11 @@ if (m_currentSession) { m_currentSession.data()->run(); } else { - if (ICore::self()->runController()->launchConfigurations().isEmpty()) { - LaunchConfigurationDialog d; - d.exec(); + auto runController = ICore::self()->runController(); + if (runController->launchConfigurations().isEmpty()) { + runController->showConfigurationDialog(); } - ICore::self()->runController()->executeDefaultLaunch(QStringLiteral("debug")); + runController->executeDefaultLaunch(QStringLiteral("debug")); } } diff --git a/shell/runcontroller.h b/shell/runcontroller.h --- a/shell/runcontroller.h +++ b/shell/runcontroller.h @@ -110,10 +110,14 @@ IProject* project = nullptr, const QString& name = QString() ) override; - void setDefaultLaunch(ILaunchConfiguration* l); LaunchConfiguration* defaultLaunch() const; + /** + * @copydoc IRunController::showConfigurationDialog() + */ + void showConfigurationDialog() const override; + ContextMenuExtension contextMenuExtension( KDevelop::Context* ctx ); public Q_SLOTS: diff --git a/shell/runcontroller.cpp b/shell/runcontroller.cpp --- a/shell/runcontroller.cpp +++ b/shell/runcontroller.cpp @@ -170,12 +170,6 @@ } } - void configureLaunches() - { - LaunchConfigurationDialog dlg; - dlg.exec(); - } - QString launchActionText( LaunchConfiguration* l ) { QString label; @@ -455,7 +449,7 @@ action->setStatusTip(i18n("Open Launch Configuration Dialog")); action->setToolTip(i18nc("@info:tooltip", "Open Launch Configuration Dialog")); action->setWhatsThis(i18nc("@info:whatsthis", "Opens a dialog to setup new launch configurations, or to change the existing ones.")); - connect(action, &QAction::triggered, this, [&] { d->configureLaunches(); }); + connect(action, &QAction::triggered, this, &RunController::showConfigurationDialog); d->runAction = new QAction( QIcon::fromTheme(QStringLiteral("system-run")), i18n("Execute Launch"), this); d->runAction->setIconText( i18nc("Short text for 'Execute launch' used in the toolbar", "Execute") ); @@ -546,36 +540,41 @@ void RunController::slotDebug() { - if(d->launchConfigurations.isEmpty()) { - LaunchConfigurationDialog d; - d.exec(); + if (d->launchConfigurations.isEmpty()) { + showConfigurationDialog(); } - if(!d->launchConfigurations.isEmpty()) + if (!d->launchConfigurations.isEmpty()) { executeDefaultLaunch( QStringLiteral("debug") ); + } } void RunController::slotProfile() { - if(d->launchConfigurations.isEmpty()) { - LaunchConfigurationDialog d; - d.exec(); + if (d->launchConfigurations.isEmpty()) { + showConfigurationDialog(); } - if(!d->launchConfigurations.isEmpty()) + if (!d->launchConfigurations.isEmpty()) { executeDefaultLaunch( QStringLiteral("profile") ); + } } void RunController::slotExecute() { - - if(d->launchConfigurations.isEmpty()) { - LaunchConfigurationDialog d; - d.exec(); + if (d->launchConfigurations.isEmpty()) { + showConfigurationDialog(); } - if(!d->launchConfigurations.isEmpty()) + if (!d->launchConfigurations.isEmpty()) { executeDefaultLaunch( QStringLiteral("execute") ); + } +} + +void KDevelop::RunController::showConfigurationDialog() const +{ + LaunchConfigurationDialog dlg; + dlg.exec(); } LaunchConfiguration* KDevelop::RunController::defaultLaunch() const @@ -884,13 +883,11 @@ void KDevelop::RunController::executeDefaultLaunch(const QString& runMode) { - auto dl = defaultLaunch(); - if( !dl ) - { + if (auto dl = defaultLaunch()) { + execute(runMode, dl); + } else { qWarning() << "no default launch!"; - return; } - execute( runMode, dl ); } void RunController::setDefaultLaunch(ILaunchConfiguration* l)