← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~crichter/openlp/shortcut-dialog into lp:openlp

 

rimach has proposed merging lp:~crichter/openlp/shortcut-dialog into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


Hello,
may you could have a look into this branch, although I know there are a lot of open issues.
But I want to know if these changes are on a good way?

What work:
- use actions for define of shortcuts
- Live View Shortcuts (Down/Up and PgDown/PgUp as Alternate, Left/Right for Service Control)
- Preview View Shortcuts (Down/Up)
- Double Click at shortcut Listview catch the next key Event and replace the related shortcut
- Sorting of Actions

Not yet implemented:
- save/read changed shortcuts (xml file)
- set correct category for other actions

Open Issues:
- Code not clean and may could simplified


Other question:
http://bazaar.launchpad.net/%7Eopenlp-core/openlp/trunk/annotate/head%3A/openlp/core/ui/slidecontroller.py#L81
Is it correct to define: isLive=False
here?


-- 
https://code.launchpad.net/~crichter/openlp/shortcut-dialog/+merge/43137
Your team OpenLP Core is requested to review the proposed merge of lp:~crichter/openlp/shortcut-dialog into lp:openlp.
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2010-12-06 19:25:44 +0000
+++ openlp/core/ui/maindisplay.py	2010-12-08 21:16:26 +0000
@@ -50,45 +50,46 @@
         QtGui.QGraphicsView.__init__(self)
         self.parent = parent
         self.live = live
-        self.hotkey_map = {
-            QtCore.Qt.Key_Return: 'servicemanager_next_item',
-            QtCore.Qt.Key_Space: 'slidecontroller_live_next_noloop',
-            QtCore.Qt.Key_Enter: 'slidecontroller_live_next_noloop',
-            QtCore.Qt.Key_0: 'servicemanager_next_item',
-            QtCore.Qt.Key_Backspace: 'slidecontroller_live_previous_noloop'}
-        self.setStyleSheet(u'border: none;')
 
-    def keyPressEvent(self, event):
-        """
-        Handle key events from display screen
-        """
-        # Key events only needed for live
-        if not self.live:
-            return
-        if isinstance(event, QtGui.QKeyEvent):
-            # Here accept the event and do something
-            if event.key() == QtCore.Qt.Key_Up:
-                Receiver.send_message(u'slidecontroller_live_previous')
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_Down:
-                Receiver.send_message(u'slidecontroller_live_next')
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_PageUp:
-                Receiver.send_message(u'slidecontroller_live_first')
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_PageDown:
-                Receiver.send_message(u'slidecontroller_live_last')
-                event.accept()
-            elif event.key() in self.hotkey_map:
-                Receiver.send_message(self.hotkey_map[event.key()])
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_Escape:
-                self.setVisible(False)
-                self.videoStop()
-                event.accept()
-            event.ignore()
-        else:
-            event.ignore()
+#        self.hotkey_map = {
+#            QtCore.Qt.Key_Return: 'servicemanager_next_item',
+#            QtCore.Qt.Key_Space: 'slidecontroller_live_next_noloop',
+#            QtCore.Qt.Key_Enter: 'slidecontroller_live_next_noloop',
+#            QtCore.Qt.Key_0: 'servicemanager_next_item',
+#            QtCore.Qt.Key_Backspace: 'slidecontroller_live_previous_noloop'}
+#        self.setStyleSheet(u'border: none;')
+#
+#    def keyPressEvent(self, event):
+#        """
+#        Handle key events from display screen
+#        """
+#        # Key events only needed for live
+#        if not self.live:
+#            return
+#        if isinstance(event, QtGui.QKeyEvent):
+#            # Here accept the event and do something
+#            if event.key() == QtCore.Qt.Key_Up:
+#                Receiver.send_message(u'slidecontroller_live_previous')
+#                event.accept()
+#            elif event.key() == QtCore.Qt.Key_Down:
+#                Receiver.send_message(u'slidecontroller_live_next')
+#                event.accept()
+#            elif event.key() == QtCore.Qt.Key_PageUp:
+#                Receiver.send_message(u'slidecontroller_live_first')
+#                event.accept()
+#            elif event.key() == QtCore.Qt.Key_PageDown:
+#                Receiver.send_message(u'slidecontroller_live_last')
+#                event.accept()
+#            elif event.key() in self.hotkey_map:
+#                Receiver.send_message(self.hotkey_map[event.key()])
+#                event.accept()
+#            elif event.key() == QtCore.Qt.Key_Escape:
+#                self.setVisible(False)
+#                self.videoStop()
+#                event.accept()
+#            event.ignore()
+#        else:
+#            event.ignore()
 
 class MainDisplay(DisplayWidget):
     """
@@ -111,6 +112,12 @@
                 QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay)
             QtCore.QObject.connect(Receiver.get_receiver(),
                 QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay)
+#        if  self.live:
+#            self.addAction(self.parent.next_item)
+#            self.addAction(self.parent.previous_item)
+#            self.addAction(self.parent.previous_service)
+#            self.addAction(self.parent.next_service)
+#            self.addAction(self.parent.escape_item)
 
     def setup(self):
         """

