next steps for shortcuts, please give a try

This commit is contained in:
rimach 2010-12-07 23:38:41 +01:00
parent d7f944b49a
commit dd8bc1dd9d
6 changed files with 240 additions and 101 deletions

View File

@ -49,45 +49,46 @@ class DisplayWidget(QtGui.QGraphicsView):
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):
"""
@ -110,6 +111,12 @@ class MainDisplay(DisplayWidget):
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):
"""

View File

@ -47,33 +47,33 @@ class ServiceManagerList(QtGui.QTreeWidget):
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 @@ class ServiceManager(QtGui.QWidget):
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):
"""

View File

@ -39,7 +39,7 @@ class Ui_ShortcutListDialog(object):
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 @@ class Ui_ShortcutListDialog(object):
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'))

View File

@ -106,13 +106,20 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
for num in range(len(self.actionList)):
action = self.actionList[num]
actionText = action.objectName() or action.parentWidget().objectName()
shortcutText = action.shortcut().toString()
#if not shortcutText:
# continue
categorie = action.data().toString() or 'Sonstige'
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], num)
actionItem = QtGui.QTreeWidgetItem([actionText, shortcutText, shortcutAlternative], num)
actionItem.setIcon(0, action.icon())
catItemDict[categorie].addChild(actionItem)
catItemDict[categorie].setExpanded(True)

View File

@ -44,34 +44,44 @@ class SlideList(QtGui.QTableWidget):
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)
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()
# 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):
"""
@ -87,6 +97,8 @@ class SlideController(QtGui.QWidget):
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 @@ class SlideController(QtGui.QWidget):
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 @@ class SlideController(QtGui.QWidget):
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 @@ class SlideController(QtGui.QWidget):
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 @@ class SlideController(QtGui.QWidget):
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(