summaryrefslogtreecommitdiff
path: root/src/plugins/macros/macromanager.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@digia.com>2014-02-28 17:33:48 +0100
committerEike Ziller <eike.ziller@digia.com>2014-03-03 13:07:28 +0100
commite58c1ab06eca83134889d35beaf2771c73d2bcd3 (patch)
treea25df8832f9611e6c5ece2cb6ac83336f957a86e /src/plugins/macros/macromanager.cpp
parent92e930b36727b22dafaf5bfe8145aa549edc51fe (diff)
downloadqt-creator-e58c1ab06eca83134889d35beaf2771c73d2bcd3.tar.gz
ActionManager: Remove QShortcut registration API
Registering QShortcuts doesn't solve any problem that is not already solved by registering QActions, and shortcuts are in fact much more limited (not being able to register multiple shortcuts for different contexts). Change-Id: I9478e601b2cbc3c5e12fb5baee43cacc20d0fb9c Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src/plugins/macros/macromanager.cpp')
-rw-r--r--src/plugins/macros/macromanager.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/plugins/macros/macromanager.cpp b/src/plugins/macros/macromanager.cpp
index 65efbda964..742c5933eb 100644
--- a/src/plugins/macros/macromanager.cpp
+++ b/src/plugins/macros/macromanager.cpp
@@ -49,6 +49,7 @@
#include <coreplugin/icontext.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
+#include <utils/qtcassert.h>
#include <QDir>
#include <QFile>
@@ -57,7 +58,6 @@
#include <QSignalMapper>
#include <QList>
-#include <QShortcut>
#include <QAction>
#include <QFileDialog>
#include <QMessageBox>
@@ -100,6 +100,7 @@ public:
MacroManager *q;
QMap<QString, Macro *> macros;
+ QMap<QString, QAction *> actions;
Macro *currentMacro;
bool isRecording;
@@ -163,14 +164,16 @@ void MacroManager::MacroManagerPrivate::addMacro(Macro *macro)
{
// Add sortcut
Core::Context context(TextEditor::Constants::C_TEXTEDITOR);
- QShortcut *shortcut = new QShortcut(Core::ICore::mainWindow());
- shortcut->setWhatsThis(macro->description());
- Core::ActionManager::registerShortcut(shortcut, makeId(macro->displayName()), context);
- connect(shortcut, SIGNAL(activated()), mapper, SLOT(map()));
- mapper->setMapping(shortcut, macro->displayName());
+ QAction *action = new QAction(macro->description(), q);
+ Core::Command *command = Core::ActionManager::registerAction(
+ action, makeId(macro->displayName()), context);
+ command->setAttribute(Core::Command::CA_UpdateText);
+ connect(action, SIGNAL(triggered()), mapper, SLOT(map()));
+ mapper->setMapping(action, macro->displayName());
// Add macro to the map
macros[macro->displayName()] = macro;
+ actions[macro->displayName()] = action;
}
void MacroManager::MacroManagerPrivate::removeMacro(const QString &name)
@@ -178,7 +181,9 @@ void MacroManager::MacroManagerPrivate::removeMacro(const QString &name)
if (!macros.contains(name))
return;
// Remove shortcut
- Core::ActionManager::unregisterShortcut(makeId(name));
+ QAction *action = actions.take(name);
+ Core::ActionManager::unregisterAction(action, makeId(name));
+ delete action;
// Remove macro from the map
Macro *macro = macros.take(name);
@@ -192,10 +197,9 @@ void MacroManager::MacroManagerPrivate::changeMacroDescription(Macro *macro, con
macro->setDescription(description);
macro->save(macro->fileName(), Core::ICore::mainWindow());
- // Change shortcut what's this
- Core::Command *command = Core::ActionManager::command(makeId(macro->displayName()));
- if (command && command->shortcut())
- command->shortcut()->setWhatsThis(description);
+ QAction *action = actions[macro->displayName()];
+ QTC_ASSERT(action, return);
+ action->setText(description);
}
bool MacroManager::MacroManagerPrivate::executeMacro(Macro *macro)