Skip to content

Commit

Permalink
Merge pull request #6192 from slarosa/fix_shortcut_macos
Browse files Browse the repository at this point in the history
Fix displaying keyboard shortcut under macos
  • Loading branch information
slarosa committed Feb 13, 2018
2 parents 231dae3 + abeef25 commit 345088c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
15 changes: 10 additions & 5 deletions python/plugins/processing/ProcessingPlugin.py
Expand Up @@ -40,7 +40,7 @@
QgsCustomDropHandler)
from qgis.PyQt.QtCore import Qt, QCoreApplication, QDir, QFileInfo
from qgis.PyQt.QtWidgets import QMenu, QAction
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtGui import QIcon, QKeySequence

from processing.core.Processing import Processing
from processing.gui.AlgorithmDialog import AlgorithmDialog
Expand Down Expand Up @@ -189,7 +189,8 @@ def initGui(self):
self.toolboxAction.setObjectName('toolboxAction')
self.toolboxAction.setIcon(
QgsApplication.getThemeIcon("/processingAlgorithm.svg"))
self.iface.registerMainWindowAction(self.toolboxAction, 'Ctrl+Alt+T')
self.iface.registerMainWindowAction(self.toolboxAction,
QKeySequence('Ctrl+Alt+T').toString(QKeySequence.NativeText))
self.toolboxAction.toggled.connect(self.openToolbox)
self.iface.attributesToolBar().insertAction(self.iface.actionOpenStatisticalSummary(), self.toolboxAction)
self.menu.addAction(self.toolboxAction)
Expand All @@ -199,23 +200,27 @@ def initGui(self):
self.tr('Graphical &Modeler...'), self.iface.mainWindow())
self.modelerAction.setObjectName('modelerAction')
self.modelerAction.triggered.connect(self.openModeler)
self.iface.registerMainWindowAction(self.modelerAction, 'Ctrl+Alt+M')
self.iface.registerMainWindowAction(self.modelerAction,
QKeySequence('Ctrl+Alt+M').toString(QKeySequence.NativeText))
self.menu.addAction(self.modelerAction)

self.historyAction = QAction(
QIcon(os.path.join(pluginPath, 'images', 'history.svg')),
self.tr('&History...'), self.iface.mainWindow())
self.historyAction.setObjectName('historyAction')
self.historyAction.triggered.connect(self.openHistory)
self.iface.registerMainWindowAction(self.historyAction, 'Ctrl+Alt+H')
self.iface.registerMainWindowAction(self.historyAction,
QKeySequence('Ctrl+Alt+H').toString(QKeySequence.NativeText))
self.menu.addAction(self.historyAction)
self.toolbox.processingToolbar.addAction(self.historyAction)

self.resultsAction = QAction(
QgsApplication.getThemeIcon("/processingResult.svg"),
self.tr('&Results Viewer'), self.iface.mainWindow())
self.resultsAction.setCheckable(True)
self.iface.registerMainWindowAction(self.resultsAction, 'Ctrl+Alt+R')
self.iface.registerMainWindowAction(self.resultsAction,
QKeySequence('Ctrl+Alt+R').toString(QKeySequence.NativeText))

self.menu.addAction(self.resultsAction)
self.toolbox.processingToolbar.addAction(self.resultsAction)
self.resultsDock.visibilityChanged.connect(self.resultsAction.setChecked)
Expand Down
10 changes: 5 additions & 5 deletions src/gui/qgsconfigureshortcutsdialog.cpp
Expand Up @@ -69,13 +69,13 @@ void QgsConfigureShortcutsDialog::populateActions()
{
actionText = action->text();
actionText.remove( '&' ); // remove the accelerator
sequence = action->shortcut().toString();
sequence = action->shortcut().toString( QKeySequence::NativeText );
icon = action->icon();
}
else if ( QShortcut *shortcut = qobject_cast< QShortcut * >( obj ) )
{
actionText = shortcut->whatsThis();
sequence = shortcut->key().toString();
sequence = shortcut->key().toString( QKeySequence::NativeText );
icon = shortcut->property( "Icon" ).value<QIcon>();
}
else
Expand Down Expand Up @@ -391,7 +391,7 @@ void QgsConfigureShortcutsDialog::updateShortcutText()
{
// update text of the button so that user can see what has typed already
QKeySequence s( mModifiers + mKey );
btnChangeShortcut->setText( tr( "Input: " ) + s.toString() );
btnChangeShortcut->setText( tr( "Input: " ) + s.toString( QKeySequence::NativeText ) );
}

void QgsConfigureShortcutsDialog::setGettingShortcut( bool getting )
Expand Down Expand Up @@ -449,10 +449,10 @@ void QgsConfigureShortcutsDialog::setCurrentActionShortcut( const QKeySequence &
}

// update manager
mManager->setObjectKeySequence( object, s.toString() );
mManager->setObjectKeySequence( object, s.toString( QKeySequence::NativeText ) );

// update gui
treeActions->currentItem()->setText( 1, s.toString() );
treeActions->currentItem()->setText( 1, s.toString( QKeySequence::NativeText ) );

actionChanged( treeActions->currentItem(), nullptr );
}
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsshortcutsmanager.cpp
Expand Up @@ -38,7 +38,7 @@ void QgsShortcutsManager::registerAllChildActions( QObject *object, bool recursi
QList< QAction * > actions = object->findChildren< QAction * >();
Q_FOREACH ( QAction *a, actions )
{
registerAction( a, a->shortcut().toString() );
registerAction( a, a->shortcut().toString( QKeySequence::NativeText ) );
}
}
else
Expand All @@ -47,7 +47,7 @@ void QgsShortcutsManager::registerAllChildActions( QObject *object, bool recursi
{
if ( QAction *a = qobject_cast<QAction *>( child ) )
{
registerAction( a, a->shortcut().toString() );
registerAction( a, a->shortcut().toString( QKeySequence::NativeText ) );
}
}
}
Expand All @@ -60,7 +60,7 @@ void QgsShortcutsManager::registerAllChildShortcuts( QObject *object, bool recur
QList< QShortcut * > shortcuts = object->findChildren< QShortcut * >();
Q_FOREACH ( QShortcut *s, shortcuts )
{
registerShortcut( s, s->key().toString() );
registerShortcut( s, s->key().toString( QKeySequence::NativeText ) );
}
}
else
Expand All @@ -69,7 +69,7 @@ void QgsShortcutsManager::registerAllChildShortcuts( QObject *object, bool recur
{
if ( QShortcut *s = qobject_cast<QShortcut *>( child ) )
{
registerShortcut( s, s->key().toString() );
registerShortcut( s, s->key().toString( QKeySequence::NativeText ) );
}
}
}
Expand Down

0 comments on commit 345088c

Please sign in to comment.