forked from qt-creator/qt-creator
ActionManager API cleanup.
d-pointer instead of inheritance static methods Change-Id: I7b2f0c8b05ad3951e1ff26a7d4e08e195d2dd258 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -207,13 +207,12 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
// Add Home, Previous and Next actions (used in the toolbar)
|
||||
QAction *action = new QAction(QIcon(QLatin1String(IMAGEPATH "home.png")),
|
||||
tr("Home"), this);
|
||||
Core::ActionManager *am = Core::ICore::actionManager();
|
||||
am->registerAction(action, "Help.Home", globalcontext);
|
||||
Core::ActionManager::registerAction(action, "Help.Home", globalcontext);
|
||||
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(home()));
|
||||
|
||||
action = new QAction(QIcon(QLatin1String(IMAGEPATH "previous.png")),
|
||||
tr("Previous Page"), this);
|
||||
Core::Command *cmd = am->registerAction(action, Core::Id("Help.Previous"), modecontext);
|
||||
Core::Command *cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Previous"), modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::Back);
|
||||
action->setEnabled(m_centralWidget->isBackwardAvailable());
|
||||
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(backward()));
|
||||
@@ -222,7 +221,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
|
||||
action = new QAction(QIcon(QLatin1String(IMAGEPATH "next.png")), tr("Next Page"),
|
||||
this);
|
||||
cmd = am->registerAction(action, Core::Id("Help.Next"), modecontext);
|
||||
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Next"), modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence::Forward);
|
||||
action->setEnabled(m_centralWidget->isForwardAvailable());
|
||||
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(forward()));
|
||||
@@ -231,7 +230,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
|
||||
action = new QAction(QIcon(QLatin1String(IMAGEPATH "bookmark.png")),
|
||||
tr("Add Bookmark"), this);
|
||||
cmd = am->registerAction(action, Core::Id("Help.AddBookmark"),
|
||||
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.AddBookmark"),
|
||||
modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::Key_M));
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(addBookmark()));
|
||||
@@ -239,81 +238,81 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
// Add Contents, Index, and Context menu items and a separator to the Help menu
|
||||
action = new QAction(QIcon::fromTheme(QLatin1String("help-contents")),
|
||||
tr(SB_CONTENTS), this);
|
||||
cmd = am->registerAction(action, Core::Id("Help.Contents"), globalcontext);
|
||||
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Contents"), globalcontext);
|
||||
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(activateContents()));
|
||||
|
||||
action = new QAction(tr(SB_INDEX), this);
|
||||
cmd = am->registerAction(action, Core::Id("Help.Index"), globalcontext);
|
||||
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Index"), globalcontext);
|
||||
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(activateIndex()));
|
||||
|
||||
action = new QAction(tr("Context Help"), this);
|
||||
cmd = am->registerAction(action, Core::Id("Help.Context"), globalcontext);
|
||||
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Context"), globalcontext);
|
||||
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(activateContext()));
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
action = new QAction(this);
|
||||
action->setSeparator(true);
|
||||
cmd = am->registerAction(action, Core::Id("Help.Separator"), globalcontext);
|
||||
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Separator"), globalcontext);
|
||||
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
#endif
|
||||
|
||||
action = new QAction(tr("Technical Support"), this);
|
||||
cmd = am->registerAction(action, Core::Id("Help.TechSupport"), globalcontext);
|
||||
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.TechSupport"), globalcontext);
|
||||
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(slotOpenSupportPage()));
|
||||
|
||||
action = new QAction(tr("Report Bug..."), this);
|
||||
cmd = am->registerAction(action, Core::Id("Help.ReportBug"), globalcontext);
|
||||
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.ReportBug"), globalcontext);
|
||||
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(slotReportBug()));
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
action = new QAction(this);
|
||||
action->setSeparator(true);
|
||||
cmd = am->registerAction(action, Core::Id("Help.Separator2"), globalcontext);
|
||||
am->actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Separator2"), globalcontext);
|
||||
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
|
||||
#endif
|
||||
|
||||
action = new QAction(this);
|
||||
am->registerAction(action, Core::Constants::PRINT, modecontext);
|
||||
Core::ActionManager::registerAction(action, Core::Constants::PRINT, modecontext);
|
||||
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(print()));
|
||||
|
||||
action = new QAction(this);
|
||||
cmd = am->registerAction(action, Core::Constants::COPY, modecontext);
|
||||
cmd = Core::ActionManager::registerAction(action, Core::Constants::COPY, modecontext);
|
||||
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(copy()));
|
||||
action->setText(cmd->action()->text());
|
||||
action->setIcon(cmd->action()->icon());
|
||||
|
||||
if (Core::ActionContainer *advancedMenu = am->actionContainer(Core::Constants::M_EDIT_ADVANCED)) {
|
||||
if (Core::ActionContainer *advancedMenu = Core::ActionManager::actionContainer(Core::Constants::M_EDIT_ADVANCED)) {
|
||||
// reuse TextEditor constants to avoid a second pair of menu actions
|
||||
action = new QAction(tr("Increase Font Size"), this);
|
||||
cmd = am->registerAction(action, TextEditor::Constants::INCREASE_FONT_SIZE,
|
||||
cmd = Core::ActionManager::registerAction(action, TextEditor::Constants::INCREASE_FONT_SIZE,
|
||||
modecontext);
|
||||
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(zoomIn()));
|
||||
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
||||
|
||||
action = new QAction(tr("Decrease Font Size"), this);
|
||||
cmd = am->registerAction(action, TextEditor::Constants::DECREASE_FONT_SIZE,
|
||||
cmd = Core::ActionManager::registerAction(action, TextEditor::Constants::DECREASE_FONT_SIZE,
|
||||
modecontext);
|
||||
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(zoomOut()));
|
||||
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
||||
|
||||
action = new QAction(tr("Reset Font Size"), this);
|
||||
cmd = am->registerAction(action, TextEditor::Constants::RESET_FONT_SIZE,
|
||||
cmd = Core::ActionManager::registerAction(action, TextEditor::Constants::RESET_FONT_SIZE,
|
||||
modecontext);
|
||||
connect(action, SIGNAL(triggered()), m_centralWidget, SLOT(resetZoom()));
|
||||
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
||||
}
|
||||
|
||||
if (Core::ActionContainer *windowMenu = am->actionContainer(Core::Constants::M_WINDOW)) {
|
||||
if (Core::ActionContainer *windowMenu = Core::ActionManager::actionContainer(Core::Constants::M_WINDOW)) {
|
||||
// reuse EditorManager constants to avoid a second pair of menu actions
|
||||
action = new QAction(QApplication::translate("EditorManager",
|
||||
"Next Open Document in History"), this);
|
||||
Core::Command *ctrlTab = am->registerAction(action, Core::Constants::GOTOPREVINHISTORY,
|
||||
Core::Command *ctrlTab = Core::ActionManager::registerAction(action, Core::Constants::GOTOPREVINHISTORY,
|
||||
modecontext); // Goto Previous In History Action
|
||||
windowMenu->addAction(ctrlTab, Core::Constants::G_WINDOW_NAVIGATE);
|
||||
connect(action, SIGNAL(triggered()), &OpenPagesManager::instance(),
|
||||
@@ -321,7 +320,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
|
||||
action = new QAction(QApplication::translate("EditorManager",
|
||||
"Previous Open Document in History"), this);
|
||||
Core::Command *ctrlShiftTab = am->registerAction(action, Core::Constants::GOTONEXTINHISTORY,
|
||||
Core::Command *ctrlShiftTab = Core::ActionManager::registerAction(action, Core::Constants::GOTONEXTINHISTORY,
|
||||
modecontext); // Goto Next In History Action
|
||||
windowMenu->addAction(ctrlShiftTab, Core::Constants::G_WINDOW_NAVIGATE);
|
||||
connect(action, SIGNAL(triggered()), &OpenPagesManager::instance(),
|
||||
@@ -429,7 +428,6 @@ ExtensionSystem::IPlugin::ShutdownFlag HelpPlugin::aboutToShutdown()
|
||||
void HelpPlugin::setupUi()
|
||||
{
|
||||
// side bar widgets and shortcuts
|
||||
Core::ActionManager *am = Core::ICore::actionManager();
|
||||
Core::Context modecontext(Constants::C_MODE_HELP);
|
||||
|
||||
IndexWindow *indexWindow = new IndexWindow();
|
||||
@@ -444,7 +442,7 @@ void HelpPlugin::setupUi()
|
||||
QMap<QString, Core::Command*> shortcutMap;
|
||||
QShortcut *shortcut = new QShortcut(m_splitter);
|
||||
shortcut->setWhatsThis(tr("Activate Index in Help mode"));
|
||||
Core::Command* cmd = am->registerShortcut(shortcut,
|
||||
Core::Command* cmd = Core::ActionManager::registerShortcut(shortcut,
|
||||
Core::Id("Help.IndexShortcut"), modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateIndex()));
|
||||
@@ -458,7 +456,7 @@ void HelpPlugin::setupUi()
|
||||
|
||||
shortcut = new QShortcut(m_splitter);
|
||||
shortcut->setWhatsThis(tr("Activate Contents in Help mode"));
|
||||
cmd = am->registerShortcut(shortcut, Core::Id("Help.ContentsShortcut"),
|
||||
cmd = Core::ActionManager::registerShortcut(shortcut, Core::Id("Help.ContentsShortcut"),
|
||||
modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C));
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateContents()));
|
||||
@@ -472,7 +470,7 @@ void HelpPlugin::setupUi()
|
||||
|
||||
shortcut = new QShortcut(m_splitter);
|
||||
shortcut->setWhatsThis(tr("Activate Search in Help mode"));
|
||||
cmd = am->registerShortcut(shortcut, Core::Id("Help.SearchShortcut"),
|
||||
cmd = Core::ActionManager::registerShortcut(shortcut, Core::Id("Help.SearchShortcut"),
|
||||
modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Slash));
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateSearch()));
|
||||
@@ -489,7 +487,7 @@ void HelpPlugin::setupUi()
|
||||
|
||||
shortcut = new QShortcut(m_splitter);
|
||||
shortcut->setWhatsThis(tr("Activate Bookmarks in Help mode"));
|
||||
cmd = am->registerShortcut(shortcut, Core::Id("Help.BookmarkShortcut"),
|
||||
cmd = Core::ActionManager::registerShortcut(shortcut, Core::Id("Help.BookmarkShortcut"),
|
||||
modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B));
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateBookmarks()));
|
||||
@@ -501,7 +499,7 @@ void HelpPlugin::setupUi()
|
||||
|
||||
shortcut = new QShortcut(m_splitter);
|
||||
shortcut->setWhatsThis(tr("Activate Open Pages in Help mode"));
|
||||
cmd = am->registerShortcut(shortcut, Core::Id("Help.PagesShortcut"),
|
||||
cmd = Core::ActionManager::registerShortcut(shortcut, Core::Id("Help.PagesShortcut"),
|
||||
modecontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O));
|
||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateOpenPages()));
|
||||
@@ -527,7 +525,7 @@ void HelpPlugin::setupUi()
|
||||
tr("Show Sidebar"), this);
|
||||
m_toggleSideBarAction->setCheckable(true);
|
||||
connect(m_toggleSideBarAction, SIGNAL(triggered(bool)), this, SLOT(showHideSidebar()));
|
||||
cmd = am->registerAction(m_toggleSideBarAction, Core::Constants::TOGGLE_SIDEBAR, modecontext);
|
||||
cmd = Core::ActionManager::registerAction(m_toggleSideBarAction, Core::Constants::TOGGLE_SIDEBAR, modecontext);
|
||||
}
|
||||
|
||||
void HelpPlugin::resetFilter()
|
||||
@@ -621,7 +619,7 @@ void HelpPlugin::createRightPaneContextViewer()
|
||||
Core::ICore::addContextObject(icontext);
|
||||
|
||||
QAction *copy = new QAction(this);
|
||||
Core::Command *cmd = Core::ICore::actionManager()->registerAction(copy,
|
||||
Core::Command *cmd = Core::ActionManager::registerAction(copy,
|
||||
Core::Constants::COPY, context);
|
||||
copy->setText(cmd->action()->text());
|
||||
copy->setIcon(cmd->action()->icon());
|
||||
@@ -637,23 +635,22 @@ void HelpPlugin::createRightPaneContextViewer()
|
||||
connect(m_helpViewerForSideBar, SIGNAL(backwardAvailable(bool)), back,
|
||||
SLOT(setEnabled(bool)));
|
||||
|
||||
Core::ActionManager *am = Core::ICore::actionManager();
|
||||
if (Core::ActionContainer *advancedMenu = am->actionContainer(Core::Constants::M_EDIT_ADVANCED)) {
|
||||
if (Core::ActionContainer *advancedMenu = Core::ActionManager::actionContainer(Core::Constants::M_EDIT_ADVANCED)) {
|
||||
// reuse TextEditor constants to avoid a second pair of menu actions
|
||||
QAction *action = new QAction(tr("Increase Font Size"), this);
|
||||
cmd = am->registerAction(action, TextEditor::Constants::INCREASE_FONT_SIZE,
|
||||
cmd = Core::ActionManager::registerAction(action, TextEditor::Constants::INCREASE_FONT_SIZE,
|
||||
context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(scaleRightPaneUp()));
|
||||
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
||||
|
||||
action = new QAction(tr("Decrease Font Size"), this);
|
||||
cmd = am->registerAction(action, TextEditor::Constants::DECREASE_FONT_SIZE,
|
||||
cmd = Core::ActionManager::registerAction(action, TextEditor::Constants::DECREASE_FONT_SIZE,
|
||||
context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(scaleRightPaneDown()));
|
||||
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
||||
|
||||
action = new QAction(tr("Reset Font Size"), this);
|
||||
cmd = am->registerAction(action, TextEditor::Constants::RESET_FONT_SIZE,
|
||||
cmd = Core::ActionManager::registerAction(action, TextEditor::Constants::RESET_FONT_SIZE,
|
||||
context);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(resetRightPaneScale()));
|
||||
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_FONT);
|
||||
@@ -1065,11 +1062,10 @@ Utils::StyledBar *HelpPlugin::createIconToolBar(bool external)
|
||||
tr("Add Bookmark"), toolBar);
|
||||
connect(bookmark, SIGNAL(triggered()), this, SLOT(addBookmark()));
|
||||
} else {
|
||||
Core::ActionManager *am = Core::ICore::actionManager();
|
||||
home = am->command(Core::Id("Help.Home"))->action();
|
||||
back = am->command(Core::Id("Help.Previous"))->action();
|
||||
next = am->command(Core::Id("Help.Next"))->action();
|
||||
bookmark = am->command(Core::Id("Help.AddBookmark"))->action();
|
||||
home = Core::ActionManager::command(Core::Id("Help.Home"))->action();
|
||||
back = Core::ActionManager::command(Core::Id("Help.Previous"))->action();
|
||||
next = Core::ActionManager::command(Core::Id("Help.Next"))->action();
|
||||
bookmark = Core::ActionManager::command(Core::Id("Help.AddBookmark"))->action();
|
||||
}
|
||||
|
||||
setupNavigationMenus(back, next, toolBar);
|
||||
|
||||
Reference in New Issue
Block a user