=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2010-12-02 14:37:38 +0000
+++ openlp/core/ui/mainwindow.py	2010-12-08 21:16:26 +0000
@@ -671,7 +671,7 @@
             if savedPlugin != -1:
                 self.MediaToolBox.setCurrentIndex(savedPlugin)
         self.settingsForm.postSetUp()
-
+        
     def setAutoLanguage(self, value):
         self.LanguageGroup.setDisabled(value)
         LanguageManager.auto_language = value
@@ -763,7 +763,7 @@
         """
         Show the shortcuts dialog
         """
-        self.shortcutForm.exec_(self.actionList)
+        self.shortcutForm.exec_(self)
 
     def onModeDefaultItemClicked(self):
         """

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2010-12-03 18:56:12 +0000
+++ openlp/core/ui/servicemanager.py	2010-12-08 21:16:26 +0000
@@ -37,7 +37,7 @@
     Receiver, build_icon, ItemCapabilities, SettingsManager, translate, \
     ThemeLevel
 from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm
-from openlp.core.utils import AppLocation
+from openlp.core.utils import AppLocation, ActionConfig
 
 class ServiceManagerList(QtGui.QTreeWidget):
     """
@@ -47,34 +47,6 @@
         QtGui.QTreeWidget.__init__(self, parent)
         self.parent = parent
 
-    def keyPressEvent(self, event):
-        if isinstance(event, QtGui.QKeyEvent):
-            #here accept the event and do something
-            if event.key() == QtCore.Qt.Key_Enter:
-                self.parent.makeLive()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_Home:
-                self.parent.onServiceTop()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_End:
-                self.parent.onServiceEnd()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_PageUp:
-                self.parent.onServiceUp()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_PageDown:
-                self.parent.onServiceDown()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_Up:
-                self.parent.onMoveSelectionUp()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_Down:
-                self.parent.onMoveSelectionDown()
-                event.accept()
-            event.ignore()
-        else:
-            event.ignore()
-
     def mouseMoveEvent(self, event):
         """
         Drag and drop event does not care what data is selected
@@ -281,6 +253,66 @@
             translate('OpenLP.ServiceManager', '&Change Item Theme'))
         self.menu.addMenu(self.themeMenu)
         self.configUpdated(True)
+        self.setServiceHotkeys(self.serviceManagerList)
+        self.serviceManagerList.addActions([self.serviceManagerList.move_down, 
+                                            self.serviceManagerList.move_up, 
+                                            self.serviceManagerList.enter, 
+                                            self.serviceManagerList.home, 
+                                            self.serviceManagerList.end, 
+                                            self.serviceManagerList.up, 
+                                            self.serviceManagerList.down])
+
+    def setServiceHotkeys(self, parent=None):
+        widget = self
+        self.serviceManagerList.move_down = \
+                QtGui.QAction(QtGui.QIcon(u':/services/service_down.png'),
+                                    u'Move_down', parent)
+        ActionConfig.set(self.serviceManagerList.move_down, 
+                                    widget, u'Move_down', 
+                                    u'Service Settings', self.onServiceDown,  
+                                    QtCore.Qt.Key_PageDown)
+        self.serviceManagerList.move_up = \
+                QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                                    u'Move_up', parent)
+        ActionConfig.set(self.serviceManagerList.move_up, 
+                                    widget, u'Move_up', 
+                                    u'Service Settings', self.onServiceUp,  
+                                    QtCore.Qt.Key_PageUp)
+        self.serviceManagerList.enter = \
+                QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                                    u'Make Live', parent)
+        ActionConfig.set(self.serviceManagerList.enter, 
+                                    widget, u'Make Live', 
+                                    u'Service Settings', self.makeLive,  
+                                    QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return)
+        self.serviceManagerList.home = \
+                QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                                    u'Home', parent)
+        ActionConfig.set(self.serviceManagerList.home, 
+                                    widget, u'Home', 
+                                    u'Service Settings', self.onServiceTop,  
+                                    QtCore.Qt.Key_Home)
+        self.serviceManagerList.end = \
+                QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                                    u'End', parent)
+        ActionConfig.set(self.serviceManagerList.end, 
+                                    widget, u'End', 
+                                    u'Service Settings', self.onServiceEnd,  
+                                    QtCore.Qt.Key_End)
+        self.serviceManagerList.up = \
+                QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                                    u'Move Selection up', parent)
+        ActionConfig.set(self.serviceManagerList.up, 
+                                    widget, u'Move Selection up', 
+                                    u'Service Settings', self.onMoveSelectionUp,  
+                                    QtCore.Qt.Key_Up)
+        self.serviceManagerList.down = \
+                QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                                    u'Move Selection down', parent)
+        ActionConfig.set(self.serviceManagerList.down, 
+                                    widget, u'Move Selection down', 
+                                    u'Service Settings', self.onMoveSelectionDown,  
+                                    QtCore.Qt.Key_Down)
 
     def configUpdated(self, firstTime=False):
         """

