Skip to content
Permalink
Browse files

Merge pull request #6192 from slarosa/fix_shortcut_macos

Fix displaying keyboard shortcut under macos
  • Loading branch information
slarosa committed Feb 13, 2018
2 parents 231dae3 + abeef25 commit 345088c8637e5277e264ab2aa5033e55f250c1d8
@@ -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
@@ -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)
@@ -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)
@@ -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
@@ -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 )
@@ -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 );
}
@@ -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
@@ -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 ) );
}
}
}
@@ -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
@@ -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 ) );
}
}
}

0 comments on commit 345088c

Please sign in to comment.
You can’t perform that action at this time.