Register stop action globally

Default shortcut is Ctrl+Shift+R now, but maybe there's something better
or more widely accepted. No menu entry yet.
This commit is contained in:
Thorbjørn Lindeijer
2009-01-09 12:58:02 +01:00
parent ce1d728b9a
commit 9b35e32e85
5 changed files with 36 additions and 18 deletions

View File

@@ -35,6 +35,9 @@
#include "projectexplorerconstants.h" #include "projectexplorerconstants.h"
#include "runconfiguration.h" #include "runconfiguration.h"
#include <coreplugin/actionmanager/actionmanagerinterface.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
#include <find/basetextfind.h> #include <find/basetextfind.h>
#include <aggregation/aggregate.h> #include <aggregation/aggregate.h>
@@ -52,7 +55,7 @@
using namespace ProjectExplorer::Internal; using namespace ProjectExplorer::Internal;
using namespace ProjectExplorer; using namespace ProjectExplorer;
OutputPane::OutputPane() OutputPane::OutputPane(Core::ICore *core)
: m_mainWidget(new QWidget) : m_mainWidget(new QWidget)
{ {
// m_insertLineButton = new QToolButton; // m_insertLineButton = new QToolButton;
@@ -75,12 +78,22 @@ OutputPane::OutputPane()
this, SLOT(reRunRunControl())); this, SLOT(reRunRunControl()));
// Stop // Stop
Core::ActionManagerInterface *am = core->actionManager();
QList<int> globalcontext;
globalcontext.append(Core::Constants::C_GLOBAL_ID);
m_stopAction = new QAction(QIcon(Constants::ICON_STOP), tr("Stop"), this);
m_stopAction->setToolTip(tr("Stop"));
m_stopAction->setEnabled(false);
Core::ICommand *cmd = am->registerAction(m_stopAction, Constants::STOP, globalcontext);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+R")));
m_stopButton = new QToolButton; m_stopButton = new QToolButton;
m_stopButton->setIcon(QIcon(Constants::ICON_STOP)); m_stopButton->setDefaultAction(cmd->action());
m_stopButton->setToolTip(tr("Stop"));
m_stopButton->setAutoRaise(true); m_stopButton->setAutoRaise(true);
m_stopButton->setEnabled(false);
connect(m_stopButton, SIGNAL(clicked()), connect(m_stopAction, SIGNAL(triggered()),
this, SLOT(stopRunControl())); this, SLOT(stopRunControl()));
// Spacer (?) // Spacer (?)
@@ -252,11 +265,11 @@ void OutputPane::projectRemoved()
void OutputPane::tabChanged(int i) void OutputPane::tabChanged(int i)
{ {
if (i == -1) { if (i == -1) {
m_stopButton->setEnabled(false); m_stopAction->setEnabled(false);
m_reRunButton->setEnabled(false); m_reRunButton->setEnabled(false);
} else { } else {
RunControl *rc = runControlForTab(i); RunControl *rc = runControlForTab(i);
m_stopButton->setEnabled(rc->isRunning()); m_stopAction->setEnabled(rc->isRunning());
m_reRunButton->setEnabled(!rc->isRunning() && rc->runConfiguration()->project()); m_reRunButton->setEnabled(!rc->isRunning() && rc->runConfiguration()->project());
} }
} }
@@ -266,7 +279,7 @@ void OutputPane::runControlStarted()
RunControl *rc = runControlForTab(m_tabWidget->currentIndex()); RunControl *rc = runControlForTab(m_tabWidget->currentIndex());
if (rc == qobject_cast<RunControl *>(sender())) { if (rc == qobject_cast<RunControl *>(sender())) {
m_reRunButton->setEnabled(false); m_reRunButton->setEnabled(false);
m_stopButton->setEnabled(true); m_stopAction->setEnabled(true);
} }
} }
@@ -275,7 +288,7 @@ void OutputPane::runControlFinished()
RunControl *rc = runControlForTab(m_tabWidget->currentIndex()); RunControl *rc = runControlForTab(m_tabWidget->currentIndex());
if (rc == qobject_cast<RunControl *>(sender())) { if (rc == qobject_cast<RunControl *>(sender())) {
m_reRunButton->setEnabled(rc->runConfiguration()->project()); m_reRunButton->setEnabled(rc->runConfiguration()->project());
m_stopButton->setEnabled(false); m_stopAction->setEnabled(false);
} }
} }

