diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d0f6338e3..1fdf0fd76 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -762,7 +762,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Show the shortcuts dialog """ if self.shortcutForm.exec_(): - self.shortcutForm.saveShortcuts() + self.shortcutForm.save() def onModeDefaultItemClicked(self): """ diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 127569f24..15c6c53e5 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -87,10 +87,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.shortcutButton.setChecked(False) def exec_(self): - self.refreshActionList() + self.reloadActionList() return QtGui.QDialog.exec_(self) - def refreshActionList(self): + def reloadActionList(self): self.assingedShortcuts = [] self.treeWidget.clear() for category in actionList.categories: @@ -147,36 +147,23 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): action = item.data(0, QtCore.Qt.UserRole).toPyObject() self.shortcutButton.setEnabled(True) text = u'' - if action is None or column not in [1, 2] or \ - len(action.shortcuts()) == 0: + if action is None or column not in [1, 2]: self.shortcutButton.setEnabled(False) - elif column == 1: + elif column == 1 and len(action.shortcuts()) != 0: text = action.shortcuts()[0].toString() - elif len(action.shortcuts()) == 2: + elif len(action.shortcuts()) == 2 and len(action.shortcuts()) != 0: text = action.shortcuts()[1].toString() self.shortcutButton.setText(text) - def saveShortcuts(self): + def save(self): """ - Save the shortcuts. + Save the shortcuts. **Note**, that we do not have to load the shortcuts, + as they are loaded in :class:`~openlp.core.utils.ActionList`. """ settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') for category in actionList.categories: - break for action in category.actions: - if action.defaultShortcuts != action.shortcuts(): - settings.setValue(action.text(), - QtCore.QVariant(action.shortcuts())) - settings.endGroup() - - def loadShortcuts(self): - """ - Load the shortcuts. - """ - settings = QtCore.QSettings() - settings.beginGroup(u'shortcuts') - for shortcut in settings.allKeys(): - pass - # TODO: Load shortcuts + settings.setValue( + action.objectName(), QtCore.QVariant(action.shortcuts())) settings.endGroup() diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index d94ee1511..6b7df6817 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -27,6 +27,10 @@ The :mod:`~openlp.core.utils.actions` module provides action list classes used by the shortcuts system. """ +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import translate + class ActionCategory(object): """ The :class:`~openlp.core.utils.ActionCategory` class encapsulates a @@ -190,6 +194,14 @@ class ActionList(object): self.categories[category].actions.append(action) else: self.categories[category].actions.add(action, weight) + # Load the shortcut from the config. + settings = QtCore.QSettings() + settings.beginGroup(u'shortcuts') + shortcuts = settings.value(action.objectName(), + QtCore.QVariant(action.shortcuts())).toStringList() + action.setShortcuts( + [QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) + settings.endGroup() def remove_action(self, action, category): if category not in self.categories: