This commit is contained in:
Andreas Preikschat 2011-05-13 15:58:17 +02:00
parent 0f73fbd310
commit 07b704677a
2 changed files with 35 additions and 47 deletions

View File

@ -331,7 +331,7 @@ def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None,
def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, def context_menu_action(base, icon, text, slot, shortcuts=None, category=None,
context=QtCore.Qt.WindowShortcut): context=QtCore.Qt.WindowShortcut):
""" """
Utility method to help build context menus for plugins Utility method to help build context menus.
``base`` ``base``
The parent menu to add this menu item to The parent menu to add this menu item to
@ -350,7 +350,7 @@ def context_menu_action(base, icon, text, slot, shortcuts=None, category=None,
``category`` ``category``
The category the shortcut should be listed in the shortcut dialog. If The category the shortcut should be listed in the shortcut dialog. If
left to None, then the action will be hidden in the shortcut dialog. left to ``None``, then the action will be hidden in the shortcut dialog.
``context`` ``context``
The context the shortcut is valid. The context the shortcut is valid.
@ -369,7 +369,7 @@ def context_menu_action(base, icon, text, slot, shortcuts=None, category=None,
def context_menu(base, icon, text): def context_menu(base, icon, text):
""" """
Utility method to help build context menus for plugins Utility method to help build context menus.
``base`` ``base``
The parent object to add this menu to The parent object to add this menu to

View File

@ -36,7 +36,7 @@ from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \
ItemCapabilities, SettingsManager, translate ItemCapabilities, SettingsManager, translate
from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.theme import ThemeLevel
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
context_menu_action, find_and_set_in_combo_box context_menu_action, context_menu_separator, find_and_set_in_combo_box
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.ui.printserviceform import PrintServiceForm
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
@ -301,31 +301,34 @@ class ServiceManager(QtGui.QWidget):
self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) self.addToAction.setIcon(build_icon(u':/general/general_edit.png'))
# build the context menu # build the context menu
self.menu = QtGui.QMenu() self.menu = QtGui.QMenu()
self.editAction = self.menu.addAction( self.editAction = context_menu_action(
translate('OpenLP.ServiceManager', '&Edit Item')) self.menu, u':/general/general_edit.png',
self.editAction.setIcon(build_icon(u':/general/general_edit.png')) translate('OpenLP.ServiceManager', '&Edit Item'), self.remoteEdit)
self.maintainAction = self.menu.addAction( self.maintainAction = context_menu_action(
translate('OpenLP.ServiceManager', '&Reorder Item')) self.menu, u':/general/general_edit.png',
self.maintainAction.setIcon(build_icon(u':/general/general_edit.png')) translate('OpenLP.ServiceManager', '&Reorder Item'),
self.notesAction = self.menu.addAction( self.onServiceItemEditForm)
translate('OpenLP.ServiceManager', '&Notes')) self.notesAction = context_menu_action(
self.notesAction.setIcon(build_icon(u':/services/service_notes.png')) self.menu, u':/services/service_notes.png',
self.timeAction = self.menu.addAction( translate('OpenLP.ServiceManager', '&Notes'),
translate('OpenLP.ServiceManager', '&Start Time')) self.onServiceItemNoteForm)
self.timeAction.setIcon(build_icon(u':/media/media_time.png')) self.timeAction = context_menu_action(
self.deleteAction = self.menu.addAction( self.menu, u':/media/media_time.png',
translate('OpenLP.ServiceManager', '&Delete From Service')) translate('OpenLP.ServiceManager', '&Start Time'),
self.deleteAction.setIcon(build_icon(u':/general/general_delete.png')) self.onStartTimeForm)
self.sep1 = self.menu.addAction(u'') self.deleteAction = context_menu_action(
self.sep1.setSeparator(True) self.menu, u':/general/general_delete.png',
self.previewAction = self.menu.addAction( translate('OpenLP.ServiceManager', '&Delete From Service'),
translate('OpenLP.ServiceManager', 'Show &Preview')) self.onDeleteFromService)
self.previewAction.setIcon(build_icon(u':/general/general_preview.png')) context_menu_separator(self.menu)
self.liveAction = self.menu.addAction( self.previewAction = context_menu_action(
translate('OpenLP.ServiceManager', 'Show &Live')) self.menu, u':/general/general_preview.png',
self.liveAction.setIcon(build_icon(u':/general/general_live.png')) translate('OpenLP.ServiceManager', 'Show &Preview'),
self.sep2 = self.menu.addAction(u'') self.makePreview)
self.sep2.setSeparator(True) self.liveAction = context_menu_action(
self.menu, u':/general/general_live.png',
translate('OpenLP.ServiceManager', 'Show &Live'), self.makeLive)
context_menu_separator(self.menu)
self.themeMenu = QtGui.QMenu( self.themeMenu = QtGui.QMenu(
translate('OpenLP.ServiceManager', '&Change Item Theme')) translate('OpenLP.ServiceManager', '&Change Item Theme'))
self.menu.addMenu(self.themeMenu) self.menu.addMenu(self.themeMenu)
@ -675,20 +678,6 @@ class ServiceManager(QtGui.QWidget):
if serviceItem[u'service_item'].is_text(): if serviceItem[u'service_item'].is_text():
self.themeMenu.menuAction().setVisible(True) self.themeMenu.menuAction().setVisible(True)
action = self.menu.exec_(self.serviceManagerList.mapToGlobal(point)) action = self.menu.exec_(self.serviceManagerList.mapToGlobal(point))
if action == self.editAction:
self.remoteEdit()
elif action == self.maintainAction:
self.onServiceItemEditForm()
elif action == self.deleteAction:
self.onDeleteFromService()
elif action == self.notesAction:
self.onServiceItemNoteForm()
elif action == self.timeAction:
self.onStartTimeForm()
elif action == self.previewAction:
self.makePreview()
elif action == self.liveAction:
self.makeLive()
def onServiceItemNoteForm(self): def onServiceItemNoteForm(self):
item = self.findServiceItem()[0] item = self.findServiceItem()[0]
@ -1288,9 +1277,8 @@ class ServiceManager(QtGui.QWidget):
self.themeComboBox.addItem(u'') self.themeComboBox.addItem(u'')
for theme in theme_list: for theme in theme_list:
self.themeComboBox.addItem(theme) self.themeComboBox.addItem(theme)
action = context_menu_action(self.serviceManagerList, None, theme, context_menu_action(self.themeMenu, None, theme,
self.onThemeChangeAction, context=QtCore.Qt.WidgetShortcut) self.onThemeChangeAction)
self.themeMenu.addAction(action)
find_and_set_in_combo_box(self.themeComboBox, self.service_theme) find_and_set_in_combo_box(self.themeComboBox, self.service_theme)
self.mainwindow.renderer.set_service_theme(self.service_theme) self.mainwindow.renderer.set_service_theme(self.service_theme)
self.regenerateServiceItems() self.regenerateServiceItems()