openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #05604
[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)
For more details, see:
https://code.launchpad.net/~crichter/openlp/shortcut-dialog/+merge/46398
Next try for changing the key events into action and adding to action list
--
https://code.launchpad.net/~crichter/openlp/shortcut-dialog/+merge/46398
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 2011-01-14 18:58:47 +0000
+++ openlp/core/ui/maindisplay.py 2011-01-15 23:09:57 +0000
@@ -54,45 +54,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):
"""
@@ -116,6 +117,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 retranslateUi(self):
"""
=== 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-15 23:09:57 +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,73 @@
translate('OpenLP.ServiceManager', '&Change Item Theme'))
self.menu.addMenu(self.themeMenu)
self.configUpdated(True)
+ self.setServiceHotkeys(self.serviceManagerList)
+ 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 setServiceHotkeys(self, parent=None):
+ widget = self
+ self.serviceManagerList.move_down = \
+ QtGui.QAction(QtGui.QIcon(u':/services/service_down.png'),
+ u'Move_down', parent)
+ ActionList.set(self.serviceManagerList.move_down,
+ widget, u'Move_down',
+ u'Service Settings', self.onServiceDown,
+ QtCore.Qt.Key_PageDown)
+ self.mainwindow.actionList.add_action(self.serviceManagerList.move_down, u'Service')
+ self.serviceManagerList.move_up = \
+ QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+ u'Move_up', parent)
+ ActionList.set(self.serviceManagerList.move_up,
+ widget, u'Move_up',
+ u'Service Settings', self.onServiceUp,
+ QtCore.Qt.Key_PageUp)
+ self.mainwindow.actionList.add_action(self.serviceManagerList.move_up, u'Service')
+ self.serviceManagerList.enter = \
+ QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
+ u'Make Live', parent)
+ ActionList.set(self.serviceManagerList.enter,
+ widget, u'Make Live',
+ u'Service Settings', 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,
+ widget, u'Home',
+ u'Service Settings', 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,
+ widget, u'End',
+ u'Service Settings', 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,
+ widget, u'Move Selection up',
+ u'Service Settings', 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,
+ widget, u'Move Selection down',
+ u'Service Settings', 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/shortcutlistdialog.py'
--- openlp/core/ui/shortcutlistdialog.py 2011-01-03 11:25:30 +0000
+++ openlp/core/ui/shortcutlistdialog.py 2011-01-15 23:09:57 +0000
@@ -85,3 +85,82 @@
translate('OpenLP.ShortcutListDialog', 'Custom:'))
self.shortcutButton.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))
+
=== 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-15 23:09:57 +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,22 @@
self.onGoLiveClick)
self.Toolbar.makeWidgetsInvisible(self.songEditList)
self.Mediabar.setVisible(False)
+ if self.isLive:
+ self.setLiveHotkeys(self)
+ 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.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)
@@ -381,6 +370,66 @@
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged)
+ def setPreviewHotkeys(self, parent=None):
+ widget = self
+ self.preview_previous_item = QtGui.QAction(u'previous_item', parent)
+ ActionList.set(self.preview_previous_item, widget, u'previous_item',
+ u'Preview Settings', self.onSlideSelectedPrevious, QtCore.Qt.Key_Up)
+ self.parent.actionList.add_action(self.preview_previous_item, u'Preview')
+
+ self.preview_next_item = QtGui.QAction(u'next_item', parent)
+ ActionList.set(self.preview_next_item, widget, u'next_item',
+ u'Preview Settings', self.onSlideSelectedNext, QtCore.Qt.Key_Down)
+ self.parent.actionList.add_action(self.preview_next_item, u'Preview')
+
+ def setLiveHotkeys(self, parent=None):
+ widget = self
+ self.next_item = QtGui.QAction(u'next_item', parent)
+ ActionList.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)
+ self.parent.actionList.add_action(self.next_item, u'Live View Settings')
+
+ parent.previous_service = QtGui.QAction(u'previous_service', parent)
+ ActionList.set(parent.previous_service, widget, u'previous_service',
+ u'Live View Settings', self.servicePrevious,
+ QtCore.Qt.Key_Left,
+ context=QtCore.Qt.WidgetWithChildrenShortcut)
+ self.parent.actionList.add_action(self.previous_service, u'Live View Settings')
+
+ self.next_service = QtGui.QAction(u'next_service', parent)
+ ActionList.set(self.next_service, widget, u'next_service',
+ u'Live View Settings', self.serviceNext,
+ QtCore.Qt.Key_Right,
+ context=QtCore.Qt.WidgetWithChildrenShortcut)
+ self.parent.actionList.add_action(self.next_service, u'Live View Settings')
+
+ self.previous_item = QtGui.QAction(u'previous_item', parent)
+ ActionList.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.parent.actionList.add_action(self.previous_item, u'Live View Settings')
+
+ self.escape_item = QtGui.QAction(u'escape_item', parent)
+ ActionList.set(self.escape_item, widget, u'escape_item',
+ u'Live View Settings', self.liveEscape,
+ QtCore.Qt.Key_Escape,
+ context=QtCore.Qt.WidgetWithChildrenShortcut)
+ self.parent.actionList.add_action(self.escape_item, 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 +440,15 @@
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.previous_item,
+ self.next_item,
+ self.previous_service,
+ self.next_service,
+ self.escape_item])
# The SlidePreview's ratio.
self.ratio = float(self.screens.current[u'size'].width()) / \
float(self.screens.current[u'size'].height())
@@ -880,7 +938,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(
=== 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-15 23:09:57 +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,14 @@
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, 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)
Follow ups