forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()));
|
||||
|
||||
|
||||
@@ -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()));
|
||||
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()));
|
||||
// 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
|
||||
// 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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user