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) QtGui.QGraphicsView.__init__(self)
self.parent = parent self.parent = parent
self.live = live 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): # self.hotkey_map = {
""" # QtCore.Qt.Key_Return: 'servicemanager_next_item',
Handle key events from display screen # QtCore.Qt.Key_Space: 'slidecontroller_live_next_noloop',
""" # QtCore.Qt.Key_Enter: 'slidecontroller_live_next_noloop',
# Key events only needed for live # QtCore.Qt.Key_0: 'servicemanager_next_item',
if not self.live: # QtCore.Qt.Key_Backspace: 'slidecontroller_live_previous_noloop'}
return # self.setStyleSheet(u'border: none;')
if isinstance(event, QtGui.QKeyEvent): #
# Here accept the event and do something # def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Up: # """
Receiver.send_message(u'slidecontroller_live_previous') # Handle key events from display screen
event.accept() # """
elif event.key() == QtCore.Qt.Key_Down: # # Key events only needed for live
Receiver.send_message(u'slidecontroller_live_next') # if not self.live:
event.accept() # return
elif event.key() == QtCore.Qt.Key_PageUp: # if isinstance(event, QtGui.QKeyEvent):
Receiver.send_message(u'slidecontroller_live_first') # # Here accept the event and do something
event.accept() # if event.key() == QtCore.Qt.Key_Up:
elif event.key() == QtCore.Qt.Key_PageDown: # Receiver.send_message(u'slidecontroller_live_previous')
Receiver.send_message(u'slidecontroller_live_last') # event.accept()
event.accept() # elif event.key() == QtCore.Qt.Key_Down:
elif event.key() in self.hotkey_map: # Receiver.send_message(u'slidecontroller_live_next')
Receiver.send_message(self.hotkey_map[event.key()]) # event.accept()
event.accept() # elif event.key() == QtCore.Qt.Key_PageUp:
elif event.key() == QtCore.Qt.Key_Escape: # Receiver.send_message(u'slidecontroller_live_first')
self.setVisible(False) # event.accept()
self.videoStop() # elif event.key() == QtCore.Qt.Key_PageDown:
event.accept() # Receiver.send_message(u'slidecontroller_live_last')
event.ignore() # event.accept()
else: # elif event.key() in self.hotkey_map:
event.ignore() # 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): class MainDisplay(DisplayWidget):
""" """
@ -110,6 +111,12 @@ class MainDisplay(DisplayWidget):
QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay) 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): def setup(self):
""" """

View File

@ -671,7 +671,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
if savedPlugin != -1: if savedPlugin != -1:
self.MediaToolBox.setCurrentIndex(savedPlugin) self.MediaToolBox.setCurrentIndex(savedPlugin)
self.settingsForm.postSetUp() self.settingsForm.postSetUp()
def setAutoLanguage(self, value): def setAutoLanguage(self, value):
self.LanguageGroup.setDisabled(value) self.LanguageGroup.setDisabled(value)
LanguageManager.auto_language = value LanguageManager.auto_language = value

View File

