Commit 7f001dab authored by hjk's avatar hjk
Browse files

Core: Make Context parameter to registerAction optional



... and default to C_GLOBAL. A rather common case.
Similar for ActionContainer::addSeparator().

Change-Id: I7f9ba573af201c0a472132d5a494ad17cc4175b7
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 5b804630
...@@ -216,7 +216,6 @@ AnalyzerManagerPrivate::~AnalyzerManagerPrivate() ...@@ -216,7 +216,6 @@ AnalyzerManagerPrivate::~AnalyzerManagerPrivate()
void AnalyzerManagerPrivate::setupActions() void AnalyzerManagerPrivate::setupActions()
{ {
const Context globalcontext(C_GLOBAL);
Command *command = 0; Command *command = 0;
// Menus // Menus
...@@ -235,15 +234,16 @@ void AnalyzerManagerPrivate::setupActions() ...@@ -235,15 +234,16 @@ void AnalyzerManagerPrivate::setupActions()
m_startAction = new QAction(tr("Start"), m_menu); m_startAction = new QAction(tr("Start"), m_menu);
m_startAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_START_ICON))); m_startAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_START_ICON)));
ActionManager::registerAction(m_startAction, "Analyzer.Start", globalcontext); ActionManager::registerAction(m_startAction, "Analyzer.Start");
connect(m_startAction, &QAction::triggered, this, &AnalyzerManagerPrivate::startTool); connect(m_startAction, &QAction::triggered, this, &AnalyzerManagerPrivate::startTool);
m_stopAction = new QAction(tr("Stop"), m_menu); m_stopAction = new QAction(tr("Stop"), m_menu);
m_stopAction->setEnabled(false); m_stopAction->setEnabled(false);
m_stopAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_STOP_ICON))); m_stopAction->setIcon(QIcon(QLatin1String(ANALYZER_CONTROL_STOP_ICON)));
command = ActionManager::registerAction(m_stopAction, "Analyzer.Stop", globalcontext); command = ActionManager::registerAction(m_stopAction, "Analyzer.Stop");
m_menu->addAction(command, G_ANALYZER_CONTROL); m_menu->addAction(command, G_ANALYZER_CONTROL);
const Context globalcontext(C_GLOBAL);
m_menu->addSeparator(globalcontext, G_ANALYZER_TOOLS); m_menu->addSeparator(globalcontext, G_ANALYZER_TOOLS);
m_menu->addSeparator(globalcontext, G_ANALYZER_REMOTE_TOOLS); m_menu->addSeparator(globalcontext, G_ANALYZER_REMOTE_TOOLS);
m_menu->addSeparator(globalcontext, G_ANALYZER_OPTIONS); m_menu->addSeparator(globalcontext, G_ANALYZER_OPTIONS);
...@@ -377,12 +377,10 @@ void AnalyzerManagerPrivate::activateDock(Qt::DockWidgetArea area, QDockWidget * ...@@ -377,12 +377,10 @@ void AnalyzerManagerPrivate::activateDock(Qt::DockWidgetArea area, QDockWidget *
dockWidget->setParent(m_mainWindow); dockWidget->setParent(m_mainWindow);
m_mainWindow->addDockWidget(area, dockWidget); m_mainWindow->addDockWidget(area, dockWidget);
Context globalContext(C_GLOBAL);
QAction *toggleViewAction = dockWidget->toggleViewAction(); QAction *toggleViewAction = dockWidget->toggleViewAction();
toggleViewAction->setText(dockWidget->windowTitle()); toggleViewAction->setText(dockWidget->windowTitle());
Command *cmd = ActionManager::registerAction(toggleViewAction, Command *cmd = ActionManager::registerAction(toggleViewAction,
Id("Analyzer.").withSuffix(dockWidget->objectName()), globalContext); Id("Analyzer.").withSuffix(dockWidget->objectName()));
cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_Hide);
ActionContainer *viewsMenu = ActionManager::actionContainer(Id(M_WINDOW_VIEWS)); ActionContainer *viewsMenu = ActionManager::actionContainer(Id(M_WINDOW_VIEWS));
...@@ -525,7 +523,7 @@ void AnalyzerManagerPrivate::addAction(AnalyzerAction *action) ...@@ -525,7 +523,7 @@ void AnalyzerManagerPrivate::addAction(AnalyzerAction *action)
Id menuGroup = action->menuGroup(); Id menuGroup = action->menuGroup();
if (menuGroup.isValid()) { if (menuGroup.isValid()) {
Command *command = ActionManager::registerAction(action, action->actionId(), Context(C_GLOBAL)); Command *command = ActionManager::registerAction(action, action->actionId());
m_menu->addAction(command, menuGroup); m_menu->addAction(command, menuGroup);
} }
......
...@@ -79,11 +79,8 @@ bool ArtisticStyle::initialize() ...@@ -79,11 +79,8 @@ bool ArtisticStyle::initialize()
menu->menu()->setTitle(QLatin1String(Constants::ArtisticStyle::DISPLAY_NAME)); menu->menu()->setTitle(QLatin1String(Constants::ArtisticStyle::DISPLAY_NAME));
m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this);
Core::Command *cmd menu->addAction(Core::ActionManager::registerAction(m_formatFile,
= Core::ActionManager::registerAction(m_formatFile, Constants::ArtisticStyle::ACTION_FORMATFILE));
Constants::ArtisticStyle::ACTION_FORMATFILE,
Core::Context(Core::Constants::C_GLOBAL));
menu->addAction(cmd);
connect(m_formatFile, &QAction::triggered, this, &ArtisticStyle::formatFile); connect(m_formatFile, &QAction::triggered, this, &ArtisticStyle::formatFile);
Core::ActionManager::actionContainer(Constants::MENU_ID)->addMenu(menu); Core::ActionManager::actionContainer(Constants::MENU_ID)->addMenu(menu);
......
...@@ -77,15 +77,13 @@ bool ClangFormat::initialize() ...@@ -77,15 +77,13 @@ bool ClangFormat::initialize()
m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this);
Core::Command *cmd Core::Command *cmd
= Core::ActionManager::registerAction(m_formatFile, = Core::ActionManager::registerAction(m_formatFile,
Constants::ClangFormat::ACTION_FORMATFILE, Constants::ClangFormat::ACTION_FORMATFILE);
Core::Context(Core::Constants::C_GLOBAL));
menu->addAction(cmd); menu->addAction(cmd);
connect(m_formatFile, &QAction::triggered, this, &ClangFormat::formatFile); connect(m_formatFile, &QAction::triggered, this, &ClangFormat::formatFile);
m_formatRange = new QAction(BeautifierPlugin::msgFormatSelectedText(), this); m_formatRange = new QAction(BeautifierPlugin::msgFormatSelectedText(), this);
cmd = Core::ActionManager::registerAction(m_formatRange, cmd = Core::ActionManager::registerAction(m_formatRange,
Constants::ClangFormat::ACTION_FORMATSELECTED, Constants::ClangFormat::ACTION_FORMATSELECTED);
Core::Context(Core::Constants::C_GLOBAL));
menu->addAction(cmd); menu->addAction(cmd);
connect(m_formatRange, &QAction::triggered, this, &ClangFormat::formatSelectedText); connect(m_formatRange, &QAction::triggered, this, &ClangFormat::formatSelectedText);
......
...@@ -80,8 +80,7 @@ bool Uncrustify::initialize() ...@@ -80,8 +80,7 @@ bool Uncrustify::initialize()
m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this);
Core::Command *cmd Core::Command *cmd
= Core::ActionManager::registerAction(m_formatFile, = Core::ActionManager::registerAction(m_formatFile,
Constants::Uncrustify::ACTION_FORMATFILE, Constants::Uncrustify::ACTION_FORMATFILE);
Core::Context(Core::Constants::C_GLOBAL));
menu->addAction(cmd); menu->addAction(cmd);
connect(m_formatFile, &QAction::triggered, this, &Uncrustify::formatFile); connect(m_formatFile, &QAction::triggered, this, &Uncrustify::formatFile);
......
...@@ -72,7 +72,6 @@ BookmarksPlugin::BookmarksPlugin() : ...@@ -72,7 +72,6 @@ BookmarksPlugin::BookmarksPlugin() :
bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *) bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
{ {
Context textcontext(TextEditor::Constants::C_TEXTEDITOR); Context textcontext(TextEditor::Constants::C_TEXTEDITOR);
Context globalcontext(Core::Constants::C_GLOBAL);
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS); ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
ActionContainer *mbm = ActionManager::createMenu(Id(BOOKMARKS_MENU)); ActionContainer *mbm = ActionManager::createMenu(Id(BOOKMARKS_MENU));
...@@ -89,26 +88,26 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *) ...@@ -89,26 +88,26 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
//Previous //Previous
m_prevAction = new QAction(tr("Previous Bookmark"), this); m_prevAction = new QAction(tr("Previous Bookmark"), this);
cmd = ActionManager::registerAction(m_prevAction, BOOKMARKS_PREV_ACTION, globalcontext); cmd = ActionManager::registerAction(m_prevAction, BOOKMARKS_PREV_ACTION);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+,") : tr("Ctrl+,"))); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+,") : tr("Ctrl+,")));
mbm->addAction(cmd); mbm->addAction(cmd);
//Next //Next
m_nextAction = new QAction(tr("Next Bookmark"), this); m_nextAction = new QAction(tr("Next Bookmark"), this);
cmd = ActionManager::registerAction(m_nextAction, BOOKMARKS_NEXT_ACTION, globalcontext); cmd = ActionManager::registerAction(m_nextAction, BOOKMARKS_NEXT_ACTION);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+.") : tr("Ctrl+."))); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+.") : tr("Ctrl+.")));
mbm->addAction(cmd); mbm->addAction(cmd);
mbm->addSeparator(globalcontext); mbm->addSeparator();
//Previous Doc //Previous Doc
m_docPrevAction = new QAction(tr("Previous Bookmark in Document"), this); m_docPrevAction = new QAction(tr("Previous Bookmark in Document"), this);
cmd = ActionManager::registerAction(m_docPrevAction, BOOKMARKS_PREVDOC_ACTION, globalcontext); cmd = ActionManager::registerAction(m_docPrevAction, BOOKMARKS_PREVDOC_ACTION);
mbm->addAction(cmd); mbm->addAction(cmd);
//Next Doc //Next Doc
m_docNextAction = new QAction(tr("Next Bookmark in Document"), this); m_docNextAction = new QAction(tr("Next Bookmark in Document"), this);
cmd = ActionManager::registerAction(m_docNextAction, BOOKMARKS_NEXTDOC_ACTION, globalcontext); cmd = ActionManager::registerAction(m_docNextAction, BOOKMARKS_NEXTDOC_ACTION);
mbm->addAction(cmd); mbm->addAction(cmd);
m_editBookmarkAction = new QAction(tr("Edit Bookmark"), this); m_editBookmarkAction = new QAction(tr("Edit Bookmark"), this);
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
virtual void addAction(Command *action, Id group = Id()) = 0; virtual void addAction(Command *action, Id group = Id()) = 0;
virtual void addMenu(ActionContainer *menu, Id group = Id()) = 0; virtual void addMenu(ActionContainer *menu, Id group = Id()) = 0;
virtual void addMenu(ActionContainer *before, ActionContainer *menu, Id group = Id()) = 0; virtual void addMenu(ActionContainer *before, ActionContainer *menu, Id group = Id()) = 0;
virtual Command *addSeparator(const Context &context, Id group = Id(), QAction **outSeparator = 0) = 0; virtual Command *addSeparator(const Context &context = Context(), Id group = Id(), QAction **outSeparator = 0) = 0;
// This clears this menu and submenus from all actions and submenus. // This clears this menu and submenus from all actions and submenus.
// It does not destroy the submenus and commands, just removes them from their parents. // It does not destroy the submenus and commands, just removes them from their parents.
......
...@@ -243,6 +243,8 @@ ActionContainer *ActionManager::createMenuBar(Id id) ...@@ -243,6 +243,8 @@ ActionContainer *ActionManager::createMenuBar(Id id)
same \a id as long as the \a context is different. In this case same \a id as long as the \a context is different. In this case
a trigger of the actual action is forwarded to the registered QAction a trigger of the actual action is forwarded to the registered QAction
for the currently active context. for the currently active context.
If the optional \a context argument is not specified, the global context
will be assumed.
A scriptable action can be called from a script without the need for the user A scriptable action can be called from a script without the need for the user
to interact with it. to interact with it.
*/ */
......
...@@ -32,7 +32,8 @@ ...@@ -32,7 +32,8 @@
#define ACTIONMANAGER_H #define ACTIONMANAGER_H
#include "coreplugin/core_global.h" #include "coreplugin/core_global.h"
#include "coreplugin/id.h" #include "coreplugin/coreconstants.h"
#include "coreplugin/icontext.h"
#include <coreplugin/actionmanager/command.h> #include <coreplugin/actionmanager/command.h>
#include <QObject> #include <QObject>
...@@ -62,7 +63,9 @@ public: ...@@ -62,7 +63,9 @@ public:
static ActionContainer *createMenu(Id id); static ActionContainer *createMenu(Id id);
static ActionContainer *createMenuBar(Id id); static ActionContainer *createMenuBar(Id id);
static Command *registerAction(QAction *action, Id id, const Context &context, bool scriptable = false); static Command *registerAction(QAction *action, Id id,
const Context &context = Context(Constants::C_GLOBAL),
bool scriptable = false);
static Command *command(Id id); static Command *command(Id id);
static ActionContainer *actionContainer(Id id); static ActionContainer *actionContainer(Id id);
......
...@@ -244,7 +244,7 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<ExternalT ...@@ -244,7 +244,7 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<ExternalT
MessageManager::write(runner->errorString()); MessageManager::write(runner->errorString());
}); });
command = ActionManager::registerAction(action, externalToolsPrefix.withSuffix(toolId), Context(Constants::C_GLOBAL)); command = ActionManager::registerAction(action, externalToolsPrefix.withSuffix(toolId));
command->setAttribute(Command::CA_UpdateText); command->setAttribute(Command::CA_UpdateText);
} }
action->setText(tool->displayName()); action->setText(tool->displayName());
......
...@@ -213,7 +213,7 @@ void FindPlugin::setupMenu() ...@@ -213,7 +213,7 @@ void FindPlugin::setupMenu()
mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS); mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS);
d->m_openFindDialog = new QAction(tr("Open Advanced Find..."), this); d->m_openFindDialog = new QAction(tr("Open Advanced Find..."), this);
d->m_openFindDialog->setIconText(tr("Advanced...")); d->m_openFindDialog->setIconText(tr("Advanced..."));
cmd = ActionManager::registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND, globalcontext); cmd = ActionManager::registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F")));
mfindadvanced->addAction(cmd); mfindadvanced->addAction(cmd);
connect(d->m_openFindDialog, &QAction::triggered, connect(d->m_openFindDialog, &QAction::triggered,
...@@ -225,7 +225,6 @@ void FindPlugin::setupFilterMenuItems() ...@@ -225,7 +225,6 @@ void FindPlugin::setupFilterMenuItems()
QList<IFindFilter*> findInterfaces = QList<IFindFilter*> findInterfaces =
ExtensionSystem::PluginManager::getObjects<IFindFilter>(); ExtensionSystem::PluginManager::getObjects<IFindFilter>();
Command *cmd; Command *cmd;
Context globalcontext(Constants::C_GLOBAL);
ActionContainer *mfindadvanced = ActionManager::actionContainer(Constants::M_FIND_ADVANCED); ActionContainer *mfindadvanced = ActionManager::actionContainer(Constants::M_FIND_ADVANCED);
d->m_filterActions.clear(); d->m_filterActions.clear();
...@@ -238,8 +237,7 @@ void FindPlugin::setupFilterMenuItems() ...@@ -238,8 +237,7 @@ void FindPlugin::setupFilterMenuItems()
haveEnabledFilters = true; haveEnabledFilters = true;
action->setEnabled(isEnabled); action->setEnabled(isEnabled);
action->setData(qVariantFromValue(filter)); action->setData(qVariantFromValue(filter));
cmd = ActionManager::registerAction(action, cmd = ActionManager::registerAction(action, base.withSuffix(filter->id()));
base.withSuffix(filter->id()), globalcontext);
cmd->setDefaultKeySequence(filter->defaultShortcut()); cmd->setDefaultKeySequence(filter->defaultShortcut());
mfindadvanced->addAction(cmd); mfindadvanced->addAction(cmd);
d->m_filterActions.insert(filter, action); d->m_filterActions.insert(filter, action);
......
...@@ -153,7 +153,6 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -153,7 +153,6 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
QMetaTypeId<QStringList>::qt_metatype_id(); QMetaTypeId<QStringList>::qt_metatype_id();
// register actions // register actions
Context globalcontext(Constants::C_GLOBAL);
Context findcontext(Constants::C_FINDTOOLBAR); Context findcontext(Constants::C_FINDTOOLBAR);
ActionContainer *mfind = ActionManager::actionContainer(Constants::M_FIND); ActionContainer *mfind = ActionManager::actionContainer(Constants::M_FIND);
Command *cmd; Command *cmd;
...@@ -168,7 +167,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -168,7 +167,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
QIcon icon = QIcon::fromTheme(QLatin1String("edit-find-replace")); QIcon icon = QIcon::fromTheme(QLatin1String("edit-find-replace"));
m_findInDocumentAction = new QAction(icon, tr("Find/Replace"), this); m_findInDocumentAction = new QAction(icon, tr("Find/Replace"), this);
cmd = ActionManager::registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT, globalcontext); cmd = ActionManager::registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT);
cmd->setDefaultKeySequence(QKeySequence::Find); cmd->setDefaultKeySequence(QKeySequence::Find);
mfind->addAction(cmd, Constants::G_FIND_CURRENTDOCUMENT); mfind->addAction(cmd, Constants::G_FIND_CURRENTDOCUMENT);
connect(m_findInDocumentAction, SIGNAL(triggered()), this, SLOT(openFind())); connect(m_findInDocumentAction, SIGNAL(triggered()), this, SLOT(openFind()));
...@@ -183,7 +182,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -183,7 +182,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
if (QApplication::clipboard()->supportsFindBuffer()) { if (QApplication::clipboard()->supportsFindBuffer()) {
m_enterFindStringAction = new QAction(tr("Enter Find String"), this); m_enterFindStringAction = new QAction(tr("Enter Find String"), this);
cmd = ActionManager::registerAction(m_enterFindStringAction, "Find.EnterFindString", globalcontext); cmd = ActionManager::registerAction(m_enterFindStringAction, "Find.EnterFindString");
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E")));
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_enterFindStringAction, &QAction::triggered, this, &FindToolBar::putSelectionToFindClipboard); connect(m_enterFindStringAction, &QAction::triggered, this, &FindToolBar::putSelectionToFindClipboard);
...@@ -191,7 +190,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -191,7 +190,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
} }
m_findNextAction = new QAction(tr("Find Next"), this); m_findNextAction = new QAction(tr("Find Next"), this);
cmd = ActionManager::registerAction(m_findNextAction, Constants::FIND_NEXT, globalcontext); cmd = ActionManager::registerAction(m_findNextAction, Constants::FIND_NEXT);
cmd->setDefaultKeySequence(QKeySequence::FindNext); cmd->setDefaultKeySequence(QKeySequence::FindNext);
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_findNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindNext); connect(m_findNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindNext);
...@@ -202,7 +201,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -202,7 +201,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_ui.findNextButton->setDefaultAction(m_localFindNextAction); m_ui.findNextButton->setDefaultAction(m_localFindNextAction);
m_findPreviousAction = new QAction(tr("Find Previous"), this); m_findPreviousAction = new QAction(tr("Find Previous"), this);
cmd = ActionManager::registerAction(m_findPreviousAction, Constants::FIND_PREVIOUS, globalcontext); cmd = ActionManager::registerAction(m_findPreviousAction, Constants::FIND_PREVIOUS);
cmd->setDefaultKeySequence(QKeySequence::FindPrevious); cmd->setDefaultKeySequence(QKeySequence::FindPrevious);
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_findPreviousAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindPrevious); connect(m_findPreviousAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindPrevious);
...@@ -213,19 +212,19 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -213,19 +212,19 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_ui.findPreviousButton->setDefaultAction(m_localFindPreviousAction); m_ui.findPreviousButton->setDefaultAction(m_localFindPreviousAction);
m_findNextSelectedAction = new QAction(tr("Find Next (Selected)"), this); m_findNextSelectedAction = new QAction(tr("Find Next (Selected)"), this);
cmd = ActionManager::registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED, globalcontext); cmd = ActionManager::registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F3"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F3")));
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_findNextSelectedAction, &QAction::triggered, this, &FindToolBar::findNextSelected); connect(m_findNextSelectedAction, &QAction::triggered, this, &FindToolBar::findNextSelected);
m_findPreviousSelectedAction = new QAction(tr("Find Previous (Selected)"), this); m_findPreviousSelectedAction = new QAction(tr("Find Previous (Selected)"), this);
cmd = ActionManager::registerAction(m_findPreviousSelectedAction, Constants::FIND_PREV_SELECTED, globalcontext); cmd = ActionManager::registerAction(m_findPreviousSelectedAction, Constants::FIND_PREV_SELECTED);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F3"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F3")));
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_findPreviousSelectedAction, &QAction::triggered, this, &FindToolBar::findPreviousSelected); connect(m_findPreviousSelectedAction, &QAction::triggered, this, &FindToolBar::findPreviousSelected);
m_replaceAction = new QAction(tr("Replace"), this); m_replaceAction = new QAction(tr("Replace"), this);
cmd = ActionManager::registerAction(m_replaceAction, Constants::REPLACE, globalcontext); cmd = ActionManager::registerAction(m_replaceAction, Constants::REPLACE);
cmd->setDefaultKeySequence(QKeySequence()); cmd->setDefaultKeySequence(QKeySequence());
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_replaceAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplace); connect(m_replaceAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplace);
...@@ -236,7 +235,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -236,7 +235,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_ui.replaceButton->setDefaultAction(m_localReplaceAction); m_ui.replaceButton->setDefaultAction(m_localReplaceAction);
m_replaceNextAction = new QAction(tr("Replace && Find"), this); m_replaceNextAction = new QAction(tr("Replace && Find"), this);
cmd = ActionManager::registerAction(m_replaceNextAction, Constants::REPLACE_NEXT, globalcontext); cmd = ActionManager::registerAction(m_replaceNextAction, Constants::REPLACE_NEXT);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+="))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+=")));
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_replaceNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceNext); connect(m_replaceNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceNext);
...@@ -248,7 +247,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -248,7 +247,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_ui.replaceNextButton->setDefaultAction(m_localReplaceNextAction); m_ui.replaceNextButton->setDefaultAction(m_localReplaceNextAction);
m_replacePreviousAction = new QAction(tr("Replace && Find Previous"), this); m_replacePreviousAction = new QAction(tr("Replace && Find Previous"), this);
cmd = ActionManager::registerAction(m_replacePreviousAction, Constants::REPLACE_PREVIOUS, globalcontext); cmd = ActionManager::registerAction(m_replacePreviousAction, Constants::REPLACE_PREVIOUS);
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_replacePreviousAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplacePrevious); connect(m_replacePreviousAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplacePrevious);
m_localReplacePreviousAction = new QAction(m_replacePreviousAction->text(), this); m_localReplacePreviousAction = new QAction(m_replacePreviousAction->text(), this);
...@@ -257,7 +256,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -257,7 +256,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
connect(m_localReplacePreviousAction, &QAction::triggered, this, &FindToolBar::invokeReplacePrevious); connect(m_localReplacePreviousAction, &QAction::triggered, this, &FindToolBar::invokeReplacePrevious);
m_replaceAllAction = new QAction(tr("Replace All"), this); m_replaceAllAction = new QAction(tr("Replace All"), this);
cmd = ActionManager::registerAction(m_replaceAllAction, Constants::REPLACE_ALL, globalcontext); cmd = ActionManager::registerAction(m_replaceAllAction, Constants::REPLACE_ALL);
mfind->addAction(cmd, Constants::G_FIND_ACTIONS); mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
connect(m_replaceAllAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceAll); connect(m_replaceAllAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceAll);
m_localReplaceAllAction = new QAction(m_replaceAllAction->text(), this); m_localReplaceAllAction = new QAction(m_replaceAllAction->text(), this);
...@@ -270,7 +269,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -270,7 +269,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_caseSensitiveAction->setIcon(QIcon(QLatin1String(":/find/images/casesensitively.png"))); m_caseSensitiveAction->setIcon(QIcon(QLatin1String(":/find/images/casesensitively.png")));
m_caseSensitiveAction->setCheckable(true); m_caseSensitiveAction->setCheckable(true);
m_caseSensitiveAction->setChecked(false); m_caseSensitiveAction->setChecked(false);
cmd = ActionManager::registerAction(m_caseSensitiveAction, Constants::CASE_SENSITIVE, globalcontext); cmd = ActionManager::registerAction(m_caseSensitiveAction, Constants::CASE_SENSITIVE);
mfind->addAction(cmd, Constants::G_FIND_FLAGS); mfind->addAction(cmd, Constants::G_FIND_FLAGS);
connect(m_caseSensitiveAction, &QAction::toggled, this, &FindToolBar::setCaseSensitive); connect(m_caseSensitiveAction, &QAction::toggled, this, &FindToolBar::setCaseSensitive);
...@@ -278,7 +277,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -278,7 +277,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_wholeWordAction->setIcon(QIcon(QLatin1String(":/find/images/wholewords.png"))); m_wholeWordAction->setIcon(QIcon(QLatin1String(":/find/images/wholewords.png")));
m_wholeWordAction->setCheckable(true); m_wholeWordAction->setCheckable(true);
m_wholeWordAction->setChecked(false); m_wholeWordAction->setChecked(false);
cmd = ActionManager::registerAction(m_wholeWordAction, Constants::WHOLE_WORDS, globalcontext); cmd = ActionManager::registerAction(m_wholeWordAction, Constants::WHOLE_WORDS);
mfind->addAction(cmd, Constants::G_FIND_FLAGS); mfind->addAction(cmd, Constants::G_FIND_FLAGS);
connect(m_wholeWordAction, &QAction::toggled, this, &FindToolBar::setWholeWord); connect(m_wholeWordAction, &QAction::toggled, this, &FindToolBar::setWholeWord);
...@@ -286,7 +285,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -286,7 +285,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_regularExpressionAction->setIcon(QIcon(QLatin1String(":/find/images/regexp.png"))); m_regularExpressionAction->setIcon(QIcon(QLatin1String(":/find/images/regexp.png")));
m_regularExpressionAction->setCheckable(true); m_regularExpressionAction->setCheckable(true);
m_regularExpressionAction->setChecked(false); m_regularExpressionAction->setChecked(false);
cmd = ActionManager::registerAction(m_regularExpressionAction, Constants::REGULAR_EXPRESSIONS, globalcontext); cmd = ActionManager::registerAction(m_regularExpressionAction, Constants::REGULAR_EXPRESSIONS);
mfind->addAction(cmd, Constants::G_FIND_FLAGS); mfind->addAction(cmd, Constants::G_FIND_FLAGS);
connect(m_regularExpressionAction, &QAction::toggled, this, &FindToolBar::setRegularExpressions); connect(m_regularExpressionAction, &QAction::toggled, this, &FindToolBar::setRegularExpressions);
...@@ -294,7 +293,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen ...@@ -294,7 +293,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_preserveCaseAction->setIcon(QPixmap(QLatin1String(":/find/images/preservecase.png"))); m_preserveCaseAction->setIcon(QPixmap(QLatin1String(":/find/images/preservecase.png")));
m_preserveCaseAction->setCheckable(true); m_preserveCaseAction->setCheckable(true);
m_preserveCaseAction->setChecked(false); m_preserveCaseAction->setChecked(false);
cmd = ActionManager::registerAction(m_preserveCaseAction, Constants::PRESERVE_CASE, globalcontext); cmd = ActionManager::registerAction(m_preserveCaseAction, Constants::PRESERVE_CASE);
mfind->addAction(cmd, Constants::G_FIND_FLAGS); mfind->addAction(cmd, Constants::G_FIND_FLAGS);
connect(m_preserveCaseAction, &QAction::toggled, this, &FindToolBar::setPreserveCase); connect(m_preserveCaseAction, &QAction::toggled, this, &FindToolBar::setPreserveCase);
......
...@@ -313,9 +313,7 @@ SearchResultWindow::SearchResultWindow(QWidget *newSearchPanel) ...@@ -313,9 +313,7 @@ SearchResultWindow::SearchResultWindow(QWidget *newSearchPanel)
d->m_expandCollapseAction = new QAction(tr("Expand All"), this); d->m_expandCollapseAction = new QAction(tr("Expand All"), this);
d->m_expandCollapseAction->setCheckable(true); d->m_expandCollapseAction->setCheckable(true);
d->m_expandCollapseAction->setIcon(QIcon(QLatin1String(":/find/images/expand.png"))); d->m_expandCollapseAction->setIcon(QIcon(QLatin1String(":/find/images/expand.png")));
Command *cmd = ActionManager::registerAction( Command *cmd = ActionManager::registerAction( d->m_expandCollapseAction, "Find.ExpandAll");
d->m_expandCollapseAction, "Find.ExpandAll",
Context(Constants::C_GLOBAL));
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
d->m_expandCollapseButton->setDefaultAction(cmd->action()); d->m_expandCollapseButton->setDefaultAction(cmd->action());
......
...@@ -98,8 +98,7 @@ void Locator::initialize(CorePlugin *corePlugin, const QStringList &, QString *) ...@@ -98,8 +98,7 @@ void Locator::initialize(CorePlugin *corePlugin, const QStringList &, QString *)
m_corePlugin->addAutoReleasedObject(view); m_corePlugin->addAutoReleasedObject(view);
QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this); QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this);
Command *cmd = ActionManager::registerAction(action, Constants::LOCATE, Command *cmd = ActionManager::registerAction(action, Constants::LOCATE);
Context(Constants::C_GLOBAL));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+K"))); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+K")));
connect(action, &QAction::triggered, this, &Locator::openLocator); connect(action, &QAction::triggered, this, &Locator::openLocator);
connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePlaceholderText())); connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePlaceholderText()));
......
...@@ -327,8 +327,7 @@ void LocatorWidget::updateFilterList() ...@@ -327,8 +327,7 @@ void LocatorWidget::updateFilterList()
if (!actionCopy.contains(filterId)) { if (!actionCopy.contains(filterId)) {
// register new action