Commit 2182ded5 authored by BogDan Vatra's avatar BogDan Vatra

ProjectExplorer: Use Core::Id as RunMode "enum values"

This provides a way for third-party plugins to implement run
modes without the need to add a value to the central enum or
using manual workarounds like RunMode(*(int*)&someUniqueObject).

Instead of centrally defined enum values this uses Core::Id that could
be defined anywhere.

Change-Id: Ic350e3d8dbb8042c61b2d4ffec993ca151f53099
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 77436649
......@@ -36,10 +36,11 @@
#include <QMetaType>
#include <coreplugin/id.h>
#include <ssh/sshconnection.h>
#include <utils/environment.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/applicationlauncher.h>
#include <projectexplorer/projectexplorerconstants.h>
namespace Analyzer {
......@@ -49,7 +50,7 @@ namespace Analyzer {
class ANALYZER_EXPORT AnalyzerStartParameters
{
public:
ProjectExplorer::RunMode runMode;
Core::Id runMode = ProjectExplorer::Constants::NO_RUN_MODE;
QSsh::SshConnectionParameters connParams;
ProjectExplorer::ApplicationLauncher::Mode localRunMode
= ProjectExplorer::ApplicationLauncher::Gui;
......
......@@ -86,8 +86,8 @@ public:
void setToolId(Core::Id id) { m_toolId = id; }
void setToolMode(ToolMode mode) { m_toolMode = mode; }
ProjectExplorer::RunMode runMode() const { return m_runMode; }
void setRunMode(ProjectExplorer::RunMode mode) { m_runMode = mode; }
Core::Id runMode() const { return m_runMode; }
void setRunMode(Core::Id mode) { m_runMode = mode; }
bool isRunnable(QString *reason = 0) const;
/// Creates all widgets used by the tool.
......@@ -119,7 +119,7 @@ protected:
Core::Id m_actionId;
Core::Id m_toolId;
ToolMode m_toolMode;
ProjectExplorer::RunMode m_runMode;
Core::Id m_runMode;
WidgetCreator m_widgetCreator;
RunControlCreator m_runControlCreator;
ToolStarter m_customToolStarter;
......
......@@ -52,7 +52,7 @@ namespace Android {
namespace Internal {
RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
RunMode runMode)
Core::Id runMode)
{
Target *target = runConfig->target();
AnalyzerStartParameters params;
......@@ -61,7 +61,7 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati
params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString();
// TODO: Not sure if these are the right paths.
params.workingDirectory = target->project()->projectDirectory().toString();
if (runMode == QmlProfilerRunMode) {
if (runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
QTcpServer server;
QTC_ASSERT(server.listen(QHostAddress::LocalHost)
|| server.listen(QHostAddress::LocalHostIPv6), return 0);
......
......@@ -51,7 +51,7 @@ public:
Analyzer::AnalyzerRunControl *runControl);
static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
ProjectExplorer::RunMode runMode);
Core::Id runMode);
private:
QmlDebug::QmlOutputParser m_outputParser;
......
......@@ -42,8 +42,8 @@ namespace Android {
namespace Internal {
AndroidRunControl::AndroidRunControl(AndroidRunConfiguration *rc)
: RunControl(rc, NormalRunMode)
, m_runner(new AndroidRunner(this, rc, NormalRunMode))
: RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE)
, m_runner(new AndroidRunner(this, rc, ProjectExplorer::Constants::NORMAL_RUN_MODE))
, m_running(false)
{
setIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL));
......
......@@ -56,35 +56,30 @@ AndroidRunControlFactory::AndroidRunControlFactory(QObject *parent)
{
}
bool AndroidRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const
bool AndroidRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
{
if (mode != NormalRunMode && mode != DebugRunMode && mode != QmlProfilerRunMode)
if (mode != ProjectExplorer::Constants::NORMAL_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN
&& mode != ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
return false;
}
return qobject_cast<AndroidRunConfiguration *>(runConfiguration);
}
RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig,
RunMode mode, QString *errorMessage)
Core::Id mode, QString *errorMessage)
{
Q_ASSERT(canRun(runConfig, mode));
AndroidRunConfiguration *rc = qobject_cast<AndroidRunConfiguration *>(runConfig);
Q_ASSERT(rc);
switch (mode) {
case NormalRunMode:
if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
return new AndroidRunControl(rc);
case DebugRunMode:
if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE || mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN)
return AndroidDebugSupport::createDebugRunControl(rc, errorMessage);
case QmlProfilerRunMode:
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
return AndroidAnalyzeSupport::createAnalyzeRunControl(rc, mode);
case NoRunMode:
case DebugRunModeWithBreakOnMain:
case CallgrindRunMode:
case MemcheckRunMode:
case MemcheckWithGdbRunMode:
case ClangStaticAnalyzerMode:
case PerfProfilerRunMode:
QTC_CHECK(false); // The other run modes are not supported
}
return 0;
}
......
......@@ -53,9 +53,9 @@ public:
explicit AndroidRunControlFactory(QObject *parent = 0);
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const;
Core::Id mode) const;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode,
Core::Id mode,
QString *errorMessage);
};
......
......@@ -125,21 +125,21 @@ static int socketHandShakePort = MIN_SOCKET_HANDSHAKE_PORT;
AndroidRunner::AndroidRunner(QObject *parent,
AndroidRunConfiguration *runConfig,
ProjectExplorer::RunMode runMode)
Core::Id runMode)
: QThread(parent), m_handShakeMethod(SocketHandShake), m_socket(0),
m_customPort(false)
{
m_tries = 0;
Debugger::DebuggerRunConfigurationAspect *aspect
= runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
const bool debuggingMode = runMode == ProjectExplorer::DebugRunMode;
const bool debuggingMode = (runMode == ProjectExplorer::Constants::DEBUG_RUN_MODE || runMode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
m_useCppDebugger = debuggingMode && aspect->useCppDebugger();
m_useQmlDebugger = debuggingMode && aspect->useQmlDebugger();
QString channel = runConfig->remoteChannel();
QTC_CHECK(channel.startsWith(QLatin1Char(':')));
m_localGdbServerPort = channel.mid(1).toUShort();
QTC_CHECK(m_localGdbServerPort);
m_useQmlProfiler = runMode == ProjectExplorer::QmlProfilerRunMode;
m_useQmlProfiler = runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE;
if (m_useQmlDebugger || m_useQmlProfiler) {
QTcpServer server;
QTC_ASSERT(server.listen(QHostAddress::LocalHost)
......
......@@ -33,7 +33,7 @@
#include "androidconfigurations.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>
#include <QObject>
#include <QTimer>
......@@ -58,7 +58,7 @@ class AndroidRunner : public QThread
public:
AndroidRunner(QObject *parent, AndroidRunConfiguration *runConfig,
ProjectExplorer::RunMode runMode);
Core::Id runMode);
~AndroidRunner();
QString displayName() const;
......
......@@ -71,17 +71,20 @@ BareMetalRunControlFactory::~BareMetalRunControlFactory()
{
}
bool BareMetalRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const
bool BareMetalRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
{
if (mode != NormalRunMode && mode != DebugRunMode && mode != DebugRunModeWithBreakOnMain)
if (mode != ProjectExplorer::Constants::NORMAL_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) {
return false;
}
const QByteArray idStr = runConfiguration->id().name();
return runConfiguration->isEnabled() && idStr.startsWith(BareMetalRunConfiguration::IdPrefix);
}
RunControl *BareMetalRunControlFactory::create(
RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage)
{
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
......
......@@ -47,9 +47,9 @@ class BareMetalRunControlFactory : public ProjectExplorer::IRunControlFactory
public:
explicit BareMetalRunControlFactory(QObject *parent = 0);
~BareMetalRunControlFactory();
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const;
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, Core::Id mode) const;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode,
Core::Id mode,
QString *errorMessage);
};
......
......@@ -810,7 +810,7 @@ public slots:
void handleExecStep()
{
if (currentEngine()->state() == DebuggerNotReady) {
ProjectExplorerPlugin::runStartupProject(DebugRunModeWithBreakOnMain);
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
} else {
currentEngine()->resetLocation();
if (boolSetting(OperateByInstruction))
......@@ -823,7 +823,7 @@ public slots:
void handleExecNext()
{
if (currentEngine()->state() == DebuggerNotReady) {
ProjectExplorerPlugin::runStartupProject(DebugRunModeWithBreakOnMain);
ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
} else {
currentEngine()->resetLocation();
if (boolSetting(OperateByInstruction))
......@@ -1306,7 +1306,7 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false);
QString whyNot;
const bool canRun = ProjectExplorerPlugin::canRun(project, DebugRunMode, &whyNot);
const bool canRun = ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE, &whyNot);
m_startAction->setEnabled(canRun);
m_startAction->setToolTip(whyNot);
m_debugWithoutDeployAction->setEnabled(canRun);
......@@ -1978,7 +1978,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_localsAndExpressionsWindow->setShowLocals(false);
} else if (state == DebuggerFinished) {
Project *project = SessionManager::startupProject();
const bool canRun = ProjectExplorerPlugin::canRun(project, DebugRunMode);
const bool canRun = ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE);
// We don't want to do anything anymore.
m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(false);
......@@ -2080,7 +2080,7 @@ void DebuggerPluginPrivate::updateDebugActions()
Project *project = SessionManager::startupProject();
QString whyNot;
const bool canRun = ProjectExplorerPlugin::canRun(project, DebugRunMode, &whyNot);
const bool canRun = ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE, &whyNot);
m_startAction->setEnabled(canRun);
m_startAction->setToolTip(whyNot);
m_debugWithoutDeployAction->setEnabled(canRun);
......@@ -2089,7 +2089,7 @@ void DebuggerPluginPrivate::updateDebugActions()
if (m_snapshotHandler->currentIndex() < 0) {
QString toolTip;
const bool canRunAndBreakMain
= ProjectExplorerPlugin::canRun(project, DebugRunModeWithBreakOnMain, &toolTip);
= ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN, &toolTip);
m_stepAction->setEnabled(canRunAndBreakMain);
m_nextAction->setEnabled(canRunAndBreakMain);
if (canRunAndBreakMain) {
......@@ -2592,11 +2592,11 @@ void DebuggerPluginPrivate::extensionsInitialized()
debuggerIcon.addFile(QLatin1String(":/projectexplorer/images/debugger_start.png"));
act->setIcon(debuggerIcon);
act->setText(tr("Start Debugging"));
connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(DebugRunMode); });
connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE); });
act = m_debugWithoutDeployAction = new QAction(this);
act->setText(tr("Start Debugging Without Deployment"));
connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(DebugRunMode, true); });
connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, true); });
act = m_startAndDebugApplicationAction = new QAction(this);
act->setText(tr("Start and Debug External Application..."));
......
......@@ -70,6 +70,9 @@ namespace Debugger {
namespace Internal {
DebuggerEngine *createCdbEngine(const DebuggerRunParameters &rp, QStringList *error);
const auto *DebugRunMode = ProjectExplorer::Constants::DEBUG_RUN_MODE;
const auto *DebugRunModeWithBreakOnMain = ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN;
DebuggerEngine *createGdbEngine(const DebuggerRunParameters &rp);
DebuggerEngine *createPdbEngine(const DebuggerRunParameters &rp);
DebuggerEngine *createQmlEngine(const DebuggerRunParameters &rp);
......@@ -295,7 +298,7 @@ public:
// detectable pieces, construct an Engine and a RunControl.
void initialize(const DebuggerStartParameters &sp);
void enrich(const RunConfiguration *runConfig, const Kit *kit);
void createRunControl(RunMode runMode);
void createRunControl(Core::Id runMode = DebugRunMode);
QString fullError() const { return m_errors.join(QLatin1Char('\n')); }
// Result.
......@@ -536,7 +539,7 @@ DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters
return 0;
}
void DebuggerRunControlCreator::createRunControl(RunMode runMode)
void DebuggerRunControlCreator::createRunControl(Core::Id runMode)
{
if (runMode == DebugRunModeWithBreakOnMain)
m_rp.breakOnMain = true;
......@@ -569,7 +572,7 @@ public:
{}
RunControl *create(RunConfiguration *runConfig,
RunMode mode, QString *errorMessage) override
Core::Id mode, QString *errorMessage) override
{
QTC_ASSERT(runConfig, return 0);
QTC_ASSERT(mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain, return 0);
......@@ -584,7 +587,7 @@ public:
return creator.m_runControl;
}
bool canRun(RunConfiguration *runConfig, RunMode mode) const override
bool canRun(RunConfiguration *runConfig, Core::Id mode) const override
{
return (mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain)
&& qobject_cast<LocalApplicationRunConfiguration *>(runConfig);
......@@ -633,7 +636,7 @@ DebuggerRunControl *createAndScheduleRun(const DebuggerRunParameters &rp, const
DebuggerRunControl *createDebuggerRunControl(const DebuggerStartParameters &sp,
RunConfiguration *runConfig,
QString *errorMessage,
RunMode runMode)
Core::Id runMode)
{
DebuggerRunControlCreator creator;
creator.initialize(sp);
......
......@@ -50,7 +50,7 @@ class DebuggerRunControlCreator;
DEBUGGER_EXPORT DebuggerRunControl *createDebuggerRunControl(const DebuggerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfig,
QString *errorMessage,
ProjectExplorer::RunMode runMode = ProjectExplorer::DebugRunMode);
Core::Id runMode = ProjectExplorer::Constants::DEBUG_RUN_MODE);
class DEBUGGER_EXPORT DebuggerRunControl
: public ProjectExplorer::RunControl
......
......@@ -84,7 +84,7 @@ RunControl *IosAnalyzeSupport::createAnalyzeRunControl(IosRunConfiguration *runC
if (device.isNull())
return 0;
AnalyzerStartParameters params;
params.runMode = QmlProfilerRunMode;
params.runMode = ProjectExplorer::Constants::QML_PROFILER_RUN_MODE;
params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString();
params.debuggee = runConfig->localExecutable().toUserOutput();
params.debuggeeArgs = Utils::QtcProcess::joinArgs(runConfig->commandLineArguments());
......
......@@ -41,7 +41,7 @@ namespace Ios {
namespace Internal {
IosRunControl::IosRunControl(IosRunConfiguration *rc)
: RunControl(rc, NormalRunMode)
: RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE)
, m_runner(new IosRunner(this, rc, false, false))
, m_running(false)
{
......
......@@ -159,16 +159,20 @@ IosRunControlFactory::IosRunControlFactory(QObject *parent)
}
bool IosRunControlFactory::canRun(RunConfiguration *runConfiguration,
RunMode mode) const
Core::Id mode) const
{
if (mode != NormalRunMode && mode != DebugRunMode && mode != QmlProfilerRunMode
&& mode != DebugRunModeWithBreakOnMain)
if (mode != ProjectExplorer::Constants::NORMAL_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN
&& mode != ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
return false;
}
return qobject_cast<IosRunConfiguration *>(runConfiguration);
}
RunControl *IosRunControlFactory::create(RunConfiguration *runConfig,
RunMode mode, QString *errorMessage)
Core::Id mode, QString *errorMessage)
{
Q_ASSERT(canRun(runConfig, mode));
IosRunConfiguration *rc = qobject_cast<IosRunConfiguration *>(runConfig);
......@@ -181,9 +185,9 @@ RunControl *IosRunControlFactory::create(RunConfiguration *runConfig,
activeRunControl->stop();
m_activeRunControls.remove(devId);
}
if (mode == NormalRunMode)
if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
res = new Ios::Internal::IosRunControl(rc);
else if (mode == QmlProfilerRunMode)
else if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
res = IosAnalyzeSupport::createAnalyzeRunControl(rc, errorMessage);
else
res = IosDebugSupport::createDebugRunControl(rc, errorMessage);
......
......@@ -81,9 +81,9 @@ public:
explicit IosRunControlFactory(QObject *parent = 0);
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const override;
Core::Id mode) const override;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode,
Core::Id mode,
QString *errorMessage) override;
private:
mutable QMap<Core::Id, QPointer<ProjectExplorer::RunControl> > m_activeRunControls;
......
......@@ -48,12 +48,12 @@ LocalApplicationRunControlFactory::~LocalApplicationRunControlFactory()
{
}
bool LocalApplicationRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const
bool LocalApplicationRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
{
return mode == NormalRunMode && qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
return mode == Constants::NORMAL_RUN_MODE && qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
}
RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage)
RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage)
{
Q_UNUSED(errorMessage)
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
......@@ -72,7 +72,7 @@ RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfi
// ApplicationRunControl
LocalApplicationRunControl::LocalApplicationRunControl(RunConfiguration *rc, RunMode mode)
LocalApplicationRunControl::LocalApplicationRunControl(RunConfiguration *rc, Core::Id mode)
: RunControl(rc, mode), m_runMode(ApplicationLauncher::Console), m_running(false)
{
setIcon(QLatin1String(Constants::ICON_RUN_SMALL));
......
......@@ -43,8 +43,8 @@ class LocalApplicationRunControlFactory : public IRunControlFactory
public:
LocalApplicationRunControlFactory ();
~LocalApplicationRunControlFactory();
bool canRun(RunConfiguration *runConfiguration, RunMode mode) const;
RunControl* create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage);
bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const;
RunControl* create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage);
};
} // namespace Internal
......@@ -53,7 +53,7 @@ class PROJECTEXPLORER_EXPORT LocalApplicationRunControl : public RunControl
{
Q_OBJECT
public:
LocalApplicationRunControl(RunConfiguration *runConfiguration, RunMode mode);
LocalApplicationRunControl(RunConfiguration *runConfiguration, Core::Id mode);
~LocalApplicationRunControl();
void start();
StopResult stop();
......
......@@ -203,12 +203,12 @@ public:
void deploy(QList<Project *>);
int queue(QList<Project *>, QList<Id> stepIds);
void updateContextMenuActions();
void executeRunConfiguration(RunConfiguration *, RunMode mode);
void executeRunConfiguration(RunConfiguration *, Core::Id mode);
QPair<bool, QString> buildSettingsEnabledForSession();
QPair<bool, QString> buildSettingsEnabled(Project *pro);
void addToRecentProjects(const QString &fileName, const QString &displayName);
void startRunControl(RunControl *runControl, RunMode runMode);
void startRunControl(RunControl *runControl, Core::Id runMode);
void updateActions();
void updateContext();
......@@ -350,9 +350,9 @@ public:
QString m_lastOpenDirectory;
QPointer<RunConfiguration> m_delayedRunConfiguration;
QList<QPair<RunConfiguration *, RunMode>> m_delayedRunConfigurationForRun;
QList<QPair<RunConfiguration *, Core::Id>> m_delayedRunConfigurationForRun;
bool m_shouldHaveRunConfiguration;
RunMode m_runMode;
Core::Id m_runMode;
QString m_projectFilterString;
MiniProjectTargetSelector * m_targetSelector;
ProjectExplorerSettings m_projectExplorerSettings;
......@@ -373,7 +373,7 @@ public:
ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
m_shouldHaveRunConfiguration(false),
m_runMode(NoRunMode),
m_runMode(Constants::NO_RUN_MODE),
m_projectsMode(0),
m_kitManager(0),
m_toolChainManager(0),
......@@ -1901,7 +1901,7 @@ void ProjectExplorerPluginPrivate::buildStateChanged(Project * pro)
}
// NBS TODO implement more than one runner
static IRunControlFactory *findRunControlFactory(RunConfiguration *config, RunMode mode)
static IRunControlFactory *findRunControlFactory(RunConfiguration *config, Core::Id mode)
{
return ExtensionSystem::PluginManager::getObject<IRunControlFactory>(
[&config, &mode](IRunControlFactory *factory) {
......@@ -1909,7 +1909,7 @@ static IRunControlFactory *findRunControlFactory(RunConfiguration *config, RunMo
});
}
void ProjectExplorerPluginPrivate::executeRunConfiguration(RunConfiguration *runConfiguration, RunMode runMode)
void ProjectExplorerPluginPrivate::executeRunConfiguration(RunConfiguration *runConfiguration, Core::Id runMode)
{
if (!runConfiguration->isConfigured()) {
QString errorMessage;
......@@ -1947,18 +1947,18 @@ void ProjectExplorerPlugin::showRunErrorMessage(const QString &errorMessage)
QMessageBox::critical(ICore::mainWindow(), errorMessage.isNull() ? tr("Unknown error") : tr("Could Not Run"), errorMessage);
}
void ProjectExplorerPlugin::startRunControl(RunControl *runControl, RunMode runMode)
void ProjectExplorerPlugin::startRunControl(RunControl *runControl, Core::Id runMode)
{
dd->startRunControl(runControl, runMode);
}
void ProjectExplorerPluginPrivate::startRunControl(RunControl *runControl, RunMode runMode)
void ProjectExplorerPluginPrivate::startRunControl(RunControl *runControl, Core::Id runMode)
{
m_outputPane->createNewOutputWindow(runControl);
m_outputPane->flash(); // one flash for starting
m_outputPane->showTabFor(runControl);
bool popup = (runMode == NormalRunMode && dd->m_projectExplorerSettings.showRunOutput)
|| ((runMode == DebugRunMode || runMode == DebugRunModeWithBreakOnMain)
bool popup = (runMode == Constants::NORMAL_RUN_MODE && dd->m_projectExplorerSettings.showRunOutput)
|| ((runMode == Constants::DEBUG_RUN_MODE || runMode == Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN)
&& m_projectExplorerSettings.showDebugOutput);
m_outputPane->setBehaviorOnOutput(runControl, popup ? AppOutputPane::Popup : AppOutputPane::Flash);
runControl->start();
......@@ -2001,13 +2001,13 @@ void ProjectExplorerPluginPrivate::buildQueueFinished(bool success)
}
m_delayedRunConfiguration = 0;
m_shouldHaveRunConfiguration = false;
m_runMode = NoRunMode;
m_runMode = Constants::NO_RUN_MODE;
}
void ProjectExplorerPluginPrivate::runConfigurationConfigurationFinished()
{
RunConfiguration *rc = qobject_cast<RunConfiguration *>(sender());
RunMode runMode = NoRunMode;
Core::Id runMode = Constants::NO_RUN_MODE;
for (int i = 0; i < m_delayedRunConfigurationForRun.size(); ++i) {
if (m_delayedRunConfigurationForRun.at(i).first == rc) {
runMode = m_delayedRunConfigurationForRun.at(i).second;
......@@ -2015,7 +2015,7 @@ void ProjectExplorerPluginPrivate::runConfigurationConfigurationFinished()
break;
}
}
if (runMode != NoRunMode && rc->isConfigured())
if (runMode != Constants::NO_RUN_MODE && rc->isConfigured())
executeRunConfiguration(rc, runMode);
}
......@@ -2368,12 +2368,12 @@ void ProjectExplorerPluginPrivate::cleanSession()
void ProjectExplorerPluginPrivate::handleRunProject()
{
m_instance->runStartupProject(NormalRunMode);
m_instance->runStartupProject(Constants::NORMAL_RUN_MODE);
}
void ProjectExplorerPluginPrivate::runProjectWithoutDeploy()
{
m_instance->runStartupProject(NormalRunMode, true);
m_instance->runStartupProject(Constants::NORMAL_RUN_MODE, true);
}
void ProjectExplorerPluginPrivate::runProjectContextMenu()
......@@ -2381,7 +2381,7 @@ void ProjectExplorerPluginPrivate::runProjectContextMenu()
Node *node = ProjectTree::currentNode();
ProjectNode *projectNode = node ? node->asProjectNode() : 0;
if (projectNode == ProjectTree::currentProject()->rootProjectNode() || !projectNode) {
m_instance->runProject(ProjectTree::currentProject(), NormalRunMode);
m_instance->runProject(ProjectTree::currentProject(), Constants::NORMAL_RUN_MODE);
} else {
QAction *act = qobject_cast<QAction *>(sender());
if (!act)
......@@ -2389,7 +2389,7 @@ void ProjectExplorerPluginPrivate::runProjectContextMenu()
RunConfiguration *rc = act->data().value<RunConfiguration *>();
if (!rc)
return;
m_instance->runRunConfiguration(rc, NormalRunMode);
m_instance->runRunConfiguration(rc, Constants::NORMAL_RUN_MODE);
}
}
......@@ -2493,7 +2493,7 @@ static bool hasDeploySettings(Project *pro)
});
}
void ProjectExplorerPlugin::runProject(Project *pro, RunMode mode, const bool forceSkipDeploy)
void ProjectExplorerPlugin::runProject(Project *pro, Core::Id mode, const bool forceSkipDeploy)
{
if (!pro)
return;
......@@ -2503,13 +2503,13 @@ void ProjectExplorerPlugin::runProject(Project *pro, RunMode mode, const bool fo
runRunConfiguration(rc, mode, forceSkipDeploy);
}
void ProjectExplorerPlugin::runStartupProject(RunMode runMode, bool forceSkipDeploy)
void ProjectExplorerPlugin::runStartupProject(Core::Id runMode, bool forceSkipDeploy)
{
runProject(SessionManager::startupProject(), runMode, forceSkipDeploy);
}
void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc,
RunMode runMode,
Core::Id runMode,
const bool forceSkipDeploy)
{
if (!rc->isEnabled())
......@@ -2680,7 +2680,7 @@ void ProjectExplorerPluginPrivate::updateDeployActions()
emit m_instance->updateRunActions();
}
bool ProjectExplorerPlugin::canRun(Project *project, RunMode runMode, QString *whyNot)
bool ProjectExplorerPlugin::canRun(Project *project, Core::Id runMode, QString *whyNot)
{
if (!project) {
if (whyNot)
......@@ -2747,7 +2747,7 @@ void ProjectExplorerPluginPrivate::slotUpdateRunActions()
{
Project *project = SessionManager::startupProject();
QString whyNot;
const bool state = ProjectExplorerPlugin::canRun(project, NormalRunMode, &whyNot);
const bool state = ProjectExplorerPlugin::canRun(project, Constants::NORMAL_RUN_MODE, &whyNot);
m_runAction->setEnabled(state);
m_runAction->setToolTip(whyNot);
m_runWithoutDeployAction->setEnabled(state);
......
......@@ -33,6 +33,7 @@
#include "projectexplorer_export.h"
#include "projectexplorerconstants.h"
#include "runconfiguration.h"
#include <extensionsystem/iplugin.h>
......@@ -88,7 +89,7 @@ public:
static void setProjectExplorerSettings(const Internal::ProjectExplorerSettings &pes);
static Internal::ProjectExplorerSettings projectExplorerSettings();
static void startRunControl(RunControl *runControl, RunMode runMode);
static void startRunControl(RunControl *runControl, Core::Id runMode);
static void showRunErrorMessage(const QString &errorMessage);
// internal public for FlatModel
......@@ -97,10 +98,10 @@ public:
static bool coreAboutToClose();