next steps

This commit is contained in:
rimach 2010-12-08 22:03:25 +01:00
parent 5a5d03a7bd
commit 653f1e8ea6
6 changed files with 358 additions and 208 deletions

View File

@ -37,7 +37,7 @@ from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \
Receiver, build_icon, ItemCapabilities, SettingsManager, translate, \
ThemeLevel
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm
from openlp.core.utils import AppLocation
from openlp.core.utils import AppLocation, ActionConfig
class ServiceManagerList(QtGui.QTreeWidget):
"""
@ -47,34 +47,6 @@ 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 mouseMoveEvent(self, event):
"""
Drag and drop event does not care what data is selected
@ -282,28 +254,65 @@ class ServiceManager(QtGui.QWidget):
self.menu.addMenu(self.themeMenu)
self.configUpdated(True)
self.setServiceHotkeys(self.serviceManagerList)
self.serviceManagerList.addAction(self.serviceManagerList.move_down)
self.serviceManagerList.addActions([self.serviceManagerList.move_down,
self.serviceManagerList.move_up,
self.serviceManagerList.enter,
self.serviceManagerList.home,
self.serviceManagerList.end,
self.serviceManagerList.up,
self.serviceManagerList.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,
u'Move_down', parent)
ActionConfig.set(self.serviceManagerList.move_down,
widget, u'Move_down',
u'Service Settings', self.onServiceDown,
QtCore.Qt.Key_PageDown)
self.serviceManagerList.move_up = \
QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
u'Move_up', parent)
ActionConfig.set(self.serviceManagerList.move_up,
widget, u'Move_up',
u'Service Settings', self.onServiceUp,
QtCore.Qt.Key_PageUp)
self.serviceManagerList.enter = \
QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
u'Make Live', parent)
ActionConfig.set(self.serviceManagerList.enter,
widget, u'Make Live',
u'Service Settings', self.makeLive,
QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return)
self.serviceManagerList.home = \
QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
u'Home', parent)
ActionConfig.set(self.serviceManagerList.home,
widget, u'Home',
u'Service Settings', self.onServiceTop,
QtCore.Qt.Key_Home)
self.serviceManagerList.end = \
QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
u'End', parent)
ActionConfig.set(self.serviceManagerList.end,
widget, u'End',
u'Service Settings', self.onServiceEnd,
QtCore.Qt.Key_End)
self.serviceManagerList.up = \
QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
u'Move Selection up', parent)
ActionConfig.set(self.serviceManagerList.up,
widget, u'Move Selection up',
u'Service Settings', self.onMoveSelectionUp,
QtCore.Qt.Key_Up)
self.serviceManagerList.down = \
QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
u'Move Selection down', parent)
ActionConfig.set(self.serviceManagerList.down,
widget, u'Move Selection down',
u'Service Settings', self.onMoveSelectionDown,
QtCore.Qt.Key_Down)
def configUpdated(self, firstTime=False):
"""

View File

@ -113,3 +113,81 @@ class Ui_ShortcutListDialog(object):
self.shortcutPushButton.setText(
translate('OpenLP.ShortcutListDialog', 'None'))
class Ui_ShortcutDialog(object):
def setupUi(self, ShortcutDialog):
ShortcutDialog.setObjectName(u'ShortcutDialog')
ShortcutDialog.resize(539, 125)
self.vboxlayout = QtGui.QVBoxLayout(ShortcutDialog)
self.vboxlayout.setObjectName(u'vboxlayout')
self.shortcutsGroup = QtGui.QGroupBox(ShortcutDialog)
self.shortcutsGroup.setTitle(u'')
self.shortcutsGroup.setObjectName(u'shortcutsGroup')
self.gridlayout = QtGui.QGridLayout(self.shortcutsGroup)
self.gridlayout.setObjectName(u'gridlayout')
self.alternateButton = QtGui.QRadioButton(self.shortcutsGroup)
self.alternateButton.setFocusPolicy(QtCore.Qt.NoFocus)
self.alternateButton.setObjectName(u'alternateButton')
self.gridlayout.addWidget(self.alternateButton, 1, 0, 1, 1)
self.primaryClearButton = QtGui.QPushButton(self.shortcutsGroup)
self.primaryClearButton.setFocusPolicy(QtCore.Qt.NoFocus)
self.primaryClearButton.setObjectName(u'primaryClearButton')
self.gridlayout.addWidget(self.primaryClearButton, 0, 1, 1, 1)
self.alternateKeyLabel = QtGui.QLabel(self.shortcutsGroup)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.alternateKeyLabel.sizePolicy().hasHeightForWidth())
self.alternateKeyLabel.setSizePolicy(sizePolicy)
self.alternateKeyLabel.setToolTip(u'')
self.alternateKeyLabel.setFrameShape(QtGui.QFrame.StyledPanel)
self.alternateKeyLabel.setFrameShadow(QtGui.QFrame.Sunken)
self.alternateKeyLabel.setText(u'')
self.alternateKeyLabel.setObjectName(u'alternateKeyLabel')
self.gridlayout.addWidget(self.alternateKeyLabel, 1, 2, 1, 1)
self.keyLabel = QtGui.QLabel(self.shortcutsGroup)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.keyLabel.sizePolicy().hasHeightForWidth())
self.keyLabel.setSizePolicy(sizePolicy)
self.keyLabel.setToolTip(u'')
self.keyLabel.setFrameShape(QtGui.QFrame.StyledPanel)
self.keyLabel.setFrameShadow(QtGui.QFrame.Sunken)
self.keyLabel.setText(u'')
self.keyLabel.setObjectName(u'keyLabel')
self.gridlayout.addWidget(self.keyLabel, 0, 2, 1, 1)
self.primaryButton = QtGui.QRadioButton(self.shortcutsGroup)
self.primaryButton.setFocusPolicy(QtCore.Qt.NoFocus)
self.primaryButton.setChecked(True)
self.primaryButton.setObjectName(u'primaryButton')
self.gridlayout.addWidget(self.primaryButton, 0, 0, 1, 1)
self.alternateClearButton = QtGui.QPushButton(self.shortcutsGroup)
self.alternateClearButton.setEnabled(False)
self.alternateClearButton.setFocusPolicy(QtCore.Qt.NoFocus)
self.alternateClearButton.setObjectName(u'alternateClearButton')
self.gridlayout.addWidget(self.alternateClearButton, 1, 1, 1, 1)
self.vboxlayout.addWidget(self.shortcutsGroup)
self.buttonBox = QtGui.QDialogButtonBox(ShortcutDialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(u'buttonBox')
self.vboxlayout.addWidget(self.buttonBox)
self.retranslateUi(ShortcutDialog)
QtCore.QObject.connect(self.primaryButton, QtCore.SIGNAL(u'toggled(bool)'), self.primaryClearButton.setEnabled)
QtCore.QObject.connect(self.alternateButton, QtCore.SIGNAL(u'toggled(bool)'), self.alternateClearButton.setEnabled)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), ShortcutDialog.reject)
QtCore.QMetaObject.connectSlotsByName(ShortcutDialog)
def retranslateUi(self, ShortcutDialog):
ShortcutDialog.setWindowTitle(QtGui.QApplication.translate("ShortcutDialog", "Edit Shortcut", None, QtGui.QApplication.UnicodeUTF8))
ShortcutDialog.setWhatsThis(QtGui.QApplication.translate("ShortcutDialog", "Press your shortcut keys and select OK", None, QtGui.QApplication.UnicodeUTF8))
self.alternateButton.setToolTip(QtGui.QApplication.translate("ShortcutDialog", "Select to change the alternative keyboard shortcut", None, QtGui.QApplication.UnicodeUTF8))
self.alternateButton.setText(QtGui.QApplication.translate("ShortcutDialog", "Alternative Shortcut:", None, QtGui.QApplication.UnicodeUTF8))
self.primaryClearButton.setToolTip(QtGui.QApplication.translate("ShortcutDialog", "Press to clear the key sequence buffer.", None, QtGui.QApplication.UnicodeUTF8))
self.primaryClearButton.setText(QtGui.QApplication.translate("ShortcutDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))
self.primaryButton.setToolTip(QtGui.QApplication.translate("ShortcutDialog", "Select to change the primary keyboard shortcut", None, QtGui.QApplication.UnicodeUTF8))
self.primaryButton.setText(QtGui.QApplication.translate("ShortcutDialog", "Primary Shortcut:", None, QtGui.QApplication.UnicodeUTF8))
self.alternateClearButton.setToolTip(QtGui.QApplication.translate("ShortcutDialog", "Press to clear the key sequence buffer.", None, QtGui.QApplication.UnicodeUTF8))
self.alternateClearButton.setText(QtGui.QApplication.translate("ShortcutDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -30,7 +30,7 @@ import re
from PyQt4 import QtCore, QtGui
from openlp.core.utils import translate
from shortcutlistdialog import Ui_ShortcutListDialog
from shortcutlistdialog import Ui_ShortcutListDialog, Ui_ShortcutDialog
REMOVE_AMPERSAND = re.compile(r'&{1}')
@ -58,42 +58,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
)
self.shortcutListTreeWidget.itemDoubleClicked.connect(self.shortcutEdit)
def keyReleaseEvent(self, event):
Qt = QtCore.Qt
if not self.captureShortcut:
return
key = event.key()
if key == Qt.Key_Shift or key == Qt.Key_Control or \
key == Qt.Key_Meta or key == Qt.Key_Alt:
return
key_string = QtGui.QKeySequence(key).toString()
if event.modifiers() & Qt.ControlModifier == Qt.ControlModifier:
key_string = u'Ctrl+' + key_string
if event.modifiers() & Qt.AltModifier == Qt.AltModifier:
key_string = u'Alt+' + key_string
if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier:
key_string = u'Shift+' + key_string
key_sequence = QtGui.QKeySequence(key_string)
existing_key = QtGui.QKeySequence("Ctrl+Shift+F8")
if key_sequence == existing_key:
QtGui.QMessageBox.warning(
self,
translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'),
unicode(translate('OpenLP.ShortcutListDialog', 'The shortcut '
'"%s" is already assigned to another action, please '
'use a different shortcut.')) % key_sequence.toString(),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
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 setNewShortcut(self, shortcut, alternate):
if self.currentItem:
self.actionList[self.currentItem].setShortcuts([shortcut, alternate])
self.shortcutListTreeWidget.currentItem().setText(1, shortcut.toString())
self.shortcutListTreeWidget.currentItem().setText(2, alternate.toString())
def exec_(self, parent):
self.actionList = parent.findChildren(QtGui.QAction)
@ -119,45 +88,175 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
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 = QtGui.QTreeWidgetItem([actionText, shortcutText, shortcutAlternate], 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
for key in sorted(catItemDict.iterkeys()):
self.shortcutListTreeWidget.addTopLevelItem(catItemDict[key])
self.shortcutListTreeWidget.expandItem(catItemDict[key])
self.shortcutListTreeWidget.sortItems(0, QtCore.Qt.AscendingOrder)
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
dialog = ShortcutDialog(self, u'Press new Shortcut', item.text(1), item.text(2))
dialog.show()
#self.shortcutListTreeWidget.currentItem().setText(column, u'Press new Shortcut')
#self.captureShortcut = True
class ShortcutDialog(QtGui.QDialog, Ui_ShortcutDialog):
"""
Class implementing a dialog for the configuration of a keyboard shortcut.
"""
def __init__(self, parent = None, name = None, key=0, alternate=0):
"""
Constructor
@param parent The parent widget of this dialog. (QWidget)
@param name The name of this dialog. (QString)
@param modal Flag indicating a modal dialog. (boolean)
"""
QtGui.QDialog.__init__(self, parent)
self.parent = parent
if name:
self.setObjectName(name)
self.setupUi(self)
self.setKeys(key, alternate)
self.keyIndex = 0
self.keys = [0, 0, 0, 0]
self.noCheck = False
self.objectType = None
self.connect(self.primaryClearButton, QtCore.SIGNAL("clicked()"), self.__clear)
self.connect(self.alternateClearButton, QtCore.SIGNAL("clicked()"), self.__clear)
self.connect(self.primaryButton, QtCore.SIGNAL("clicked()"), self.__typeChanged)
self.connect(self.alternateButton, QtCore.SIGNAL("clicked()"), self.__typeChanged)
self.shortcutsGroup.installEventFilter(self)
self.primaryButton.installEventFilter(self)
self.alternateButton.installEventFilter(self)
self.primaryClearButton.installEventFilter(self)
self.alternateClearButton.installEventFilter(self)
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).installEventFilter(self)
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).installEventFilter(self)
def setKeys(self, key, alternateKey, noCheck=None, objectType=None):
"""
Public method to set the key to be configured.
@param key key sequence to be changed (QKeySequence)
@param alternateKey alternate key sequence to be changed (QKeySequence)
@param noCheck flag indicating that no uniqueness check should
be performed (boolean)
@param objectType type of the object (string).
"""
self.keyIndex = 0
self.keys = [0, 0, 0, 0]
self.keyLabel.setText(QtCore.QString(key))
self.alternateKeyLabel.setText(QtCore.QString(alternateKey))
self.primaryButton.setChecked(True)
self.noCheck = noCheck
self.objectType = objectType
def on_buttonBox_accepted(self):
"""
Private slot to handle the OK button press.
"""
self.parent.setNewShortcut(QtGui.QKeySequence(self.keyLabel.text()),
QtGui.QKeySequence(self.alternateKeyLabel.text()))#,
# self.noCheck, self.objectType)
self.close()
def __clear(self):
"""
Private slot to handle the Clear button press.
"""
self.keyIndex = 0
self.keys = [0, 0, 0, 0]
self.__setKeyLabelText("")
def __typeChanged(self):
"""
Private slot to handle the change of the shortcuts type.
"""
self.keyIndex = 0
self.keys = [0, 0, 0, 0]
def __setKeyLabelText(self, txt):
"""
Private method to set the text of a key label.
@param txt text to be set (QString)
"""
if self.primaryButton.isChecked():
self.keyLabel.setText(txt)
else:
self.alternateKeyLabel.setText(txt)
def eventFilter(self, watched, event):
"""
Method called to filter the event queue.
@param watched the QObject being watched
@param event the event that occurred
@return always False
"""
if event.type() == QtCore.QEvent.KeyPress:
self.keyPressEvent(event)
return True
return False
def keyPressEvent(self, evt):
"""
Private method to handle a key press event.
@param evt the key event (QKeyEvent)
"""
if evt.key() == QtCore.Qt.Key_Control:
return
if evt.key() == QtCore.Qt.Key_Meta:
return
if evt.key() == QtCore.Qt.Key_Shift:
return
if evt.key() == QtCore.Qt.Key_Alt:
return
if evt.key() == QtCore.Qt.Key_Menu:
return
if self.keyIndex == 4:
self.keyIndex = 0
self.keys = [0, 0, 0, 0]
if evt.key() == QtCore.Qt.Key_Backtab and evt.modifiers() & QtCore.Qt.ShiftModifier:
self.keys[self.keyIndex] = QtCore.Qt.Key_Tab
else:
self.keys[self.keyIndex] = evt.key()
if evt.modifiers() & QtCore.Qt.ShiftModifier:
self.keys[self.keyIndex] += QtCore.Qt.SHIFT
if evt.modifiers() & QtCore.Qt.ControlModifier:
self.keys[self.keyIndex] += QtCore.Qt.CTRL
if evt.modifiers() & QtCore.Qt.AltModifier:
self.keys[self.keyIndex] += QtCore.Qt.ALT
if evt.modifiers() & QtCore.Qt.MetaModifier:
self.keys[self.keyIndex] += QtCore.Qt.META
self.keyIndex += 1
if self.keyIndex == 1:
self.__setKeyLabelText(QtCore.QString(QtGui.QKeySequence(self.keys[0])))
elif self.keyIndex == 2:
self.__setKeyLabelText(QtCore.QString(QtGui.QKeySequence(self.keys[0], self.keys[1])))
elif self.keyIndex == 3:
self.__setKeyLabelText(QtCore.QString(QtGui.QKeySequence(self.keys[0], self.keys[1],
self.keys[2])))
elif self.keyIndex == 4:
self.__setKeyLabelText(QtCore.QString(QtGui.QKeySequence(self.keys[0], self.keys[1],
self.keys[2], self.keys[3])))

View File

@ -33,7 +33,7 @@ from PyQt4.phonon import Phonon
from openlp.core.ui import HideMode, MainDisplay
from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \
ItemCapabilities, translate
from openlp.core.utils import ActionConfig
log = logging.getLogger(__name__)
class SlideList(QtGui.QTableWidget):
@ -44,44 +44,6 @@ class SlideList(QtGui.QTableWidget):
def __init__(self, parent=None, name=None):
QtGui.QTableWidget.__init__(self, parent.Controller)
self.parent = parent
# 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()
class SlideController(QtGui.QWidget):
"""
@ -97,8 +59,6 @@ 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)
@ -357,19 +317,20 @@ class SlideController(QtGui.QWidget):
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)
self.PreviewListWidget.addActions([self.previous_item,
self.next_item,
self.previous_service,
self.next_service,
self.escape_item])
self.display.addActions([self.previous_item,
self.next_item,
self.previous_service,
self.next_service,
self.escape_item])
else:
self.setPreviewHotkeys()#self.PreviewListWidget)
self.PreviewListWidget.addAction(self.preview_next_item)
self.PreviewListWidget.addAction(self.preview_previous_item)
self.setPreviewHotkeys()
self.PreviewListWidget.addActions([self.preview_next_item,
self.preview_previous_item])
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix),
self.onStopLoop)
@ -419,65 +380,50 @@ 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)
ActionConfig.set(self.preview_previous_item, widget, u'previous_item',
u'Preview Settings', self.onSlideSelectedPrevious, 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)
ActionConfig.set(self.preview_next_item, widget, u'next_item',
u'Preview Settings', self.onSlideSelectedNext, 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)
ActionConfig.set(self.next_item, widget, u'next_item',
u'Live View Settings', self.onSlideSelectedNext,
QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown,
context=QtCore.Qt.WidgetWithChildrenShortcut)
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)
ActionConfig.set(parent.previous_service, widget, u'previous_service',
u'Live View Settings', self.servicePrevious,
QtCore.Qt.Key_Left,
context=QtCore.Qt.WidgetWithChildrenShortcut)
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)
ActionConfig.set(self.next_service, widget, u'next_service',
u'Live View Settings', self.serviceNext,
QtCore.Qt.Key_Right,
context=QtCore.Qt.WidgetWithChildrenShortcut)
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)
ActionConfig.set(self.previous_item, widget, u'previous_item',
u'Live View Settings', self.onSlideSelectedPrevious,
QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp,
context=QtCore.Qt.WidgetWithChildrenShortcut)
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()
ActionConfig.set(self.escape_item, widget, u'escape_item',
u'Live View Settings', self.liveEscape,
QtCore.Qt.Key_Escape,
context=QtCore.Qt.WidgetWithChildrenShortcut)
def liveEscape(self):
self.display.setVisible(False)
self.display.videoStop()
@ -507,8 +453,10 @@ class SlideController(QtGui.QWidget):
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])
self.next_item,
self.previous_service,
self.next_service,
self.escape_item])
def widthChanged(self):
"""

View File

@ -276,7 +276,7 @@ def get_images_filter():
return images_filter
from languagemanager import LanguageManager
from actions import ActionList
from actions import ActionList, ActionConfig
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions',
u'get_filesystem_encoding', u'LanguageManager', u'ActionList']

View File

@ -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):
"""
@ -182,3 +183,18 @@ class ActionList(object):
self.categories[category].actions.append(action)
else:
self.categories[category].actions.add(action, weight)
class ActionConfig(object):
"""
Helper for configuration of OpenLP Shortcut actions
"""
@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)