@ -47,33 +47,33 @@ class ServiceManagerList(QtGui.QTreeWidget):
QtGui.QTreeWidget.__init__(self, parent) QtGui.QTreeWidget.__init__(self, parent)
self.parent = parent self.parent = parent
def keyPressEvent(self, event): # def keyPressEvent(self, event):
if isinstance(event, QtGui.QKeyEvent): # if isinstance(event, QtGui.QKeyEvent):
#here accept the event and do something # #here accept the event and do something
if event.key() == QtCore.Qt.Key_Enter: # if event.key() == QtCore.Qt.Key_Enter:
self.parent.makeLive() # self.parent.makeLive()
event.accept() # event.accept()
elif event.key() == QtCore.Qt.Key_Home: # elif event.key() == QtCore.Qt.Key_Home:
self.parent.onServiceTop() # self.parent.onServiceTop()
event.accept() # event.accept()
elif event.key() == QtCore.Qt.Key_End: # elif event.key() == QtCore.Qt.Key_End:
self.parent.onServiceEnd() # self.parent.onServiceEnd()
event.accept() # event.accept()
elif event.key() == QtCore.Qt.Key_PageUp: # elif event.key() == QtCore.Qt.Key_PageUp:
self.parent.onServiceUp() # self.parent.onServiceUp()
event.accept() # event.accept()
elif event.key() == QtCore.Qt.Key_PageDown: # elif event.key() == QtCore.Qt.Key_PageDown:
self.parent.onServiceDown() # self.parent.onServiceDown()
event.accept() # event.accept()
elif event.key() == QtCore.Qt.Key_Up: # elif event.key() == QtCore.Qt.Key_Up:
self.parent.onMoveSelectionUp() # self.parent.onMoveSelectionUp()
event.accept() # event.accept()
elif event.key() == QtCore.Qt.Key_Down: # elif event.key() == QtCore.Qt.Key_Down:
self.parent.onMoveSelectionDown() # self.parent.onMoveSelectionDown()
event.accept() # event.accept()
event.ignore() # event.ignore()
else: # else:
event.ignore() # event.ignore()
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
""" """
@ -281,6 +281,29 @@ class ServiceManager(QtGui.QWidget):
translate('OpenLP.ServiceManager', '&Change Item Theme')) translate('OpenLP.ServiceManager', '&Change Item Theme'))
self.menu.addMenu(self.themeMenu) self.menu.addMenu(self.themeMenu)
self.configUpdated(True) 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): def configUpdated(self, firstTime=False):
""" """

View File

@ -39,7 +39,7 @@ class Ui_ShortcutListDialog(object):
self.shortcutListTreeWidget = QtGui.QTreeWidget(shortcutListDialog) self.shortcutListTreeWidget = QtGui.QTreeWidget(shortcutListDialog)
self.shortcutListTreeWidget.setAlternatingRowColors(True) self.shortcutListTreeWidget.setAlternatingRowColors(True)
self.shortcutListTreeWidget.setObjectName(u'shortcutListTreeWidget') self.shortcutListTreeWidget.setObjectName(u'shortcutListTreeWidget')
self.shortcutListTreeWidget.setColumnCount(2) self.shortcutListTreeWidget.setColumnCount(3)
self.shortcutListTreeWidget.setSelectionBehavior( self.shortcutListTreeWidget.setSelectionBehavior(
QtGui.QAbstractItemView.SelectRows) QtGui.QAbstractItemView.SelectRows)
self.shortcutListLayout.addWidget(self.shortcutListTreeWidget) self.shortcutListLayout.addWidget(self.shortcutListTreeWidget)
@ -103,7 +103,8 @@ class Ui_ShortcutListDialog(object):
translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts')) translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts'))
self.shortcutListTreeWidget.setHeaderLabels([ self.shortcutListTreeWidget.setHeaderLabels([
translate('OpenLP.ShortcutListDialog', 'Action'), translate('OpenLP.ShortcutListDialog', 'Action'),
translate('OpenLP.ShortcutListDialog', 'Shortcut') translate('OpenLP.ShortcutListDialog', 'Shortcut'),
translate('OpenLP.ShortcutListDialog', 'Alternative')
]) ])
self.defaultRadioButton.setText( self.defaultRadioButton.setText(
translate('OpenLP.ShortcutListDialog', 'Default: %s')) translate('OpenLP.ShortcutListDialog', 'Default: %s'))

View File

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

View File

