"Change some keyboard shortcuts to use predefined platform dependent shortcuts from Qt.

Display keyboard shortcuts with modifiers in their platform native form."

bzr-revno: 2584
This commit is contained in:
springermac@gmail.com 2015-12-28 21:35:15 +02:00 committed by Raoul Snyman
commit 160550f836
4 changed files with 206 additions and 159 deletions

View File

@ -26,7 +26,7 @@ import datetime
import logging
import os
from PyQt5 import QtCore, QtGui
from PyQt5 import QtCore, QtGui, QtWidgets
from openlp.core.common import ThemeLevel, SlideLimits, UiStrings, is_win, is_linux
@ -170,142 +170,6 @@ class Settings(QtCore.QSettings):
'SettingsImport/Make_Changes': 'At_Own_RISK',
'SettingsImport/type': 'OpenLP_settings_export',
'SettingsImport/version': '',
'shortcuts/aboutItem': [QtGui.QKeySequence('Ctrl+F1')],
'shortcuts/addToService': [],
'shortcuts/audioPauseItem': [],
'shortcuts/displayTagItem': [],
'shortcuts/blankScreen': [QtGui.QKeySequence(QtCore.Qt.Key_Period)],
'shortcuts/collapse': [QtGui.QKeySequence(QtCore.Qt.Key_Minus)],
'shortcuts/desktopScreen': [QtGui.QKeySequence('D')],
'shortcuts/delete': [],
'shortcuts/down': [QtGui.QKeySequence(QtCore.Qt.Key_Down)],
'shortcuts/editSong': [],
'shortcuts/escapeItem': [QtGui.QKeySequence(QtCore.Qt.Key_Escape)],
'shortcuts/expand': [QtGui.QKeySequence(QtCore.Qt.Key_Plus)],
'shortcuts/exportThemeItem': [],
'shortcuts/fileNewItem': [QtGui.QKeySequence('Ctrl+N')],
'shortcuts/fileSaveAsItem': [QtGui.QKeySequence('Ctrl+Shift+S')],
'shortcuts/fileExitItem': [QtGui.QKeySequence('Alt+F4')],
'shortcuts/fileSaveItem': [QtGui.QKeySequence('Ctrl+S')],
'shortcuts/fileOpenItem': [QtGui.QKeySequence('Ctrl+O')],
'shortcuts/goLive': [],
'shortcuts/importThemeItem': [],
'shortcuts/importBibleItem': [],
'shortcuts/listViewBiblesDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewBiblesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
'shortcuts/listViewBiblesLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
'shortcuts/listViewBiblesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/listViewCustomDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewCustomPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
'shortcuts/listViewCustomLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
'shortcuts/listViewCustomServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/listViewImagesDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewImagesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
'shortcuts/listViewImagesLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
'shortcuts/listViewImagesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/listViewMediaDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewMediaPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
'shortcuts/listViewMediaLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
'shortcuts/listViewMediaServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/listViewPresentationsDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewPresentationsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
'shortcuts/listViewPresentationsLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
'shortcuts/listViewPresentationsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/listViewSongsDeleteItem': [QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewSongsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.Key_Return)],
'shortcuts/listViewSongsLiveItem': [QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter),
QtGui.QKeySequence(QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return)],
'shortcuts/listViewSongsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/lockPanel': [],
'shortcuts/modeDefaultItem': [],
'shortcuts/modeLiveItem': [],
'shortcuts/make_live': [QtGui.QKeySequence(QtCore.Qt.Key_Enter), QtGui.QKeySequence(QtCore.Qt.Key_Return)],
'shortcuts/moveUp': [QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
'shortcuts/moveTop': [QtGui.QKeySequence(QtCore.Qt.Key_Home)],
'shortcuts/modeSetupItem': [],
'shortcuts/moveBottom': [QtGui.QKeySequence(QtCore.Qt.Key_End)],
'shortcuts/moveDown': [QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
'shortcuts/nextTrackItem': [],
'shortcuts/nextItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Down), QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
'shortcuts/nextItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Down),
QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
'shortcuts/nextService': [QtGui.QKeySequence(QtCore.Qt.Key_Right)],
'shortcuts/newService': [],
'shortcuts/offlineHelpItem': [],
'shortcuts/onlineHelpItem': [QtGui.QKeySequence('Alt+F1')],
'shortcuts/openService': [],
'shortcuts/saveService': [],
'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up), QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
'shortcuts/playbackPause': [],
'shortcuts/playbackPlay': [],
'shortcuts/playbackStop': [],
'shortcuts/playSlidesLoop': [],
'shortcuts/playSlidesOnce': [],
'shortcuts/previousService': [QtGui.QKeySequence(QtCore.Qt.Key_Left)],
'shortcuts/previousItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Up),
QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
'shortcuts/printServiceItem': [QtGui.QKeySequence('Ctrl+P')],
'shortcuts/songExportItem': [],
'shortcuts/songUsageStatus': [QtGui.QKeySequence(QtCore.Qt.Key_F4)],
'shortcuts/searchShortcut': [QtGui.QKeySequence('Ctrl+F')],
'shortcuts/settingsShortcutsItem': [],
'shortcuts/settingsImportItem': [],
'shortcuts/settingsPluginListItem': [QtGui.QKeySequence('Alt+F7')],
'shortcuts/songUsageDelete': [],
'shortcuts/settingsConfigureItem': [],
'shortcuts/shortcutAction_B': [QtGui.QKeySequence('B')],
'shortcuts/shortcutAction_C': [QtGui.QKeySequence('C')],
'shortcuts/shortcutAction_E': [QtGui.QKeySequence('E')],
'shortcuts/shortcutAction_I': [QtGui.QKeySequence('I')],
'shortcuts/shortcutAction_O': [QtGui.QKeySequence('O')],
'shortcuts/shortcutAction_P': [QtGui.QKeySequence('P')],
'shortcuts/shortcutAction_V': [QtGui.QKeySequence('V')],
'shortcuts/shortcutAction_0': [QtGui.QKeySequence('0')],
'shortcuts/shortcutAction_1': [QtGui.QKeySequence('1')],
'shortcuts/shortcutAction_2': [QtGui.QKeySequence('2')],
'shortcuts/shortcutAction_3': [QtGui.QKeySequence('3')],
'shortcuts/shortcutAction_4': [QtGui.QKeySequence('4')],
'shortcuts/shortcutAction_5': [QtGui.QKeySequence('5')],
'shortcuts/shortcutAction_6': [QtGui.QKeySequence('6')],
'shortcuts/shortcutAction_7': [QtGui.QKeySequence('7')],
'shortcuts/shortcutAction_8': [QtGui.QKeySequence('8')],
'shortcuts/shortcutAction_9': [QtGui.QKeySequence('9')],
'shortcuts/settingsExportItem': [],
'shortcuts/songUsageReport': [],
'shortcuts/songImportItem': [],
'shortcuts/themeScreen': [QtGui.QKeySequence('T')],
'shortcuts/toolsReindexItem': [],
'shortcuts/toolsFindDuplicates': [],
'shortcuts/toolsAlertItem': [QtGui.QKeySequence('F7')],
'shortcuts/toolsFirstTimeWizard': [],
'shortcuts/toolsOpenDataFolder': [],
'shortcuts/toolsAddToolItem': [],
'shortcuts/updateThemeImages': [],
'shortcuts/up': [QtGui.QKeySequence(QtCore.Qt.Key_Up)],
'shortcuts/viewProjectorManagerItem': [QtGui.QKeySequence('F6')],
'shortcuts/viewThemeManagerItem': [QtGui.QKeySequence('F10')],
'shortcuts/viewMediaManagerItem': [QtGui.QKeySequence('F8')],
'shortcuts/viewPreviewPanel': [QtGui.QKeySequence('F11')],
'shortcuts/viewLivePanel': [QtGui.QKeySequence('F12')],
'shortcuts/viewServiceManagerItem': [QtGui.QKeySequence('F9')],
'shortcuts/webSiteItem': [],
'themes/global theme': '',
'themes/last directory': '',
'themes/last directory export': '',
@ -379,6 +243,159 @@ class Settings(QtCore.QSettings):
QtCore.QSettings.__init__(self, Settings.__file_path__, Settings.IniFormat)
else:
QtCore.QSettings.__init__(self, *args)
# Add shortcuts here so QKeySequence has a QApplication instance to use.
Settings.__default_settings__.update({
'shortcuts/aboutItem': [QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_F1)],
'shortcuts/addToService': [],
'shortcuts/audioPauseItem': [],
'shortcuts/displayTagItem': [],
'shortcuts/blankScreen': [QtGui.QKeySequence(QtCore.Qt.Key_Period)],
'shortcuts/collapse': [QtGui.QKeySequence(QtCore.Qt.Key_Minus)],
'shortcuts/desktopScreen': [QtGui.QKeySequence(QtCore.Qt.Key_D)],
'shortcuts/delete': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/down': [QtGui.QKeySequence(QtCore.Qt.Key_Down)],
'shortcuts/editSong': [],
'shortcuts/escapeItem': [QtGui.QKeySequence(QtCore.Qt.Key_Escape)],
'shortcuts/expand': [QtGui.QKeySequence(QtCore.Qt.Key_Plus)],
'shortcuts/exportThemeItem': [],
'shortcuts/fileNewItem': [QtGui.QKeySequence(QtGui.QKeySequence.New),
QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_N)],
'shortcuts/fileSaveAsItem': [QtGui.QKeySequence(QtGui.QKeySequence.SaveAs),
QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.SHIFT + QtCore.Qt.Key_S)],
'shortcuts/fileExitItem': [QtGui.QKeySequence(QtGui.QKeySequence.Quit),
QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F4)],
'shortcuts/fileSaveItem': [QtGui.QKeySequence(QtGui.QKeySequence.Save),
QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_S)],
'shortcuts/fileOpenItem': [QtGui.QKeySequence(QtGui.QKeySequence.Open),
QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_O)],
'shortcuts/goLive': [],
'shortcuts/importThemeItem': [],
'shortcuts/importBibleItem': [],
'shortcuts/listViewBiblesDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete),
QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewBiblesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.Key_Enter)],
'shortcuts/listViewBiblesLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)],
'shortcuts/listViewBiblesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/listViewCustomDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete),
QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewCustomPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.Key_Enter)],
'shortcuts/listViewCustomLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)],
'shortcuts/listViewCustomServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/listViewImagesDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete),
QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewImagesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.Key_Enter)],
'shortcuts/listViewImagesLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)],
'shortcuts/listViewImagesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/listViewMediaDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete),
QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewMediaPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.Key_Enter)],
'shortcuts/listViewMediaLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)],
'shortcuts/listViewMediaServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/listViewPresentationsDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete),
QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewPresentationsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.Key_Enter)],
'shortcuts/listViewPresentationsLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)],
'shortcuts/listViewPresentationsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/listViewSongsDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete),
QtGui.QKeySequence(QtCore.Qt.Key_Delete)],
'shortcuts/listViewSongsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.Key_Enter)],
'shortcuts/listViewSongsLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return),
QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)],
'shortcuts/listViewSongsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus),
QtGui.QKeySequence(QtCore.Qt.Key_Equal)],
'shortcuts/lockPanel': [],
'shortcuts/modeDefaultItem': [],
'shortcuts/modeLiveItem': [],
'shortcuts/make_live': [QtGui.QKeySequence(QtCore.Qt.Key_Return), QtGui.QKeySequence(QtCore.Qt.Key_Enter)],
'shortcuts/moveUp': [QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
'shortcuts/moveTop': [QtGui.QKeySequence(QtCore.Qt.Key_Home)],
'shortcuts/modeSetupItem': [],
'shortcuts/moveBottom': [QtGui.QKeySequence(QtCore.Qt.Key_End)],
'shortcuts/moveDown': [QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
'shortcuts/nextTrackItem': [],
'shortcuts/nextItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Down), QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
'shortcuts/nextItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Down),
QtGui.QKeySequence(QtCore.Qt.Key_PageDown)],
'shortcuts/nextService': [QtGui.QKeySequence(QtCore.Qt.Key_Right)],
'shortcuts/newService': [],
'shortcuts/offlineHelpItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents)],
'shortcuts/onlineHelpItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents),
QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F1)],
'shortcuts/openService': [],
'shortcuts/saveService': [],
'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up), QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
'shortcuts/playbackPause': [],
'shortcuts/playbackPlay': [],
'shortcuts/playbackStop': [],
'shortcuts/playSlidesLoop': [],
'shortcuts/playSlidesOnce': [],
'shortcuts/previousService': [QtGui.QKeySequence(QtCore.Qt.Key_Left)],
'shortcuts/previousItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Up),
QtGui.QKeySequence(QtCore.Qt.Key_PageUp)],
'shortcuts/printServiceItem': [QtGui.QKeySequence(QtGui.QKeySequence.Print),
QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_P)],
'shortcuts/songExportItem': [],
'shortcuts/songUsageStatus': [QtGui.QKeySequence(QtCore.Qt.Key_F4)],
'shortcuts/searchShortcut': [QtGui.QKeySequence(QtGui.QKeySequence.Find),
QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_F)],
'shortcuts/settingsShortcutsItem': [],
'shortcuts/settingsImportItem': [],
'shortcuts/settingsPluginListItem': [QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F7)],
'shortcuts/songUsageDelete': [],
'shortcuts/settingsConfigureItem': [QtGui.QKeySequence(QtGui.QKeySequence.Preferences)],
'shortcuts/shortcutAction_B': [QtGui.QKeySequence(QtCore.Qt.Key_B)],
'shortcuts/shortcutAction_C': [QtGui.QKeySequence(QtCore.Qt.Key_C)],
'shortcuts/shortcutAction_E': [QtGui.QKeySequence(QtCore.Qt.Key_E)],
'shortcuts/shortcutAction_I': [QtGui.QKeySequence(QtCore.Qt.Key_I)],
'shortcuts/shortcutAction_O': [QtGui.QKeySequence(QtCore.Qt.Key_O)],
'shortcuts/shortcutAction_P': [QtGui.QKeySequence(QtCore.Qt.Key_P)],
'shortcuts/shortcutAction_V': [QtGui.QKeySequence(QtCore.Qt.Key_V)],
'shortcuts/shortcutAction_0': [QtGui.QKeySequence(QtCore.Qt.Key_0)],
'shortcuts/shortcutAction_1': [QtGui.QKeySequence(QtCore.Qt.Key_1)],
'shortcuts/shortcutAction_2': [QtGui.QKeySequence(QtCore.Qt.Key_2)],
'shortcuts/shortcutAction_3': [QtGui.QKeySequence(QtCore.Qt.Key_3)],
'shortcuts/shortcutAction_4': [QtGui.QKeySequence(QtCore.Qt.Key_4)],
'shortcuts/shortcutAction_5': [QtGui.QKeySequence(QtCore.Qt.Key_5)],
'shortcuts/shortcutAction_6': [QtGui.QKeySequence(QtCore.Qt.Key_6)],
'shortcuts/shortcutAction_7': [QtGui.QKeySequence(QtCore.Qt.Key_7)],
'shortcuts/shortcutAction_8': [QtGui.QKeySequence(QtCore.Qt.Key_8)],
'shortcuts/shortcutAction_9': [QtGui.QKeySequence(QtCore.Qt.Key_9)],
'shortcuts/settingsExportItem': [],
'shortcuts/songUsageReport': [],
'shortcuts/songImportItem': [],
'shortcuts/themeScreen': [QtGui.QKeySequence(QtCore.Qt.Key_T)],
'shortcuts/toolsReindexItem': [],
'shortcuts/toolsFindDuplicates': [],
'shortcuts/toolsAlertItem': [QtGui.QKeySequence(QtCore.Qt.Key_F7)],
'shortcuts/toolsFirstTimeWizard': [],
'shortcuts/toolsOpenDataFolder': [],
'shortcuts/toolsAddToolItem': [],
'shortcuts/updateThemeImages': [],
'shortcuts/up': [QtGui.QKeySequence(QtCore.Qt.Key_Up)],
'shortcuts/viewProjectorManagerItem': [QtGui.QKeySequence(QtCore.Qt.Key_F6)],
'shortcuts/viewThemeManagerItem': [QtGui.QKeySequence(QtCore.Qt.Key_F10)],
'shortcuts/viewMediaManagerItem': [QtGui.QKeySequence(QtCore.Qt.Key_F8)],
'shortcuts/viewPreviewPanel': [QtGui.QKeySequence(QtCore.Qt.Key_F11)],
'shortcuts/viewLivePanel': [QtGui.QKeySequence(QtCore.Qt.Key_F12)],
'shortcuts/viewServiceManagerItem': [QtGui.QKeySequence(QtCore.Qt.Key_F9)],
'shortcuts/webSiteItem': []
})
def get_default_value(self, key):
"""

View File

@ -50,6 +50,19 @@ class CaptureShortcutButton(QtWidgets.QPushButton):
event.ignore()
class ShortcutTreeWidget(QtWidgets.QTreeWidget):
def __init__(self, *args):
super(ShortcutTreeWidget, self).__init__(*args)
def keyboardSearch(self, search):
"""
Ignore searches to prevent single letter searches from highlighting items.
:param search: Search string
"""
pass
class Ui_ShortcutListDialog(object):
"""
The UI widgets for the shortcut dialog.
@ -67,7 +80,7 @@ class Ui_ShortcutListDialog(object):
self.description_label.setObjectName('description_label')
self.description_label.setWordWrap(True)
self.shortcut_list_layout.addWidget(self.description_label)
self.tree_widget = QtWidgets.QTreeWidget(shortcutListDialog)
self.tree_widget = ShortcutTreeWidget(shortcutListDialog)
self.tree_widget.setObjectName('tree_widget')
self.tree_widget.setAlternatingRowColors(True)
self.tree_widget.setColumnCount(3)