=== modified file 'openlp/core/ui/shortcutlistdialog.py'
--- openlp/core/ui/shortcutlistdialog.py	2010-10-30 07:51:34 +0000
+++ openlp/core/ui/shortcutlistdialog.py	2010-12-08 21:16:26 +0000
@@ -39,7 +39,7 @@
         self.shortcutListTreeWidget = QtGui.QTreeWidget(shortcutListDialog)
         self.shortcutListTreeWidget.setAlternatingRowColors(True)
         self.shortcutListTreeWidget.setObjectName(u'shortcutListTreeWidget')
-        self.shortcutListTreeWidget.setColumnCount(2)
+        self.shortcutListTreeWidget.setColumnCount(3)
         self.shortcutListTreeWidget.setSelectionBehavior(
             QtGui.QAbstractItemView.SelectRows)
         self.shortcutListLayout.addWidget(self.shortcutListTreeWidget)
@@ -103,7 +103,8 @@
             translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts'))
         self.shortcutListTreeWidget.setHeaderLabels([
             translate('OpenLP.ShortcutListDialog', 'Action'),
-            translate('OpenLP.ShortcutListDialog', 'Shortcut')
+            translate('OpenLP.ShortcutListDialog', 'Shortcut'), 
+            translate('OpenLP.ShortcutListDialog', 'Alternative')
         ])
         self.defaultRadioButton.setText(
             translate('OpenLP.ShortcutListDialog', 'Default: %s'))
@@ -112,3 +113,81 @@
         self.shortcutPushButton.setText(
             translate('OpenLP.ShortcutListDialog', 'None'))
 
