← 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:
  Jon Tibble (meths)

For more details, see:
https://code.launchpad.net/~crichter/openlp/shortcut-dialog/+merge/46423

- correct long lines
- correct indentation
- use camelCase variables
- remove unused ..ui class

-- 
https://code.launchpad.net/~crichter/openlp/shortcut-dialog/+merge/46423
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2011-01-14 18:58:47 +0000
+++ openlp/core/ui/maindisplay.py	2011-01-16 21:00:45 +0000
@@ -54,45 +54,6 @@
         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()
 
 class MainDisplay(DisplayWidget):
     """

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2011-01-15 20:06:25 +0000
+++ openlp/core/ui/servicemanager.py	2011-01-16 21:00:45 +0000
@@ -39,7 +39,7 @@
 from openlp.core.ui import criticalErrorMessageBox, ServiceNoteForm, \
     ServiceItemEditForm
 from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
-    split_filename
+    split_filename, ActionList
 
 class ServiceManagerList(QtGui.QTreeWidget):
     """
@@ -49,34 +49,6 @@
         QtGui.QTreeWidget.__init__(self, parent)
         self.mainwindow = mainwindow
 
-    def keyPressEvent(self, event):
-        if isinstance(event, QtGui.QKeyEvent):
-            #here accept the event and do something
-            if event.key() == QtCore.Qt.Key_Enter:
-                self.mainwindow.makeLive()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_Home:
-                self.mainwindow.onServiceTop()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_End:
-                self.mainwindow.onServiceEnd()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_PageUp:
-                self.mainwindow.onServiceUp()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_PageDown:
-                self.mainwindow.onServiceDown()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_Up:
-                self.mainwindow.onMoveSelectionUp()
-                event.accept()
-            elif event.key() == QtCore.Qt.Key_Down:
-                self.mainwindow.onMoveSelectionDown()
-                event.accept()
-            event.ignore()
-        else:
-            event.ignore()
-
     def mouseMoveEvent(self, event):
         """
         Drag and drop event does not care what data is selected
@@ -290,6 +262,82 @@
             translate('OpenLP.ServiceManager', '&Change Item Theme'))
         self.menu.addMenu(self.themeMenu)
         self.configUpdated(True)
+        self.setServiceHotkeys(self.serviceManagerList)
+        self.serviceManagerList.addActions(
+            [self.serviceManagerList.moveDown, 
+            self.serviceManagerList.moveUp, 
+            self.serviceManagerList.enter, 
+            self.serviceManagerList.home, 
+            self.serviceManagerList.end, 
+            self.serviceManagerList.up, 
+            self.serviceManagerList.down])
+
+    def setServiceHotkeys(self, parent=None):
+        widget = self
+        self.serviceManagerList.moveDown = \
+            QtGui.QAction(QtGui.QIcon(u':/services/service_down.png'),
+                u'Move_down', parent)
+        ActionList.set(self.serviceManagerList.moveDown, 
+            widget, u'Move_down', 
+            u'Service Settings', self.onServiceDown,  
+            QtCore.Qt.Key_PageDown)
+        self.mainwindow.actionList.add_action(
+            self.serviceManagerList.moveDown,
+            u'Service')
+        self.serviceManagerList.moveUp = \
+            QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                u'Move_up', parent)
+        ActionList.set(self.serviceManagerList.moveUp, 
+            widget, u'Move_up', 
+            u'Service Settings', self.onServiceUp,  
+            QtCore.Qt.Key_PageUp)
+        self.mainwindow.actionList.add_action(self.serviceManagerList.moveUp,
+            u'Service')
+        self.serviceManagerList.enter = \
+            QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                u'Make Live', parent)
+        ActionList.set(self.serviceManagerList.enter, 
+            widget, u'Make Live', 
+            u'Service Settings', self.makeLive,  
+            QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return)
+        self.mainwindow.actionList.add_action(self.serviceManagerList.enter,
+            u'Service')
+        self.serviceManagerList.home = \
+            QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                u'Home', parent)
+        ActionList.set(self.serviceManagerList.home, 
+            widget, u'Home', 
+            u'Service Settings', self.onServiceTop,  
+            QtCore.Qt.Key_Home)
+        self.mainwindow.actionList.add_action(self.serviceManagerList.home,
+            u'Service')
+        self.serviceManagerList.end = \
+            QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                u'End', parent)
+        ActionList.set(self.serviceManagerList.end, 
+            widget, u'End', 
+            u'Service Settings', self.onServiceEnd,  
+            QtCore.Qt.Key_End)
+        self.mainwindow.actionList.add_action(self.serviceManagerList.end,
+            u'Service')
+        self.serviceManagerList.up = \
+            QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                u'Move Selection up', parent)
+        ActionList.set(self.serviceManagerList.up, 
+            widget, u'Move Selection up', 
+            u'Service Settings', self.onMoveSelectionUp,  
+            QtCore.Qt.Key_Up)
+        self.mainwindow.actionList.add_action(self.serviceManagerList.up,
+            u'Service')
+        self.serviceManagerList.down = \
+            QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+                u'Move Selection down', parent)
+        ActionList.set(self.serviceManagerList.down, 
+            widget, u'Move Selection down', 
+            u'Service Settings', self.onMoveSelectionDown,  
+            QtCore.Qt.Key_Down)
+        self.mainwindow.actionList.add_action(self.serviceManagerList.down,
+            u'Service')
 
     def setModified(self, modified=True):
         """

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2011-01-14 17:02:06 +0000
+++ openlp/core/ui/slidecontroller.py	2011-01-16 21:00:45 +0000
@@ -33,6 +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 ActionList
 
 log = logging.getLogger(__name__)
 