View File

@ -96,9 +96,11 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert
key_sequence = QtGui.QKeySequence(key_string)
if self._validiate_shortcut(self._current_item_action(), key_sequence):
if self.primary_push_button.isChecked():
self._adjust_button(self.primary_push_button, False, text=key_sequence.toString())
self._adjust_button(self.primary_push_button, False,
text=self.get_shortcut_string(key_sequence, for_display=True))
elif self.alternate_push_button.isChecked():
self._adjust_button(self.alternate_push_button, False, text=key_sequence.toString())
self._adjust_button(self.alternate_push_button, False,
text=self.get_shortcut_string(key_sequence, for_display=True))
def exec(self):
"""
@ -154,11 +156,11 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert
item.setText(1, '')
item.setText(2, '')
elif len(shortcuts) == 1:
item.setText(1, shortcuts[0].toString())
item.setText(1, self.get_shortcut_string(shortcuts[0], for_display=True))
item.setText(2, '')
else:
item.setText(1, shortcuts[0].toString())
item.setText(2, shortcuts[1].toString())
item.setText(1, self.get_shortcut_string(shortcuts[0], for_display=True))
item.setText(2, self.get_shortcut_string(shortcuts[1], for_display=True))
self.on_current_item_changed()
def on_primary_push_button_clicked(self, toggled):
@ -238,9 +240,9 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert
self.alternate_push_button.setChecked(False)
else:
if action.default_shortcuts:
primary_label_text = action.default_shortcuts[0].toString()
primary_label_text = self.get_shortcut_string(action.default_shortcuts[0], for_display=True)
if len(action.default_shortcuts) == 2:
alternate_label_text = action.default_shortcuts[1].toString()
alternate_label_text = self.get_shortcut_string(action.default_shortcuts[1], for_display=True)
shortcuts = self._action_shortcuts(action)
# We do not want to loose pending changes, that is why we have to keep the text when, this function has not
# been triggered by a signal.
@ -248,10 +250,10 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert
primary_text = self.primary_push_button.text()
alternate_text = self.alternate_push_button.text()
elif len(shortcuts) == 1:
primary_text = shortcuts[0].toString()
primary_text = self.get_shortcut_string(shortcuts[0], for_display=True)
elif len(shortcuts) == 2:
primary_text = shortcuts[0].toString()
alternate_text = shortcuts[1].toString()
primary_text = self.get_shortcut_string(shortcuts[0], for_display=True)
alternate_text = self.get_shortcut_string(shortcuts[1], for_display=True)
# When we are capturing a new shortcut, we do not want, the buttons to display the current shortcut.
if self.primary_push_button.isChecked():
primary_text = ''
@ -305,9 +307,9 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert
primary_button_text = ''
alternate_button_text = ''
if temp_shortcuts:
primary_button_text = temp_shortcuts[0].toString()
primary_button_text = self.get_shortcut_string(temp_shortcuts[0], for_display=True)
if len(temp_shortcuts) == 2:
alternate_button_text = temp_shortcuts[1].toString()
alternate_button_text = self.get_shortcut_string(temp_shortcuts[1], for_display=True)
self.primary_push_button.setText(primary_button_text)
self.alternate_push_button.setText(alternate_button_text)
@ -335,7 +337,7 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert
continue
for action in category.actions:
if action in self.changed_actions:
old_shortcuts = list(map(QtGui.QKeySequence.toString, action.shortcuts()))
old_shortcuts = list(map(self.get_shortcut_string, action.shortcuts()))
action.setShortcuts(self.changed_actions[action])
self.action_list.update_shortcut_map(action, old_shortcuts)
settings.setValue(action.objectName(), action.shortcuts())
@ -418,14 +420,15 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert
self.main_window.warning_message(translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'),
translate('OpenLP.ShortcutListDialog',
'The shortcut "%s" is already assigned to another action, please'
' use a different shortcut.') % key_sequence.toString())
' use a different shortcut.') %
self.get_shortcut_string(key_sequence, for_display=True))
self.dialog_was_shown = True
return is_valid
def _action_shortcuts(self, action):
"""
This returns the shortcuts for the given ``action``, which also includes those shortcuts which are not saved
yet but already assigned (as changes yre applied when closing the dialog).
yet but already assigned (as changes are applied when closing the dialog).
"""
if action in self.changed_actions:
return self.changed_actions[action]
@ -453,3 +456,14 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert
button.setChecked(checked)
if enabled is not None:
button.setEnabled(enabled)
@staticmethod
def get_shortcut_string(shortcut, for_display=False):
if for_display:
if any(modifier in shortcut.toString() for modifier in ['Ctrl', 'Alt', 'Meta', 'Shift']):
sequence_format = QtGui.QKeySequence.NativeText
else:
sequence_format = QtGui.QKeySequence.PortableText
else:
sequence_format = QtGui.QKeySequence.PortableText
return shortcut.toString(sequence_format)

View File

@ -163,8 +163,9 @@ class TestActionList(TestCase, TestMixin):
action_with_same_shortcuts1.setObjectName('action_with_same_shortcuts1')
# Add default shortcuts to Settings class.
default_shortcuts = {
'shortcuts/action1': [QtGui.QKeySequence('a'), QtGui.QKeySequence('b')],
'shortcuts/action_with_same_shortcuts1': [QtGui.QKeySequence('b'), QtGui.QKeySequence('a')]
'shortcuts/action1': [QtGui.QKeySequence(QtCore.Qt.Key_A), QtGui.QKeySequence(QtCore.Qt.Key_B)],
'shortcuts/action_with_same_shortcuts1': [QtGui.QKeySequence(QtCore.Qt.Key_B),
QtGui.QKeySequence(QtCore.Qt.Key_A)]
}
Settings.extend_default_settings(default_shortcuts)
@ -193,8 +194,9 @@ class TestActionList(TestCase, TestMixin):
action_with_same_shortcuts2.setObjectName('action_with_same_shortcuts2')
# Add default shortcuts to Settings class.
default_shortcuts = {
'shortcuts/action2': [QtGui.QKeySequence('c'), QtGui.QKeySequence('d')],
'shortcuts/action_with_same_shortcuts2': [QtGui.QKeySequence('d'), QtGui.QKeySequence('c')]
'shortcuts/action2': [QtGui.QKeySequence(QtCore.Qt.Key_C), QtGui.QKeySequence(QtCore.Qt.Key_D)],
'shortcuts/action_with_same_shortcuts2': [QtGui.QKeySequence(QtCore.Qt.Key_D),
QtGui.QKeySequence(QtCore.Qt.Key_C)]
}
Settings.extend_default_settings(default_shortcuts)
@ -225,8 +227,9 @@ class TestActionList(TestCase, TestMixin):
action_with_same_shortcuts3.setShortcutContext(QtCore.Qt.WidgetShortcut)
# Add default shortcuts to Settings class.
default_shortcuts = {
'shortcuts/action3': [QtGui.QKeySequence('e'), QtGui.QKeySequence('f')],
'shortcuts/action_with_same_shortcuts3': [QtGui.QKeySequence('e'), QtGui.QKeySequence('f')]
'shortcuts/action3': [QtGui.QKeySequence(QtCore.Qt.Key_E), QtGui.QKeySequence(QtCore.Qt.Key_F)],
'shortcuts/action_with_same_shortcuts3': [QtGui.QKeySequence(QtCore.Qt.Key_E),
QtGui.QKeySequence(QtCore.Qt.Key_F)]
}
Settings.extend_default_settings(default_shortcuts)