View File

@@ -48,6 +48,10 @@ QT_BEGIN_NAMESPACE
class QTabWidget; class QTabWidget;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Core {
class ICore;
}
namespace ProjectExplorer { namespace ProjectExplorer {
class RunControl; class RunControl;
@@ -61,7 +65,7 @@ class OutputPane : public Core::IOutputPane
Q_OBJECT Q_OBJECT
public: public:
OutputPane(); OutputPane(Core::ICore *core);
~OutputPane(); ~OutputPane();
QWidget *outputWidget(QWidget *); QWidget *outputWidget(QWidget *);
@@ -99,6 +103,7 @@ private:
QWidget *m_mainWidget; QWidget *m_mainWidget;
QTabWidget *m_tabWidget; QTabWidget *m_tabWidget;
QHash<RunControl *, OutputWindow *> m_outputWindows; QHash<RunControl *, OutputWindow *> m_outputWindows;
QAction *m_stopAction;
// QToolButton *m_insertLineButton; // QToolButton *m_insertLineButton;
QToolButton *m_reRunButton; QToolButton *m_reRunButton;
QToolButton *m_stopButton; QToolButton *m_stopButton;

View File

@@ -200,7 +200,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin
addAutoReleasedObject(new CoreListenerCheckingForRunningBuild(m_buildManager)); addAutoReleasedObject(new CoreListenerCheckingForRunningBuild(m_buildManager));
m_outputPane = new OutputPane(); m_outputPane = new OutputPane(m_core);
addAutoReleasedObject(m_outputPane); addAutoReleasedObject(m_outputPane);
connect(m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)), connect(m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)),
m_outputPane, SLOT(projectRemoved())); m_outputPane, SLOT(projectRemoved()));

View File

@@ -56,6 +56,8 @@ const char * const CLEANSESSION = "ProjectExplorer.CleanSession";
const char * const BUILDCONFIGURATIONMENU = "ProjectExplorer.BuildConfigurationMenu"; const char * const BUILDCONFIGURATIONMENU = "ProjectExplorer.BuildConfigurationMenu";
const char * const CANCELBUILD = "ProjectExplorer.CancelBuild"; const char * const CANCELBUILD = "ProjectExplorer.CancelBuild";
const char * const RUNCONFIGURATIONMENU = "ProjectExplorer.RunConfigurationMenu"; const char * const RUNCONFIGURATIONMENU = "ProjectExplorer.RunConfigurationMenu";
const char * const RUN = "ProjectExplorer.Run";
const char * const STOP = "ProjectExplorer.Stop";
const char * const DEBUG = "ProjectExplorer.Debug"; const char * const DEBUG = "ProjectExplorer.Debug";
const char * const DEPENDENCIES = "ProjectExplorer.Dependencies"; const char * const DEPENDENCIES = "ProjectExplorer.Dependencies";
const char * const FINDINALLPROJECTS = "ProjectExplorer.FindInAllProjects"; const char * const FINDINALLPROJECTS = "ProjectExplorer.FindInAllProjects";
@@ -76,8 +78,6 @@ const int P_ACTION_RUN = 100;
const int P_ACTION_DEBUG = 90; const int P_ACTION_DEBUG = 90;
const int P_ACTION_BUILDSESSION = 80; const int P_ACTION_BUILDSESSION = 80;
const char * const RUN = "ProjectExplorer.Run";
// context // context
const char * const C_PROJECTEXPLORER = "Project Explorer"; const char * const C_PROJECTEXPLORER = "Project Explorer";

View File

@@ -261,7 +261,7 @@ QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) :
m_configureAction(new QAction(tr("Configure..."), this)), m_configureAction(new QAction(tr("Configure..."), this)),
m_fileLineEdit(new Core::Utils::FancyLineEdit) m_fileLineEdit(new Core::Utils::FancyLineEdit)
{ {
// Explcitly hide the completion list popup. // Explicitly hide the completion list popup.
m_completionList->hide(); m_completionList->hide();
setWindowTitle("Locate..."); setWindowTitle("Locate...");