Commit f4ea0d79 authored by dt's avatar dt
Browse files

Add a runMode method to the RunControl

And use it to implement changing the run icon in the application output.
That implementation does only support the two run modes run and debug
for now. Further abstraction for more run modes to be done once needed.

Task-Nr:   QTCREATORBUG-1232
parent 4532087c
......@@ -106,7 +106,7 @@ QWidget *DebuggerRunControlFactory::createConfigurationWidget(RunConfiguration *
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
LocalApplicationRunConfiguration *runConfiguration)
: RunControl(runConfiguration),
: RunControl(runConfiguration, ProjectExplorer::Constants::DEBUGMODE),
m_startParameters(new DebuggerStartParameters()),
m_manager(manager),
m_running(false)
......@@ -157,7 +157,7 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager,
}
DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager, const DebuggerStartParametersPtr &startParameters)
: RunControl(0),
: RunControl(0, ProjectExplorer::Constants::DEBUGMODE),
m_startParameters(startParameters),
m_manager(manager),
m_running(false)
......
......@@ -80,7 +80,7 @@ QString LocalApplicationRunControlFactory::displayName() const
RunControl *LocalApplicationRunControlFactory::create(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode)
{
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
return new LocalApplicationRunControl(qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration));
return new LocalApplicationRunControl(qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration), mode);
}
QWidget *LocalApplicationRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
......@@ -91,8 +91,8 @@ QWidget *LocalApplicationRunControlFactory::createConfigurationWidget(RunConfigu
// ApplicationRunControl
LocalApplicationRunControl::LocalApplicationRunControl(LocalApplicationRunConfiguration *runConfiguration)
: RunControl(runConfiguration)
LocalApplicationRunControl::LocalApplicationRunControl(LocalApplicationRunConfiguration *runConfiguration, QString mode)
: RunControl(runConfiguration, mode)
{
m_applicationLauncher.setEnvironment(runConfiguration->environment().toStringList());
m_applicationLauncher.setWorkingDirectory(runConfiguration->workingDirectory());
......
......@@ -81,7 +81,7 @@ class LocalApplicationRunControl : public RunControl
{
Q_OBJECT
public:
LocalApplicationRunControl(LocalApplicationRunConfiguration *runConfiguration);
LocalApplicationRunControl(LocalApplicationRunConfiguration *runConfiguration, QString mode);
virtual ~LocalApplicationRunControl();
virtual void start();
virtual void stop();
......
......@@ -64,12 +64,15 @@ static const int MaxBlockCount = 100000;
OutputPane::OutputPane()
: m_mainWidget(new QWidget)
{
QIcon runIcon(Constants::ICON_RUN);
runIcon.addFile(Constants::ICON_RUN_SMALL);
m_runIcon.addFile(Constants::ICON_RUN);
m_runIcon.addFile(Constants::ICON_RUN_SMALL);
m_debugIcon.addFile(Constants::ICON_DEBUG);
m_debugIcon.addFile(Constants::ICON_DEBUG_SMALL);
// Rerun
m_reRunButton = new QToolButton;
m_reRunButton->setIcon(runIcon);
m_reRunButton->setIcon(m_runIcon);
m_reRunButton->setToolTip(tr("Re-run this run-configuration"));
m_reRunButton->setAutoRaise(true);
m_reRunButton->setEnabled(false);
......@@ -296,6 +299,7 @@ void OutputPane::tabChanged(int i)
RunControl *rc = runControlForTab(i);
m_stopAction->setEnabled(rc->isRunning());
m_reRunButton->setEnabled(!rc->isRunning());
m_reRunButton->setIcon( rc->runMode() == Constants::DEBUGMODE ? m_debugIcon : m_runIcon);
}
}
......@@ -305,6 +309,7 @@ void OutputPane::runControlStarted()
if (rc == qobject_cast<RunControl *>(sender())) {
m_reRunButton->setEnabled(false);
m_stopAction->setEnabled(true);
m_reRunButton->setIcon( rc->runMode() == Constants::DEBUGMODE ? m_debugIcon : m_runIcon);
}
}
......@@ -314,6 +319,7 @@ void OutputPane::runControlFinished()
if (rc == qobject_cast<RunControl *>(sender())) {
m_reRunButton->setEnabled(rc);
m_stopAction->setEnabled(false);
m_reRunButton->setIcon( rc->runMode() == Constants::DEBUGMODE ? m_debugIcon : m_runIcon);
}
}
......
......@@ -35,6 +35,7 @@
#include <QtCore/QObject>
#include <QtCore/QHash>
#include <QtGui/QIcon>
#include <QtGui/QShowEvent>
#include <QtGui/QPlainTextEdit>
......@@ -115,6 +116,8 @@ private:
QAction *m_stopAction;
QToolButton *m_reRunButton;
QToolButton *m_stopButton;
QIcon m_runIcon;
QIcon m_debugIcon;
};
......
......@@ -215,8 +215,8 @@ IRunControlFactory::~IRunControlFactory()
{
}
RunControl::RunControl(RunConfiguration *runConfiguration)
: m_runConfiguration(runConfiguration)
RunControl::RunControl(RunConfiguration *runConfiguration, QString mode)
: m_runMode(mode), m_runConfiguration(runConfiguration)
{
if (runConfiguration)
m_displayName = runConfiguration->displayName();
......@@ -227,6 +227,11 @@ RunControl::~RunControl()
}
QString RunControl::runMode() const
{
return m_runMode;
}
QString RunControl::displayName() const
{
return m_displayName;
......
......@@ -160,7 +160,7 @@ class PROJECTEXPLORER_EXPORT RunControl : public QObject
{
Q_OBJECT
public:
explicit RunControl(RunConfiguration *runConfiguration);
explicit RunControl(RunConfiguration *runConfiguration, QString mode);
virtual ~RunControl();
virtual void start() = 0;
virtual void stop() = 0; // Warning: assumed to be synchroneous!
......@@ -170,6 +170,7 @@ public:
bool sameRunConfiguration(RunControl *other);
virtual OutputFormatter *createOutputFormatter(QObject *parent = 0);
QString runMode() const;
signals:
void addToOutputWindow(RunControl *, const QString &line, bool onStdErr);
......@@ -186,6 +187,7 @@ private slots:
private:
QString m_displayName;
QString m_runMode;
const QWeakPointer<RunConfiguration> m_runConfiguration;
#ifdef Q_OS_MAC
......
......@@ -52,11 +52,11 @@ using ProjectExplorer::RunControl;
namespace QmlProjectManager {
namespace Internal {
QmlRunControl::QmlRunControl(QmlProjectRunConfiguration *runConfiguration, bool debugMode)
: RunControl(runConfiguration), m_debugMode(debugMode)
QmlRunControl::QmlRunControl(QmlProjectRunConfiguration *runConfiguration, QString mode)
: RunControl(runConfiguration, mode)
{
ProjectExplorer::Environment environment = ProjectExplorer::Environment::systemEnvironment();
if (debugMode)
if (runMode() == ProjectExplorer::Constants::DEBUGMODE)
environment.set(QmlProjectManager::Constants::E_QML_DEBUG_SERVER_PORT, QString::number(runConfiguration->debugServerPort()));
m_applicationLauncher.setEnvironment(environment.toStringList());
......@@ -121,7 +121,7 @@ void QmlRunControl::slotError(const QString &err, bool isError)
void QmlRunControl::slotAddToOutputWindow(const QString &line, bool onStdErr)
{
if (m_debugMode && line.startsWith("QDeclarativeDebugServer: Waiting for connection")) {
if (runMode() == ProjectExplorer::Constants::DEBUGMODE && line.startsWith("QDeclarativeDebugServer: Waiting for connection")) {
Core::ICore *core = Core::ICore::instance();
core->modeManager()->activateMode(Debugger::Constants::MODE_DEBUG);
}
......@@ -155,8 +155,7 @@ RunControl *QmlRunControlFactory::create(RunConfiguration *runConfiguration,
const QString &mode)
{
QTC_ASSERT(canRun(runConfiguration, mode), return 0);
return new QmlRunControl(qobject_cast<QmlProjectRunConfiguration *>(runConfiguration),
mode == ProjectExplorer::Constants::DEBUGMODE);
return new QmlRunControl(qobject_cast<QmlProjectRunConfiguration *>(runConfiguration), mode);
}
QString QmlRunControlFactory::displayName() const
......
......@@ -39,10 +39,11 @@ class QmlProjectRunConfiguration;
namespace Internal {
class QmlRunControl : public ProjectExplorer::RunControl {
class QmlRunControl : public ProjectExplorer::RunControl
{
Q_OBJECT
public:
explicit QmlRunControl(QmlProjectRunConfiguration *runConfiguration, bool debugMode);
explicit QmlRunControl(QmlProjectRunConfiguration *runConfiguration, QString mode);
virtual ~QmlRunControl ();
// RunControl
......@@ -63,7 +64,6 @@ private:
QString m_executable;
QStringList m_commandLineArguments;
bool m_debugMode;
};
class QmlRunControlFactory : public ProjectExplorer::IRunControlFactory {
......
......@@ -44,6 +44,7 @@
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/toolchain.h>
#include <utils/qtcassert.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
......@@ -59,8 +60,8 @@ namespace Internal {
using ProjectExplorer::RunConfiguration;
using ProjectExplorer::ToolChain;
AbstractMaemoRunControl::AbstractMaemoRunControl(RunConfiguration *rc)
: RunControl(rc)
AbstractMaemoRunControl::AbstractMaemoRunControl(RunConfiguration *rc, QString mode)
: RunControl(rc, mode)
, m_runConfig(qobject_cast<MaemoRunConfiguration *>(rc))
, m_devConfig(m_runConfig ? m_runConfig->deviceConfig() : MaemoDeviceConfig())
{
......@@ -343,7 +344,7 @@ void AbstractMaemoRunControl::handleError(const QString &errString)
MaemoRunControl::MaemoRunControl(RunConfiguration *runConfiguration)
: AbstractMaemoRunControl(runConfiguration)
: AbstractMaemoRunControl(runConfiguration, ProjectExplorer::Constants::RUNMODE)
{
}
......@@ -375,7 +376,7 @@ void MaemoRunControl::handleRemoteOutput(const QString &output)
MaemoDebugRunControl::MaemoDebugRunControl(RunConfiguration *runConfiguration)
: AbstractMaemoRunControl(runConfiguration)
: AbstractMaemoRunControl(runConfiguration, ProjectExplorer::Constants::DEBUGMODE)
, m_debuggerManager(ExtensionSystem::PluginManager::instance()
->getObject<Debugger::DebuggerManager>())
, m_startParams(new Debugger::DebuggerStartParameters)
......
......@@ -63,7 +63,7 @@ class AbstractMaemoRunControl : public ProjectExplorer::RunControl
Q_OBJECT
public:
explicit AbstractMaemoRunControl(ProjectExplorer::RunConfiguration *runConfig);
explicit AbstractMaemoRunControl(ProjectExplorer::RunConfiguration *runConfig, QString mode);
virtual ~AbstractMaemoRunControl();
protected:
......
......@@ -451,8 +451,8 @@ RunConfiguration *S60DeviceRunConfigurationFactory::clone(Target *parent, RunCon
// ======== S60DeviceRunControlBase
S60DeviceRunControlBase::S60DeviceRunControlBase(RunConfiguration *runConfiguration) :
RunControl(runConfiguration),
S60DeviceRunControlBase::S60DeviceRunControlBase(RunConfiguration *runConfiguration, QString mode) :
RunControl(runConfiguration, mode),
m_toolChain(ProjectExplorer::ToolChain::INVALID),
m_releaseDeviceAfterLauncherFinish(false),
m_handleDeviceRemoval(true),
......@@ -812,8 +812,8 @@ bool S60DeviceRunControlBase::checkConfiguration(QString * /* errorMessage */,
// =============== S60DeviceRunControl
S60DeviceRunControl::S60DeviceRunControl(ProjectExplorer::RunConfiguration *runConfiguration) :
S60DeviceRunControlBase(runConfiguration)
S60DeviceRunControl::S60DeviceRunControl(ProjectExplorer::RunConfiguration *runConfiguration, QString mode) :
S60DeviceRunControlBase(runConfiguration, mode)
{
}
......@@ -849,8 +849,8 @@ void S60DeviceRunControl::printRunFailNotice(const QString &errorMessage) {
// ======== S60DeviceDebugRunControl
S60DeviceDebugRunControl::S60DeviceDebugRunControl(S60DeviceRunConfiguration *runConfiguration) :
S60DeviceRunControlBase(runConfiguration),
S60DeviceDebugRunControl::S60DeviceDebugRunControl(S60DeviceRunConfiguration *runConfiguration, QString mode) :
S60DeviceRunControlBase(runConfiguration, mode),
m_startParams(new Debugger::DebuggerStartParameters)
{
setReleaseDeviceAfterLauncherFinish(true); // Debugger controls device after install
......
......@@ -144,7 +144,7 @@ class S60DeviceRunControlBase : public ProjectExplorer::RunControl
{
Q_OBJECT
public:
explicit S60DeviceRunControlBase(ProjectExplorer::RunConfiguration *runConfiguration);
explicit S60DeviceRunControlBase(ProjectExplorer::RunConfiguration *runConfiguration, QString mode);
~S60DeviceRunControlBase();
virtual void start();
virtual void stop();
......@@ -206,7 +206,7 @@ class S60DeviceRunControl : public S60DeviceRunControlBase
{
Q_OBJECT
public:
explicit S60DeviceRunControl(ProjectExplorer::RunConfiguration *runConfiguration);
explicit S60DeviceRunControl(ProjectExplorer::RunConfiguration *runConfiguration, QString mode);
protected:
virtual void initLauncher(const QString &executable, trk::Launcher *);
......@@ -225,7 +225,7 @@ class S60DeviceDebugRunControl : public S60DeviceRunControlBase
Q_DISABLE_COPY(S60DeviceDebugRunControl)
Q_OBJECT
public:
explicit S60DeviceDebugRunControl(S60DeviceRunConfiguration *runConfiguration);
explicit S60DeviceDebugRunControl(S60DeviceRunConfiguration *runConfiguration, QString mode);
virtual ~S60DeviceDebugRunControl();
virtual void stop();
......
......@@ -293,8 +293,8 @@ QString S60EmulatorRunConfigurationFactory::displayNameForId(const QString &id)
// ======== S60EmulatorRunControl
S60EmulatorRunControl::S60EmulatorRunControl(S60EmulatorRunConfiguration *runConfiguration)
: RunControl(runConfiguration)
S60EmulatorRunControl::S60EmulatorRunControl(S60EmulatorRunConfiguration *runConfiguration, QString mode)
: RunControl(runConfiguration, mode)
{
// stuff like the EPOCROOT and EPOCDEVICE env variable
Environment env = Environment::systemEnvironment();
......
......@@ -129,7 +129,7 @@ class S60EmulatorRunControl : public ProjectExplorer::RunControl
{
Q_OBJECT
public:
explicit S60EmulatorRunControl(S60EmulatorRunConfiguration *runConfiguration);
explicit S60EmulatorRunControl(S60EmulatorRunConfiguration *runConfiguration, QString mode);
~S60EmulatorRunControl() {}
void start();
void stop();
......
......@@ -80,7 +80,7 @@ public:
ProjectExplorer::RunControl* create(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode) {
RunConfiguration *rc = qobject_cast<RunConfiguration *>(runConfiguration);
QTC_ASSERT(rc && mode == m_mode, return 0);
return new RunControl(rc);
return new RunControl(rc, mode);
}
QString displayName() const {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment