forked from openlp/openlp
correct icons, use existant actions
This commit is contained in:
parent
4144f9b6a1
commit
d052098287
@ -51,7 +51,8 @@ class OpenLPToolbar(QtGui.QToolBar):
|
||||
log.debug(u'Init done')
|
||||
|
||||
def addToolbarButton(self, title, icon, tooltip=None, slot=None,
|
||||
checkable=False):
|
||||
checkable=False, shortcut=0, alternate=0,
|
||||
context=QtCore.Qt.WidgetShortcut):
|
||||
"""
|
||||
A method to help developers easily add a button to the toolbar.
|
||||
|
||||
@ -71,6 +72,15 @@ class OpenLPToolbar(QtGui.QToolBar):
|
||||
|
||||
``objectname``
|
||||
The name of the object, as used in `<button>.setObjectName()`.
|
||||
|
||||
``shortcut``
|
||||
The primary shortcut for this action
|
||||
|
||||
``alternate``
|
||||
The alternate shortcut for this action
|
||||
|
||||
``context``
|
||||
Specify the context in which this shortcut is valid
|
||||
"""
|
||||
newAction = None
|
||||
if icon:
|
||||
@ -92,6 +102,8 @@ class OpenLPToolbar(QtGui.QToolBar):
|
||||
QtCore.QObject.connect(newAction,
|
||||
QtCore.SIGNAL(u'toggled(bool)'), slot)
|
||||
self.actions[title] = newAction
|
||||
newAction.setShortcuts([shortcut, alternate])
|
||||
newAction.setShortcutContext(context)
|
||||
return newAction
|
||||
|
||||
def addToolbarSeparator(self, handle):
|
||||
|
@ -39,7 +39,7 @@ from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \
|
||||
from openlp.core.ui import criticalErrorMessageBox, ServiceNoteForm, \
|
||||
ServiceItemEditForm
|
||||
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
|
||||
split_filename, ActionList
|
||||
split_filename
|
||||
|
||||
class ServiceManagerList(QtGui.QTreeWidget):
|
||||
"""
|
||||
@ -150,50 +150,72 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.layout.addWidget(self.serviceManagerList)
|
||||
# Add the bottom toolbar
|
||||
self.orderToolbar = OpenLPToolbar(self)
|
||||
self.orderToolbar.addToolbarButton(
|
||||
self.serviceManagerList.moveTop = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', 'Move to &top'),
|
||||
u':/services/service_top.png',
|
||||
translate('OpenLP.ServiceManager',
|
||||
'Move item to the top of the service.'),
|
||||
self.onServiceTop)
|
||||
self.orderToolbar.addToolbarButton(
|
||||
self.onServiceTop, shortcut=QtCore.Qt.Key_Home)
|
||||
self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', 'Move &up'),
|
||||
u':/services/service_up.png',
|
||||
translate('OpenLP.ServiceManager',
|
||||
'Move item up one position in the service.'),
|
||||
self.onServiceUp)
|
||||
self.orderToolbar.addToolbarButton(
|
||||
self.onServiceUp, shortcut=QtCore.Qt.Key_PageUp)
|
||||
self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', 'Move &down'),
|
||||
u':/services/service_down.png',
|
||||
translate('OpenLP.ServiceManager',
|
||||
'Move item down one position in the service.'),
|
||||
self.onServiceDown)
|
||||
self.orderToolbar.addToolbarButton(
|
||||
self.onServiceDown, shortcut=QtCore.Qt.Key_PageDown)
|
||||
self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', 'Move to &bottom'),
|
||||
u':/services/service_bottom.png',
|
||||
translate('OpenLP.ServiceManager',
|
||||
'Move item to the end of the service.'),
|
||||
self.onServiceEnd)
|
||||
self.onServiceEnd, shortcut=QtCore.Qt.Key_End)
|
||||
self.serviceManagerList.down = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', 'Move &down'),
|
||||
None,
|
||||
translate('OpenLP.ServiceManager',
|
||||
'Moves the selection up the window.'),
|
||||
self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Up)
|
||||
self.serviceManagerList.down.setVisible(False)
|
||||
self.serviceManagerList.up = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', 'Move up'),
|
||||
None,
|
||||
translate('OpenLP.ServiceManager',
|
||||
'Moves the selection up the window.'),
|
||||
self.onMoveSelectionUp, shortcut=QtCore.Qt.Key_Up)
|
||||
self.serviceManagerList.up.setVisible(False)
|
||||
self.orderToolbar.addSeparator()
|
||||
self.orderToolbar.addToolbarButton(
|
||||
self.serviceManagerList.delete = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', '&Delete From Service'),
|
||||
u':/general/general_delete.png',
|
||||
translate('OpenLP.ServiceManager',
|
||||
'Delete the selected item from the service.'),
|
||||
self.onDeleteFromService)
|
||||
self.orderToolbar.addSeparator()
|
||||
self.orderToolbar.addToolbarButton(
|
||||
self.serviceManagerList.expand = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', '&Expand all'),
|
||||
u':/services/service_expand_all.png',
|
||||
translate('OpenLP.ServiceManager',
|
||||
'Expand all the service items.'),
|
||||
self.onExpandAll)
|
||||
self.orderToolbar.addToolbarButton(
|
||||
self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', '&Collapse all'),
|
||||
u':/services/service_collapse_all.png',
|
||||
translate('OpenLP.ServiceManager',
|
||||
'Collapse all the service items.'),
|
||||
self.onCollapseAll)
|
||||
self.orderToolbar.addSeparator()
|
||||
self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', 'Go Live'),
|
||||
u':/general/general_live.png',
|
||||
translate('OpenLP.ServiceManager',
|
||||
'Send the selected item to Live.'),
|
||||
self.makeLive, shortcut=QtCore.Qt.Key_Enter,
|
||||
alternate=QtCore.Qt.Key_Return)
|
||||
self.orderToolbar.setObjectName(u'orderToolbar')
|
||||
self.layout.addWidget(self.orderToolbar)
|
||||
# Connect up our signals and slots
|
||||
@ -262,66 +284,26 @@ class ServiceManager(QtGui.QWidget):
|
||||
translate('OpenLP.ServiceManager', '&Change Item Theme'))
|
||||
self.menu.addMenu(self.themeMenu)
|
||||
self.configUpdated(True)
|
||||
self.setServiceHotkeys(self.serviceManagerList)
|
||||
self.setServiceHotkeys()
|
||||
self.serviceManagerList.addActions(
|
||||
[self.serviceManagerList.moveDown,
|
||||
self.serviceManagerList.moveUp,
|
||||
self.serviceManagerList.enter,
|
||||
self.serviceManagerList.home,
|
||||
self.serviceManagerList.end,
|
||||
self.serviceManagerList.up,
|
||||
self.serviceManagerList.down])
|
||||
[self.serviceManagerList.moveDown,
|
||||
self.serviceManagerList.moveUp,
|
||||
self.serviceManagerList.makeLive,
|
||||
self.serviceManagerList.moveTop,
|
||||
self.serviceManagerList.moveBottom,
|
||||
self.serviceManagerList.up,
|
||||
self.serviceManagerList.down
|
||||
])
|
||||
|
||||
def setServiceHotkeys(self, parent=None):
|
||||
self.serviceManagerList.moveDown = \
|
||||
QtGui.QAction(QtGui.QIcon(u':/services/service_down.png'),
|
||||
u'Move_down', parent)
|
||||
ActionList.set(self.serviceManagerList.moveDown, u'Move_down',
|
||||
self.onServiceDown, QtCore.Qt.Key_PageDown)
|
||||
self.mainwindow.actionList.add_action(
|
||||
self.serviceManagerList.moveDown, u'Service')
|
||||
self.serviceManagerList.moveUp = \
|
||||
QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
|
||||
u'Move_up', parent)
|
||||
ActionList.set(self.serviceManagerList.moveUp,
|
||||
u'Move_up', self.onServiceUp, QtCore.Qt.Key_PageUp)
|
||||
self.mainwindow.actionList.add_action(self.serviceManagerList.moveUp,
|
||||
u'Service')
|
||||
self.serviceManagerList.enter = \
|
||||
QtGui.QAction(QtGui.QIcon(u':/services/service_up.png'),
|
||||
u'Make Live', parent)
|
||||
ActionList.set(self.serviceManagerList.enter, u'Make Live',
|
||||
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, u'Home',
|
||||
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, u'End',
|
||||
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, u'Move Selection up',
|
||||
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, u'Move Selection down',
|
||||
self.onMoveSelectionDown, QtCore.Qt.Key_Down)
|
||||
self.mainwindow.actionList.add_action(self.serviceManagerList.down,
|
||||
u'Service')
|
||||
def setServiceHotkeys(self):
|
||||
actionList = self.mainwindow.actionList
|
||||
actionList.add_action(self.serviceManagerList.moveDown, u'Service')
|
||||
actionList.add_action(self.serviceManagerList.moveUp, u'Service')
|
||||
actionList.add_action(self.serviceManagerList.moveTop, u'Service')
|
||||
actionList.add_action(self.serviceManagerList.moveBottom, u'Service')
|
||||
actionList.add_action(self.serviceManagerList.makeLive, u'Service')
|
||||
actionList.add_action(self.serviceManagerList.up, u'Service')
|
||||
actionList.add_action(self.serviceManagerList.down, u'Service')
|
||||
|
||||
def setModified(self, modified=True):
|
||||
"""
|
||||
|
@ -135,12 +135,14 @@ class SlideController(QtGui.QWidget):
|
||||
sizeToolbarPolicy.setHeightForWidth(
|
||||
self.Toolbar.sizePolicy().hasHeightForWidth())
|
||||
self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
||||
self.Toolbar.addToolbarButton(
|
||||
u'Previous Slide', u':/slides/slide_previous.png',
|
||||
self.previousItem = self.Toolbar.addToolbarButton(
|
||||
translate('OpenLP.SlideController', 'Previous Slide'),
|
||||
u':/slides/slide_previous.png',
|
||||
translate('OpenLP.SlideController', 'Move to previous'),
|
||||
self.onSlideSelectedPrevious)
|
||||
self.Toolbar.addToolbarButton(
|
||||
u'Next Slide', u':/slides/slide_next.png',
|
||||
self.nextItem = self.Toolbar.addToolbarButton(
|
||||
translate('OpenLP.SlideController', 'Next Slide'),
|
||||
u':/slides/slide_next.png',
|
||||
translate('OpenLP.SlideController', 'Move to next'),
|
||||
self.onSlideSelectedNext)
|
||||
if self.isLive:
|
||||
@ -315,22 +317,22 @@ class SlideController(QtGui.QWidget):
|
||||
if self.isLive:
|
||||
self.setLiveHotkeys(self)
|
||||
self.PreviewListWidget.addActions(
|
||||
[self.previousItem,
|
||||
self.nextItem,
|
||||
self.previousService,
|
||||
self.nextService,
|
||||
[self.previousItem,
|
||||
self.nextItem,
|
||||
self.previousService,
|
||||
self.nextService,
|
||||
self.escapeItem])
|
||||
self.display.addActions(
|
||||
[self.previousItem,
|
||||
self.nextItem,
|
||||
self.previousService,
|
||||
self.nextService,
|
||||
[self.previousItem,
|
||||
self.nextItem,
|
||||
self.previousService,
|
||||
self.nextService,
|
||||
self.escapeItem])
|
||||
else:
|
||||
self.setPreviewHotkeys()
|
||||
self.PreviewListWidget.addActions(
|
||||
[self.previewNextItem,
|
||||
self.previewPreviousItem])
|
||||
[self.nextItem,
|
||||
self.previousItem])
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix),
|
||||
self.onStopLoop)
|
||||
@ -374,51 +376,47 @@ class SlideController(QtGui.QWidget):
|
||||
QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged)
|
||||
|
||||
def setPreviewHotkeys(self, parent=None):
|
||||
self.previewPreviousItem = QtGui.QAction(u'previous_item', parent)
|
||||
ActionList.set(self.previewPreviousItem, u'previous_item',
|
||||
self.onSlideSelectedPrevious, QtCore.Qt.Key_Up)
|
||||
self.parent.actionList.add_action(self.previewPreviousItem,
|
||||
u'Preview')
|
||||
self.previewNextItem = QtGui.QAction(u'next_item', parent)
|
||||
ActionList.set(self.previewNextItem, u'next_item',
|
||||
self.onSlideSelectedNext, QtCore.Qt.Key_Down)
|
||||
self.parent.actionList.add_action(self.previewNextItem, u'Preview')
|
||||
|
||||
actionList = self.parent.actionList
|
||||
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, 0])
|
||||
actionList.add_action(self.previousItem, u'Preview')
|
||||
self.nextItem.setShortcuts([QtCore.Qt.Key_Down, 0])
|
||||
actionList.add_action(self.nextItem, u'Preview')
|
||||
|
||||
def setLiveHotkeys(self, parent=None):
|
||||
self.nextItem = QtGui.QAction(u'next_item', parent)
|
||||
ActionList.set(self.nextItem, u'next_item', self.onSlideSelectedNext,
|
||||
QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown,
|
||||
context=QtCore.Qt.WidgetWithChildrenShortcut)
|
||||
self.parent.actionList.add_action(self.nextItem, u'Live View Settings')
|
||||
parent.previousService = QtGui.QAction(u'previous_service', parent)
|
||||
ActionList.set(parent.previousService, u'previous_service',
|
||||
self.servicePrevious, QtCore.Qt.Key_Left,
|
||||
context=QtCore.Qt.WidgetWithChildrenShortcut)
|
||||
self.parent.actionList.add_action(self.previousService,
|
||||
u'Live View Settings')
|
||||
self.nextService = QtGui.QAction(u'next_service', parent)
|
||||
ActionList.set(self.nextService, u'next_service',
|
||||
self.serviceNext, QtCore.Qt.Key_Right,
|
||||
context=QtCore.Qt.WidgetWithChildrenShortcut)
|
||||
self.parent.actionList.add_action(self.nextService,
|
||||
u'Live View Settings')
|
||||
self.previousItem = QtGui.QAction(u'previous_item', parent)
|
||||
ActionList.set(self.previousItem, u'previous_item',
|
||||
self.onSlideSelectedPrevious, QtCore.Qt.Key_Up,
|
||||
QtCore.Qt.Key_PageUp, context=QtCore.Qt.WidgetWithChildrenShortcut)
|
||||
self.parent.actionList.add_action(self.previousItem,
|
||||
u'Live View Settings')
|
||||
self.escapeItem = QtGui.QAction(u'escape_item', parent)
|
||||
ActionList.set(self.escapeItem, u'escape_item',
|
||||
self.liveEscape, QtCore.Qt.Key_Escape,
|
||||
context=QtCore.Qt.WidgetWithChildrenShortcut)
|
||||
self.parent.actionList.add_action(self.escapeItem,
|
||||
u'Live View Settings')
|
||||
actionList = self.parent.actionList
|
||||
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp])
|
||||
self.previousItem.setShortcutContext(
|
||||
QtCore.Qt.WidgetWithChildrenShortcut)
|
||||
actionList.add_action(self.nextItem, u'Live')
|
||||
self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown])
|
||||
self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
|
||||
actionList.add_action(self.nextItem, u'Live')
|
||||
self.previousService = QtGui.QAction(translate(
|
||||
'OpenLP.SlideController', 'Previous Service'), parent)
|
||||
self.previousService.setShortcuts([QtCore.Qt.Key_Left, 0])
|
||||
self.previousService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
|
||||
QtCore.QObject.connect(self.previousService,
|
||||
QtCore.SIGNAL(u'triggered()'), self.servicePrevious)
|
||||
actionList.add_action(self.previousService, u'Live')
|
||||
self.nextService = QtGui.QAction(translate(
|
||||
'OpenLP.SlideController', 'Next Service'), parent)
|
||||
self.nextService.setShortcuts([QtCore.Qt.Key_Right, 0])
|
||||
self.nextService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
|
||||
QtCore.QObject.connect(self.nextService,
|
||||
QtCore.SIGNAL(u'triggered()'), self.serviceNext)
|
||||
actionList.add_action(self.nextService, u'Live')
|
||||
self.escapeItem = QtGui.QAction(translate(
|
||||
'OpenLP.SlideController', 'Escape Item'), parent)
|
||||
self.escapeItem.setShortcuts([QtCore.Qt.Key_Escape, 0])
|
||||
self.escapeItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
|
||||
QtCore.QObject.connect(self.escapeItem,
|
||||
QtCore.SIGNAL(u'triggered()'), self.liveEscape)
|
||||
actionList.add_action(self.escapeItem, u'Live')
|
||||
|
||||
def liveEscape(self):
|
||||
self.display.setVisible(False)
|
||||
self.display.videoStop()
|
||||
|
||||
|
||||
def servicePrevious(self):
|
||||
Receiver.send_message('servicemanager_previous_item')
|
||||
|
||||
@ -441,10 +439,10 @@ class SlideController(QtGui.QWidget):
|
||||
self.settingsmanager.slidecontroller_image / self.ratio))
|
||||
if self.isLive:
|
||||
self.display.addActions(
|
||||
[self.previousItem,
|
||||
self.nextItem,
|
||||
self.previousService,
|
||||
self.nextService,
|
||||
[self.previousItem,
|
||||
self.nextItem,
|
||||
self.previousService,
|
||||
self.nextService,
|
||||
self.escapeItem])
|
||||
# The SlidePreview's ratio.
|
||||
self.ratio = float(self.screens.current[u'size'].width()) / \
|
||||
@ -1127,4 +1125,3 @@ class SlideController(QtGui.QWidget):
|
||||
if self.DesktopScreen.isChecked:
|
||||
self.DesktopScreen.setChecked(False)
|
||||
self.HideMenu.setDefaultAction(self.DesktopScreen)
|
||||
|
||||
|
@ -183,21 +183,3 @@ class ActionList(object):
|
||||
self.categories[category].actions.append(action)
|
||||
else:
|
||||
self.categories[category].actions.add(action, weight)
|
||||
|
||||
@staticmethod
|
||||
def set(action, text, slot, shortcut, alternate=0,
|
||||
context=QtCore.Qt.WidgetShortcut):
|
||||
"""
|
||||
Set Parameter for Action Items
|
||||
|
||||
``action`` action Item
|
||||
``text`` object name and menu title
|
||||
``slot`` connected slot
|
||||
``shortcut`` first shortcut
|
||||
``alternate`` alternate shortcut
|
||||
``context`` used context for this action
|
||||
"""
|
||||
action.setObjectName(text)
|
||||
action.setShortcuts([shortcut, alternate])
|
||||
action.setShortcutContext(context)
|
||||
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
|
||||
|
Loading…
Reference in New Issue
Block a user