@ -44,34 +44,44 @@ class SlideList(QtGui.QTableWidget):
def __init__(self, parent=None, name=None): def __init__(self, parent=None, name=None):
QtGui.QTableWidget.__init__(self, parent.Controller) QtGui.QTableWidget.__init__(self, parent.Controller)
self.parent = parent self.parent = parent
self.hotkeyMap = { # if self.parent.isLive:
QtCore.Qt.Key_Return: 'servicemanager_next_item', # self.addAction(self.parent.next_item)
QtCore.Qt.Key_Space: 'slidecontroller_live_next_noloop', # self.addAction(self.parent.previous_item)
QtCore.Qt.Key_Enter: 'slidecontroller_live_next_noloop', # self.addAction(self.parent.previous_service)
QtCore.Qt.Key_0: 'servicemanager_next_item', # self.addAction(self.parent.next_service)
QtCore.Qt.Key_Backspace: 'slidecontroller_live_previous_noloop'} # 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): # def keyPressEvent(self, event):
if isinstance(event, QtGui.QKeyEvent): # if isinstance(event, QtGui.QKeyEvent):
#here accept the event and do something # #here accept the event and do something
if event.key() == QtCore.Qt.Key_Up: # if event.key() == QtCore.Qt.Key_Up:
self.parent.onSlideSelectedPrevious() # self.parent.onSlideSelectedPrevious()
event.accept() # event.accept()
elif event.key() == QtCore.Qt.Key_Down: # elif event.key() == QtCore.Qt.Key_Down:
self.parent.onSlideSelectedNext() # self.parent.onSlideSelectedNext()
event.accept() # event.accept()
elif event.key() == QtCore.Qt.Key_PageUp: # elif event.key() == QtCore.Qt.Key_PageUp:
self.parent.onSlideSelectedFirst() # self.parent.onSlideSelectedFirst()
event.accept() # event.accept()
elif event.key() == QtCore.Qt.Key_PageDown: # elif event.key() == QtCore.Qt.Key_PageDown:
self.parent.onSlideSelectedLast() # self.parent.onSlideSelectedLast()
event.accept() # event.accept()
elif event.key() in self.hotkeyMap and self.parent.isLive: # elif event.key() in self.hotkeyMap and self.parent.isLive:
Receiver.send_message(self.hotkeyMap[event.key()]) # Receiver.send_message(self.hotkeyMap[event.key()])
event.accept() # event.accept()
event.ignore() # event.ignore()
else: # else:
event.ignore() # event.ignore()
class SlideController(QtGui.QWidget): class SlideController(QtGui.QWidget):
""" """
@ -87,6 +97,8 @@ class SlideController(QtGui.QWidget):
self.isLive = isLive self.isLive = isLive
self.parent = parent self.parent = parent
self.screens = screens self.screens = screens
# self.setPreviewHotkeys(self)
# self.setLiveHotkeys(self)
self.ratio = float(self.screens.current[u'size'].width()) / \ self.ratio = float(self.screens.current[u'size'].width()) / \
float(self.screens.current[u'size'].height()) float(self.screens.current[u'size'].height())
self.display = MainDisplay(self, screens, isLive) self.display = MainDisplay(self, screens, isLive)
@ -343,6 +355,21 @@ class SlideController(QtGui.QWidget):
else: else:
self.Toolbar.makeWidgetsInvisible(self.songEditList) self.Toolbar.makeWidgetsInvisible(self.songEditList)
self.Mediabar.setVisible(False) 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.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix), QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix),
self.onStopLoop) self.onStopLoop)
@ -392,6 +419,76 @@ class SlideController(QtGui.QWidget):
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_active'), self.updatePreview) 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): def screenSizeChanged(self):
""" """
Settings dialog has changed the screen size of adjust output and Settings dialog has changed the screen size of adjust output and
@ -408,6 +505,10 @@ class SlideController(QtGui.QWidget):
self.SlidePreview.setFixedSize( self.SlidePreview.setFixedSize(
QtCore.QSize(self.settingsmanager.slidecontroller_image, QtCore.QSize(self.settingsmanager.slidecontroller_image,
self.settingsmanager.slidecontroller_image / self.ratio)) 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): def widthChanged(self):
""" """
@ -859,7 +960,7 @@ class SlideController(QtGui.QWidget):
if loop: if loop:
row = 0 row = 0
else: else:
Receiver.send_message('servicemanager_next_item') #Receiver.send_message('servicemanager_next_item')
return return
if row + 1 < self.PreviewListWidget.rowCount(): if row + 1 < self.PreviewListWidget.rowCount():
self.PreviewListWidget.scrollToItem( self.PreviewListWidget.scrollToItem(