Changeset View
Changeset View
Standalone View
Standalone View
plugins/documentswitcher/documentswitcherplugin.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
54 | DocumentSwitcherPlugin::DocumentSwitcherPlugin(QObject *parent, const QVariantList &/*args*/) | 54 | DocumentSwitcherPlugin::DocumentSwitcherPlugin(QObject *parent, const QVariantList &/*args*/) | ||
55 | :KDevelop::IPlugin(QStringLiteral("kdevdocumentswitcher"), parent), view(nullptr) | 55 | :KDevelop::IPlugin(QStringLiteral("kdevdocumentswitcher"), parent), view(nullptr) | ||
56 | { | 56 | { | ||
57 | setXMLFile(QStringLiteral("kdevdocumentswitcher.rc")); | 57 | setXMLFile(QStringLiteral("kdevdocumentswitcher.rc")); | ||
58 | qCDebug(PLUGIN_DOCUMENTSWITCHER) << "Adding active mainwindow from constructor" << KDevelop::ICore::self()->uiController()->activeMainWindow(); | 58 | qCDebug(PLUGIN_DOCUMENTSWITCHER) << "Adding active mainwindow from constructor" << KDevelop::ICore::self()->uiController()->activeMainWindow(); | ||
59 | addMainWindow( qobject_cast<Sublime::MainWindow*>( KDevelop::ICore::self()->uiController()->activeMainWindow() ) ); | 59 | addMainWindow( qobject_cast<Sublime::MainWindow*>( KDevelop::ICore::self()->uiController()->activeMainWindow() ) ); | ||
60 | connect( KDevelop::ICore::self()->uiController()->controller(), &Sublime::Controller::mainWindowAdded, this, &DocumentSwitcherPlugin::addMainWindow ); | 60 | connect( KDevelop::ICore::self()->uiController()->controller(), &Sublime::Controller::mainWindowAdded, this, &DocumentSwitcherPlugin::addMainWindow ); | ||
61 | 61 | | |||
62 | #ifdef Q_OS_MACOS | ||||
63 | // Qt/Mac swaps the Ctrl and Meta (Command) keys by default, so that shortcuts defined as Ctrl+X | ||||
64 | // become the platform-standard Command+X . Ideally we would map the document switcher shortcut to | ||||
65 | // Control+Tab (and thus Qt::META+Qt::Key_Tab) everywhere because Command+Tab and Command+Shift+Tab | ||||
66 | // are reserved system shortcuts that bring up the application switcher. The Control+Tab shortcut is | ||||
67 | // inoperable on Mac, so we resort to the Alt (Option) key, unless the AA_MacDontSwapCtrlAndMeta | ||||
68 | // attribute is set. | ||||
69 | const Qt::Modifier shortcutAccelerator = QCoreApplication::testAttribute(Qt::AA_MacDontSwapCtrlAndMeta) ? Qt::CTRL : Qt::ALT; | ||||
kossebau: Make both shortcutAccelerator const. | |||||
70 | #else | ||||
71 | const Qt::Modifier shortcutAccelerator = Qt::CTRL; | ||||
72 | #endif | ||||
73 | | ||||
62 | forwardAction = actionCollection()->addAction ( QStringLiteral( "last_used_views_forward" ) ); | 74 | forwardAction = actionCollection()->addAction ( QStringLiteral( "last_used_views_forward" ) ); | ||
63 | forwardAction->setText( i18n( "Last Used Views" ) ); | 75 | forwardAction->setText( i18n( "Last Used Views" ) ); | ||
64 | forwardAction->setIcon( QIcon::fromTheme( QStringLiteral( "go-next-view-page") ) ); | 76 | forwardAction->setIcon( QIcon::fromTheme( QStringLiteral( "go-next-view-page") ) ); | ||
65 | actionCollection()->setDefaultShortcut( forwardAction, Qt::CTRL | Qt::Key_Tab ); | 77 | actionCollection()->setDefaultShortcut( forwardAction, shortcutAccelerator | Qt::Key_Tab ); | ||
66 | forwardAction->setWhatsThis( i18n( "Opens a list to walk through the list of last used views." ) ); | 78 | forwardAction->setWhatsThis( i18n( "Opens a list to walk through the list of last used views." ) ); | ||
67 | forwardAction->setStatusTip( i18n( "Walk through the list of last used views" ) ); | 79 | forwardAction->setStatusTip( i18n( "Walk through the list of last used views" ) ); | ||
68 | connect( forwardAction, &QAction::triggered, this, &DocumentSwitcherPlugin::walkForward ); | 80 | connect( forwardAction, &QAction::triggered, this, &DocumentSwitcherPlugin::walkForward ); | ||
69 | 81 | | |||
70 | backwardAction = actionCollection()->addAction ( QStringLiteral( "last_used_views_backward" ) ); | 82 | backwardAction = actionCollection()->addAction ( QStringLiteral( "last_used_views_backward" ) ); | ||
71 | backwardAction->setText( i18n( "Last Used Views (Reverse)" ) ); | 83 | backwardAction->setText( i18n( "Last Used Views (Reverse)" ) ); | ||
72 | backwardAction->setIcon( QIcon::fromTheme( QStringLiteral( "go-previous-view-page") ) ); | 84 | backwardAction->setIcon( QIcon::fromTheme( QStringLiteral( "go-previous-view-page") ) ); | ||
73 | actionCollection()->setDefaultShortcut( backwardAction, Qt::CTRL | Qt::SHIFT | Qt::Key_Tab ); | 85 | actionCollection()->setDefaultShortcut( backwardAction, shortcutAccelerator | Qt::SHIFT | Qt::Key_Tab ); | ||
74 | backwardAction->setWhatsThis( i18n( "Opens a list to walk through the list of last used views in reverse." ) ); | 86 | backwardAction->setWhatsThis( i18n( "Opens a list to walk through the list of last used views in reverse." ) ); | ||
75 | backwardAction->setStatusTip( i18n( "Walk through the list of last used views" ) ); | 87 | backwardAction->setStatusTip( i18n( "Walk through the list of last used views" ) ); | ||
76 | connect( backwardAction, &QAction::triggered, this, &DocumentSwitcherPlugin::walkBackward ); | 88 | connect( backwardAction, &QAction::triggered, this, &DocumentSwitcherPlugin::walkBackward ); | ||
77 | 89 | | |||
78 | view = new DocumentSwitcherTreeView( this ); | 90 | view = new DocumentSwitcherTreeView( this ); | ||
79 | view->setSelectionBehavior( QAbstractItemView::SelectRows ); | 91 | view->setSelectionBehavior( QAbstractItemView::SelectRows ); | ||
80 | view->setSelectionMode( QAbstractItemView::SingleSelection ); | 92 | view->setSelectionMode( QAbstractItemView::SingleSelection ); | ||
81 | view->setUniformRowHeights( true ); | 93 | view->setUniformRowHeights( true ); | ||
▲ Show 20 Lines • Show All 315 Lines • Show Last 20 Lines |
Make both shortcutAccelerator const.