diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 467fb0534..5f8936628 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -58,7 +58,7 @@ class Ui_ShortcutListDialog(object): self.dialogLayout.addLayout(self.customLayout) self.buttonBox = QtGui.QDialogButtonBox(shortcutListDialog) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Reset) + QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.RestoreDefaults) self.buttonBox.setObjectName(u'buttonBox') self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(shortcutListDialog) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index bd4fb8ab6..14aa1d009 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -41,7 +41,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ The shortcut list dialog """ -#TODO: do not close on ESC + def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) @@ -58,6 +58,16 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.onItemDoubleClicked) QtCore.QObject.connect(self.clearShortcutButton, QtCore.SIGNAL(u'clicked(bool)'), self.onClearShortcutButtonClicked) + QtCore.QObject.connect(self.buttonBox, + QtCore.SIGNAL(u'clicked(QAbstractButton*)'), + self.onRestoreDefaultsClicked) + + def keyPressEvent(self, event): + if self.shortcutButton.isChecked(): + event.ignore() + elif event.key() == QtCore.Qt.Key_Escape: + event.accept() + self.close() def keyReleaseEvent(self, event): Qt = QtCore.Qt @@ -229,6 +239,26 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.refreshShortcutList() self.onItemPressed(item, self.column) + def onRestoreDefaultsClicked(self, button): + """ + Restores all default shortcuts. + """ + if self.buttonBox.buttonRole(button) != QtGui.QDialogButtonBox.ResetRole: + return + if QtGui.QMessageBox.question(self, + translate('OpenLP.ShortcutListDialog', 'Restore Default Shortcuts'), + translate('OpenLP.ShortcutListDialog', 'Do you want to restore all ' + 'shortcuts to their defaults?'), QtGui.QMessageBox.StandardButtons( + QtGui.QMessageBox.Yes | + QtGui.QMessageBox.No)) == QtGui.QMessageBox.No: + return + self.shortcutButton.setChecked(False) + self.shortcutButton.setText(u'') + for category in ActionList.categories: + for action in category.actions: + action.setShortcuts(action.defaultShortcuts) + self.refreshShortcutList() + def save(self): """ Save the shortcuts. **Note**, that we do not have to load the shortcuts, diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 9f486518b..1ec2e1772 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -141,19 +141,18 @@ class SlideController(QtGui.QWidget): translate('OpenLP.SlideController', 'Previous Slide'), u':/slides/slide_previous.png', translate('OpenLP.SlideController', 'Move to previous'), - self.onSlideSelectedPrevious) - self.previousItem.setObjectName(u'previousItem') - self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp]) - self.previousItem.setShortcutContext( - QtCore.Qt.WidgetWithChildrenShortcut) + self.onSlideSelectedPrevious, + shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.previousItem.setObjectName(u'previousItem') self.nextItem = self.toolbar.addToolbarButton( translate('OpenLP.SlideController', 'Next Slide'), u':/slides/slide_next.png', translate('OpenLP.SlideController', 'Move to next'), - self.onSlideSelectedNext) + self.onSlideSelectedNext, + shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], + context=QtCore.Qt.WidgetWithChildrenShortcut) self.nextItem.setObjectName(u'nextItem') - self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown]) - self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.toolbar.addToolbarSeparator(u'Close Separator') if self.isLive: self.hideMenu = QtGui.QToolButton(self.toolbar)