@@ -44,34 +45,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):
@@ -339,6 +312,25 @@
                 self.onGoLiveClick)
             self.Toolbar.makeWidgetsInvisible(self.songEditList)
         self.Mediabar.setVisible(False)
+        if self.isLive:
+            self.setLiveHotkeys(self)
+            self.PreviewListWidget.addActions(
+                [self.previousItem, 
+                self.nextItem, 
+                self.previousService, 
+                self.nextService, 
+                self.escapeItem])
+            self.display.addActions(
+                [self.previousItem, 
+                self.nextItem, 
+                self.previousService, 
+                self.nextService, 
+                self.escapeItem])
+        else:
+            self.setPreviewHotkeys()
+            self.PreviewListWidget.addActions(
+                [self.previewNextItem, 
+                self.previewPreviousItem])
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix),
             self.onStopLoop)
@@ -381,6 +373,73 @@
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged)
 
+    def setPreviewHotkeys(self, parent=None):
+        widget = self
+        self.previewPreviousItem = QtGui.QAction(u'previous_item', parent)
+        ActionList.set(
+            self.previewPreviousItem, widget, u'previous_item', 
+            u'Preview Settings', self.onSlideSelectedPrevious, 
+            QtCore.Qt.Key_Up)
+        self.parent.actionList.add_action(self.previewPreviousItem,
+            u'Preview')
+        self.previewNextItem = QtGui.QAction(u'next_item', parent)
+        ActionList.set(self.previewNextItem, widget, u'next_item', 
+            u'Preview Settings', self.onSlideSelectedNext, 
+            QtCore.Qt.Key_Down)
+        self.parent.actionList.add_action(self.previewNextItem, u'Preview')
+        
+    def setLiveHotkeys(self, parent=None):
+        widget = self
+        self.nextItem = QtGui.QAction(u'next_item', parent)
+        ActionList.set(self.nextItem, widget, u'next_item', 
+            u'Live View Settings', self.onSlideSelectedNext, 
+            QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown, 
+            context=QtCore.Qt.WidgetWithChildrenShortcut)
+        self.parent.actionList.add_action(self.nextItem, u'Live View Settings')
+            
+        parent.previousService = QtGui.QAction(u'previous_service', parent)
+        ActionList.set(parent.previousService, widget, u'previous_service', 
+            u'Live View Settings', self.servicePrevious, 
+            QtCore.Qt.Key_Left, 
+            context=QtCore.Qt.WidgetWithChildrenShortcut)
+        self.parent.actionList.add_action(self.previousService,
+            u'Live View Settings')
+            
+        self.nextService = QtGui.QAction(u'next_service', parent)
+        ActionList.set(self.nextService, widget, u'next_service', 
+            u'Live View Settings', self.serviceNext, 
+            QtCore.Qt.Key_Right, 
+            context=QtCore.Qt.WidgetWithChildrenShortcut)
+        self.parent.actionList.add_action(self.nextService,
+            u'Live View Settings')
+            
+        self.previousItem = QtGui.QAction(u'previous_item', parent)
+        ActionList.set(self.previousItem, widget, u'previous_item', 
+            u'Live View Settings', self.onSlideSelectedPrevious, 
+            QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp, 
+            context=QtCore.Qt.WidgetWithChildrenShortcut)
+        self.parent.actionList.add_action(self.previousItem,
+            u'Live View Settings')
+            
+        self.escapeItem = QtGui.QAction(u'escape_item', parent)
+        ActionList.set(self.escapeItem, widget, u'escape_item', 
+            u'Live View Settings', self.liveEscape, 
+            QtCore.Qt.Key_Escape, 
+            context=QtCore.Qt.WidgetWithChildrenShortcut)
+        self.parent.actionList.add_action(self.escapeItem,
+            u'Live View Settings')
+
+    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
@@ -391,6 +450,16 @@
         self.display.imageManager = self.parent.renderManager.image_manager
         self.display.alertTab = self.alertTab
         self.display.setup()
+        self.SlidePreview.setFixedSize(
+            QtCore.QSize(self.settingsmanager.slidecontroller_image,
+            self.settingsmanager.slidecontroller_image / self.ratio))
+        if self.isLive:
+            self.display.addActions(
+                [self.previousItem, 
+                self.nextItem, 
+                self.previousService, 
+                self.nextService, 
+                self.escapeItem])
         # The SlidePreview's ratio.
         self.ratio = float(self.screens.current[u'size'].width()) / \
             float(self.screens.current[u'size'].height())
@@ -880,7 +949,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/actions.py'
--- openlp/core/utils/actions.py	2010-12-26 11:04:47 +0000
+++ openlp/core/utils/actions.py	2011-01-16 21:00:45 +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):
     """
@@ -181,4 +182,14 @@
         if weight is None:
             self.categories[category].actions.append(action)
         else:
-            self.categories[category].actions.add(action, weight)
\ No newline at end of file
+            self.categories[category].actions.add(action, weight)
+
+    @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)


Follow ups