openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #04697
[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
Not yet implemented:
- Service Manager actions not yet complete
- save/read changed shortcuts (xml file)
- set correct category for other actions
Open Issues:
- Code not clean and may could simplified
- Changing of Shortcut actually remove alternate
- Changing of Alternate Shortcut not yet possible
- Key Left/Right/Down/Up will not be recognized correctly while catching key event
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/43044
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 06:48:54 +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 06:48:54 +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 06:48:54 +0000
@@ -47,33 +47,33 @@
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 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):
"""
@@ -281,6 +281,29 @@
translate('OpenLP.ServiceManager', '&Change Item Theme'))
self.menu.addMenu(self.themeMenu)
self.configUpdated(True)
+ self.setServiceHotkeys(self.serviceManagerList)
+ self.serviceManagerList.addAction(self.serviceManagerList.move_down)
+
+ def configureAction(self, action, widget, text, category, slot, shortcut, alternate=0):
+ action.setObjectName(text)
+ if alternate > 0:
+ action.setShortcuts([shortcut, alternate])
+ else:
+ action.setShortcut(QtGui.QKeySequence(shortcut))
+ action.setShortcutContext(QtCore.Qt.WidgetShortcut)
+ action.setData(QtCore.QVariant(category))
+ QtCore.QObject.connect(action,
+ QtCore.SIGNAL(u'triggered()'), slot)
+
+ def setServiceHotkeys(self, parent=None):
+ widget = self
+ self.serviceManagerList.move_down = \
+ QtGui.QAction(QtGui.QIcon(u':/services/service_down.png'),
+ u'move_down', parent)
+ self.configureAction(self.serviceManagerList.move_down,
+ widget, u'Move_down',
+ u'Service Settings', self.onServiceDown,
+ QtCore.Qt.Key_PageDown)
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 06:48:54 +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'))
=== 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 06:48:54 +0000
@@ -49,11 +49,14 @@
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
)
+ self.shortcutListTreeWidget.itemDoubleClicked.connect(self.shortcutEdit)
def keyReleaseEvent(self, event):
Qt = QtCore.Qt
@@ -83,28 +86,78 @@
QtGui.QMessageBox.Ok
)
else:
+ self.newShortcut = key_sequence.toString()
self.shortcutPushButton.setText(key_sequence.toString())
+ if self.currentItem:
+ self.actionList[self.currentItem].setShortcut(QtGui.QKeySequence(self.newShortcut))
+ self.shortcutListTreeWidget.currentItem().setText(1, self.newShortcut)
+
self.shortcutPushButton.setChecked(False)
self.captureShortcut = False
- def exec_(self, actionList):
- self.actionList = actionList
+ 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, shortcutAlternative], num)
+ actionItem.setIcon(0, action.icon())
+ catItemDict[categorie].addChild(actionItem)
+ catItemDict[categorie].setExpanded(True)
+ for item in catItemDict:
+ self.shortcutListTreeWidget.addTopLevelItem(catItemDict[item])
+ self.shortcutListTreeWidget.expandItem(catItemDict[item])
+
+ def load_action_list(self, file):
+ """
+ Load an actionList from a xml file
+ """
+ pass
+
+ def write_action_list(self, file):
+ """
+ Write the current actionList into a xml file
+ """
+ pass
+
+ def read_action_list(self):
+ """
+ disply current actionList
+ """
+ pass
+
+ def update_action_list(self):
+ """
+ apply shortcut changes to the related actions
+ """
+ pass
def onShortcutPushButtonClicked(self, toggled):
self.captureShortcut = toggled
+ def shortcutEdit(self, item, column):
+ #print "ändern", item.parent().text(0), item.text(0), column, item.type(), item
+ self.currentItem = item.type()
+ self.newShortcut = item.text(1)
+ self.shortcutListTreeWidget.currentItem().setText(column, u'Press new Shortcut')
+ self.captureShortcut = True
+
=== 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 06:48:54 +0000
@@ -44,34 +44,44 @@
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'}
+# if self.parent.isLive:
+# 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)
+# else:
+# self.addAction(self.parent.preview_previous_item)
+# self.addAction(self.parent.preview_next_item)
+
+# 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()
+# 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):
"""
@@ -87,6 +97,8 @@
self.isLive = isLive
self.parent = parent
self.screens = screens
+# self.setPreviewHotkeys(self)
+# self.setLiveHotkeys(self)
self.ratio = float(self.screens.current[u'size'].width()) / \
float(self.screens.current[u'size'].height())
self.display = MainDisplay(self, screens, isLive)
@@ -343,6 +355,21 @@
else:
self.Toolbar.makeWidgetsInvisible(self.songEditList)
self.Mediabar.setVisible(False)
+ if self.isLive:
+ self.setLiveHotkeys(self)
+ self.PreviewListWidget.addAction(self.previous_item)
+ self.PreviewListWidget.addAction(self.next_item)
+ self.PreviewListWidget.addAction(self.previous_service)
+ self.PreviewListWidget.addAction(self.next_service)
+ self.PreviewListWidget.addAction(self.escape_item)
+ self.display.addAction(self.previous_item)
+ self.display.addAction(self.previous_service)
+ self.display.addAction(self.next_service)
+ self.display.addAction(self.escape_item)
+ else:
+ self.setPreviewHotkeys()#self.PreviewListWidget)
+ self.PreviewListWidget.addAction(self.preview_next_item)
+ self.PreviewListWidget.addAction(self.preview_previous_item)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix),
self.onStopLoop)
@@ -392,6 +419,76 @@
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_active'), self.updatePreview)
+ def configureAction(self, action, widget, text, category, slot, shortcut, alternate=0):
+ action.setObjectName(text)
+ if alternate > 0:
+ action.setShortcuts([shortcut, alternate])
+ else:
+ action.setShortcut(QtGui.QKeySequence(shortcut))
+ action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
+ action.setData(QtCore.QVariant(category))
+ QtCore.QObject.connect(action,
+ QtCore.SIGNAL(u'triggered()'), slot)
+
+ def setPreviewHotkeys(self, parent=None):
+ widget = self
+ self.preview_previous_item = QtGui.QAction(u'previous_item', parent)
+ self.configureAction(self.preview_previous_item, widget, u'previous_item',
+ u'Preview Settings', self.previewPrevious, QtCore.Qt.Key_Up)
+
+ self.preview_next_item = QtGui.QAction(u'next_item', parent)
+ self.configureAction(self.preview_next_item, widget, u'next_item',
+ u'Preview Settings', self.previewNext, 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)
+ self.configureAction(self.next_item, widget, u'next_item',
+ u'Live View Settings', self.liveNext, QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown)
+ #self.parent.display.addAction(self.next_item)
+
+ parent.previous_service = QtGui.QAction(u'previous_service', parent)
+ self.configureAction(parent.previous_service, widget, u'previous_service',
+ u'Live View Settings', self.servicePrevious, QtCore.Qt.Key_Left)
+
+ self.next_service = QtGui.QAction(u'next_service', parent)
+ self.configureAction(self.next_service, widget, u'next_service',
+ u'Live View Settings', self.serviceNext, QtCore.Qt.Key_Right)
+
+ self.previous_item = QtGui.QAction(u'previous_item', parent)
+ self.configureAction(self.previous_item, widget, u'previous_item',
+ u'Live View Settings', self.livePrevious, QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp)
+ #self.parent.display.addAction(self.previous_item)
+
+ self.escape_item = QtGui.QAction(u'escape_item', parent)
+ self.configureAction(self.escape_item, widget, u'escape_item',
+ u'Live View Settings', self.liveEscape, QtCore.Qt.Key_Escape)
+
+ def liveNext(self):
+ self.onSlideSelectedNext()
+
+
+ def livePrevious(self):
+ self.onSlideSelectedPrevious()
+
+ def previewNext(self):
+ self.onSlideSelectedNext()
+
+ def previewPrevious(self):
+ self.onSlideSelectedPrevious()
+
+ 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 +505,10 @@
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 +960,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(
Follow ups