openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #05653
[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)
Tim Bentley (trb143)
For more details, see:
https://code.launchpad.net/~crichter/openlp/shortcut-dialog/+merge/46545
- correct long lines
- correct indentation
- use camelCase variables
- remove unused ..ui class
--
https://code.launchpad.net/~crichter/openlp/shortcut-dialog/+merge/46545
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py 2011-01-17 22:25:52 +0000
+++ openlp/core/ui/maindisplay.py 2011-01-17 22:37:24 +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-17 22:37:24 +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,66 @@
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):
+ self.serviceManagerList.moveDown = \
+ QtGui.QAction(QtGui.QIcon(u':/services/service_down.png'),
+ u'Move_down', parent)
+ ActionList.set(self.serviceManagerList.moveDown, u'Move_down',
+ 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,
+ u'Move_up', 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, u'Make Live',
+ 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, u'Home',
+ 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, u'End',
+ 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, u'Move Selection up',
+ 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, u'Move Selection down',
+ 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-17 22:37:24 +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,59 @@
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged)
+ def setPreviewHotkeys(self, parent=None):
+ self.previewPreviousItem = QtGui.QAction(u'previous_item', parent)
+ ActionList.set(self.previewPreviousItem, u'previous_item',
+ 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, u'next_item',
+ self.onSlideSelectedNext, QtCore.Qt.Key_Down)
+ self.parent.actionList.add_action(self.previewNextItem, u'Preview')
+
+ def setLiveHotkeys(self, parent=None):
+ self.nextItem = QtGui.QAction(u'next_item', parent)
+ ActionList.set(self.nextItem, u'next_item', 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, u'previous_service',
+ 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, u'next_service',
+ 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, u'previous_item',
+ 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, u'escape_item',
+ 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 +436,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())
=== 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-17 22:37:24 +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,22 @@
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, text, slot, shortcut, alternate=0,
+ context=QtCore.Qt.WidgetShortcut):
+ """
+ Set Parameter for Action Items
+
+ ``action`` action Item
+ ``text`` object name and menu title
+ ``slot`` connected slot
+ ``shortcut`` first shortcut
+ ``alternate`` alternate shortcut
+ ``context`` used context for this action
+ """
+ action.setObjectName(text)
+ action.setShortcuts([shortcut, alternate])
+ action.setShortcutContext(context)
+ QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
Follow ups