From 1781617f8e88f1466ab2a1ad3d87ba3be92bca23 Mon Sep 17 00:00:00 2001 From: Eike Ziller <eike.ziller@nokia.com> Date: Wed, 23 May 2012 13:25:51 +0200 Subject: [PATCH] Get rid of lots of ifdef Q_OS_MAC for shortcuts. Using a central enum now. Change-Id: I20d88c9a3f8c62cf33e4b89a3442269f71918b06 Reviewed-by: hjk <qthjk@ovi.com> --- src/plugins/bazaar/bazaarplugin.cpp | 24 +----- src/plugins/bookmarks/bookmarksplugin.cpp | 18 +--- .../coreplugin/actionmanager/command.h | 6 ++ .../editormanager/editormanager.cpp | 40 ++------- src/plugins/coreplugin/mainwindow.cpp | 82 ++++++++----------- src/plugins/coreplugin/mainwindow.h | 2 - src/plugins/coreplugin/modemanager.cpp | 7 +- src/plugins/coreplugin/outputpanemanager.cpp | 6 +- src/plugins/cpaster/cpasterplugin.cpp | 12 +-- src/plugins/cvs/cvsplugin.cpp | 18 +--- .../debugger/debuggerinternalconstants.h | 5 -- src/plugins/debugger/debuggerplugin.cpp | 58 +++---------- src/plugins/designer/formeditorw.cpp | 14 +--- src/plugins/fakevim/fakevimplugin.cpp | 6 +- src/plugins/git/gitplugin.cpp | 50 ++--------- src/plugins/macros/macrosplugin.cpp | 12 +-- src/plugins/mercurial/mercurialplugin.cpp | 24 +----- src/plugins/perforce/perforceplugin.cpp | 42 ++-------- src/plugins/qmljseditor/qmljseditorplugin.cpp | 7 +- src/plugins/subversion/subversionplugin.cpp | 18 +--- .../texteditor/texteditoractionhandler.cpp | 16 +--- src/plugins/texteditor/texteditorplugin.cpp | 6 +- 22 files changed, 116 insertions(+), 357 deletions(-) diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index 1185720304f..a377b74fe9a 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -245,11 +245,7 @@ void BazaarPlugin::createFileActions(const Core::Context &context) m_diffFile = new Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = m_actionManager->registerAction(m_diffFile, Core::Id(Constants::DIFF), context); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+Z,Meta+D"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("ALT+Z,Alt+D"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Z,Meta+D") : tr("ALT+Z,Alt+D"))); connect(m_diffFile, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); @@ -257,11 +253,7 @@ void BazaarPlugin::createFileActions(const Core::Context &context) m_logFile = new Utils::ParameterAction(tr("Log Current File"), tr("Log \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = m_actionManager->registerAction(m_logFile, Core::Id(Constants::LOG), context); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+Z,Meta+L"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("ALT+Z,Alt+L"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Z,Meta+L") : tr("ALT+Z,Alt+L"))); connect(m_logFile, SIGNAL(triggered()), this, SLOT(logCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); @@ -269,11 +261,7 @@ void BazaarPlugin::createFileActions(const Core::Context &context) m_statusFile = new Utils::ParameterAction(tr("Status Current File"), tr("Status \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = m_actionManager->registerAction(m_statusFile, Core::Id(Constants::STATUS), context); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+Z,Meta+S"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("ALT+Z,Alt+S"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Z,Meta+S") : tr("ALT+Z,Alt+S"))); connect(m_statusFile, SIGNAL(triggered()), this, SLOT(statusCurrentFile())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); @@ -453,11 +441,7 @@ void BazaarPlugin::createRepositoryActions(const Core::Context &context) action = new QAction(tr("Commit..."), this); m_repositoryActionList.append(action); command = m_actionManager->registerAction(action, Core::Id(Constants::COMMIT), context); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+Z,Meta+C"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("ALT+Z,Alt+C"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Z,Meta+C") : tr("ALT+Z,Alt+C"))); connect(action, SIGNAL(triggered()), this, SLOT(commit())); m_bazaarContainer->addAction(command); m_commandLocator->appendCommand(command); diff --git a/src/plugins/bookmarks/bookmarksplugin.cpp b/src/plugins/bookmarks/bookmarksplugin.cpp index e477eb260b3..a0562e8354d 100644 --- a/src/plugins/bookmarks/bookmarksplugin.cpp +++ b/src/plugins/bookmarks/bookmarksplugin.cpp @@ -83,11 +83,7 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *) m_toggleAction = new QAction(tr("Toggle Bookmark"), this); Core::Command *cmd = am->registerAction(m_toggleAction, BOOKMARKS_TOGGLE_ACTION, textcontext); -#ifndef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+M"))); -#else - cmd->setDefaultKeySequence(QKeySequence(tr("Meta+M"))); -#endif + cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+M") : tr("Ctrl+M"))); mbm->addAction(cmd); QAction *sep = new QAction(this); @@ -98,21 +94,13 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *) //Previous m_prevAction = new QAction(tr("Previous Bookmark"), this); cmd = am->registerAction(m_prevAction, BOOKMARKS_PREV_ACTION, globalcontext); -#ifndef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+,"))); -#else - cmd->setDefaultKeySequence(QKeySequence(tr("Meta+,"))); -#endif + cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+,") : tr("Ctrl+,"))); mbm->addAction(cmd); //Next m_nextAction = new QAction(tr("Next Bookmark"), this); cmd = am->registerAction(m_nextAction, BOOKMARKS_NEXT_ACTION, globalcontext); -#ifndef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+."))); -#else - cmd->setDefaultKeySequence(QKeySequence(tr("Meta+."))); -#endif + cmd->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+.") : tr("Ctrl+."))); mbm->addAction(cmd); sep = new QAction(this); diff --git a/src/plugins/coreplugin/actionmanager/command.h b/src/plugins/coreplugin/actionmanager/command.h index c7c9dcaaae2..e65523029e5 100644 --- a/src/plugins/coreplugin/actionmanager/command.h +++ b/src/plugins/coreplugin/actionmanager/command.h @@ -49,6 +49,12 @@ namespace Core { class Context; +#ifdef Q_OS_MAC +enum { UseMacShortcuts = 1 }; +#else +enum { UseMacShortcuts = 0 }; +#endif + class CORE_EXPORT Command : public QObject { Q_OBJECT diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 8f5f8619dc7..15e7f340f54 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -369,77 +369,55 @@ EditorManager::EditorManager(QWidget *parent) : // Goto Previous In History Action cmd = am->registerAction(d->m_gotoPreviousDocHistoryAction, Constants::GOTOPREVINHISTORY, editDesignContext); -#ifdef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Alt+Tab"))); -#else - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Tab"))); -#endif + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Alt+Tab") : tr("Ctrl+Tab"))); mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE); connect(d->m_gotoPreviousDocHistoryAction, SIGNAL(triggered()), this, SLOT(gotoPreviousDocHistory())); // Goto Next In History Action cmd = am->registerAction(d->m_gotoNextDocHistoryAction, Constants::GOTONEXTINHISTORY, editDesignContext); -#ifdef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+Tab"))); -#else - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Tab"))); -#endif + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Alt+Shift+Tab") : tr("Ctrl+Shift+Tab"))); mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE); connect(d->m_gotoNextDocHistoryAction, SIGNAL(triggered()), this, SLOT(gotoNextDocHistory())); // Go back in navigation history cmd = am->registerAction(d->m_goBackAction, Constants::GO_BACK, editDesignContext); -#ifdef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Left"))); -#else - cmd->setDefaultKeySequence(QKeySequence(tr("Alt+Left"))); -#endif + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Alt+Left") : tr("Alt+Left"))); mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE); connect(d->m_goBackAction, SIGNAL(triggered()), this, SLOT(goBackInNavigationHistory())); // Go forward in navigation history cmd = am->registerAction(d->m_goForwardAction, Constants::GO_FORWARD, editDesignContext); -#ifdef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Right"))); -#else - cmd->setDefaultKeySequence(QKeySequence(tr("Alt+Right"))); -#endif + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Alt+Right") : tr("Alt+Right"))); mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE); connect(d->m_goForwardAction, SIGNAL(triggered()), this, SLOT(goForwardInNavigationHistory())); -#ifdef Q_OS_MAC - QString prefix = tr("Meta+E"); -#else - QString prefix = tr("Ctrl+E"); -#endif - d->m_splitAction = new QAction(tr("Split"), this); cmd = am->registerAction(d->m_splitAction, Constants::SPLIT, editManagerContext); - cmd->setDefaultKeySequence(QKeySequence(tr("%1,2").arg(prefix))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,2") : tr("Ctrl+E,2"))); mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); connect(d->m_splitAction, SIGNAL(triggered()), this, SLOT(split())); d->m_splitSideBySideAction = new QAction(tr("Split Side by Side"), this); cmd = am->registerAction(d->m_splitSideBySideAction, Constants::SPLIT_SIDE_BY_SIDE, editManagerContext); - cmd->setDefaultKeySequence(QKeySequence(tr("%1,3").arg(prefix))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,3") : tr("Ctrl+E,3"))); mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); connect(d->m_splitSideBySideAction, SIGNAL(triggered()), this, SLOT(splitSideBySide())); d->m_removeCurrentSplitAction = new QAction(tr("Remove Current Split"), this); cmd = am->registerAction(d->m_removeCurrentSplitAction, Constants::REMOVE_CURRENT_SPLIT, editManagerContext); - cmd->setDefaultKeySequence(QKeySequence(tr("%1,0").arg(prefix))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,0") : tr("Ctrl+E,0"))); mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); connect(d->m_removeCurrentSplitAction, SIGNAL(triggered()), this, SLOT(removeCurrentSplit())); d->m_removeAllSplitsAction = new QAction(tr("Remove All Splits"), this); cmd = am->registerAction(d->m_removeAllSplitsAction, Constants::REMOVE_ALL_SPLITS, editManagerContext); - cmd->setDefaultKeySequence(QKeySequence(tr("%1,1").arg(prefix))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,1") : tr("Ctrl+E,1"))); mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); connect(d->m_removeAllSplitsAction, SIGNAL(triggered()), this, SLOT(removeAllSplits())); d->m_gotoOtherSplitAction = new QAction(tr("Go to Next Split"), this); cmd = am->registerAction(d->m_gotoOtherSplitAction, Constants::GOTO_OTHER_SPLIT, editManagerContext); - cmd->setDefaultKeySequence(QKeySequence(tr("%1,o").arg(prefix))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+E,o") : tr("Ctrl+E,o"))); mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); connect(d->m_gotoOtherSplitAction, SIGNAL(triggered()), this, SLOT(gotoOtherSplit())); diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index be2fbb310f7..f300ea94874 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -657,9 +657,7 @@ void MainWindow::registerDefaultActions() tmpaction = new QAction(icon, tr("Save &As..."), this); tmpaction->setEnabled(false); cmd = am->registerAction(tmpaction, Constants::SAVEAS, globalContext); -#ifdef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+S"))); -#endif + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+S") : QString())); cmd->setAttribute(Command::CA_UpdateText); cmd->setDescription(tr("Save As...")); mfile->addAction(cmd, Constants::G_FILE_SAVE); @@ -667,9 +665,7 @@ void MainWindow::registerDefaultActions() // SaveAll Action m_saveAllAction = new QAction(tr("Save A&ll"), this); cmd = am->registerAction(m_saveAllAction, Constants::SAVEALL, globalContext); -#ifndef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+S"))); -#endif + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? QString() : tr("Ctrl+Shift+S"))); mfile->addAction(cmd, Constants::G_FILE_SAVE); connect(m_saveAllAction, SIGNAL(triggered()), this, SLOT(saveAll())); @@ -755,31 +751,31 @@ void MainWindow::registerDefaultActions() mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS); m_optionsAction = new QAction(tr("&Options..."), this); cmd = am->registerAction(m_optionsAction, Constants::OPTIONS, globalContext); -#ifdef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+,"))); - cmd->action()->setMenuRole(QAction::PreferencesRole); -#endif + if (UseMacShortcuts) { + cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+,"))); + cmd->action()->setMenuRole(QAction::PreferencesRole); + } mtools->addAction(cmd, Constants::G_TOOLS_OPTIONS); connect(m_optionsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog())); -#ifdef Q_OS_MAC - // Minimize Action - m_minimizeAction = new QAction(tr("Minimize"), this); - cmd = am->registerAction(m_minimizeAction, Constants::MINIMIZE_WINDOW, globalContext); - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+M"))); - mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); - connect(m_minimizeAction, SIGNAL(triggered()), this, SLOT(showMinimized())); - - // Zoom Action - m_zoomAction = new QAction(tr("Zoom"), this); - cmd = am->registerAction(m_zoomAction, Constants::ZOOM_WINDOW, globalContext); - mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); - connect(m_zoomAction, SIGNAL(triggered()), this, SLOT(showMaximized())); - - // Window separator - cmd = createSeparator(am, this, Id("QtCreator.Window.Sep.Size"), globalContext); - mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); -#endif + if (UseMacShortcuts) { + // Minimize Action + m_minimizeAction = new QAction(tr("Minimize"), this); + cmd = am->registerAction(m_minimizeAction, Constants::MINIMIZE_WINDOW, globalContext); + cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+M"))); + mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); + connect(m_minimizeAction, SIGNAL(triggered()), this, SLOT(showMinimized())); + + // Zoom Action + m_zoomAction = new QAction(tr("Zoom"), this); + cmd = am->registerAction(m_zoomAction, Constants::ZOOM_WINDOW, globalContext); + mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); + connect(m_zoomAction, SIGNAL(triggered()), this, SLOT(showMaximized())); + + // Window separator + cmd = createSeparator(am, this, Id("QtCreator.Window.Sep.Size"), globalContext); + mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); + } // Show Sidebar Action m_toggleSideBarAction = new QAction(QIcon(QLatin1String(Constants::ICON_TOGGLE_SIDEBAR)), @@ -787,11 +783,7 @@ void MainWindow::registerDefaultActions() m_toggleSideBarAction->setCheckable(true); cmd = am->registerAction(m_toggleSideBarAction, Constants::TOGGLE_SIDEBAR, globalContext); cmd->setAttribute(Command::CA_UpdateText); -#ifdef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+0"))); -#else - cmd->setDefaultKeySequence(QKeySequence(tr("Alt+0"))); -#endif + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+0") : tr("Alt+0"))); connect(m_toggleSideBarAction, SIGNAL(triggered(bool)), this, SLOT(setSidebarVisible(bool))); m_toggleSideBarButton->setDefaultAction(cmd->action()); mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS); @@ -799,25 +791,23 @@ void MainWindow::registerDefaultActions() #if defined(Q_OS_MAC) bool fullScreenCheckable = false; - QKeySequence fullScreenKeySequence(tr("Ctrl+Meta+F")); const QString fullScreenActionText(tr("Enter Full Screen")); - if (MacFullScreen::supportsFullScreen()) { + bool supportsFullScreen = MacFullScreen::supportsFullScreen(); #else bool fullScreenCheckable = true; - QKeySequence fullScreenKeySequence(tr("Ctrl+Shift+F11")); const QString fullScreenActionText(tr("Full Screen")); + bool supportsFullScreen = true; #endif - // Full Screen Action - m_toggleFullScreenAction = new QAction(fullScreenActionText, this); - m_toggleFullScreenAction->setCheckable(fullScreenCheckable); - cmd = am->registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext); - cmd->setDefaultKeySequence(fullScreenKeySequence); - cmd->setAttribute(Command::CA_UpdateText); /* for Mac */ - mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); - connect(m_toggleFullScreenAction, SIGNAL(triggered(bool)), this, SLOT(setFullScreen(bool))); -#ifdef Q_OS_MAC + if (supportsFullScreen) { + // Full Screen Action + m_toggleFullScreenAction = new QAction(fullScreenActionText, this); + m_toggleFullScreenAction->setCheckable(fullScreenCheckable); + cmd = am->registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11"))); + cmd->setAttribute(Command::CA_UpdateText); /* for Mac */ + mwindow->addAction(cmd, Constants::G_WINDOW_SIZE); + connect(m_toggleFullScreenAction, SIGNAL(triggered(bool)), this, SLOT(setFullScreen(bool))); } -#endif // Window->Views ActionContainer *mviews = am->createMenu(Constants::M_WINDOW_VIEWS); diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h index 20be8cf83c9..60c6486a6b1 100644 --- a/src/plugins/coreplugin/mainwindow.h +++ b/src/plugins/coreplugin/mainwindow.h @@ -227,10 +227,8 @@ private: QAction *m_optionsAction; QAction *m_toggleSideBarAction; QAction *m_toggleFullScreenAction; -#ifdef Q_OS_MAC QAction *m_minimizeAction; QAction *m_zoomAction; -#endif QToolButton *m_toggleSideBarButton; QColor m_overrideColor; diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp index 898dc35ec71..c46429de879 100644 --- a/src/plugins/coreplugin/modemanager.cpp +++ b/src/plugins/coreplugin/modemanager.cpp @@ -212,11 +212,8 @@ void ModeManager::objectAdded(QObject *obj) // and still expect the current shortcut to change with it bool currentlyHasDefaultSequence = (currentCmd->keySequence() == currentCmd->defaultKeySequence()); -#ifdef Q_OS_MAC - currentCmd->setDefaultKeySequence(QKeySequence(QString::fromLatin1("Meta+%1").arg(i+1))); -#else - currentCmd->setDefaultKeySequence(QKeySequence(QString::fromLatin1("Ctrl+%1").arg(i+1))); -#endif + currentCmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? QString::fromLatin1("Meta+%1").arg(i+1) + : QString::fromLatin1("Ctrl+%1").arg(i+1))); if (currentlyHasDefaultSequence) currentCmd->setKeySequence(currentCmd->defaultKeySequence()); } diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp index f7f3c2e559f..e42305eaf4f 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -236,11 +236,7 @@ void OutputPaneManager::init() mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); cmd = am->registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalContext); -#ifdef Q_OS_MAC - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+9"))); -#else - cmd->setDefaultKeySequence(QKeySequence(tr("Alt+9"))); -#endif + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+9") : tr("Alt+9"))); cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateIcon); mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup"); diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index 3c4d792cb85..a92de4b33db 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -174,11 +174,7 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *errorMe m_postEditorAction = new QAction(tr("Paste Snippet..."), this); command = actionManager->registerAction(m_postEditorAction, "CodePaster.Post", globalcontext); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+C,Meta+P"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+P"))); -#endif + command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+C,Meta+P") : tr("Alt+C,Alt+P"))); connect(m_postEditorAction, SIGNAL(triggered()), this, SLOT(postEditor())); cpContainer->addAction(command); @@ -189,11 +185,7 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *errorMe m_fetchAction = new QAction(tr("Fetch Snippet..."), this); command = actionManager->registerAction(m_fetchAction, "CodePaster.Fetch", globalcontext); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+C,Meta+F"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+F"))); -#endif + command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+C,Meta+F") : tr("Alt+C,Alt+F"))); connect(m_fetchAction, SIGNAL(triggered()), this, SLOT(fetch())); cpContainer->addAction(command); diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index baa3a35c500..778e9ed420c 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -285,11 +285,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage) command = ami->registerAction(m_diffCurrentAction, CMD_ID_DIFF_CURRENT, globalcontext); command->setAttribute(Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+C,Meta+D"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+D"))); -#endif + command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+C,Meta+D") : tr("Alt+C,Alt+D"))); connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); cvsMenu->addAction(command); m_commandLocator->appendCommand(command); @@ -318,11 +314,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage) command = ami->registerAction(m_addAction, CMD_ID_ADD, globalcontext); command->setAttribute(Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+C,Meta+A"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+A"))); -#endif + command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+C,Meta+A") : tr("Alt+C,Alt+A"))); connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile())); cvsMenu->addAction(command); m_commandLocator->appendCommand(command); @@ -331,11 +323,7 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage) command = ami->registerAction(m_commitCurrentAction, CMD_ID_COMMIT_CURRENT, globalcontext); command->setAttribute(Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+C,Meta+C"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+C"))); -#endif + command->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+C,Meta+C") : tr("Alt+C,Alt+C"))); connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile())); cvsMenu->addAction(command); m_commandLocator->appendCommand(command); diff --git a/src/plugins/debugger/debuggerinternalconstants.h b/src/plugins/debugger/debuggerinternalconstants.h index 5132fd328b5..b9143825081 100644 --- a/src/plugins/debugger/debuggerinternalconstants.h +++ b/src/plugins/debugger/debuggerinternalconstants.h @@ -54,11 +54,6 @@ const char OPENED_WITH_MEMORY[] = "MemoryView"; // Debug action const char DEBUG[] = "Debugger.Debug"; const int P_ACTION_DEBUG = 90; // Priority for the modemanager. -#ifdef Q_OS_MAC -const char DEBUG_KEY[] = "Ctrl+Y"; -#else -const char DEBUG_KEY[] = "F5"; -#endif } // namespace Constants diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 648b31639d6..69dc1c5f6e1 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -385,38 +385,6 @@ namespace PE = ProjectExplorer::Constants; namespace Debugger { namespace Constants { -#ifdef Q_OS_MAC -const char STOP_KEY[] = "Shift+Ctrl+Y"; -const char RESET_KEY[] = "Ctrl+Shift+F5"; -const char STEP_KEY[] = "Ctrl+Shift+I"; -const char STEPOUT_KEY[] = "Ctrl+Shift+T"; -const char NEXT_KEY[] = "Ctrl+Shift+O"; -const char REVERSE_KEY[] = ""; -const char RUN_TO_LINE_KEY[] = "Shift+F8"; -const char RUN_TO_SELECTED_FUNCTION_KEY[] = "Ctrl+F6"; -const char JUMP_TO_LINE_KEY[] = "Ctrl+D,Ctrl+L"; -const char TOGGLE_BREAK_KEY[] = "F8"; -const char BREAK_BY_FUNCTION_KEY[] = "Ctrl+D,Ctrl+F"; -const char BREAK_AT_MAIN_KEY[] = "Ctrl+D,Ctrl+M"; -const char ADD_TO_WATCH_KEY[] = "Ctrl+D,Ctrl+W"; -const char SNAPSHOT_KEY[] = "Ctrl+D,Ctrl+S"; -#else -const char STOP_KEY[] = "Shift+F5"; -const char RESET_KEY[] = "Ctrl+Shift+F5"; -const char STEP_KEY[] = "F11"; -const char STEPOUT_KEY[] = "Shift+F11"; -const char NEXT_KEY[] = "F10"; -const char REVERSE_KEY[] = "F12"; -const char RUN_TO_LINE_KEY[] = "Ctrl+F10"; -const char RUN_TO_SELECTED_FUNCTION_KEY[] = "Ctrl+F6"; -const char JUMP_TO_LINE_KEY[] = ""; -const char TOGGLE_BREAK_KEY[] = "F9"; -const char BREAK_BY_FUNCTION_KEY[] = ""; -const char BREAK_AT_MAIN_KEY[] = ""; -const char ADD_TO_WATCH_KEY[] = "Ctrl+Alt+Q"; -const char SNAPSHOT_KEY[] = "Ctrl+D,Ctrl+S"; -#endif - } // namespace Constants @@ -2871,6 +2839,8 @@ QMessageBox *showMessageBox(int icon, const QString &title, void DebuggerPluginPrivate::extensionsInitialized() { + const QKeySequence debugKey = QKeySequence(UseMacShortcuts ? tr("Ctrl+Y") : tr("F5")); + m_coreSettings = ICore::settings(); m_debuggerSettings = new DebuggerSettings(m_coreSettings); @@ -3158,7 +3128,7 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_startAction, Constants::DEBUG, globalcontext); cmd->setDescription(tr("Start Debugging")); - cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::DEBUG_KEY))); + cmd->setDefaultKeySequence(debugKey); cmd->setAttribute(Command::CA_UpdateText); mstart->addAction(cmd, CC::G_DEFAULT_ONE); @@ -3254,7 +3224,7 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_continueAction, Constants::CONTINUE, globalcontext); - cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::DEBUG_KEY))); + cmd->setDefaultKeySequence(debugKey); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); cmd = am->registerAction(m_exitAction, @@ -3269,11 +3239,10 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_hiddenStopAction, Constants::HIDDEN_STOP, globalcontext); - cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::STOP_KEY))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Shift+Ctrl+Y") : tr("Shift+F5"))); cmd = am->registerAction(m_abortAction, Constants::ABORT, globalcontext); - //cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::RESET_KEY))); cmd->setDescription(tr("Reset Debugger")); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); @@ -3284,34 +3253,33 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_nextAction, Constants::NEXT, globalcontext); - cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::NEXT_KEY))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+O") : tr("F10"))); cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_UpdateText); debugMenu->addAction(cmd); cmd = am->registerAction(m_stepAction, Constants::STEP, globalcontext); - cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::STEP_KEY))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+I") : tr("F11"))); cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_UpdateText); debugMenu->addAction(cmd); cmd = am->registerAction(m_stepOutAction, Constants::STEPOUT, cppDebuggercontext); - cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::STEPOUT_KEY))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Shift+T") : tr("Shift+F11"))); cmd->setAttribute(Command::CA_Hide); debugMenu->addAction(cmd); cmd = am->registerAction(m_runToLineAction, "Debugger.RunToLine", cppDebuggercontext); - cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::RUN_TO_LINE_KEY))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Shift+F8") : tr("Ctrl+F10"))); cmd->setAttribute(Command::CA_Hide); debugMenu->addAction(cmd); cmd = am->registerAction(m_runToSelectedFunctionAction, "Debugger.RunToSelectedFunction", cppDebuggercontext); - cmd->setDefaultKeySequence(QKeySequence( - QLatin1String(Constants::RUN_TO_SELECTED_FUNCTION_KEY))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+F6") : tr("Ctrl+F6"))); cmd->setAttribute(Command::CA_Hide); // Don't add to menu by default as keeping its enabled state // and text up-to-date is a lot of hassle. @@ -3329,7 +3297,7 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_reverseDirectionAction, Constants::REVERSE, cppDebuggercontext); - cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::REVERSE_KEY))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? QString() : tr("F12"))); cmd->setAttribute(Command::CA_Hide); debugMenu->addAction(cmd); @@ -3340,7 +3308,7 @@ void DebuggerPluginPrivate::extensionsInitialized() //cmd = am->registerAction(m_snapshotAction, // "Debugger.Snapshot", cppDebuggercontext); - //cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::SNAPSHOT_KEY))); + //cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+D,Ctrl+S"))); //cmd->setAttribute(Command::CA_Hide); //debugMenu->addAction(cmd); @@ -3356,7 +3324,7 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_breakAction, "Debugger.ToggleBreak", globalcontext); - cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::TOGGLE_BREAK_KEY))); + cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("F8") : tr("F9"))); debugMenu->addAction(cmd); connect(m_breakAction, SIGNAL(triggered()), SLOT(toggleBreakpoint())); diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp index 8f366d70f9b..d1d339ddd11 100644 --- a/src/plugins/designer/formeditorw.cpp +++ b/src/plugins/designer/formeditorw.cpp @@ -105,12 +105,6 @@ static const char settingsGroupC[] = "Designer"; -#ifdef Q_OS_MAC - enum { osMac = 1 }; -#else - enum { osMac = 0 }; -#endif - /* Actions of the designer plugin: * Designer provides a toolbar which is subject to a context change (to * "edit mode" context) when it is focused. @@ -499,12 +493,12 @@ void FormEditorW::setupActions() //tool actions m_toolActionIds.push_back(Core::Id("FormEditor.LayoutHorizontally")); - const QString horizLayoutShortcut = osMac ? tr("Meta+Shift+H") : tr("Ctrl+H"); + const QString horizLayoutShortcut = Core::UseMacShortcuts ? tr("Meta+Shift+H") : tr("Ctrl+H"); addToolAction(m_fwm->actionHorizontalLayout(), am, m_contexts, m_toolActionIds.back(), mformtools, horizLayoutShortcut); m_toolActionIds.push_back(Core::Id("FormEditor.LayoutVertically")); - const QString vertLayoutShortcut = osMac ? tr("Meta+L") : tr("Ctrl+L"); + const QString vertLayoutShortcut = Core::UseMacShortcuts ? tr("Meta+L") : tr("Ctrl+L"); addToolAction(m_fwm->actionVerticalLayout(), am, m_contexts, m_toolActionIds.back(), mformtools, vertLayoutShortcut); @@ -521,7 +515,7 @@ void FormEditorW::setupActions() m_toolActionIds.back(), mformtools); m_toolActionIds.push_back(Core::Id("FormEditor.LayoutGrid")); - const QString gridShortcut = osMac ? tr("Meta+Shift+G") : tr("Ctrl+G"); + const QString gridShortcut = Core::UseMacShortcuts ? tr("Meta+Shift+G") : tr("Ctrl+G"); addToolAction(m_fwm->actionGridLayout(), am, m_contexts, m_toolActionIds.back(), mformtools, gridShortcut); @@ -530,7 +524,7 @@ void FormEditorW::setupActions() m_toolActionIds.back(), mformtools); m_toolActionIds.push_back(Core::Id("FormEditor.LayoutAdjustSize")); - const QString adjustShortcut = osMac ? tr("Meta+J") : tr("Ctrl+J"); + const QString adjustShortcut = Core::UseMacShortcuts ? tr("Meta+J") : tr("Ctrl+J"); addToolAction(m_fwm->actionAdjustSize(), am, m_contexts, m_toolActionIds.back(), mformtools, adjustShortcut); diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 34c7e0affb5..fbb1c559112 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -107,7 +107,6 @@ namespace Constants { const char INSTALL_HANDLER[] = "TextEditor.FakeVimHandler"; const char MINI_BUFFER[] = "TextEditor.FakeVimMiniBuffer"; -const char INSTALL_KEY[] = "Alt+V,Alt+V"; const char SETTINGS_CATEGORY[] = "D.FakeVim"; const char SETTINGS_CATEGORY_FAKEVIM_ICON[] = ":/core/images/category_fakevim.png"; const char SETTINGS_ID[] = "A.General"; @@ -971,7 +970,7 @@ bool FakeVimPluginPrivate::initialize() Core::Command *cmd = 0; cmd = actionManager->registerAction(theFakeVimSetting(ConfigUseFakeVim), Constants::INSTALL_HANDLER, globalcontext, true); - cmd->setDefaultKeySequence(QKeySequence(Constants::INSTALL_KEY)); + cmd->setDefaultKeySequence(QKeySequence(tr("Alt+V,Alt+V"))); ActionContainer *advancedMenu = actionManager->actionContainer(Core::Constants::M_EDIT_ADVANCED); @@ -982,9 +981,8 @@ bool FakeVimPluginPrivate::initialize() act->setText(tr("Execute User Action #%1").arg(i)); act->setData(i); QString id = QString("FakeVim.UserAction%1").arg(i); - QString keys = QString("Alt+V,%1").arg(i); cmd = actionManager->registerAction(act, Core::Id(id), globalcontext); - cmd->setDefaultKeySequence(QKeySequence(keys)); + cmd->setDefaultKeySequence(QKeySequence(tr("Alt+V,%1").arg(i))); connect(act, SIGNAL(triggered()), SLOT(userActionTriggered())); } diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 186aae1ca65..74f409a9a0a 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -328,33 +328,20 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) tr("Blame Current File"), tr("Blame for \"%1\""), Core::Id("Git.Blame"), globalcontext, true, SLOT(blameFile())); -#ifdef Q_OS_MAC - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Meta+G,Meta+B"))); -#else - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+B"))); -#endif + parameterActionCommand.second->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+G,Meta+B") : tr("Alt+G,Alt+B"))); parameterActionCommand = createFileAction(actionManager, gitContainer, tr("Diff Current File"), tr("Diff of \"%1\""), Core::Id("Git.Diff"), globalcontext, true, SLOT(diffCurrentFile())); -#ifdef Q_OS_MAC - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Meta+G,Meta+D"))); -#else - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+D"))); -#endif + parameterActionCommand.second->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+G,Meta+D") : tr("Alt+G,Alt+D"))); parameterActionCommand = createFileAction(actionManager, gitContainer, tr("Log Current File"), tr("Log of \"%1\""), Core::Id("Git.Log"), globalcontext, true, SLOT(logFile())); -#ifdef Q_OS_MAC - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Meta+G,Meta+L"))); -#else - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+L"))); -#endif - + parameterActionCommand.second->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+G,Meta+L") : tr("Alt+G,Alt+L"))); // ------ gitContainer->addAction(createSeparator(actionManager, globalcontext, Core::Id("Git.Sep.File"), this)); @@ -363,11 +350,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) = createFileAction(actionManager, gitContainer, tr("Stage File for Commit"), tr("Stage \"%1\" for Commit"), Core::Id("Git.Stage"), globalcontext, true, SLOT(stageFile())); -#ifdef Q_OS_MAC - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Meta+G,Meta+A"))); -#else - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+A"))); -#endif + parameterActionCommand.second->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+G,Meta+A") : tr("Alt+G,Alt+A"))); parameterActionCommand = createFileAction(actionManager, gitContainer, @@ -385,12 +368,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) tr("Undo Uncommitted Changes"), tr("Undo Uncommitted Changes for \"%1\""), Core::Id("Git.Undo"), globalcontext, true, SLOT(undoFileChanges())); -#ifdef Q_OS_MAC - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Meta+G,Meta+U"))); -#else - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+U"))); -#endif - + parameterActionCommand.second->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+G,Meta+U") : tr("Alt+G,Alt+U"))); // ------------ gitContainer->addAction(createSeparator(actionManager, globalcontext, Core::Id("Git.Sep.Project"), this)); @@ -401,22 +379,14 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) Core::Id("Git.DiffProject"), globalcontext, true, SLOT(diffCurrentProject())); -#ifdef Q_OS_MAC - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Meta+G,Meta+Shift+D"))); -#else - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+Shift+D"))); -#endif + parameterActionCommand.second->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+G,Meta+Shift+D") : tr("Alt+G,Alt+Shift+D"))); parameterActionCommand = createProjectAction(actionManager, gitContainer, tr("Log Project"), tr("Log Project \"%1\""), Core::Id("Git.LogProject"), globalcontext, true, SLOT(logProject())); -#ifdef Q_OS_MAC - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Meta+G,Meta+K"))); -#else - parameterActionCommand.second->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+K"))); -#endif + parameterActionCommand.second->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+G,Meta+K") : tr("Alt+G,Alt+K"))); parameterActionCommand = createProjectAction(actionManager, gitContainer, @@ -560,11 +530,7 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) actionCommand = createRepositoryAction(actionManager, gitContainer, tr("Commit..."), Core::Id("Git.Commit"), globalcontext, true, SLOT(startCommit())); -#ifdef Q_OS_MAC - actionCommand.second->setDefaultKeySequence(QKeySequence(tr("Meta+G,Meta+C"))); -#else - actionCommand.second->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+C"))); -#endif + actionCommand.second->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+G,Meta+C") : tr("Alt+G,Alt+C"))); createRepositoryAction(actionManager, gitContainer, tr("Amend Last Commit..."), Core::Id("Git.AmendCommit"), diff --git a/src/plugins/macros/macrosplugin.cpp b/src/plugins/macros/macrosplugin.cpp index 3fd60310ebd..374bbb16b90 100644 --- a/src/plugins/macros/macrosplugin.cpp +++ b/src/plugins/macros/macrosplugin.cpp @@ -88,22 +88,14 @@ bool MacrosPlugin::initialize(const QStringList &arguments, QString *errorMessag QAction *startMacro = new QAction(tr("Record Macro"), this); Core::Command *command = am->registerAction(startMacro, Constants::START_MACRO, textContext); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Ctrl+("))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+("))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Ctrl+(") : tr("Alt+("))); mmacrotools->addAction(command); connect(startMacro, SIGNAL(triggered()), m_macroManager, SLOT(startMacro())); QAction *endMacro = new QAction(tr("Stop Recording Macro"), this); endMacro->setEnabled(false); command = am->registerAction(endMacro, Constants::END_MACRO, globalcontext); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Ctrl+)"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+)"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Ctrl+)") : tr("Alt+)"))); mmacrotools->addAction(command); connect(endMacro, SIGNAL(triggered()), m_macroManager, SLOT(endMacro())); diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp index 201300ac870..e93adb099fa 100644 --- a/src/plugins/mercurial/mercurialplugin.cpp +++ b/src/plugins/mercurial/mercurialplugin.cpp @@ -233,11 +233,7 @@ void MercurialPlugin::createFileActions(const Core::Context &context) diffFile = new ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), ParameterAction::EnabledWithParameter, this); command = actionManager->registerAction(diffFile, Core::Id(Constants::DIFF), context); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+H,Meta+D"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+D"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+D") : tr("Alt+H,Alt+D"))); connect(diffFile, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); @@ -245,11 +241,7 @@ void MercurialPlugin::createFileActions(const Core::Context &context) logFile = new ParameterAction(tr("Log Current File"), tr("Log \"%1\""), ParameterAction::EnabledWithParameter, this); command = actionManager->registerAction(logFile, Core::Id(Constants::LOG), context); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+H,Meta+L"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+L"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+L") : tr("Alt+H,Alt+L"))); connect(logFile, SIGNAL(triggered()), this, SLOT(logCurrentFile())); mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); @@ -257,11 +249,7 @@ void MercurialPlugin::createFileActions(const Core::Context &context) statusFile = new ParameterAction(tr("Status Current File"), tr("Status \"%1\""), ParameterAction::EnabledWithParameter, this); command = actionManager->registerAction(statusFile, Core::Id(Constants::STATUS), context); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+H,Meta+S"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+S"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+S") : tr("Alt+H,Alt+S"))); connect(statusFile, SIGNAL(triggered()), this, SLOT(statusCurrentFile())); mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); @@ -451,11 +439,7 @@ void MercurialPlugin::createRepositoryActions(const Core::Context &context) action = new QAction(tr("Commit..."), this); m_repositoryActionList.append(action); command = actionManager->registerAction(action, Core::Id(Constants::COMMIT), context); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+H,Meta+C"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+H,Alt+C"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+H,Meta+C") : tr("Alt+H,Alt+C"))); connect(action, SIGNAL(triggered()), this, SLOT(commit())); mercurialContainer->addAction(command); m_commandLocator->appendCommand(command); diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 6615b14f240..14bd8feb33b 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -294,11 +294,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er m_filelogCurrentAction = new Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = am->registerAction(m_filelogCurrentAction, CMD_ID_FILELOG_CURRENT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+P,Meta+F"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+F"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+P,Meta+F") : tr("Alt+P,Alt+F"))); command->setDescription(tr("Filelog Current File")); connect(m_filelogCurrentAction, SIGNAL(triggered()), this, SLOT(filelogCurrentFile())); mperforce->addAction(command); @@ -309,11 +305,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er m_editAction = new Utils::ParameterAction(tr("Edit"), tr("Edit \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = am->registerAction(m_editAction, CMD_ID_EDIT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+P,Meta+E"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+E"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+P,Meta+E") : tr("Alt+P,Alt+E"))); command->setDescription(tr("Edit File")); connect(m_editAction, SIGNAL(triggered()), this, SLOT(openCurrentFile())); mperforce->addAction(command); @@ -322,11 +314,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er m_addAction = new Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = am->registerAction(m_addAction, CMD_ID_ADD, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+P,Meta+A"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+A"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+P,Meta+A") : tr("Alt+P,Alt+A"))); command->setDescription(tr("Add File")); connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile())); mperforce->addAction(command); @@ -343,11 +331,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er m_revertFileAction = new Utils::ParameterAction(tr("Revert"), tr("Revert \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = am->registerAction(m_revertFileAction, CMD_ID_REVERT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+P,Meta+R"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+R"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+P,Meta+R") : tr("Alt+P,Alt+R"))); command->setDescription(tr("Revert File")); connect(m_revertFileAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile())); mperforce->addAction(command); @@ -359,11 +343,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er m_diffProjectAction = new Utils::ParameterAction(diffProjectDefaultText, tr("Diff Project \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); command = am->registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+P,Meta+D"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+D"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+P,Meta+D") : tr("Alt+P,Alt+D"))); command->setDescription(diffProjectDefaultText); connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffCurrentProject())); mperforce->addAction(command); @@ -379,11 +359,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er m_submitProjectAction = new Utils::ParameterAction(tr("Submit Project"), tr("Submit Project \"%1\""), Utils::ParameterAction::EnabledWithParameter, this); command = am->registerAction(m_submitProjectAction, CMD_ID_SUBMIT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+P,Meta+S"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+S"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+P,Meta+S") : tr("Alt+P,Alt+S"))); connect(m_submitProjectAction, SIGNAL(triggered()), this, SLOT(startSubmitProject())); mperforce->addAction(command); m_commandLocator->appendCommand(command); @@ -421,11 +397,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er m_openedAction = new QAction(tr("Opened"), this); command = am->registerAction(m_openedAction, CMD_ID_OPENED, globalcontext); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+P,Meta+O"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+P,Alt+O"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+P,Meta+O") : tr("Alt+P,Alt+O"))); connect(m_openedAction, SIGNAL(triggered()), this, SLOT(printOpenedFileList())); mperforce->addAction(command); m_commandLocator->appendCommand(command); diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 649ed1b0779..05f39c89629 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -217,11 +217,8 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e QAction *showQuickToolbar = new QAction(tr("Show Qt Quick Toolbar"), this); cmd = am->registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context); -#ifdef Q_OS_MACX - cmd->setDefaultKeySequence(QKeySequence(Qt::META + Qt::ALT + Qt::Key_Space)); -#else - cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Space)); -#endif + cmd->setDefaultKeySequence(Core::UseMacShortcuts ? QKeySequence(Qt::META + Qt::ALT + Qt::Key_Space) + : QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Space)); connect(showQuickToolbar, SIGNAL(triggered()), this, SLOT(showContextPane())); contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index ce152fd30ad..afac58b7bec 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -309,11 +309,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e command = ami->registerAction(m_diffCurrentAction, CMD_ID_DIFF_CURRENT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+S,Meta+D"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+D"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+S,Meta+D") : tr("Alt+S,Alt+D"))); connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); @@ -342,11 +338,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e command = ami->registerAction(m_addAction, CMD_ID_ADD, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+S,Meta+A"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+A"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+S,Meta+A") : tr("Alt+S,Alt+A"))); connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); @@ -355,11 +347,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e command = ami->registerAction(m_commitCurrentAction, CMD_ID_COMMIT_CURRENT, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); -#ifdef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Meta+S,Meta+C"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+C"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+S,Meta+C") : tr("Alt+S,Alt+C"))); connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile())); subversionMenu->addAction(command); m_commandLocator->appendCommand(command); diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 84747b76750..269d67d32ac 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -170,16 +170,10 @@ void TextEditorActionHandler::createActions() advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_formatAction, SIGNAL(triggered(bool)), this, SLOT(formatAction())); -#ifdef Q_OS_MAC - QString modifier = tr("Meta"); -#else - QString modifier = tr("Ctrl"); -#endif - m_rewrapParagraphAction = new QAction(tr("&Rewrap Paragraph"), this); m_modifyingActions << m_rewrapParagraphAction; command = am->registerAction(m_rewrapParagraphAction, TextEditor::Constants::REWRAP_PARAGRAPH, m_contextId, true); - command->setDefaultKeySequence(QKeySequence(tr("%1+E, R").arg(modifier))); + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+E, R") : tr("Ctrl+E, R"))); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_rewrapParagraphAction, SIGNAL(triggered(bool)), this, SLOT(rewrapParagraphAction())); @@ -188,7 +182,7 @@ void TextEditorActionHandler::createActions() m_visualizeWhitespaceAction->setCheckable(true); command = am->registerAction(m_visualizeWhitespaceAction, TextEditor::Constants::VISUALIZE_WHITESPACE, m_contextId); - command->setDefaultKeySequence(QKeySequence(tr("%1+E, %2+V").arg(modifier, modifier))); + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+E, Meta+V") : tr("Ctrl+E, Ctrl+V"))); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_visualizeWhitespaceAction, SIGNAL(triggered(bool)), this, SLOT(setVisualizeWhitespace(bool))); @@ -203,7 +197,7 @@ void TextEditorActionHandler::createActions() m_textWrappingAction = new QAction(tr("Enable Text &Wrapping"), this); m_textWrappingAction->setCheckable(true); command = am->registerAction(m_textWrappingAction, TextEditor::Constants::TEXT_WRAPPING, m_contextId); - command->setDefaultKeySequence(QKeySequence(tr("%1+E, %2+W").arg(modifier, modifier))); + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+E, Meta+W") : tr("Ctrl+E, Ctrl+W"))); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_textWrappingAction, SIGNAL(triggered(bool)), this, SLOT(setTextWrapping(bool))); @@ -282,9 +276,7 @@ void TextEditorActionHandler::createActions() m_resetFontSizeAction = new QAction(tr("Reset Font Size"), this); command = am->registerAction(m_resetFontSizeAction, Constants::RESET_FONT_SIZE, m_contextId); -#ifndef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Ctrl+0"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? QString() : tr("Ctrl+0"))); connect(m_resetFontSizeAction, SIGNAL(triggered()), this, SLOT(resetFontSize())); advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT); diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index b4eec0dcfd4..865f4307d73 100644 --- a/src/plugins/texteditor/texteditorplugin.cpp +++ b/src/plugins/texteditor/texteditorplugin.cpp @@ -189,11 +189,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe // Make sure the shortcut still works when the completion widget is active completionShortcut->setContext(Qt::ApplicationShortcut); Core::Command *command = am->registerShortcut(completionShortcut, Constants::COMPLETE_THIS, context); -#ifndef Q_OS_MAC - command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Space"))); -#else - command->setDefaultKeySequence(QKeySequence(tr("Meta+Space"))); -#endif + command->setDefaultKeySequence(QKeySequence(Core::UseMacShortcuts ? tr("Meta+Space") : tr("Ctrl+Space"))); connect(completionShortcut, SIGNAL(activated()), this, SLOT(invokeCompletion())); // Add shortcut for invoking quick fix options -- GitLab