+class Ui_ShortcutDialog(object):
+    def setupUi(self, ShortcutDialog):
+        ShortcutDialog.setObjectName(u'ShortcutDialog')
+        ShortcutDialog.resize(539, 125)
+        self.vboxlayout = QtGui.QVBoxLayout(ShortcutDialog)
+        self.vboxlayout.setObjectName(u'vboxlayout')
+        self.shortcutsGroup = QtGui.QGroupBox(ShortcutDialog)
+        self.shortcutsGroup.setTitle(u'')
+        self.shortcutsGroup.setObjectName(u'shortcutsGroup')
+        self.gridlayout = QtGui.QGridLayout(self.shortcutsGroup)
+        self.gridlayout.setObjectName(u'gridlayout')
+        self.alternateButton = QtGui.QRadioButton(self.shortcutsGroup)
+        self.alternateButton.setFocusPolicy(QtCore.Qt.NoFocus)
+        self.alternateButton.setObjectName(u'alternateButton')
+        self.gridlayout.addWidget(self.alternateButton, 1, 0, 1, 1)
+        self.primaryClearButton = QtGui.QPushButton(self.shortcutsGroup)
+        self.primaryClearButton.setFocusPolicy(QtCore.Qt.NoFocus)
+        self.primaryClearButton.setObjectName(u'primaryClearButton')
+        self.gridlayout.addWidget(self.primaryClearButton, 0, 1, 1, 1)
+        self.alternateKeyLabel = QtGui.QLabel(self.shortcutsGroup)
+        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
+        sizePolicy.setHorizontalStretch(0)
+        sizePolicy.setVerticalStretch(0)
+        sizePolicy.setHeightForWidth(self.alternateKeyLabel.sizePolicy().hasHeightForWidth())
+        self.alternateKeyLabel.setSizePolicy(sizePolicy)
+        self.alternateKeyLabel.setToolTip(u'')
+        self.alternateKeyLabel.setFrameShape(QtGui.QFrame.StyledPanel)
+        self.alternateKeyLabel.setFrameShadow(QtGui.QFrame.Sunken)
+        self.alternateKeyLabel.setText(u'')
+        self.alternateKeyLabel.setObjectName(u'alternateKeyLabel')
+        self.gridlayout.addWidget(self.alternateKeyLabel, 1, 2, 1, 1)
+        self.keyLabel = QtGui.QLabel(self.shortcutsGroup)
+        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
+        sizePolicy.setHorizontalStretch(0)
+        sizePolicy.setVerticalStretch(0)
+        sizePolicy.setHeightForWidth(self.keyLabel.sizePolicy().hasHeightForWidth())
+        self.keyLabel.setSizePolicy(sizePolicy)
+        self.keyLabel.setToolTip(u'')
+        self.keyLabel.setFrameShape(QtGui.QFrame.StyledPanel)
+        self.keyLabel.setFrameShadow(QtGui.QFrame.Sunken)
+        self.keyLabel.setText(u'')
+        self.keyLabel.setObjectName(u'keyLabel')
+        self.gridlayout.addWidget(self.keyLabel, 0, 2, 1, 1)
+        self.primaryButton = QtGui.QRadioButton(self.shortcutsGroup)
+        self.primaryButton.setFocusPolicy(QtCore.Qt.NoFocus)
+        self.primaryButton.setChecked(True)
+        self.primaryButton.setObjectName(u'primaryButton')
+        self.gridlayout.addWidget(self.primaryButton, 0, 0, 1, 1)
+        self.alternateClearButton = QtGui.QPushButton(self.shortcutsGroup)
+        self.alternateClearButton.setEnabled(False)
+        self.alternateClearButton.setFocusPolicy(QtCore.Qt.NoFocus)
+        self.alternateClearButton.setObjectName(u'alternateClearButton')
+        self.gridlayout.addWidget(self.alternateClearButton, 1, 1, 1, 1)
+        self.vboxlayout.addWidget(self.shortcutsGroup)
+        self.buttonBox = QtGui.QDialogButtonBox(ShortcutDialog)
+        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
+        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
+        self.buttonBox.setObjectName(u'buttonBox')
+        self.vboxlayout.addWidget(self.buttonBox)
+
+        self.retranslateUi(ShortcutDialog)
+        QtCore.QObject.connect(self.primaryButton, QtCore.SIGNAL(u'toggled(bool)'), self.primaryClearButton.setEnabled)
+        QtCore.QObject.connect(self.alternateButton, QtCore.SIGNAL(u'toggled(bool)'), self.alternateClearButton.setEnabled)
+        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), ShortcutDialog.reject)
+        QtCore.QMetaObject.connectSlotsByName(ShortcutDialog)
+
+    def retranslateUi(self, ShortcutDialog):
+        ShortcutDialog.setWindowTitle(QtGui.QApplication.translate("ShortcutDialog", "Edit Shortcut", None, QtGui.QApplication.UnicodeUTF8))
+        ShortcutDialog.setWhatsThis(QtGui.QApplication.translate("ShortcutDialog", "Press your shortcut keys and select OK", None, QtGui.QApplication.UnicodeUTF8))
+        self.alternateButton.setToolTip(QtGui.QApplication.translate("ShortcutDialog", "Select to change the alternative keyboard shortcut", None, QtGui.QApplication.UnicodeUTF8))
+        self.alternateButton.setText(QtGui.QApplication.translate("ShortcutDialog", "Alternative Shortcut:", None, QtGui.QApplication.UnicodeUTF8))
+        self.primaryClearButton.setToolTip(QtGui.QApplication.translate("ShortcutDialog", "Press to clear the key sequence buffer.", None, QtGui.QApplication.UnicodeUTF8))
+        self.primaryClearButton.setText(QtGui.QApplication.translate("ShortcutDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))
+        self.primaryButton.setToolTip(QtGui.QApplication.translate("ShortcutDialog", "Select to change the primary keyboard shortcut", None, QtGui.QApplication.UnicodeUTF8))
+        self.primaryButton.setText(QtGui.QApplication.translate("ShortcutDialog", "Primary Shortcut:", None, QtGui.QApplication.UnicodeUTF8))
+        self.alternateClearButton.setToolTip(QtGui.QApplication.translate("ShortcutDialog", "Press to clear the key sequence buffer.", None, QtGui.QApplication.UnicodeUTF8))
+        self.alternateClearButton.setText(QtGui.QApplication.translate("ShortcutDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))
+        

=== modified file 'openlp/core/ui/shortcutlistform.py'
--- openlp/core/ui/shortcutlistform.py	2010-11-03 17:19:44 +0000
+++ openlp/core/ui/shortcutlistform.py	2010-12-08 21:16:26 +0000
@@ -30,7 +30,7 @@
 from PyQt4 import QtCore, QtGui
 
 from openlp.core.utils import translate
-from shortcutlistdialog import Ui_ShortcutListDialog
+from shortcutlistdialog import Ui_ShortcutListDialog, Ui_ShortcutDialog
 
 REMOVE_AMPERSAND = re.compile(r'&{1}')
 
@@ -49,62 +49,214 @@
         self.setupUi(self)
         self.actionList = None
         self.captureShortcut = False
+        self.currentItem = None
+        self.newShortcut = None
         QtCore.QObject.connect(
             self.shortcutPushButton,
             QtCore.SIGNAL(u'toggled(bool)'),
             self.onShortcutPushButtonClicked
         )
-
-    def keyReleaseEvent(self, event):
-        Qt = QtCore.Qt
-        if not self.captureShortcut:
-            return
-        key = event.key()
-        if key == Qt.Key_Shift or key == Qt.Key_Control or \
-            key == Qt.Key_Meta or key == Qt.Key_Alt:
-            return
-        key_string = QtGui.QKeySequence(key).toString()
-        if event.modifiers() & Qt.ControlModifier == Qt.ControlModifier:
-            key_string = u'Ctrl+' + key_string
-        if event.modifiers() & Qt.AltModifier == Qt.AltModifier:
-            key_string = u'Alt+' + key_string
-        if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier:
-            key_string = u'Shift+' + key_string
-        key_sequence = QtGui.QKeySequence(key_string)
-        existing_key = QtGui.QKeySequence("Ctrl+Shift+F8")
-        if key_sequence == existing_key:
-            QtGui.QMessageBox.warning(
-                self,
-                translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'),
-                unicode(translate('OpenLP.ShortcutListDialog', 'The shortcut '
-                    '"%s" is already assigned to another action, please '
-                    'use a different shortcut.')) % key_sequence.toString(),
-                QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
-                QtGui.QMessageBox.Ok
-            )
-        else:
-            self.shortcutPushButton.setText(key_sequence.toString())
-        self.shortcutPushButton.setChecked(False)
-        self.captureShortcut = False
-
-    def exec_(self, actionList):
-        self.actionList = actionList
+        self.shortcutListTreeWidget.itemDoubleClicked.connect(self.shortcutEdit)
+
+    def setNewShortcut(self, shortcut, alternate):
+        if self.currentItem:
+            self.actionList[self.currentItem].setShortcuts([shortcut, alternate])
+            self.shortcutListTreeWidget.currentItem().setText(1, shortcut.toString())
+            self.shortcutListTreeWidget.currentItem().setText(2, alternate.toString())
+
+    def exec_(self, parent):
+        self.actionList = parent.findChildren(QtGui.QAction)
         self.refreshActions()
         return QtGui.QDialog.exec_(self)
 
     def refreshActions(self):
         self.shortcutListTreeWidget.clear()
-        for category in self.actionList.categories:
-            item = QtGui.QTreeWidgetItem([category.name])
-            for action in category.actions:
-                actionText = REMOVE_AMPERSAND.sub('', unicode(action.text()))
-                shortcutText = action.shortcut().toString()
-                actionItem = QtGui.QTreeWidgetItem([actionText, shortcutText])
-                actionItem.setIcon(0, action.icon())
-                item.addChild(actionItem)
-            item.setExpanded(True)
-            self.shortcutListTreeWidget.addTopLevelItem(item)
+        catItemDict = dict()
+        for num in range(len(self.actionList)):
+            action = self.actionList[num]
+            actionText = action.objectName() or action.parentWidget().objectName()
+            shortcutText = u''
+            shortcutAlternate = u''
+            if len(action.shortcuts()) > 0:
+                shortcutText = action.shortcuts()[0].toString()
+                if len(action.shortcuts()) > 1:
+                    shortcutAlternate = action.shortcuts()[1].toString()
+            if action.isSeparator():
+                continue
+            if not shortcutText:
+                continue
+            categorie = action.data().toString() or 'Unknown'
+            if not catItemDict.has_key(categorie):
+                catItemDict[categorie] = QtGui.QTreeWidgetItem([categorie])
+            actionItem = QtGui.QTreeWidgetItem([actionText, shortcutText, shortcutAlternate], num)
+            actionItem.setIcon(0, action.icon())
+            catItemDict[categorie].addChild(actionItem)
+            catItemDict[categorie].setExpanded(True)
+        for key in sorted(catItemDict.iterkeys()):
+            self.shortcutListTreeWidget.addTopLevelItem(catItemDict[key])
+            self.shortcutListTreeWidget.expandItem(catItemDict[key])
+        self.shortcutListTreeWidget.sortItems(0, QtCore.Qt.AscendingOrder)
 
     def onShortcutPushButtonClicked(self, toggled):
         self.captureShortcut = toggled
 
+    def shortcutEdit(self, item, column):
+        self.currentItem = item.type()
+        self.newShortcut = item.text(1)
+        dialog = ShortcutDialog(self, u'Press new Shortcut', item.text(1), item.text(2))
+        dialog.show()
+        #self.shortcutListTreeWidget.currentItem().setText(column, u'Press new Shortcut')
+        #self.captureShortcut = True
+   
+class ShortcutDialog(QtGui.QDialog, Ui_ShortcutDialog):
+    """
+    Class implementing a dialog for the configuration of a keyboard shortcut.
+    
+    """
+    def __init__(self, parent = None, name = None, key=0, alternate=0):
+        """
+        Constructor
+        
+        @param parent The parent widget of this dialog. (QWidget)
+        @param name The name of this dialog. (QString)
+        @param modal Flag indicating a modal dialog. (boolean)
+        """
+        QtGui.QDialog.__init__(self, parent)
+        self.parent = parent
+        if name:
+            self.setObjectName(name)
+        self.setupUi(self)
+        self.setKeys(key, alternate)
+        self.keyIndex = 0
+        self.keys = [0, 0, 0, 0]
+        self.noCheck = False
+        self.objectType = None
+        
+        self.connect(self.primaryClearButton, QtCore.SIGNAL("clicked()"), self.__clear)
+        self.connect(self.alternateClearButton, QtCore.SIGNAL("clicked()"), self.__clear)
+        self.connect(self.primaryButton, QtCore.SIGNAL("clicked()"), self.__typeChanged)
+        self.connect(self.alternateButton, QtCore.SIGNAL("clicked()"), self.__typeChanged)
+        
+        self.shortcutsGroup.installEventFilter(self)
+        self.primaryButton.installEventFilter(self)
+        self.alternateButton.installEventFilter(self)
+        self.primaryClearButton.installEventFilter(self)
+        self.alternateClearButton.installEventFilter(self)
+        
+        self.buttonBox.button(QtGui.QDialogButtonBox.Ok).installEventFilter(self)
+        self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).installEventFilter(self)
+
+    def setKeys(self, key, alternateKey,  noCheck=None, objectType=None):
+        """
+        Public method to set the key to be configured.
+        
+        @param key key sequence to be changed (QKeySequence)
+        @param alternateKey alternate key sequence to be changed (QKeySequence)
+        @param noCheck flag indicating that no uniqueness check should
+            be performed (boolean)
+        @param objectType type of the object (string).
+        """
+        self.keyIndex = 0
+        self.keys = [0, 0, 0, 0]
+        self.keyLabel.setText(QtCore.QString(key))
+        self.alternateKeyLabel.setText(QtCore.QString(alternateKey))
+        self.primaryButton.setChecked(True)
+        self.noCheck = noCheck
+        self.objectType = objectType
+        
+    def on_buttonBox_accepted(self):
+        """
+        Private slot to handle the OK button press.
+        """
+        self.parent.setNewShortcut(QtGui.QKeySequence(self.keyLabel.text()),
+                  QtGui.QKeySequence(self.alternateKeyLabel.text()))#, 
+#                  self.noCheck, self.objectType)
+        self.close()
+
+    def __clear(self):
+        """
+        Private slot to handle the Clear button press.
+        """
+        self.keyIndex = 0
+        self.keys = [0, 0, 0, 0]
+        self.__setKeyLabelText("")
+        
+    def __typeChanged(self):
+        """
+        Private slot to handle the change of the shortcuts type.
+        """
+        self.keyIndex = 0
+        self.keys = [0, 0, 0, 0]
+        
+    def __setKeyLabelText(self, txt):
+        """
+        Private method to set the text of a key label.
+        
+        @param txt text to be set (QString)
+        """
+        if self.primaryButton.isChecked():
+            self.keyLabel.setText(txt)
+        else:
+            self.alternateKeyLabel.setText(txt)
+        
+    def eventFilter(self, watched, event):
+        """
+        Method called to filter the event queue.
+        
+        @param watched the QObject being watched
+        @param event the event that occurred
+        @return always False
+        """
+        if event.type() == QtCore.QEvent.KeyPress:
+            self.keyPressEvent(event)
+            return True
+            
+        return False
+        
+    def keyPressEvent(self, evt):
+        """
+        Private method to handle a key press event.
+        
+        @param evt the key event (QKeyEvent)
+        """
+        if evt.key() == QtCore.Qt.Key_Control:
+            return
+        if evt.key() == QtCore.Qt.Key_Meta:
+            return
+        if evt.key() == QtCore.Qt.Key_Shift:
+            return
+        if evt.key() == QtCore.Qt.Key_Alt:
+            return
+        if evt.key() == QtCore.Qt.Key_Menu:
+            return
+    
+        if self.keyIndex == 4:
+            self.keyIndex = 0
+            self.keys = [0, 0, 0, 0]
+    
+        if evt.key() == QtCore.Qt.Key_Backtab and evt.modifiers() & QtCore.Qt.ShiftModifier:
+            self.keys[self.keyIndex] = QtCore.Qt.Key_Tab
+        else:
+            self.keys[self.keyIndex] = evt.key()
+        
+        if evt.modifiers() & QtCore.Qt.ShiftModifier:
+            self.keys[self.keyIndex] += QtCore.Qt.SHIFT
+        if evt.modifiers() & QtCore.Qt.ControlModifier:
+            self.keys[self.keyIndex] += QtCore.Qt.CTRL
+        if evt.modifiers() & QtCore.Qt.AltModifier:
+            self.keys[self.keyIndex] += QtCore.Qt.ALT
+        if evt.modifiers() & QtCore.Qt.MetaModifier:
+            self.keys[self.keyIndex] += QtCore.Qt.META
+        
+        self.keyIndex += 1
+        
+        if self.keyIndex == 1:
+            self.__setKeyLabelText(QtCore.QString(QtGui.QKeySequence(self.keys[0])))
+        elif self.keyIndex == 2:
+            self.__setKeyLabelText(QtCore.QString(QtGui.QKeySequence(self.keys[0], self.keys[1])))
+        elif self.keyIndex == 3:
+            self.__setKeyLabelText(QtCore.QString(QtGui.QKeySequence(self.keys[0], self.keys[1],
+                self.keys[2])))
+        elif self.keyIndex == 4:
+            self.__setKeyLabelText(QtCore.QString(QtGui.QKeySequence(self.keys[0], self.keys[1],
+                self.keys[2], self.keys[3])))

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2010-12-03 18:56:12 +0000
+++ openlp/core/ui/slidecontroller.py	2010-12-08 21:16:26 +0000
@@ -33,7 +33,7 @@
 from openlp.core.ui import HideMode, MainDisplay
 from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \
     ItemCapabilities, translate
-
+from openlp.core.utils import ActionConfig
 log = logging.getLogger(__name__)
 
 class SlideList(QtGui.QTableWidget):
@@ -44,34 +44,6 @@
     def __init__(self, parent=None, name=None):
         QtGui.QTableWidget.__init__(self, parent.Controller)
         self.parent = parent
-        self.hotkeyMap = {
-           QtCore.Qt.Key_Return: 'servicemanager_next_item',
-           QtCore.Qt.Key_Space: 'slidecontroller_live_next_noloop',
-           QtCore.Qt.Key_Enter: 'slidecontroller_live_next_noloop',
-           QtCore.Qt.Key_0: 'servicemanager_next_item',
-           QtCore.Qt.Key_Backspace: 'slidecontroller_live_previous_noloop'}
-
-    def keyPressEvent(self, event):
-        if isinstance(event, QtGui.QKeyEvent):
-            #here accept the event and do something
-            if event.key() == QtCore.Qt.Key_Up:
-                self.parent.onSlideSelectedPrevious()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_Down:
-                self.parent.onSlideSelectedNext()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_PageUp:
-                self.parent.onSlideSelectedFirst()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_PageDown:
-                self.parent.onSlideSelectedLast()
-                event.accept()
-            elif event.key() in self.hotkeyMap and self.parent.isLive:
-                Receiver.send_message(self.hotkeyMap[event.key()])
-                event.accept()
-            event.ignore()
-        else:
-            event.ignore()
 
 class SlideController(QtGui.QWidget):
     """
@@ -343,6 +315,22 @@
         else:
             self.Toolbar.makeWidgetsInvisible(self.songEditList)
         self.Mediabar.setVisible(False)
+        if self.isLive:
+            self.setLiveHotkeys(self)
+            self.PreviewListWidget.addActions([self.previous_item, 
+                                                            self.next_item, 
+                                                            self.previous_service, 
+                                                            self.next_service, 
+                                                            self.escape_item])
+            self.display.addActions([self.previous_item, 
+                                            self.next_item, 
+                                            self.previous_service, 
+                                            self.next_service, 
+                                            self.escape_item])
+        else:
+            self.setPreviewHotkeys()
+            self.PreviewListWidget.addActions([self.preview_next_item, 
+                                                            self.preview_previous_item])
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix),
             self.onStopLoop)
@@ -392,6 +380,61 @@
             QtCore.QObject.connect(Receiver.get_receiver(),
                 QtCore.SIGNAL(u'maindisplay_active'), self.updatePreview)
 
+    def setPreviewHotkeys(self, parent=None):
+        widget = self
+        self.preview_previous_item = QtGui.QAction(u'previous_item', parent)
+        ActionConfig.set(self.preview_previous_item, widget, u'previous_item', 
+            u'Preview Settings', self.onSlideSelectedPrevious,  QtCore.Qt.Key_Up)
+
+        self.preview_next_item = QtGui.QAction(u'next_item', parent)
+        ActionConfig.set(self.preview_next_item, widget, u'next_item', 
+            u'Preview Settings', self.onSlideSelectedNext, QtCore.Qt.Key_Down)
+        #self.parent.display.addAction(self.next_item)
+        
+    def setLiveHotkeys(self, parent=None):
+        widget = self
+        self.next_item = QtGui.QAction(u'next_item', parent)
+        ActionConfig.set(self.next_item, widget, u'next_item', 
+            u'Live View Settings', self.onSlideSelectedNext, 
+            QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown, 
+            context=QtCore.Qt.WidgetWithChildrenShortcut)
+
+            
+        parent.previous_service = QtGui.QAction(u'previous_service', parent)
+        ActionConfig.set(parent.previous_service, widget, u'previous_service', 
+            u'Live View Settings', self.servicePrevious, 
+            QtCore.Qt.Key_Left, 
+            context=QtCore.Qt.WidgetWithChildrenShortcut)
+            
+        self.next_service = QtGui.QAction(u'next_service', parent)
+        ActionConfig.set(self.next_service, widget, u'next_service', 
+            u'Live View Settings', self.serviceNext, 
+            QtCore.Qt.Key_Right, 
+            context=QtCore.Qt.WidgetWithChildrenShortcut)
+            
+        self.previous_item = QtGui.QAction(u'previous_item', parent)
+        ActionConfig.set(self.previous_item, widget, u'previous_item', 
+            u'Live View Settings', self.onSlideSelectedPrevious, 
+            QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp, 
+            context=QtCore.Qt.WidgetWithChildrenShortcut)
+            
+        self.escape_item = QtGui.QAction(u'escape_item', parent)
+        ActionConfig.set(self.escape_item, widget, u'escape_item', 
+            u'Live View Settings', self.liveEscape, 
+            QtCore.Qt.Key_Escape, 
+            context=QtCore.Qt.WidgetWithChildrenShortcut)
+       
+    def liveEscape(self):
+        self.display.setVisible(False)
+        self.display.videoStop()
+     
+    def servicePrevious(self):
+        Receiver.send_message('servicemanager_previous_item')
+
+    def serviceNext(self):
+        Receiver.send_message('servicemanager_next_item')
+
+
     def screenSizeChanged(self):
         """
         Settings dialog has changed the screen size of adjust output and
@@ -408,6 +451,12 @@
         self.SlidePreview.setFixedSize(
             QtCore.QSize(self.settingsmanager.slidecontroller_image,
             self.settingsmanager.slidecontroller_image / self.ratio))
+        if self.isLive:
+            self.display.addActions([self.previous_item, 
+                                self.next_item, 
+                                self.previous_service, 
+                                self.next_service, 
+                                self.escape_item])
 
     def widthChanged(self):
         """
@@ -859,7 +908,7 @@
                 if loop:
                     row = 0
                 else:
-                    Receiver.send_message('servicemanager_next_item')
+                    #Receiver.send_message('servicemanager_next_item')
                     return
             if row + 1 < self.PreviewListWidget.rowCount():
                 self.PreviewListWidget.scrollToItem(

=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py	2010-10-28 05:21:45 +0000
+++ openlp/core/utils/__init__.py	2010-12-08 21:16:26 +0000
@@ -276,7 +276,7 @@
     return images_filter
 
 from languagemanager import LanguageManager
-from actions import ActionList
+from actions import ActionList, ActionConfig
 
 __all__ = [u'AppLocation', u'check_latest_version', u'add_actions',
     u'get_filesystem_encoding', u'LanguageManager', u'ActionList']

=== modified file 'openlp/core/utils/actions.py'
--- openlp/core/utils/actions.py	2010-11-03 17:19:44 +0000
+++ openlp/core/utils/actions.py	2010-12-08 21:16:26 +0000
@@ -27,6 +27,7 @@
 The :mod:`~openlp.core.utils.actions` module provides action list classes used
 by the shortcuts system.
 """
+from PyQt4 import QtCore
 
 class ActionCategory(object):
     """
@@ -182,3 +183,18 @@
             self.categories[category].actions.append(action)
         else:
             self.categories[category].actions.add(action, weight)
+
+class ActionConfig(object):
+    """
+    Helper for configuration of OpenLP Shortcut actions
+    """
+    
+    @staticmethod
+    def set(action, widget, text, category, slot, shortcut, 
+                alternate=0, context=QtCore.Qt.WidgetShortcut):
+        action.setObjectName(text)
+        action.setShortcuts([shortcut, alternate])
+        action.setShortcutContext(context)
+        action.setData(QtCore.QVariant(category))
+        QtCore.QObject.connect(action,
+            QtCore.SIGNAL(u'triggered()'), slot)