This commit is contained in:
Tim Bentley 2011-04-13 19:20:09 +01:00
commit 0b4fd3c585
24 changed files with 1032 additions and 466 deletions

View File

@ -166,58 +166,6 @@ def build_icon(icon):
QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
return button_icon return button_icon
def context_menu_action(base, icon, text, slot, shortcuts=None):
"""
Utility method to help build context menus for plugins
``base``
The parent menu to add this menu item to
``icon``
An icon for this action
``text``
The text to display for this action
``slot``
The code to run when this action is triggered
"""
action = QtGui.QAction(text, base)
if icon:
action.setIcon(build_icon(icon))
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
if shortcuts:
action.setShortcuts(shortcuts)
return action
def context_menu(base, icon, text):
"""
Utility method to help build context menus for plugins
``base``
The parent object to add this menu to
``icon``
An icon for this menu
``text``
The text to display for this menu
"""
action = QtGui.QMenu(text, base)
action.setIcon(build_icon(icon))
return action
def context_menu_separator(base):
"""
Add a separator to a context menu
``base``
The menu object to add the separator to
"""
action = QtGui.QAction(u'', base)
action.setSeparator(True)
return action
def image_to_byte(image): def image_to_byte(image):
""" """
Resize an image to fit on the current screen for the web and returns Resize an image to fit on the current screen for the web and returns
@ -343,3 +291,4 @@ from dockwidget import OpenLPDockWidget
from renderer import Renderer from renderer import Renderer
from rendermanager import RenderManager from rendermanager import RenderManager
from mediamanageritem import MediaManagerItem from mediamanageritem import MediaManagerItem
from openlp.core.utils.actions import ActionList

View File

@ -31,10 +31,10 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import context_menu_action, context_menu_separator, \ from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \
SettingsManager, OpenLPToolbar, ServiceItem, StringContent, build_icon, \ StringContent, build_icon, translate, Receiver, ListWidgetWithDnD
translate, Receiver, ListWidgetWithDnD from openlp.core.lib.ui import UiStrings, context_menu_action, \
from openlp.core.lib.ui import UiStrings context_menu_separator
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -260,39 +260,42 @@ class MediaManagerItem(QtGui.QWidget):
context_menu_action( context_menu_action(
self.listView, u':/general/general_edit.png', self.listView, u':/general/general_edit.png',
self.plugin.getString(StringContent.Edit)[u'title'], self.plugin.getString(StringContent.Edit)[u'title'],
self.onEditClick)) self.onEditClick, context=QtCore.Qt.WidgetShortcut))
self.listView.addAction(context_menu_separator(self.listView)) self.listView.addAction(context_menu_separator(self.listView))
if self.hasDeleteIcon: if self.hasDeleteIcon:
self.listView.addAction( self.listView.addAction(
context_menu_action( context_menu_action(
self.listView, u':/general/general_delete.png', self.listView, u':/general/general_delete.png',
self.plugin.getString(StringContent.Delete)[u'title'], self.plugin.getString(StringContent.Delete)[u'title'],
self.onDeleteClick, [QtCore.Qt.Key_Delete])) self.onDeleteClick, [QtCore.Qt.Key_Delete],
context=QtCore.Qt.WidgetShortcut))
self.listView.addAction(context_menu_separator(self.listView)) self.listView.addAction(context_menu_separator(self.listView))
self.listView.addAction( self.listView.addAction(
context_menu_action( context_menu_action(
self.listView, u':/general/general_preview.png', self.listView, u':/general/general_preview.png',
self.plugin.getString(StringContent.Preview)[u'title'], self.plugin.getString(StringContent.Preview)[u'title'],
self.onPreviewClick, [QtCore.Qt.Key_Enter])) self.onPreviewClick, [QtCore.Qt.Key_Enter,
QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut))
self.listView.addAction( self.listView.addAction(
context_menu_action( context_menu_action(
self.listView, u':/general/general_live.png', self.listView, u':/general/general_live.png',
self.plugin.getString(StringContent.Live)[u'title'], self.plugin.getString(StringContent.Live)[u'title'],
self.onLiveClick, [QtCore.Qt.ShiftModifier + \ self.onLiveClick, [QtCore.Qt.ShiftModifier + \
QtCore.Qt.Key_Enter, QtCore.Qt.ShiftModifier + \ QtCore.Qt.Key_Enter, QtCore.Qt.ShiftModifier + \
QtCore.Qt.Key_Return])) QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut))
self.listView.addAction( self.listView.addAction(
context_menu_action( context_menu_action(
self.listView, u':/general/general_add.png', self.listView, u':/general/general_add.png',
self.plugin.getString(StringContent.Service)[u'title'], self.plugin.getString(StringContent.Service)[u'title'],
self.onAddClick, [QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal])) self.onAddClick, [QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal],
context=QtCore.Qt.WidgetShortcut))
if self.addToServiceItem: if self.addToServiceItem:
self.listView.addAction( self.listView.addAction(
context_menu_action( context_menu_action(
self.listView, u':/general/general_add.png', self.listView, u':/general/general_add.png',
translate('OpenLP.MediaManagerItem', translate('OpenLP.MediaManagerItem',
'&Add to selected Service Item'), '&Add to selected Service Item'),
self.onAddEditClick)) self.onAddEditClick, context=QtCore.Qt.WidgetShortcut))
QtCore.QObject.connect(self.listView, QtCore.QObject.connect(self.listView,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
self.onClickPressed) self.onClickPressed)

View File

@ -29,6 +29,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon from openlp.core.lib import build_icon
from openlp.core.lib.ui import icon_action
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -132,7 +133,8 @@ class SearchEdit(QtGui.QLineEdit):
menu = QtGui.QMenu(self) menu = QtGui.QMenu(self)
first = None first = None
for identifier, icon, title in items: for identifier, icon, title in items:
action = QtGui.QAction(build_icon(icon), title, menu) action = icon_action(menu, u'', icon)
action.setText(title)
action.setData(QtCore.QVariant(identifier)) action.setData(QtCore.QVariant(identifier))
menu.addAction(action) menu.addAction(action)
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'),

View File

@ -51,8 +51,7 @@ class OpenLPToolbar(QtGui.QToolBar):
log.debug(u'Init done for %s' % parent.__class__.__name__) log.debug(u'Init done for %s' % parent.__class__.__name__)
def addToolbarButton(self, title, icon, tooltip=None, slot=None, def addToolbarButton(self, title, icon, tooltip=None, slot=None,
checkable=False, shortcut=0, alternate=0, checkable=False, shortcuts=None, context=QtCore.Qt.WidgetShortcut):
context=QtCore.Qt.WidgetShortcut):
""" """
A method to help developers easily add a button to the toolbar. A method to help developers easily add a button to the toolbar.
@ -74,16 +73,12 @@ class OpenLPToolbar(QtGui.QToolBar):
If *True* the button has two, *off* and *on*, states. Default is If *True* the button has two, *off* and *on*, states. Default is
*False*, which means the buttons has only one state. *False*, which means the buttons has only one state.
``shortcut`` ``shortcuts``
The primary shortcut for this action The list of shortcuts for this action
``alternate``
The alternate shortcut for this action
``context`` ``context``
Specify the context in which this shortcut is valid Specify the context in which this shortcut is valid
""" """
newAction = None
if icon: if icon:
actionIcon = build_icon(icon) actionIcon = build_icon(icon)
if slot and not checkable: if slot and not checkable:
@ -92,7 +87,7 @@ class OpenLPToolbar(QtGui.QToolBar):
newAction = self.addAction(actionIcon, title) newAction = self.addAction(actionIcon, title)
self.icons[title] = actionIcon self.icons[title] = actionIcon
else: else:
newAction = QtGui.QAction(title, newAction) newAction = QtGui.QAction(title, self)
self.addAction(newAction) self.addAction(newAction)
QtCore.QObject.connect(newAction, QtCore.QObject.connect(newAction,
QtCore.SIGNAL(u'triggered()'), slot) QtCore.SIGNAL(u'triggered()'), slot)
@ -103,8 +98,9 @@ class OpenLPToolbar(QtGui.QToolBar):
QtCore.QObject.connect(newAction, QtCore.QObject.connect(newAction,
QtCore.SIGNAL(u'toggled(bool)'), slot) QtCore.SIGNAL(u'toggled(bool)'), slot)
self.actions[title] = newAction self.actions[title] = newAction
newAction.setShortcuts([shortcut, alternate]) if shortcuts is not None:
newAction.setShortcutContext(context) newAction.setShortcuts(shortcuts)
newAction.setShortcutContext(context)
return newAction return newAction
def addToolbarSeparator(self, handle): def addToolbarSeparator(self, handle):

View File

@ -31,6 +31,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, Receiver, translate from openlp.core.lib import build_icon, Receiver, translate
from openlp.core.utils.actions import ActionList
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -57,8 +58,10 @@ class UiStrings(object):
EmptyField = translate('OpenLP.Ui', 'Empty Field') EmptyField = translate('OpenLP.Ui', 'Empty Field')
Error = translate('OpenLP.Ui', 'Error') Error = translate('OpenLP.Ui', 'Error')
Export = translate('OpenLP.Ui', 'Export') Export = translate('OpenLP.Ui', 'Export')
File = translate('OpenLP.Ui', 'File')
FontSizePtUnit = translate('OpenLP.Ui', 'pt', FontSizePtUnit = translate('OpenLP.Ui', 'pt',
'Abbreviated font pointsize unit') 'Abbreviated font pointsize unit')
Help = translate('OpenLP.Ui', 'Help')
Hours = translate('OpenLP.Ui', 'h', 'The abbreviated unit for hours') Hours = translate('OpenLP.Ui', 'h', 'The abbreviated unit for hours')
Image = translate('OpenLP.Ui', 'Image') Image = translate('OpenLP.Ui', 'Image')
Import = translate('OpenLP.Ui', 'Import') Import = translate('OpenLP.Ui', 'Import')
@ -67,6 +70,7 @@ class UiStrings(object):
Live = translate('OpenLP.Ui', 'Live') Live = translate('OpenLP.Ui', 'Live')
LiveBGError = translate('OpenLP.Ui', 'Live Background Error') LiveBGError = translate('OpenLP.Ui', 'Live Background Error')
LivePanel = translate('OpenLP.Ui', 'Live Panel') LivePanel = translate('OpenLP.Ui', 'Live Panel')
LiveToolbar = translate('OpenLP.Ui', 'Live Toolbar')
Load = translate('OpenLP.Ui', 'Load') Load = translate('OpenLP.Ui', 'Load')
Minutes = translate('OpenLP.Ui', 'm', 'The abbreviated unit for minutes') Minutes = translate('OpenLP.Ui', 'm', 'The abbreviated unit for minutes')
Middle = translate('OpenLP.Ui', 'Middle') Middle = translate('OpenLP.Ui', 'Middle')
@ -84,6 +88,7 @@ class UiStrings(object):
OpenService = translate('OpenLP.Ui', 'Open Service') OpenService = translate('OpenLP.Ui', 'Open Service')
Preview = translate('OpenLP.Ui', 'Preview') Preview = translate('OpenLP.Ui', 'Preview')
PreviewPanel = translate('OpenLP.Ui', 'Preview Panel') PreviewPanel = translate('OpenLP.Ui', 'Preview Panel')
PreviewToolbar = translate('OpenLP.Ui', 'Preview Toolbar')
PrintServiceOrder = translate('OpenLP.Ui', 'Print Service Order') PrintServiceOrder = translate('OpenLP.Ui', 'Print Service Order')
ReplaceBG = translate('OpenLP.Ui', 'Replace Background') ReplaceBG = translate('OpenLP.Ui', 'Replace Background')
ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background') ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background')
@ -94,15 +99,19 @@ class UiStrings(object):
Search = translate('OpenLP.Ui', 'Search') Search = translate('OpenLP.Ui', 'Search')
SelectDelete = translate('OpenLP.Ui', 'You must select an item to delete.') SelectDelete = translate('OpenLP.Ui', 'You must select an item to delete.')
SelectEdit = translate('OpenLP.Ui', 'You must select an item to edit.') SelectEdit = translate('OpenLP.Ui', 'You must select an item to edit.')
Settings = translate('OpenLP.Ui', 'Settings')
SaveService = translate('OpenLP.Ui', 'Save Service') SaveService = translate('OpenLP.Ui', 'Save Service')
Service = translate('OpenLP.Ui', 'Service') Service = translate('OpenLP.Ui', 'Service')
StartTimeCode = unicode(translate('OpenLP.Ui', 'Start %s')) StartTimeCode = unicode(translate('OpenLP.Ui', 'Start %s'))
Theme = translate('OpenLP.Ui', 'Theme', 'Singular') Theme = translate('OpenLP.Ui', 'Theme', 'Singular')
Themes = translate('OpenLP.Ui', 'Themes', 'Plural') Themes = translate('OpenLP.Ui', 'Themes', 'Plural')
Tools = translate('OpenLP.Ui', 'Tools')
Top = translate('OpenLP.Ui', 'Top') Top = translate('OpenLP.Ui', 'Top')
VersePerSlide = translate('OpenLP.Ui', 'Verse Per Slide') VersePerSlide = translate('OpenLP.Ui', 'Verse Per Slide')
VersePerLine = translate('OpenLP.Ui', 'Verse Per Line') VersePerLine = translate('OpenLP.Ui', 'Verse Per Line')
Version = translate('OpenLP.Ui', 'Version') Version = translate('OpenLP.Ui', 'Version')
View = translate('OpenLP.Ui', 'View')
ViewMode = translate('OpenLP.Ui', 'View Model')
def add_welcome_page(parent, image): def add_welcome_page(parent, image):
""" """
@ -243,45 +252,128 @@ def create_up_down_push_button_set(parent):
QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked) QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked)
return up_button, down_button return up_button, down_button
def base_action(parent, name): def base_action(parent, name, category=None):
""" """
Return the most basic action with the object name set. Return the most basic action with the object name set.
``category``
The category the action should be listed in the shortcut dialog. If you
not wish, that this action is added to the shortcut dialog, then do not
state any.
""" """
action = QtGui.QAction(parent) action = QtGui.QAction(parent)
action.setObjectName(name) action.setObjectName(name)
if category is not None:
action_list = ActionList.get_instance()
action_list.add_action(action, category)
return action return action
def checkable_action(parent, name, checked=None): def checkable_action(parent, name, checked=None, category=None):
""" """
Return a standard action with the checkable attribute set. Return a standard action with the checkable attribute set.
""" """
action = base_action(parent, name) action = base_action(parent, name, category)
action.setCheckable(True) action.setCheckable(True)
if checked is not None: if checked is not None:
action.setChecked(checked) action.setChecked(checked)
return action return action
def icon_action(parent, name, icon, checked=None): def icon_action(parent, name, icon, checked=None, category=None):
""" """
Return a standard action with an icon. Return a standard action with an icon.
""" """
if checked is not None: if checked is not None:
action = checkable_action(parent, name, checked) action = checkable_action(parent, name, checked, category)
else: else:
action = base_action(parent, name) action = base_action(parent, name, category)
action.setIcon(build_icon(icon)) action.setIcon(build_icon(icon))
return action return action
def shortcut_action(parent, text, shortcuts, function): def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None,
category=None, context=QtCore.Qt.WindowShortcut):
""" """
Return a shortcut enabled action. Return a shortcut enabled action.
""" """
action = QtGui.QAction(text, parent) action = QtGui.QAction(parent)
action.setObjectName(name)
if icon is not None:
action.setIcon(build_icon(icon))
if checked is not None:
action.setCheckable(True)
action.setChecked(checked)
action.setShortcuts(shortcuts) action.setShortcuts(shortcuts)
action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) action.setShortcutContext(context)
action_list = ActionList.get_instance()
action_list.add_action(action, category)
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function)
return action return action
def context_menu_action(base, icon, text, slot, shortcuts=None, category=None,
context=QtCore.Qt.WindowShortcut):
"""
Utility method to help build context menus for plugins
``base``
The parent menu to add this menu item to
``icon``
An icon for this action
``text``
The text to display for this action
``slot``
The code to run when this action is triggered
``shortcuts``
The action's shortcuts.
``category``
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.
``context``
The context the shortcut is valid.
"""
action = QtGui.QAction(text, base)
if icon:
action.setIcon(build_icon(icon))
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
if shortcuts is not None:
action.setShortcuts(shortcuts)
action.setShortcutContext(context)
action_list = ActionList.get_instance()
action_list.add_action(action)
return action
def context_menu(base, icon, text):
"""
Utility method to help build context menus for plugins
``base``
The parent object to add this menu to
``icon``
An icon for this menu
``text``
The text to display for this menu
"""
action = QtGui.QMenu(text, base)
action.setIcon(build_icon(icon))
return action
def context_menu_separator(base):
"""
Add a separator to a context menu
``base``
The menu object to add the separator to
"""
action = QtGui.QAction(u'', base)
action.setSeparator(True)
return action
def add_widget_completer(cache, widget): def add_widget_completer(cache, widget):
""" """
Adds a text autocompleter to a widget. Adds a text autocompleter to a widget.

View File

@ -33,12 +33,13 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \ from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \
SettingsManager, PluginManager, Receiver, translate SettingsManager, PluginManager, Receiver, translate
from openlp.core.lib.ui import UiStrings, base_action, checkable_action, \ from openlp.core.lib.ui import UiStrings, base_action, checkable_action, \
icon_action icon_action, shortcut_action
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
ThemeManager, SlideController, PluginForm, MediaDockManager, \ ThemeManager, SlideController, PluginForm, MediaDockManager, \
ShortcutListForm, DisplayTagForm ShortcutListForm, DisplayTagForm
from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ from openlp.core.utils import AppLocation, add_actions, LanguageManager, \
ActionList, get_application_version get_application_version
from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -161,74 +162,86 @@ class Ui_MainWindow(object):
mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea,
self.themeManagerDock) self.themeManagerDock)
# Create the menu items # Create the menu items
self.FileNewItem = icon_action(mainWindow, u'FileNewItem', action_list = ActionList.get_instance()
u':/general/general_new.png') action_list.add_category(UiStrings.File, CategoryOrder.standardMenu)
mainWindow.actionList.add_action(self.FileNewItem, u'File') self.FileNewItem = shortcut_action(mainWindow, u'FileNewItem',
self.FileOpenItem = icon_action(mainWindow, u'FileOpenItem', [QtGui.QKeySequence(u'Ctrl+N')],
u':/general/general_open.png') self.ServiceManagerContents.onNewServiceClicked,
mainWindow.actionList.add_action(self.FileOpenItem, u'File') u':/general/general_new.png', category=UiStrings.File)
self.FileSaveItem = icon_action(mainWindow, u'FileSaveItem', self.FileOpenItem = shortcut_action(mainWindow, u'FileOpenItem',
u':/general/general_save.png') [QtGui.QKeySequence(u'Ctrl+O')],
mainWindow.actionList.add_action(self.FileSaveItem, u'File') self.ServiceManagerContents.onLoadServiceClicked,
self.FileSaveAsItem = base_action(mainWindow, u'FileSaveAsItem') u':/general/general_open.png', category=UiStrings.File)
mainWindow.actionList.add_action(self.FileSaveAsItem, u'File') self.FileSaveItem = shortcut_action(mainWindow, u'FileSaveItem',
self.printServiceOrderItem = base_action( [QtGui.QKeySequence(u'Ctrl+S')],
mainWindow, u'printServiceItem') self.ServiceManagerContents.saveFile,
mainWindow.actionList.add_action( u':/general/general_save.png', category=UiStrings.File)
self.printServiceOrderItem, u'Print Service Order') self.FileSaveAsItem = shortcut_action(mainWindow, u'FileSaveAsItem',
self.FileExitItem = icon_action(mainWindow, u'FileExitItem', [QtGui.QKeySequence(u'Ctrl+Shift+S')],
u':/system/system_exit.png') self.ServiceManagerContents.saveFileAs, category=UiStrings.File)
mainWindow.actionList.add_action(self.FileExitItem, u'File') self.printServiceOrderItem = shortcut_action(mainWindow,
self.ImportThemeItem = base_action(mainWindow, u'ImportThemeItem') u'printServiceItem', [QtGui.QKeySequence(u'Ctrl+P')],
mainWindow.actionList.add_action(self.ImportThemeItem, u'Import') self.ServiceManagerContents.printServiceOrder,
self.ImportLanguageItem = base_action(mainWindow, u'ImportLanguageItem') category=UiStrings.File)
mainWindow.actionList.add_action(self.ImportLanguageItem, u'Import') self.FileExitItem = shortcut_action(mainWindow, u'FileExitItem',
self.ExportThemeItem = base_action(mainWindow, u'ExportThemeItem') [QtGui.QKeySequence(u'Alt+F4')], mainWindow.close,
mainWindow.actionList.add_action(self.ExportThemeItem, u'Export') u':/system/system_exit.png', category=UiStrings.File)
self.ExportLanguageItem = base_action(mainWindow, u'ExportLanguageItem') action_list.add_category(UiStrings.Import, CategoryOrder.standardMenu)
mainWindow.actionList.add_action(self.ExportLanguageItem, u'Export') self.ImportThemeItem = base_action(
self.ViewMediaManagerItem = icon_action(mainWindow, mainWindow, u'ImportThemeItem', UiStrings.Import)
u'ViewMediaManagerItem', u':/system/system_mediamanager.png', self.ImportLanguageItem = base_action(
self.mediaManagerDock.isVisible()) mainWindow, u'ImportLanguageItem')#, UiStrings.Import)
self.ViewThemeManagerItem = icon_action(mainWindow, action_list.add_category(UiStrings.Export, CategoryOrder.standardMenu)
u'ViewThemeManagerItem', u':/system/system_thememanager.png', self.ExportThemeItem = base_action(
self.themeManagerDock.isVisible()) mainWindow, u'ExportThemeItem', UiStrings.Export)
mainWindow.actionList.add_action(self.ViewMediaManagerItem, u'View') self.ExportLanguageItem = base_action(
self.ViewServiceManagerItem = icon_action(mainWindow, mainWindow, u'ExportLanguageItem')#, UiStrings.Export)
u'ViewServiceManagerItem', u':/system/system_servicemanager.png', action_list.add_category(UiStrings.View, CategoryOrder.standardMenu)
self.serviceManagerDock.isVisible()) self.ViewMediaManagerItem = shortcut_action(mainWindow,
mainWindow.actionList.add_action(self.ViewServiceManagerItem, u'View') u'ViewMediaManagerItem', [QtGui.QKeySequence(u'F8')],
self.ViewPreviewPanel = checkable_action(mainWindow, self.toggleMediaManager, u':/system/system_mediamanager.png',
u'ViewPreviewPanel', previewVisible) self.mediaManagerDock.isVisible(), UiStrings.View)
mainWindow.actionList.add_action(self.ViewPreviewPanel, u'View') self.ViewThemeManagerItem = shortcut_action(mainWindow,
self.ViewLivePanel = checkable_action(mainWindow, u'ViewLivePanel', u'ViewThemeManagerItem', [QtGui.QKeySequence(u'F10')],
liveVisible) self.toggleThemeManager, u':/system/system_thememanager.png',
mainWindow.actionList.add_action(self.ViewLivePanel, u'View') self.themeManagerDock.isVisible(), UiStrings.View)
self.ModeDefaultItem = checkable_action(mainWindow, u'ModeDefaultItem') self.ViewServiceManagerItem = shortcut_action(mainWindow,
mainWindow.actionList.add_action(self.ModeDefaultItem, u'View Mode') u'ViewServiceManagerItem', [QtGui.QKeySequence(u'F9')],
self.ModeSetupItem = checkable_action(mainWindow, u'ModeLiveItem') self.toggleServiceManager, u':/system/system_servicemanager.png',
mainWindow.actionList.add_action(self.ModeSetupItem, u'View Mode') self.serviceManagerDock.isVisible(), UiStrings.View)
self.ModeLiveItem = checkable_action(mainWindow, u'ModeLiveItem', True) self.ViewPreviewPanel = shortcut_action(mainWindow,
mainWindow.actionList.add_action(self.ModeLiveItem, u'View Mode') u'ViewPreviewPanel', [QtGui.QKeySequence(u'F11')],
self.setPreviewPanelVisibility, checked=previewVisible,
category=UiStrings.View)
self.ViewLivePanel = shortcut_action(mainWindow, u'ViewLivePanel',
[QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility,
checked=liveVisible, category=UiStrings.View)
action_list.add_category(UiStrings.ViewMode, CategoryOrder.standardMenu)
self.ModeDefaultItem = checkable_action(
mainWindow, u'ModeDefaultItem', category=UiStrings.ViewMode)
self.ModeSetupItem = checkable_action(
mainWindow, u'ModeLiveItem', category=UiStrings.ViewMode)
self.ModeLiveItem = checkable_action(
mainWindow, u'ModeLiveItem', True, UiStrings.ViewMode)
self.ModeGroup = QtGui.QActionGroup(mainWindow) self.ModeGroup = QtGui.QActionGroup(mainWindow)
self.ModeGroup.addAction(self.ModeDefaultItem) self.ModeGroup.addAction(self.ModeDefaultItem)
self.ModeGroup.addAction(self.ModeSetupItem) self.ModeGroup.addAction(self.ModeSetupItem)
self.ModeGroup.addAction(self.ModeLiveItem) self.ModeGroup.addAction(self.ModeLiveItem)
self.ModeDefaultItem.setChecked(True) self.ModeDefaultItem.setChecked(True)
action_list.add_category(UiStrings.Tools, CategoryOrder.standardMenu)
self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem', self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem',
u':/tools/tools_add.png') u':/tools/tools_add.png', category=UiStrings.Tools)
mainWindow.actionList.add_action(self.ToolsAddToolItem, u'Tools')
self.ToolsOpenDataFolder = icon_action(mainWindow, self.ToolsOpenDataFolder = icon_action(mainWindow,
u'ToolsOpenDataFolder', u':/general/general_open.png') u'ToolsOpenDataFolder', u':/general/general_open.png',
mainWindow.actionList.add_action(self.ToolsOpenDataFolder, u'Tools') category=UiStrings.Tools)
self.settingsPluginListItem = icon_action(mainWindow, action_list.add_category(UiStrings.Settings, CategoryOrder.standardMenu)
u'settingsPluginListItem', u':/system/settings_plugin_list.png') self.settingsPluginListItem = shortcut_action(mainWindow,
mainWindow.actionList.add_action(self.settingsPluginListItem, u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')],
u'Settings') self.onPluginItemClicked, u':/system/settings_plugin_list.png',
category=UiStrings.Settings)
# i18n Language Items # i18n Language Items
self.AutoLanguageItem = checkable_action(mainWindow, self.AutoLanguageItem = checkable_action(mainWindow,
u'AutoLanguageItem', LanguageManager.auto_language) u'AutoLanguageItem', LanguageManager.auto_language)
mainWindow.actionList.add_action(self.AutoLanguageItem, u'Settings')
self.LanguageGroup = QtGui.QActionGroup(mainWindow) self.LanguageGroup = QtGui.QActionGroup(mainWindow)
self.LanguageGroup.setExclusive(True) self.LanguageGroup.setExclusive(True)
self.LanguageGroup.setObjectName(u'LanguageGroup') self.LanguageGroup.setObjectName(u'LanguageGroup')
@ -241,24 +254,26 @@ class Ui_MainWindow(object):
add_actions(self.LanguageGroup, [languageItem]) add_actions(self.LanguageGroup, [languageItem])
self.SettingsShortcutsItem = icon_action(mainWindow, self.SettingsShortcutsItem = icon_action(mainWindow,
u'SettingsShortcutsItem', u'SettingsShortcutsItem',
u':/system/system_configure_shortcuts.png') u':/system/system_configure_shortcuts.png',
category=UiStrings.Settings)
self.DisplayTagItem = icon_action(mainWindow, self.DisplayTagItem = icon_action(mainWindow,
u'DisplayTagItem', u':/system/tag_editor.png') u'DisplayTagItem', u':/system/tag_editor.png',
category=UiStrings.Settings)
self.SettingsConfigureItem = icon_action(mainWindow, self.SettingsConfigureItem = icon_action(mainWindow,
u'SettingsConfigureItem', u':/system/system_settings.png') u'SettingsConfigureItem', u':/system/system_settings.png',
mainWindow.actionList.add_action(self.SettingsShortcutsItem, category=UiStrings.Settings)
u'Settings') action_list.add_category(UiStrings.Help, CategoryOrder.standardMenu)
self.HelpDocumentationItem = icon_action(mainWindow, self.HelpDocumentationItem = icon_action(mainWindow,
u'HelpDocumentationItem', u':/system/system_help_contents.png') u'HelpDocumentationItem', u':/system/system_help_contents.png',
category=None)#UiStrings.Help)
self.HelpDocumentationItem.setEnabled(False) self.HelpDocumentationItem.setEnabled(False)
mainWindow.actionList.add_action(self.HelpDocumentationItem, u'Help') self.HelpAboutItem = shortcut_action(mainWindow, u'HelpAboutItem',
self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem', [QtGui.QKeySequence(u'Ctrl+F1')], self.onHelpAboutItemClicked,
u':/system/system_about.png') u':/system/system_about.png', category=UiStrings.Help)
mainWindow.actionList.add_action(self.HelpAboutItem, u'Help') self.HelpOnlineHelpItem = base_action(
self.HelpOnlineHelpItem = base_action(mainWindow, u'HelpOnlineHelpItem') mainWindow, u'HelpOnlineHelpItem', category=UiStrings.Help)
mainWindow.actionList.add_action(self.HelpOnlineHelpItem, u'Help') self.helpWebSiteItem = base_action(
self.helpWebSiteItem = base_action(mainWindow, u'helpWebSiteItem') mainWindow, u'helpWebSiteItem', category=UiStrings.Help)
mainWindow.actionList.add_action(self.helpWebSiteItem, u'Help')
add_actions(self.FileImportMenu, add_actions(self.FileImportMenu,
(self.ImportThemeItem, self.ImportLanguageItem)) (self.ImportThemeItem, self.ImportLanguageItem))
add_actions(self.FileExportMenu, add_actions(self.FileExportMenu,
@ -294,14 +309,11 @@ class Ui_MainWindow(object):
# Connect up some signals and slots # Connect up some signals and slots
QtCore.QObject.connect(self.FileMenu, QtCore.QObject.connect(self.FileMenu,
QtCore.SIGNAL(u'aboutToShow()'), self.updateFileMenu) QtCore.SIGNAL(u'aboutToShow()'), self.updateFileMenu)
QtCore.QObject.connect(self.FileExitItem,
QtCore.SIGNAL(u'triggered()'), mainWindow.close)
QtCore.QMetaObject.connectSlotsByName(mainWindow) QtCore.QMetaObject.connectSlotsByName(mainWindow)
# Hide the entry, as it does not have any functionality yet. # Hide the entry, as it does not have any functionality yet.
self.ToolsAddToolItem.setVisible(False) self.ToolsAddToolItem.setVisible(False)
self.ImportLanguageItem.setVisible(False) self.ImportLanguageItem.setVisible(False)
self.ExportLanguageItem.setVisible(False) self.ExportLanguageItem.setVisible(False)
self.SettingsShortcutsItem.setVisible(False)
self.HelpDocumentationItem.setVisible(False) self.HelpDocumentationItem.setVisible(False)
def retranslateUi(self, mainWindow): def retranslateUi(self, mainWindow):
@ -329,36 +341,27 @@ class Ui_MainWindow(object):
self.FileNewItem.setText(translate('OpenLP.MainWindow', '&New')) self.FileNewItem.setText(translate('OpenLP.MainWindow', '&New'))
self.FileNewItem.setToolTip(UiStrings.NewService) self.FileNewItem.setToolTip(UiStrings.NewService)
self.FileNewItem.setStatusTip(UiStrings.CreateService) self.FileNewItem.setStatusTip(UiStrings.CreateService)
self.FileNewItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+N'))
self.FileOpenItem.setText(translate('OpenLP.MainWindow', '&Open')) self.FileOpenItem.setText(translate('OpenLP.MainWindow', '&Open'))
self.FileOpenItem.setToolTip(UiStrings.OpenService) self.FileOpenItem.setToolTip(UiStrings.OpenService)
self.FileOpenItem.setStatusTip( self.FileOpenItem.setStatusTip(
translate('OpenLP.MainWindow', 'Open an existing service.')) translate('OpenLP.MainWindow', 'Open an existing service.'))
self.FileOpenItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+O'))
self.FileSaveItem.setText(translate('OpenLP.MainWindow', '&Save')) self.FileSaveItem.setText(translate('OpenLP.MainWindow', '&Save'))
self.FileSaveItem.setToolTip(UiStrings.SaveService) self.FileSaveItem.setToolTip(UiStrings.SaveService)
self.FileSaveItem.setStatusTip( self.FileSaveItem.setStatusTip(
translate('OpenLP.MainWindow', 'Save the current service to disk.')) translate('OpenLP.MainWindow', 'Save the current service to disk.'))
self.FileSaveItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+S'))
self.FileSaveAsItem.setText( self.FileSaveAsItem.setText(
translate('OpenLP.MainWindow', 'Save &As...')) translate('OpenLP.MainWindow', 'Save &As...'))
self.FileSaveAsItem.setToolTip( self.FileSaveAsItem.setToolTip(
translate('OpenLP.MainWindow', 'Save Service As')) translate('OpenLP.MainWindow', 'Save Service As'))
self.FileSaveAsItem.setStatusTip(translate('OpenLP.MainWindow', self.FileSaveAsItem.setStatusTip(translate('OpenLP.MainWindow',
'Save the current service under a new name.')) 'Save the current service under a new name.'))
self.FileSaveAsItem.setShortcut(
translate('OpenLP.MainWindow', 'Ctrl+Shift+S'))
self.printServiceOrderItem.setText(UiStrings.PrintServiceOrder) self.printServiceOrderItem.setText(UiStrings.PrintServiceOrder)
self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow',
'Print the current Service Order.')) 'Print the current Service Order.'))
self.printServiceOrderItem.setShortcut(
translate('OpenLP.MainWindow', 'Ctrl+P'))
self.FileExitItem.setText( self.FileExitItem.setText(
translate('OpenLP.MainWindow', 'E&xit')) translate('OpenLP.MainWindow', 'E&xit'))
self.FileExitItem.setStatusTip( self.FileExitItem.setStatusTip(
translate('OpenLP.MainWindow', 'Quit OpenLP')) translate('OpenLP.MainWindow', 'Quit OpenLP'))
self.FileExitItem.setShortcut(
translate('OpenLP.MainWindow', 'Alt+F4'))
self.ImportThemeItem.setText( self.ImportThemeItem.setText(
translate('OpenLP.MainWindow', '&Theme')) translate('OpenLP.MainWindow', '&Theme'))
self.ImportLanguageItem.setText( self.ImportLanguageItem.setText(
@ -379,53 +382,39 @@ class Ui_MainWindow(object):
translate('OpenLP.MainWindow', 'Toggle Media Manager')) translate('OpenLP.MainWindow', 'Toggle Media Manager'))
self.ViewMediaManagerItem.setStatusTip(translate('OpenLP.MainWindow', self.ViewMediaManagerItem.setStatusTip(translate('OpenLP.MainWindow',
'Toggle the visibility of the media manager.')) 'Toggle the visibility of the media manager.'))
self.ViewMediaManagerItem.setShortcut(
translate('OpenLP.MainWindow', 'F8'))
self.ViewThemeManagerItem.setText( self.ViewThemeManagerItem.setText(
translate('OpenLP.MainWindow', '&Theme Manager')) translate('OpenLP.MainWindow', '&Theme Manager'))
self.ViewThemeManagerItem.setToolTip( self.ViewThemeManagerItem.setToolTip(
translate('OpenLP.MainWindow', 'Toggle Theme Manager')) translate('OpenLP.MainWindow', 'Toggle Theme Manager'))
self.ViewThemeManagerItem.setStatusTip(translate('OpenLP.MainWindow', self.ViewThemeManagerItem.setStatusTip(translate('OpenLP.MainWindow',
'Toggle the visibility of the theme manager.')) 'Toggle the visibility of the theme manager.'))
self.ViewThemeManagerItem.setShortcut(
translate('OpenLP.MainWindow', 'F10'))
self.ViewServiceManagerItem.setText( self.ViewServiceManagerItem.setText(
translate('OpenLP.MainWindow', '&Service Manager')) translate('OpenLP.MainWindow', '&Service Manager'))
self.ViewServiceManagerItem.setToolTip( self.ViewServiceManagerItem.setToolTip(
translate('OpenLP.MainWindow', 'Toggle Service Manager')) translate('OpenLP.MainWindow', 'Toggle Service Manager'))
self.ViewServiceManagerItem.setStatusTip(translate('OpenLP.MainWindow', self.ViewServiceManagerItem.setStatusTip(translate('OpenLP.MainWindow',
'Toggle the visibility of the service manager.')) 'Toggle the visibility of the service manager.'))
self.ViewServiceManagerItem.setShortcut(
translate('OpenLP.MainWindow', 'F9'))
self.ViewPreviewPanel.setText( self.ViewPreviewPanel.setText(
translate('OpenLP.MainWindow', '&Preview Panel')) translate('OpenLP.MainWindow', '&Preview Panel'))
self.ViewPreviewPanel.setToolTip( self.ViewPreviewPanel.setToolTip(
translate('OpenLP.MainWindow', 'Toggle Preview Panel')) translate('OpenLP.MainWindow', 'Toggle Preview Panel'))
self.ViewPreviewPanel.setStatusTip(translate('OpenLP.MainWindow', self.ViewPreviewPanel.setStatusTip(translate('OpenLP.MainWindow',
'Toggle the visibility of the preview panel.')) 'Toggle the visibility of the preview panel.'))
self.ViewPreviewPanel.setShortcut(
translate('OpenLP.MainWindow', 'F11'))
self.ViewLivePanel.setText( self.ViewLivePanel.setText(
translate('OpenLP.MainWindow', '&Live Panel')) translate('OpenLP.MainWindow', '&Live Panel'))
self.ViewLivePanel.setToolTip( self.ViewLivePanel.setToolTip(
translate('OpenLP.MainWindow', 'Toggle Live Panel')) translate('OpenLP.MainWindow', 'Toggle Live Panel'))
self.ViewLivePanel.setStatusTip(translate('OpenLP.MainWindow', self.ViewLivePanel.setStatusTip(translate('OpenLP.MainWindow',
'Toggle the visibility of the live panel.')) 'Toggle the visibility of the live panel.'))
self.ViewLivePanel.setShortcut(
translate('OpenLP.MainWindow', 'F12'))
self.settingsPluginListItem.setText(translate('OpenLP.MainWindow', self.settingsPluginListItem.setText(translate('OpenLP.MainWindow',
'&Plugin List')) '&Plugin List'))
self.settingsPluginListItem.setStatusTip( self.settingsPluginListItem.setStatusTip(
translate('OpenLP.MainWindow', 'List the Plugins')) translate('OpenLP.MainWindow', 'List the Plugins'))
self.settingsPluginListItem.setShortcut(
translate('OpenLP.MainWindow', 'Alt+F7'))
self.HelpDocumentationItem.setText( self.HelpDocumentationItem.setText(
translate('OpenLP.MainWindow', '&User Guide')) translate('OpenLP.MainWindow', '&User Guide'))
self.HelpAboutItem.setText(translate('OpenLP.MainWindow', '&About')) self.HelpAboutItem.setText(translate('OpenLP.MainWindow', '&About'))
self.HelpAboutItem.setStatusTip( self.HelpAboutItem.setStatusTip(
translate('OpenLP.MainWindow', 'More information about OpenLP')) translate('OpenLP.MainWindow', 'More information about OpenLP'))
self.HelpAboutItem.setShortcut(
translate('OpenLP.MainWindow', 'Ctrl+F1'))
self.HelpOnlineHelpItem.setText( self.HelpOnlineHelpItem.setText(
translate('OpenLP.MainWindow', '&Online Help')) translate('OpenLP.MainWindow', '&Online Help'))
# Uncomment after 1.9.5 beta string freeze # Uncomment after 1.9.5 beta string freeze
@ -467,8 +456,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
""" """
log.info(u'MainWindow loaded') log.info(u'MainWindow loaded')
actionList = ActionList()
def __init__(self, screens, clipboard, arguments): def __init__(self, screens, clipboard, arguments):
""" """
This constructor sets up the interface, the various managers, and the This constructor sets up the interface, the various managers, and the
@ -485,7 +472,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.serviceSettingsSection = u'servicemanager' self.serviceSettingsSection = u'servicemanager'
self.songsSettingsSection = u'songs' self.songsSettingsSection = u'songs'
self.serviceNotSaved = False self.serviceNotSaved = False
self.actionList = ActionList()
self.settingsmanager = SettingsManager(screens) self.settingsmanager = SettingsManager(screens)
self.aboutForm = AboutForm(self) self.aboutForm = AboutForm(self)
self.settingsForm = SettingsForm(self.screens, self, self) self.settingsForm = SettingsForm(self.screens, self, self)
@ -510,16 +496,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.QObject.connect(self.ExportThemeItem, QtCore.QObject.connect(self.ExportThemeItem,
QtCore.SIGNAL(u'triggered()'), QtCore.SIGNAL(u'triggered()'),
self.themeManagerContents.onExportTheme) self.themeManagerContents.onExportTheme)
QtCore.QObject.connect(self.ViewMediaManagerItem,
QtCore.SIGNAL(u'triggered(bool)'), self.toggleMediaManager)
QtCore.QObject.connect(self.ViewServiceManagerItem,
QtCore.SIGNAL(u'triggered(bool)'), self.toggleServiceManager)
QtCore.QObject.connect(self.ViewThemeManagerItem,
QtCore.SIGNAL(u'triggered(bool)'), self.toggleThemeManager)
QtCore.QObject.connect(self.ViewPreviewPanel,
QtCore.SIGNAL(u'toggled(bool)'), self.setPreviewPanelVisibility)
QtCore.QObject.connect(self.ViewLivePanel,
QtCore.SIGNAL(u'toggled(bool)'), self.setLivePanelVisibility)
QtCore.QObject.connect(self.mediaManagerDock, QtCore.QObject.connect(self.mediaManagerDock,
QtCore.SIGNAL(u'visibilityChanged(bool)'), QtCore.SIGNAL(u'visibilityChanged(bool)'),
self.ViewMediaManagerItem.setChecked) self.ViewMediaManagerItem.setChecked)
@ -533,32 +509,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked) QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked)
QtCore.QObject.connect(self.HelpOnlineHelpItem, QtCore.QObject.connect(self.HelpOnlineHelpItem,
QtCore.SIGNAL(u'triggered()'), self.onHelpOnLineHelpClicked) QtCore.SIGNAL(u'triggered()'), self.onHelpOnLineHelpClicked)
QtCore.QObject.connect(self.HelpAboutItem,
QtCore.SIGNAL(u'triggered()'), self.onHelpAboutItemClicked)
QtCore.QObject.connect(self.ToolsOpenDataFolder, QtCore.QObject.connect(self.ToolsOpenDataFolder,
QtCore.SIGNAL(u'triggered()'), self.onToolsOpenDataFolderClicked) QtCore.SIGNAL(u'triggered()'), self.onToolsOpenDataFolderClicked)
QtCore.QObject.connect(self.settingsPluginListItem,
QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked)
QtCore.QObject.connect(self.DisplayTagItem, QtCore.QObject.connect(self.DisplayTagItem,
QtCore.SIGNAL(u'triggered()'), self.onDisplayTagItemClicked) QtCore.SIGNAL(u'triggered()'), self.onDisplayTagItemClicked)
QtCore.QObject.connect(self.SettingsConfigureItem, QtCore.QObject.connect(self.SettingsConfigureItem,
QtCore.SIGNAL(u'triggered()'), self.onSettingsConfigureItemClicked) QtCore.SIGNAL(u'triggered()'), self.onSettingsConfigureItemClicked)
QtCore.QObject.connect(self.SettingsShortcutsItem, QtCore.QObject.connect(self.SettingsShortcutsItem,
QtCore.SIGNAL(u'triggered()'), self.onSettingsShortcutsItemClicked) QtCore.SIGNAL(u'triggered()'), self.onSettingsShortcutsItemClicked)
QtCore.QObject.connect(self.FileNewItem, QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.onNewServiceClicked)
QtCore.QObject.connect(self.FileOpenItem,
QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.onLoadServiceClicked)
QtCore.QObject.connect(self.FileSaveItem,
QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.saveFile)
QtCore.QObject.connect(self.FileSaveAsItem,
QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.saveFileAs)
QtCore.QObject.connect(self.printServiceOrderItem,
QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.printServiceOrder)
# i18n set signals for languages # i18n set signals for languages
self.LanguageGroup.triggered.connect(LanguageManager.set_language) self.LanguageGroup.triggered.connect(LanguageManager.set_language)
QtCore.QObject.connect(self.ModeDefaultItem, QtCore.QObject.connect(self.ModeDefaultItem,
@ -781,7 +739,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
""" """
Show the shortcuts dialog Show the shortcuts dialog
""" """
self.shortcutForm.exec_(self.actionList) if self.shortcutForm.exec_():
self.shortcutForm.save()
def onModeDefaultItemClicked(self): def onModeDefaultItemClicked(self):
""" """
@ -928,19 +887,16 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
unicode(translate('OpenLP.MainWindow', 'Default Theme: %s')) % unicode(translate('OpenLP.MainWindow', 'Default Theme: %s')) %
theme) theme)
def toggleMediaManager(self, visible): def toggleMediaManager(self):
if self.mediaManagerDock.isVisible() != visible: self.mediaManagerDock.setVisible(not self.mediaManagerDock.isVisible())
self.mediaManagerDock.setVisible(visible)
def toggleServiceManager(self, visible): def toggleServiceManager(self):
if self.serviceManagerDock.isVisible() != visible: self.serviceManagerDock.setVisible(not self.serviceManagerDock.isVisible())
self.serviceManagerDock.setVisible(visible)
def toggleThemeManager(self, visible): def toggleThemeManager(self):
if self.themeManagerDock.isVisible() != visible: self.themeManagerDock.setVisible(not self.themeManagerDock.isVisible())
self.themeManagerDock.setVisible(visible)
def setPreviewPanelVisibility(self, visible): def setPreviewPanelVisibility(self, visible=None):
""" """
Sets the visibility of the preview panel including saving the setting Sets the visibility of the preview panel including saving the setting
and updating the menu. and updating the menu.
@ -950,12 +906,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
True - Visible True - Visible
False - Hidden False - Hidden
""" """
if visible is None:
visible = self.ViewPreviewPanel.isVisible()
self.previewController.panel.setVisible(visible) self.previewController.panel.setVisible(visible)
QtCore.QSettings().setValue(u'user interface/preview panel', QtCore.QSettings().setValue(u'user interface/preview panel',
QtCore.QVariant(visible)) QtCore.QVariant(visible))
self.ViewPreviewPanel.setChecked(visible) self.ViewPreviewPanel.setChecked(visible)
def setLivePanelVisibility(self, visible): def setLivePanelVisibility(self, visible=None):
""" """
Sets the visibility of the live panel including saving the setting and Sets the visibility of the live panel including saving the setting and
updating the menu. updating the menu.
@ -965,6 +923,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
True - Visible True - Visible
False - Hidden False - Hidden
""" """
if visible is None:
visible = self.ViewLivePanel.isVisible()
self.liveController.panel.setVisible(visible) self.liveController.panel.setVisible(visible)
QtCore.QSettings().setValue(u'user interface/live panel', QtCore.QSettings().setValue(u'user interface/live panel',
QtCore.QVariant(visible)) QtCore.QVariant(visible))
@ -1022,8 +982,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.FileMenu.addSeparator() self.FileMenu.addSeparator()
for fileId, filename in enumerate(recentFilesToDisplay): for fileId, filename in enumerate(recentFilesToDisplay):
log.debug('Recent file name: %s', filename) log.debug('Recent file name: %s', filename)
action = QtGui.QAction(u'&%d %s' % (fileId + 1, action = base_action(self, u'')
QtCore.QFileInfo(filename).fileName()), self) action.setText(u'&%d %s' %
(fileId + 1, QtCore.QFileInfo(filename).fileName()))
action.setData(QtCore.QVariant(filename)) action.setData(QtCore.QVariant(filename))
self.connect(action, QtCore.SIGNAL(u'triggered()'), self.connect(action, QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.onRecentServiceClicked) self.ServiceManagerContents.onRecentServiceClicked)

View File

@ -32,15 +32,16 @@ log = logging.getLogger(__name__)
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \ from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \
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, \
find_and_set_in_combo_box context_menu_action, 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, \
split_filename split_filename
from openlp.core.utils.actions import ActionList, CategoryOrder
class ServiceManagerList(QtGui.QTreeWidget): class ServiceManagerList(QtGui.QTreeWidget):
""" """
@ -165,38 +166,55 @@ class ServiceManager(QtGui.QWidget):
u':/services/service_top.png', u':/services/service_top.png',
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'Move item to the top of the service.'), 'Move item to the top of the service.'),
self.onServiceTop, shortcut=QtCore.Qt.Key_Home) self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home])
self.serviceManagerList.moveTop.setObjectName(u'moveTop')
action_list = ActionList.get_instance()
action_list.add_category(UiStrings.Service, CategoryOrder.standardToolbar)
action_list.add_action(
self.serviceManagerList.moveTop, UiStrings.Service)
self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton( self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move &up'), translate('OpenLP.ServiceManager', 'Move &up'),
u':/services/service_up.png', u':/services/service_up.png',
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'Move item up one position in the service.'), 'Move item up one position in the service.'),
self.onServiceUp, shortcut=QtCore.Qt.Key_PageUp) self.onServiceUp, shortcuts=[QtCore.Qt.Key_PageUp])
self.serviceManagerList.moveUp.setObjectName(u'moveUp')
action_list.add_action(self.serviceManagerList.moveUp, UiStrings.Service)
self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton( self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move &down'), translate('OpenLP.ServiceManager', 'Move &down'),
u':/services/service_down.png', u':/services/service_down.png',
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'Move item down one position in the service.'), 'Move item down one position in the service.'),
self.onServiceDown, shortcut=QtCore.Qt.Key_PageDown) self.onServiceDown, shortcuts=[QtCore.Qt.Key_PageDown])
self.serviceManagerList.moveDown.setObjectName(u'moveDown')
action_list.add_action(
self.serviceManagerList.moveDown, UiStrings.Service)
self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton( self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move to &bottom'), translate('OpenLP.ServiceManager', 'Move to &bottom'),
u':/services/service_bottom.png', u':/services/service_bottom.png',
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'Move item to the end of the service.'), 'Move item to the end of the service.'),
self.onServiceEnd, shortcut=QtCore.Qt.Key_End) self.onServiceEnd, shortcuts=[QtCore.Qt.Key_End])
self.serviceManagerList.moveBottom.setObjectName(u'moveBottom')
action_list.add_action(
self.serviceManagerList.moveBottom, UiStrings.Service)
self.serviceManagerList.down = self.orderToolbar.addToolbarButton( self.serviceManagerList.down = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move &down'), translate('OpenLP.ServiceManager', 'Move &down'),
None, None,
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'Moves the selection down the window.'), 'Moves the selection down the window.'),
self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Down) self.onMoveSelectionDown, shortcuts=[QtCore.Qt.Key_Down])
self.serviceManagerList.down.setObjectName(u'down')
action_list.add_action(self.serviceManagerList.down)
self.serviceManagerList.down.setVisible(False) self.serviceManagerList.down.setVisible(False)
self.serviceManagerList.up = self.orderToolbar.addToolbarButton( self.serviceManagerList.up = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Move up'), translate('OpenLP.ServiceManager', 'Move up'),
None, None,
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'Moves the selection up the window.'), 'Moves the selection up the window.'),
self.onMoveSelectionUp, shortcut=QtCore.Qt.Key_Up) self.onMoveSelectionUp, shortcuts=[QtCore.Qt.Key_Up])
self.serviceManagerList.up.setObjectName(u'up')
action_list.add_action(self.serviceManagerList.up)
self.serviceManagerList.up.setVisible(False) self.serviceManagerList.up.setVisible(False)
self.orderToolbar.addSeparator() self.orderToolbar.addSeparator()
self.serviceManagerList.delete = self.orderToolbar.addToolbarButton( self.serviceManagerList.delete = self.orderToolbar.addToolbarButton(
@ -211,22 +229,28 @@ class ServiceManager(QtGui.QWidget):
u':/services/service_expand_all.png', u':/services/service_expand_all.png',
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'Expand all the service items.'), 'Expand all the service items.'),
self.onExpandAll, shortcut=QtCore.Qt.Key_Plus) self.onExpandAll, shortcuts=[QtCore.Qt.Key_Plus])
self.serviceManagerList.expand.setObjectName(u'expand')
action_list.add_action(self.serviceManagerList.expand, UiStrings.Service)
self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton( self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', '&Collapse all'), translate('OpenLP.ServiceManager', '&Collapse all'),
u':/services/service_collapse_all.png', u':/services/service_collapse_all.png',
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'Collapse all the service items.'), 'Collapse all the service items.'),
self.onCollapseAll, shortcut=QtCore.Qt.Key_Minus) self.onCollapseAll, shortcuts=[QtCore.Qt.Key_Minus])
self.serviceManagerList.collapse.setObjectName(u'collapse')
action_list.add_action(
self.serviceManagerList.collapse, UiStrings.Service)
self.orderToolbar.addSeparator() self.orderToolbar.addSeparator()
self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton( self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Go Live'), translate('OpenLP.ServiceManager', 'Go Live'),
u':/general/general_live.png', u':/general/general_live.png',
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'Send the selected item to Live.'), 'Send the selected item to Live.'), self.makeLive,
self.makeLive, shortcut=QtCore.Qt.Key_Enter, shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return])
alternate=QtCore.Qt.Key_Return) self.serviceManagerList.makeLive.setObjectName(u'orderToolbar')
self.orderToolbar.setObjectName(u'orderToolbar') action_list.add_action(
self.serviceManagerList.makeLive, UiStrings.Service)
self.layout.addWidget(self.orderToolbar) self.layout.addWidget(self.orderToolbar)
# Connect up our signals and slots # Connect up our signals and slots
QtCore.QObject.connect(self.themeComboBox, QtCore.QObject.connect(self.themeComboBox,
@ -301,7 +325,6 @@ class ServiceManager(QtGui.QWidget):
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)
self.setServiceHotkeys()
self.serviceManagerList.addActions( self.serviceManagerList.addActions(
[self.serviceManagerList.moveDown, [self.serviceManagerList.moveDown,
self.serviceManagerList.moveUp, self.serviceManagerList.moveUp,
@ -315,19 +338,6 @@ class ServiceManager(QtGui.QWidget):
]) ])
self.configUpdated() self.configUpdated()
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')
actionList.add_action(self.serviceManagerList.expand, u'Service')
actionList.add_action(self.serviceManagerList.collapse, u'Service')
def setModified(self, modified=True): def setModified(self, modified=True):
""" """
Setter for property "modified". Sets whether or not the current service Setter for property "modified". Sets whether or not the current service
@ -692,9 +702,9 @@ class ServiceManager(QtGui.QWidget):
Called by the SlideController to request a preview item be made live Called by the SlideController to request a preview item be made live
and allows the next preview to be updated if relevent. and allows the next preview to be updated if relevent.
""" """
id, row = message.split(u':') uuid, row = message.split(u':')
for sitem in self.serviceItems: for sitem in self.serviceItems:
if sitem[u'service_item']._uuid == id: if sitem[u'service_item']._uuid == uuid:
item = self.serviceManagerList.topLevelItem(sitem[u'order'] - 1) item = self.serviceManagerList.topLevelItem(sitem[u'order'] - 1)
self.serviceManagerList.setCurrentItem(item) self.serviceManagerList.setCurrentItem(item)
self.makeLive(int(row)) self.makeLive(int(row))
@ -1022,7 +1032,7 @@ class ServiceManager(QtGui.QWidget):
editId, uuid = message.split(u':') editId, uuid = message.split(u':')
for item in self.serviceItems: for item in self.serviceItems:
if item[u'service_item']._uuid == uuid: if item[u'service_item']._uuid == uuid:
item[u'service_item'].edit_id = editId item[u'service_item'].edit_id = int(editId)
self.setModified(True) self.setModified(True)
def replaceServiceItem(self, newItem): def replaceServiceItem(self, newItem):
@ -1260,7 +1270,7 @@ class ServiceManager(QtGui.QWidget):
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, action = context_menu_action(self.serviceManagerList, None, theme,
self.onThemeChangeAction) self.onThemeChangeAction, context=QtCore.Qt.WidgetShortcut)
self.themeMenu.addAction(action) 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.renderManager.set_service_theme(self.service_theme) self.mainwindow.renderManager.set_service_theme(self.service_theme)
@ -1301,4 +1311,4 @@ class ServiceManager(QtGui.QWidget):
Print a Service Order Sheet. Print a Service Order Sheet.
""" """
settingDialog = PrintServiceForm(self.mainwindow, self) settingDialog = PrintServiceForm(self.mainwindow, self)
settingDialog.exec_() settingDialog.exec_()

View File

@ -31,41 +31,72 @@ from openlp.core.lib import translate, build_icon
class Ui_ShortcutListDialog(object): class Ui_ShortcutListDialog(object):
def setupUi(self, shortcutListDialog): def setupUi(self, shortcutListDialog):
shortcutListDialog.setObjectName(u'shortcutListDialog') shortcutListDialog.setObjectName(u'shortcutListDialog')
self.dialogLayout = QtGui.QVBoxLayout(shortcutListDialog) shortcutListDialog.resize(500, 438)
self.dialogLayout.setObjectName(u'dialogLayout') self.shortcutListLayout = QtGui.QVBoxLayout(shortcutListDialog)
self.shortcutListLayout.setObjectName(u'shortcutListLayout')
self.descriptionLabel = QtGui.QLabel(shortcutListDialog)
self.descriptionLabel.setObjectName(u'descriptionLabel')
self.descriptionLabel.setWordWrap(True)
self.shortcutListLayout.addWidget(self.descriptionLabel)
self.treeWidget = QtGui.QTreeWidget(shortcutListDialog) self.treeWidget = QtGui.QTreeWidget(shortcutListDialog)
self.treeWidget.setAlternatingRowColors(True)
self.treeWidget.setObjectName(u'treeWidget') self.treeWidget.setObjectName(u'treeWidget')
self.treeWidget.setAlternatingRowColors(True)
self.treeWidget.setColumnCount(3) self.treeWidget.setColumnCount(3)
self.dialogLayout.addWidget(self.treeWidget) self.treeWidget.setColumnWidth(0, 250)
self.defaultButton = QtGui.QRadioButton(shortcutListDialog) self.shortcutListLayout.addWidget(self.treeWidget)
self.defaultButton.setChecked(True) self.detailsLayout = QtGui.QGridLayout()
self.defaultButton.setObjectName(u'defaultButton') self.detailsLayout.setObjectName(u'detailsLayout')
self.dialogLayout.addWidget(self.defaultButton) self.detailsLayout.setContentsMargins(-1, 0, -1, -1)
self.customLayout = QtGui.QHBoxLayout() self.defaultRadioButton = QtGui.QRadioButton(shortcutListDialog)
self.customLayout.setObjectName(u'customLayout') self.defaultRadioButton.setObjectName(u'defaultRadioButton')
self.customButton = QtGui.QRadioButton(shortcutListDialog) self.defaultRadioButton.setChecked(True)
self.customButton.setObjectName(u'customButton') self.detailsLayout.addWidget(self.defaultRadioButton, 0, 0, 1, 1)
self.customLayout.addWidget(self.customButton) self.customRadioButton = QtGui.QRadioButton(shortcutListDialog)
self.shortcutButton = QtGui.QPushButton(shortcutListDialog) self.customRadioButton.setObjectName(u'customRadioButton')
self.shortcutButton.setIcon( self.detailsLayout.addWidget(self.customRadioButton, 1, 0, 1, 1)
self.primaryLayout = QtGui.QHBoxLayout()
self.primaryLayout.setObjectName(u'primaryLayout')
self.primaryPushButton = QtGui.QPushButton(shortcutListDialog)
self.primaryPushButton.setObjectName(u'primaryPushButton')
self.primaryPushButton.setMinimumSize(QtCore.QSize(84, 0))
self.primaryPushButton.setIcon(
build_icon(u':/system/system_configure_shortcuts.png')) build_icon(u':/system/system_configure_shortcuts.png'))
self.shortcutButton.setCheckable(True) self.primaryPushButton.setCheckable(True)
self.shortcutButton.setObjectName(u'shortcutButton') self.primaryLayout.addWidget(self.primaryPushButton)
self.customLayout.addWidget(self.shortcutButton) self.clearPrimaryButton = QtGui.QToolButton(shortcutListDialog)
self.clearShortcutButton = QtGui.QToolButton(shortcutListDialog) self.clearPrimaryButton.setObjectName(u'clearPrimaryButton')
self.clearShortcutButton.setIcon( self.clearPrimaryButton.setMinimumSize(QtCore.QSize(0, 16))
self.clearPrimaryButton.setIcon(
build_icon(u':/system/clear_shortcut.png')) build_icon(u':/system/clear_shortcut.png'))
self.clearShortcutButton.setAutoRaise(True) self.primaryLayout.addWidget(self.clearPrimaryButton)
self.clearShortcutButton.setObjectName(u'clearShortcutButton') self.detailsLayout.addLayout(self.primaryLayout, 1, 1, 1, 1)
self.customLayout.addWidget(self.clearShortcutButton) self.alternateLayout = QtGui.QHBoxLayout()
self.customLayout.addStretch() self.alternateLayout.setObjectName(u'alternateLayout')
self.dialogLayout.addLayout(self.customLayout) self.alternatePushButton = QtGui.QPushButton(shortcutListDialog)
self.alternatePushButton.setObjectName(u'alternatePushButton')
self.alternatePushButton.setCheckable(True)
self.alternatePushButton.setIcon(
build_icon(u':/system/system_configure_shortcuts.png'))
self.alternateLayout.addWidget(self.alternatePushButton)
self.clearAlternateButton = QtGui.QToolButton(shortcutListDialog)
self.clearAlternateButton.setObjectName(u'clearAlternateButton')
self.clearAlternateButton.setIcon(
build_icon(u':/system/clear_shortcut.png'))
self.alternateLayout.addWidget(self.clearAlternateButton)
self.detailsLayout.addLayout(self.alternateLayout, 1, 2, 1, 1)
self.primaryLabel = QtGui.QLabel(shortcutListDialog)
self.primaryLabel.setObjectName(u'primaryLabel')
self.detailsLayout.addWidget(self.primaryLabel, 0, 1, 1, 1)
self.alternateLabel = QtGui.QLabel(shortcutListDialog)
self.alternateLabel.setObjectName(u'alternateLabel')
self.detailsLayout.addWidget(self.alternateLabel, 0, 2, 1, 1)
self.shortcutListLayout.addLayout(self.detailsLayout)
self.buttonBox = QtGui.QDialogButtonBox(shortcutListDialog) self.buttonBox = QtGui.QDialogButtonBox(shortcutListDialog)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Reset)
self.buttonBox.setObjectName(u'buttonBox') self.buttonBox.setObjectName(u'buttonBox')
self.dialogLayout.addWidget(self.buttonBox) self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.RestoreDefaults)
self.shortcutListLayout.addWidget(self.buttonBox)
self.retranslateUi(shortcutListDialog) self.retranslateUi(shortcutListDialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
shortcutListDialog.accept) shortcutListDialog.accept)
@ -76,13 +107,24 @@ class Ui_ShortcutListDialog(object):
def retranslateUi(self, shortcutListDialog): def retranslateUi(self, shortcutListDialog):
shortcutListDialog.setWindowTitle( shortcutListDialog.setWindowTitle(
translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts')) translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts'))
self.descriptionLabel.setText(translate('OpenLP.ShortcutListDialog',
'Select an action and click one of the buttons below to start '
'capturing a new primary or alternate shortcut, respectively.'))
self.treeWidget.setHeaderLabels([ self.treeWidget.setHeaderLabels([
translate('OpenLP.ShortcutListDialog', 'Action'), translate('OpenLP.ShortcutListDialog', 'Action'),
translate('OpenLP.ShortcutListDialog', 'Shortcut'), translate('OpenLP.ShortcutListDialog', 'Shortcut'),
translate('OpenLP.ShortcutListDialog', 'Alternate')]) translate('OpenLP.ShortcutListDialog', 'Alternate')])
self.defaultButton.setText( self.defaultRadioButton.setText(
translate('OpenLP.ShortcutListDialog', 'Default: %s')) translate('OpenLP.ShortcutListDialog', 'Default'))
self.customButton.setText( self.customRadioButton.setText(
translate('OpenLP.ShortcutListDialog', 'Custom:')) translate('OpenLP.ShortcutListDialog', 'Custom'))
self.shortcutButton.setText( self.primaryPushButton.setToolTip(
translate('OpenLP.ShortcutListDialog', 'None')) translate('OpenLP.ShortcutListDialog', 'Capture shortcut.'))
self.alternatePushButton.setToolTip(
translate('OpenLP.ShortcutListDialog', 'Capture shortcut.'))
self.clearPrimaryButton.setToolTip(
translate('OpenLP.ShortcutListDialog',
'Restore the default shortcut of this action.'))
self.clearAlternateButton.setToolTip(
translate('OpenLP.ShortcutListDialog',
'Restore the default shortcut of this action.'))

View File

@ -30,6 +30,7 @@ import re
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.utils import translate from openlp.core.utils import translate
from openlp.core.utils.actions import ActionList
from shortcutlistdialog import Ui_ShortcutListDialog from shortcutlistdialog import Ui_ShortcutListDialog
REMOVE_AMPERSAND = re.compile(r'&{1}') REMOVE_AMPERSAND = re.compile(r'&{1}')
@ -41,72 +42,391 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
The shortcut list dialog The shortcut list dialog
""" """
def __init__(self, parent): def __init__(self, parent=None):
"""
Do some initialisation stuff
"""
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
self.actionList = None self.changedActions = {}
self.captureShortcut = False self.action_list = ActionList.get_instance()
QtCore.QObject.connect(self.shortcutButton, QtCore.QObject.connect(self.primaryPushButton,
QtCore.SIGNAL(u'toggled(bool)'), self.onShortcutButtonClicked) QtCore.SIGNAL(u'toggled(bool)'), self.onPrimaryPushButtonClicked)
QtCore.QObject.connect(self.alternatePushButton,
QtCore.SIGNAL(u'toggled(bool)'), self.onAlternatePushButtonClicked)
QtCore.QObject.connect(self.treeWidget, QtCore.SIGNAL(
u'currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)'),
self.onCurrentItemChanged)
QtCore.QObject.connect(self.treeWidget,
QtCore.SIGNAL(u'itemDoubleClicked(QTreeWidgetItem*, int)'),
self.onItemDoubleClicked)
QtCore.QObject.connect(self.clearPrimaryButton,
QtCore.SIGNAL(u'clicked(bool)'), self.onClearPrimaryButtonClicked)
QtCore.QObject.connect(self.clearAlternateButton,
QtCore.SIGNAL(u'clicked(bool)'), self.onClearAlternateButtonClicked)
QtCore.QObject.connect(self.buttonBox,
QtCore.SIGNAL(u'clicked(QAbstractButton*)'),
self.onRestoreDefaultsClicked)
QtCore.QObject.connect(self.defaultRadioButton,
QtCore.SIGNAL(u'clicked(bool)'), self.onDefaultRadioButtonClicked)
QtCore.QObject.connect(self.customRadioButton,
QtCore.SIGNAL(u'clicked(bool)'), self.onCustomRadioButtonClicked)
def keyPressEvent(self, event):
if self.primaryPushButton.isChecked() or \
self.alternatePushButton.isChecked():
event.ignore()
elif event.key() == QtCore.Qt.Key_Escape:
event.accept()
self.close()
def keyReleaseEvent(self, event): def keyReleaseEvent(self, event):
Qt = QtCore.Qt if not self.primaryPushButton.isChecked() and \
if not self.captureShortcut: not self.alternatePushButton.isChecked():
return return
key = event.key() key = event.key()
if key == Qt.Key_Shift or key == Qt.Key_Control or \ if key == QtCore.Qt.Key_Shift or key == QtCore.Qt.Key_Control or \
key == Qt.Key_Meta or key == Qt.Key_Alt: key == QtCore.Qt.Key_Meta or key == QtCore.Qt.Key_Alt:
return return
key_string = QtGui.QKeySequence(key).toString() key_string = QtGui.QKeySequence(key).toString()
if event.modifiers() & Qt.ControlModifier == Qt.ControlModifier: if event.modifiers() & QtCore.Qt.ControlModifier == \
QtCore.Qt.ControlModifier:
key_string = u'Ctrl+' + key_string key_string = u'Ctrl+' + key_string
if event.modifiers() & Qt.AltModifier == Qt.AltModifier: if event.modifiers() & QtCore.Qt.AltModifier == QtCore.Qt.AltModifier:
key_string = u'Alt+' + key_string key_string = u'Alt+' + key_string
if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier: if event.modifiers() & QtCore.Qt.ShiftModifier == \
QtCore.Qt.ShiftModifier:
key_string = u'Shift+' + key_string key_string = u'Shift+' + key_string
key_sequence = QtGui.QKeySequence(key_string) key_sequence = QtGui.QKeySequence(key_string)
existing_key = QtGui.QKeySequence(u'Ctrl+Shift+F8') # The action we are attempting to change.
if key_sequence == existing_key: changing_action = self._currentItemAction()
QtGui.QMessageBox.warning( shortcut_valid = True
self, for category in self.action_list.categories:
for action in category.actions:
shortcuts = self._actionShortcuts(action)
if key_sequence not in shortcuts:
continue
if action is changing_action:
if self.primaryPushButton.isChecked() and \
shortcuts.index(key_sequence) == 0:
continue
if self.alternatePushButton.isChecked() and \
shortcuts.index(key_sequence) == 1:
continue
# Have the same parent, thus they cannot have the same shortcut.
if action.parent() is changing_action.parent():
shortcut_valid = False
# The new shortcut is already assigned, but if both shortcuts
# are only valid in a different widget the new shortcut is
# vaild, because they will not interfere.
if action.shortcutContext() in [QtCore.Qt.WindowShortcut,
QtCore.Qt.ApplicationShortcut]:
shortcut_valid = False
if changing_action.shortcutContext() in \
[QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]:
shortcut_valid = False
if not shortcut_valid:
QtGui.QMessageBox.warning(self,
translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'), translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'),
unicode(translate('OpenLP.ShortcutListDialog', 'The shortcut ' unicode(translate('OpenLP.ShortcutListDialog', 'The shortcut '
'"%s" is already assigned to another action, please ' '"%s" is already assigned to another action, please '
'use a different shortcut.')) % key_sequence.toString(), 'use a different shortcut.')) % key_sequence.toString(),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
QtGui.QMessageBox.Ok QtGui.QMessageBox.Ok
) )
else: else:
self.shortcutButton.setText(key_sequence.toString()) if self.primaryPushButton.isChecked():
self.shortcutButton.setChecked(False) self._adjustButton(self.primaryPushButton,
self.captureShortcut = False False, text=key_sequence.toString())
elif self.alternatePushButton.isChecked():
self._adjustButton(self.alternatePushButton,
False, text=key_sequence.toString())
def exec_(self, actionList): def exec_(self):
self.actionList = actionList self.changedActions = {}
self.refreshActions() self.reloadShortcutList()
self._adjustButton(self.primaryPushButton, False, False, u'')
self._adjustButton(self.alternatePushButton, False, False, u'')
return QtGui.QDialog.exec_(self) return QtGui.QDialog.exec_(self)
def refreshActions(self): def reloadShortcutList(self):
"""
Reload the ``treeWidget`` list to add new and remove old actions.
"""
self.treeWidget.clear() self.treeWidget.clear()
for category in self.actionList.categories: for category in self.action_list.categories:
# Check if the category is for internal use only.
if category.name is None:
continue
item = QtGui.QTreeWidgetItem([category.name]) item = QtGui.QTreeWidgetItem([category.name])
for action in category.actions: for action in category.actions:
actionText = REMOVE_AMPERSAND.sub('', unicode(action.text())) actionText = REMOVE_AMPERSAND.sub('', unicode(action.text()))
if (len(action.shortcuts()) == 2): actionItem = QtGui.QTreeWidgetItem([actionText])
shortcutText = action.shortcuts()[0].toString()
alternateText = action.shortcuts()[1].toString()
else:
shortcutText = action.shortcut().toString()
alternateText = u''
actionItem = QtGui.QTreeWidgetItem(
[actionText, shortcutText, alternateText])
actionItem.setIcon(0, action.icon()) actionItem.setIcon(0, action.icon())
actionItem.setData(0,
QtCore.Qt.UserRole, QtCore.QVariant(action))
item.addChild(actionItem) item.addChild(actionItem)
item.setExpanded(True)
self.treeWidget.addTopLevelItem(item) self.treeWidget.addTopLevelItem(item)
item.setExpanded(True)
self.refreshShortcutList()
def onShortcutButtonClicked(self, toggled): def refreshShortcutList(self):
self.captureShortcut = toggled """
This refreshes the item's shortcuts shown in the list. Note, this
neither adds new actions nor removes old actions.
"""
iterator = QtGui.QTreeWidgetItemIterator(self.treeWidget)
while iterator.value():
item = iterator.value()
iterator += 1
action = self._currentItemAction(item)
if action is None:
continue
shortcuts = self._actionShortcuts(action)
if len(shortcuts) == 0:
item.setText(1, u'')
item.setText(2, u'')
elif len(shortcuts) == 1:
item.setText(1, shortcuts[0].toString())
item.setText(2, u'')
else:
item.setText(1, shortcuts[0].toString())
item.setText(2, shortcuts[1].toString())
self.onCurrentItemChanged()
def onPrimaryPushButtonClicked(self, toggled):
"""
Save the new primary shortcut.
"""
self.customRadioButton.setChecked(True)
if toggled:
self.alternatePushButton.setChecked(False)
return
action = self._currentItemAction()
if action is None:
return
shortcuts = self._actionShortcuts(action)
new_shortcuts = [QtGui.QKeySequence(self.primaryPushButton.text())]
if len(shortcuts) == 2:
new_shortcuts.append(shortcuts[1])
self.changedActions[action] = new_shortcuts
self.refreshShortcutList()
def onAlternatePushButtonClicked(self, toggled):
"""
Save the new alternate shortcut.
"""
self.customRadioButton.setChecked(True)
if toggled:
self.primaryPushButton.setChecked(False)
return
action = self._currentItemAction()
if action is None:
return
shortcuts = self._actionShortcuts(action)
new_shortcuts = []
if len(shortcuts) != 0:
new_shortcuts.append(shortcuts[0])
new_shortcuts.append(
QtGui.QKeySequence(self.alternatePushButton.text()))
self.changedActions[action] = new_shortcuts
self.refreshShortcutList()
def onItemDoubleClicked(self, item, column):
"""
A item has been double clicked. The ``primaryPushButton`` will be
checked and the item's shortcut will be displayed.
"""
action = self._currentItemAction(item)
if action is None:
return
self.primaryPushButton.setChecked(column in [0, 1])
self.alternatePushButton.setChecked(column not in [0, 1])
if column in [0, 1]:
self.primaryPushButton.setFocus(QtCore.Qt.OtherFocusReason)
else:
self.alternatePushButton.setFocus(QtCore.Qt.OtherFocusReason)
self.onCurrentItemChanged(item)
def onCurrentItemChanged(self, item=None, previousItem=None):
"""
A item has been pressed. We adjust the button's text to the action's
shortcut which is encapsulate in the item.
"""
action = self._currentItemAction(item)
self.primaryPushButton.setEnabled(action is not None)
self.alternatePushButton.setEnabled(action is not None)
primary_text = u''
alternate_text = u''
primary_label_text = u''
alternate_label_text = u''
if action is None:
self.primaryPushButton.setChecked(False)
self.alternatePushButton.setChecked(False)
else:
if len(action.defaultShortcuts) != 0:
primary_label_text = action.defaultShortcuts[0].toString()
if len(action.defaultShortcuts) == 2:
alternate_label_text = action.defaultShortcuts[1].toString()
shortcuts = self._actionShortcuts(action)
# We do not want to loose pending changes, that is why we have to
# keep the text when, this function has not been triggered by a signal.
if item is None:
primary_text = self.primaryPushButton.text()
alternate_text = self.alternatePushButton.text()
elif len(shortcuts) == 1:
primary_text = shortcuts[0].toString()
elif len(shortcuts) == 2:
primary_text = shortcuts[0].toString()
alternate_text = shortcuts[1].toString()
self.primaryPushButton.setText(primary_text)
self.alternatePushButton.setText(alternate_text)
self.primaryLabel.setText(primary_label_text)
self.alternateLabel.setText(alternate_label_text)
# We do not want to toggle and radio button, as the function has not
# been triggered by a signal.
if item is None:
return
if primary_label_text == primary_text and \
alternate_label_text == alternate_text:
self.defaultRadioButton.toggle()
else:
self.customRadioButton.toggle()
def onRestoreDefaultsClicked(self, button):
"""
Restores all default shortcuts.
"""
if self.buttonBox.buttonRole(button) != QtGui.QDialogButtonBox.ResetRole:
return
if QtGui.QMessageBox.question(self,
translate('OpenLP.ShortcutListDialog', 'Restore Default Shortcuts'),
translate('OpenLP.ShortcutListDialog', 'Do you want to restore all '
'shortcuts to their defaults?'), QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No)) == QtGui.QMessageBox.No:
return
self._adjustButton(self.primaryPushButton, False, text=u'')
self._adjustButton(self.alternatePushButton, False, text=u'')
for category in self.action_list.categories:
for action in category.actions:
self.changedActions[action] = action.defaultShortcuts
self.refreshShortcutList()
def onDefaultRadioButtonClicked(self, toggled):
"""
The default radio button has been clicked, which means we have to make
sure, that we use the default shortcuts for the action.
"""
if not toggled:
return
action = self._currentItemAction()
if action is None:
return
temp_shortcuts = self._actionShortcuts(action)
self.changedActions[action] = action.defaultShortcuts
self.refreshShortcutList()
primary_button_text = u''
alternate_button_text = u''
if len(temp_shortcuts) != 0:
primary_button_text = temp_shortcuts[0].toString()
if len(temp_shortcuts) == 2:
alternate_button_text = temp_shortcuts[1].toString()
self.primaryPushButton.setText(primary_button_text)
self.alternatePushButton.setText(alternate_button_text)
def onCustomRadioButtonClicked(self, toggled):
"""
The custom shortcut radio button was clicked, thus we have to restore
the custom shortcuts by calling those functions triggered by button
clicks.
"""
if not toggled:
return
self.onPrimaryPushButtonClicked(False)
self.onAlternatePushButtonClicked(False)
self.refreshShortcutList()
def save(self):
"""
Save the shortcuts. **Note**, that we do not have to load the shortcuts,
as they are loaded in :class:`~openlp.core.utils.ActionList`.
"""
settings = QtCore.QSettings()
settings.beginGroup(u'shortcuts')
for category in self.action_list.categories:
# Check if the category is for internal use only.
if category.name is None:
continue
for action in category.actions:
if self.changedActions .has_key(action):
action.setShortcuts(self.changedActions[action])
settings.setValue(
action.objectName(), QtCore.QVariant(action.shortcuts()))
settings.endGroup()
def onClearPrimaryButtonClicked(self, toggled):
"""
Restore the defaults of this action.
"""
self.primaryPushButton.setChecked(False)
action = self._currentItemAction()
if action is None:
return
shortcuts = self._actionShortcuts(action)
new_shortcuts = []
if len(action.defaultShortcuts) != 0:
new_shortcuts.append(action.defaultShortcuts[0])
if len(shortcuts) == 2:
new_shortcuts.append(shortcuts[1])
self.changedActions[action] = new_shortcuts
self.refreshShortcutList()
self.onCurrentItemChanged(self.treeWidget.currentItem())
def onClearAlternateButtonClicked(self, toggled):
"""
Restore the defaults of this action.
"""
self.alternatePushButton.setChecked(False)
action = self._currentItemAction()
if action is None:
return
shortcuts = self._actionShortcuts(action)
new_shortcuts = []
if len(shortcuts) != 0:
new_shortcuts.append(shortcuts[0])
if len(action.defaultShortcuts) == 2:
new_shortcuts.append(action.defaultShortcuts[1])
self.changedActions[action] = new_shortcuts
self.refreshShortcutList()
self.onCurrentItemChanged(self.treeWidget.currentItem())
def _actionShortcuts(self, action):
"""
This returns the shortcuts for the given ``action``, which also includes
those shortcuts which are not saved yet but already assigned (as changes
are applied when closing the dialog).
"""
if self.changedActions.has_key(action):
return self.changedActions[action]
return action.shortcuts()
def _currentItemAction(self, item=None):
"""
Returns the action of the given ``item``. If no item is given, we return
the action of the current item of the ``treeWidget``.
"""
if item is None:
item = self.treeWidget.currentItem()
if item is None:
return
return item.data(0, QtCore.Qt.UserRole).toPyObject()
def _adjustButton(self, button, checked=None, enabled=None, text=None):
"""
Can be called to adjust more properties of the given ``button`` at once.
"""
# Set the text before checking the button, because this emits a signal.
if text is not None:
button.setText(text)
if checked is not None:
button.setChecked(checked)
if enabled is not None:
button.setEnabled(enabled)

View File

@ -32,8 +32,9 @@ from PyQt4.phonon import Phonon
from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \ from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \
ItemCapabilities, translate ItemCapabilities, translate
from openlp.core.lib.ui import icon_action, UiStrings, shortcut_action from openlp.core.lib.ui import UiStrings, shortcut_action
from openlp.core.ui import HideMode, MainDisplay from openlp.core.ui import HideMode, MainDisplay
from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -140,12 +141,16 @@ class SlideController(QtGui.QWidget):
translate('OpenLP.SlideController', 'Previous Slide'), translate('OpenLP.SlideController', 'Previous Slide'),
u':/slides/slide_previous.png', u':/slides/slide_previous.png',
translate('OpenLP.SlideController', 'Move to previous'), translate('OpenLP.SlideController', 'Move to previous'),
self.onSlideSelectedPrevious) self.onSlideSelectedPrevious,
shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp],
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.nextItem = self.toolbar.addToolbarButton( self.nextItem = self.toolbar.addToolbarButton(
translate('OpenLP.SlideController', 'Next Slide'), translate('OpenLP.SlideController', 'Next Slide'),
u':/slides/slide_next.png', u':/slides/slide_next.png',
translate('OpenLP.SlideController', 'Move to next'), translate('OpenLP.SlideController', 'Move to next'),
self.onSlideSelectedNext) self.onSlideSelectedNext,
shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown],
context=QtCore.Qt.WidgetWithChildrenShortcut)
self.toolbar.addToolbarSeparator(u'Close Separator') self.toolbar.addToolbarSeparator(u'Close Separator')
if self.isLive: if self.isLive:
self.hideMenu = QtGui.QToolButton(self.toolbar) self.hideMenu = QtGui.QToolButton(self.toolbar)
@ -154,16 +159,20 @@ class SlideController(QtGui.QWidget):
self.toolbar.addToolbarWidget(u'Hide Menu', self.hideMenu) self.toolbar.addToolbarWidget(u'Hide Menu', self.hideMenu)
self.hideMenu.setMenu(QtGui.QMenu( self.hideMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Hide'), self.toolbar)) translate('OpenLP.SlideController', 'Hide'), self.toolbar))
self.blankScreen = icon_action(self.hideMenu, u'Blank Screen', self.blankScreen = shortcut_action(self.hideMenu, u'blankScreen',
u':/slides/slide_blank.png', False) [QtCore.Qt.Key_Period], self.onBlankDisplay,
u':/slides/slide_blank.png', False, UiStrings.LiveToolbar)
self.blankScreen.setText( self.blankScreen.setText(
translate('OpenLP.SlideController', 'Blank Screen')) translate('OpenLP.SlideController', 'Blank Screen'))
self.themeScreen = icon_action(self.hideMenu, u'Blank Theme', self.themeScreen = shortcut_action(self.hideMenu, u'themeScreen',
u':/slides/slide_theme.png', False) [QtGui.QKeySequence(u'T')], self.onThemeDisplay,
u':/slides/slide_theme.png', False, UiStrings.LiveToolbar)
self.themeScreen.setText( self.themeScreen.setText(
translate('OpenLP.SlideController', 'Blank to Theme')) translate('OpenLP.SlideController', 'Blank to Theme'))
self.desktopScreen = icon_action(self.hideMenu, u'Desktop Screen', self.desktopScreen = shortcut_action(self.hideMenu,
u':/slides/slide_desktop.png', False) u'desktopScreen', [QtGui.QKeySequence(u'D')],
self.onHideDisplay, u':/slides/slide_desktop.png', False,
UiStrings.LiveToolbar)
self.desktopScreen.setText( self.desktopScreen.setText(
translate('OpenLP.SlideController', 'Show Desktop')) translate('OpenLP.SlideController', 'Show Desktop'))
self.hideMenu.setDefaultAction(self.blankScreen) self.hideMenu.setDefaultAction(self.blankScreen)
@ -291,12 +300,6 @@ class SlideController(QtGui.QWidget):
QtCore.QObject.connect(self.previewListWidget, QtCore.QObject.connect(self.previewListWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
if self.isLive: if self.isLive:
QtCore.QObject.connect(self.blankScreen,
QtCore.SIGNAL(u'triggered(bool)'), self.onBlankDisplay)
QtCore.QObject.connect(self.themeScreen,
QtCore.SIGNAL(u'triggered(bool)'), self.onThemeDisplay)
QtCore.QObject.connect(self.desktopScreen,
QtCore.SIGNAL(u'triggered(bool)'), self.onHideDisplay)
QtCore.QObject.connect(self.volumeSlider, QtCore.QObject.connect(self.volumeSlider,
QtCore.SIGNAL(u'sliderReleased()'), self.mediaVolume) QtCore.SIGNAL(u'sliderReleased()'), self.mediaVolume)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
@ -362,33 +365,37 @@ class SlideController(QtGui.QWidget):
QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged) QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged)
def setPreviewHotkeys(self, parent=None): def setPreviewHotkeys(self, parent=None):
actionList = self.parent.actionList self.previousItem.setObjectName(u'previousItemPreview')
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, 0]) self.nextItem.setObjectName(u'nextItemPreview')
actionList.add_action(self.previousItem, u'Preview') action_list = ActionList.get_instance()
self.nextItem.setShortcuts([QtCore.Qt.Key_Down, 0]) action_list.add_category(
actionList.add_action(self.nextItem, u'Preview') UiStrings.PreviewToolbar, CategoryOrder.standardToolbar)
action_list.add_action(self.previousItem, UiStrings.PreviewToolbar)
action_list.add_action(self.nextItem, UiStrings.PreviewToolbar)
def setLiveHotkeys(self, parent=None): def setLiveHotkeys(self, parent=None):
actionList = self.parent.actionList self.previousItem.setObjectName(u'previousItemLive')
self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp]) self.nextItem.setObjectName(u'nextItemLive')
self.previousItem.setShortcutContext( action_list = ActionList.get_instance()
QtCore.Qt.WidgetWithChildrenShortcut) action_list.add_category(
actionList.add_action(self.previousItem, u'Live') UiStrings.LiveToolbar, CategoryOrder.standardToolbar)
self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown]) action_list.add_action(self.previousItem, UiStrings.LiveToolbar)
self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) action_list.add_action(self.nextItem, UiStrings.LiveToolbar)
actionList.add_action(self.nextItem, u'Live') self.previousService = shortcut_action(parent, u'previousService',
self.previousService = shortcut_action(parent, [QtCore.Qt.Key_Left], self.servicePrevious, UiStrings.LiveToolbar)
translate('OpenLP.SlideController', 'Previous Service'), self.previousService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
[QtCore.Qt.Key_Left, 0], self.servicePrevious) self.previousService.setText(
actionList.add_action(self.previousService, u'Live') translate('OpenLP.SlideController', 'Previous Service'))
self.nextService = shortcut_action(parent, self.nextService = shortcut_action(parent, 'nextService',
translate('OpenLP.SlideController', 'Next Service'), [QtCore.Qt.Key_Right], self.serviceNext, UiStrings.LiveToolbar)
[QtCore.Qt.Key_Right, 0], self.serviceNext) self.nextService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
actionList.add_action(self.nextService, u'Live') self.nextService.setText(
self.escapeItem = shortcut_action(parent, translate('OpenLP.SlideController', 'Next Service'))
translate('OpenLP.SlideController', 'Escape Item'), self.escapeItem = shortcut_action(parent, 'escapeItem',
[QtCore.Qt.Key_Escape, 0], self.liveEscape) [QtCore.Qt.Key_Escape], self.liveEscape, UiStrings.LiveToolbar)
actionList.add_action(self.escapeItem, u'Live') self.escapeItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
self.escapeItem.setText(
translate('OpenLP.SlideController', 'Escape Item'))
def liveEscape(self): def liveEscape(self):
self.display.setVisible(False) self.display.setVisible(False)
@ -741,10 +748,12 @@ class SlideController(QtGui.QWidget):
""" """
self.onBlankDisplay(False) self.onBlankDisplay(False)
def onBlankDisplay(self, checked): def onBlankDisplay(self, checked=None):
""" """
Handle the blank screen button actions Handle the blank screen button actions
""" """
if checked is None:
checked = self.blankScreen.isChecked()
log.debug(u'onBlankDisplay %s' % checked) log.debug(u'onBlankDisplay %s' % checked)
self.hideMenu.setDefaultAction(self.blankScreen) self.hideMenu.setDefaultAction(self.blankScreen)
self.blankScreen.setChecked(checked) self.blankScreen.setChecked(checked)
@ -762,10 +771,12 @@ class SlideController(QtGui.QWidget):
self.blankPlugin(checked) self.blankPlugin(checked)
self.updatePreview() self.updatePreview()
def onThemeDisplay(self, checked): def onThemeDisplay(self, checked=None):
""" """
Handle the Theme screen button Handle the Theme screen button
""" """
if checked is None:
checked = self.themeScreen.isChecked()
log.debug(u'onThemeDisplay %s' % checked) log.debug(u'onThemeDisplay %s' % checked)
self.hideMenu.setDefaultAction(self.themeScreen) self.hideMenu.setDefaultAction(self.themeScreen)
self.blankScreen.setChecked(False) self.blankScreen.setChecked(False)
@ -783,10 +794,12 @@ class SlideController(QtGui.QWidget):
self.blankPlugin(checked) self.blankPlugin(checked)
self.updatePreview() self.updatePreview()
def onHideDisplay(self, checked): def onHideDisplay(self, checked=None):
""" """
Handle the Hide screen button Handle the Hide screen button
""" """
if checked is None:
checked = self.desktopScreen.isChecked()
log.debug(u'onHideDisplay %s' % checked) log.debug(u'onHideDisplay %s' % checked)
self.hideMenu.setDefaultAction(self.desktopScreen) self.hideMenu.setDefaultAction(self.desktopScreen)
self.blankScreen.setChecked(False) self.blankScreen.setChecked(False)

View File

@ -495,7 +495,7 @@ def get_uno_instance(resolver):
from languagemanager import LanguageManager from languagemanager import LanguageManager
from actions import ActionList from actions import ActionList
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions', __all__ = [u'AppLocation', u'get_application_version', u'check_latest_version',
u'get_filesystem_encoding', u'LanguageManager', u'ActionList', u'add_actions', u'get_filesystem_encoding', u'LanguageManager',
u'get_web_page', u'file_is_unicode', u'string_is_unicode', u'ActionList', u'get_web_page', u'file_is_unicode', u'string_is_unicode',
u'get_uno_command', u'get_uno_instance', u'delete_file'] u'get_uno_command', u'get_uno_instance', u'delete_file']

View File

@ -27,6 +27,8 @@
The :mod:`~openlp.core.utils.actions` module provides action list classes used The :mod:`~openlp.core.utils.actions` module provides action list classes used
by the shortcuts system. by the shortcuts system.
""" """
from PyQt4 import QtCore, QtGui
class ActionCategory(object): class ActionCategory(object):
""" """
The :class:`~openlp.core.utils.ActionCategory` class encapsulates a The :class:`~openlp.core.utils.ActionCategory` class encapsulates a
@ -67,6 +69,7 @@ class CategoryActionList(object):
Python 3 "next" method. Python 3 "next" method.
""" """
if self.index >= len(self.actions): if self.index >= len(self.actions):
self.index = 0
raise StopIteration raise StopIteration
else: else:
self.index += 1 self.index += 1
@ -94,6 +97,12 @@ class CategoryActionList(object):
self.actions.append((weight, action)) self.actions.append((weight, action))
self.actions.sort(key=lambda act: act[0]) self.actions.sort(key=lambda act: act[0])
def remove(self, remove_action):
for action in self.actions:
if action[1] == remove_action:
self.actions.remove(action)
return
class CategoryList(object): class CategoryList(object):
""" """
@ -126,6 +135,7 @@ class CategoryList(object):
Python 3 "next" method for iterator. Python 3 "next" method for iterator.
""" """
if self.index >= len(self.categories): if self.index >= len(self.categories):
self.index = 0
raise StopIteration raise StopIteration
else: else:
self.index += 1 self.index += 1
@ -163,6 +173,11 @@ class CategoryList(object):
self.categories.append(category) self.categories.append(category)
self.categories.sort(key=lambda cat: cat.weight) self.categories.sort(key=lambda cat: cat.weight)
def remove(self, name):
for category in self.categories:
if category.name == name:
self.categories.remove(category)
class ActionList(object): class ActionList(object):
""" """
@ -171,13 +186,101 @@ class ActionList(object):
has a weight by which it is sorted when iterating through the list of has a weight by which it is sorted when iterating through the list of
actions or categories. actions or categories.
""" """
instance = None
def __init__(self): def __init__(self):
self.categories = CategoryList() self.categories = CategoryList()
def add_action(self, action, category=u'Default', weight=None): @staticmethod
def get_instance():
if ActionList.instance is None:
ActionList.instance = ActionList()
return ActionList.instance
def add_action(self, action, category=None, weight=None):
"""
Add an action to the list of actions.
``action``
The action to add (QAction).
``category``
The category this action belongs to. The category can be a QString
or python unicode string. **Note**, if the category is ``None``, the
category and its actions are being hidden in the shortcut dialog.
However, if they are added, it is possible to avoid assigning
shortcuts twice, which is important.
``weight``
The weight specifies how important a category is. However, this only
has an impact on the order the categories are displayed.
"""
if category is not None:
category = unicode(category)
if category not in self.categories: if category not in self.categories:
self.categories.append(category) self.categories.append(category)
action.defaultShortcuts = action.shortcuts()
if weight is None: if weight is None:
self.categories[category].actions.append(action) self.categories[category].actions.append(action)
else: else:
self.categories[category].actions.add(action, weight) self.categories[category].actions.add(action, weight)
if category is None:
# Stop here, as this action is not configurable.
return
# Load the shortcut from the config.
settings = QtCore.QSettings()
settings.beginGroup(u'shortcuts')
shortcuts = settings.value(action.objectName(),
QtCore.QVariant(action.shortcuts())).toStringList()
action.setShortcuts(
[QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
settings.endGroup()
def remove_action(self, action, category=None):
"""
This removes an action from its category. Empty categories are
automatically removed.
``action``
The QAction object to be removed.
``category``
The name (unicode string) of the category, which contains the
action. Defaults to None.
"""
if category is not None:
category = unicode(category)
if category not in self.categories:
return
self.categories[category].actions.remove(action)
# Remove empty categories.
if len(self.categories[category].actions) == 0:
self.categories.remove(category)
def add_category(self, name, weight):
"""
Add an empty category to the list of categories. This is ony convenient
for categories with a given weight.
``name``
The category's name.
``weight``
The category's weight (int).
"""
if name in self.categories:
# Only change the weight and resort the categories again.
for category in self.categories:
if category.name == name:
category.weight = weight
self.categories.categories.sort(key=lambda cat: cat.weight)
return
self.categories.add(name, weight)
class CategoryOrder(object):
"""
An enumeration class for category weights.
"""
standardMenu = -20
standardToolbar = -10

View File

@ -30,6 +30,8 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib import Plugin, StringContent, build_icon, translate
from openlp.core.lib.db import Manager from openlp.core.lib.db import Manager
from openlp.core.lib.ui import icon_action, UiStrings
from openlp.core.utils.actions import ActionList
from openlp.plugins.alerts.lib import AlertsManager, AlertsTab from openlp.plugins.alerts.lib import AlertsManager, AlertsTab
from openlp.plugins.alerts.lib.db import init_schema from openlp.plugins.alerts.lib.db import init_schema
from openlp.plugins.alerts.forms import AlertForm from openlp.plugins.alerts.forms import AlertForm
@ -59,9 +61,8 @@ class AlertsPlugin(Plugin):
use it as their parent. use it as their parent.
""" """
log.info(u'add tools menu') log.info(u'add tools menu')
self.toolsAlertItem = QtGui.QAction(tools_menu) self.toolsAlertItem = icon_action(tools_menu, u'toolsAlertItem',
self.toolsAlertItem.setIcon(build_icon(u':/plugins/plugin_alerts.png')) u':/plugins/plugin_alerts.png')
self.toolsAlertItem.setObjectName(u'toolsAlertItem')
self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert')) self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert'))
self.toolsAlertItem.setStatusTip( self.toolsAlertItem.setStatusTip(
translate('AlertsPlugin', 'Show an alert message.')) translate('AlertsPlugin', 'Show an alert message.'))
@ -75,6 +76,8 @@ class AlertsPlugin(Plugin):
log.info(u'Alerts Initialising') log.info(u'Alerts Initialising')
Plugin.initialise(self) Plugin.initialise(self)
self.toolsAlertItem.setVisible(True) self.toolsAlertItem.setVisible(True)
action_list = ActionList.get_instance()
action_list.add_action(self.toolsAlertItem, UiStrings.Tools)
self.liveController.alertTab = self.settings_tab self.liveController.alertTab = self.settings_tab
def finalise(self): def finalise(self):
@ -85,6 +88,8 @@ class AlertsPlugin(Plugin):
self.manager.finalise() self.manager.finalise()
Plugin.finalise(self) Plugin.finalise(self)
self.toolsAlertItem.setVisible(False) self.toolsAlertItem.setVisible(False)
action_list = ActionList.get_instance()
action_list.remove_action(self.toolsAlertItem, u'Tools')
def toggleAlertsState(self): def toggleAlertsState(self):
self.alertsActive = not self.alertsActive self.alertsActive = not self.alertsActive

View File

@ -29,6 +29,8 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib import Plugin, StringContent, build_icon, translate
from openlp.core.lib.ui import base_action, UiStrings
from openlp.core.utils.actions import ActionList
from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -50,6 +52,10 @@ class BiblePlugin(Plugin):
self.manager = BibleManager(self) self.manager = BibleManager(self)
Plugin.initialise(self) Plugin.initialise(self)
self.importBibleItem.setVisible(True) self.importBibleItem.setVisible(True)
action_list = ActionList.get_instance()
action_list.add_action(self.importBibleItem, UiStrings.Import)
# Do not add the action to the list yet.
#action_list.add_action(self.exportBibleItem, UiStrings.Export)
# Set to invisible until we can export bibles # Set to invisible until we can export bibles
self.exportBibleItem.setVisible(False) self.exportBibleItem.setVisible(False)
@ -60,25 +66,25 @@ class BiblePlugin(Plugin):
log.info(u'Plugin Finalise') log.info(u'Plugin Finalise')
self.manager.finalise() self.manager.finalise()
Plugin.finalise(self) Plugin.finalise(self)
action_list = ActionList.get_instance()
action_list.remove_action(self.importBibleItem, UiStrings.Import)
self.importBibleItem.setVisible(False) self.importBibleItem.setVisible(False)
#action_list.remove_action(self.exportBibleItem, UiStrings.Export)
self.exportBibleItem.setVisible(False) self.exportBibleItem.setVisible(False)
def addImportMenuItem(self, import_menu): def addImportMenuItem(self, import_menu):
self.importBibleItem = QtGui.QAction(import_menu) self.importBibleItem = base_action(import_menu, u'importBibleItem')
self.importBibleItem.setObjectName(u'importBibleItem') self.importBibleItem.setText(translate('BiblesPlugin', '&Bible'))
import_menu.addAction(self.importBibleItem) import_menu.addAction(self.importBibleItem)
self.importBibleItem.setText(
translate('BiblesPlugin', '&Bible'))
# signals and slots # signals and slots
QtCore.QObject.connect(self.importBibleItem, QtCore.QObject.connect(self.importBibleItem,
QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick) QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick)
self.importBibleItem.setVisible(False) self.importBibleItem.setVisible(False)
def addExportMenuItem(self, export_menu): def addExportMenuItem(self, export_menu):
self.exportBibleItem = QtGui.QAction(export_menu) self.exportBibleItem = base_action(export_menu, u'exportBibleItem')
self.exportBibleItem.setObjectName(u'exportBibleItem')
export_menu.addAction(self.exportBibleItem)
self.exportBibleItem.setText(translate('BiblesPlugin', '&Bible')) self.exportBibleItem.setText(translate('BiblesPlugin', '&Bible'))
export_menu.addAction(self.exportBibleItem)
self.exportBibleItem.setVisible(False) self.exportBibleItem.setVisible(False)
def onBibleImportClick(self): def onBibleImportClick(self):

View File

@ -85,8 +85,18 @@ class BibleImportForm(OpenLPWizard):
""" """
OpenLPWizard.setupUi(self, image) OpenLPWizard.setupUi(self, image)
QtCore.QObject.connect(self.formatComboBox, QtCore.QObject.connect(self.formatComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'), self.selectStack, QtCore.SIGNAL(u'currentIndexChanged(int)'),
QtCore.SLOT(u'setCurrentIndex(int)')) self.onCurrentIndexChanged)
def onCurrentIndexChanged(self, index):
"""
Called when the format combo box's index changed. We have to check if
the import is available and accordingly to disable or enable the next
button.
"""
self.selectStack.setCurrentIndex(index)
next_button = self.button(QtGui.QWizard.NextButton)
next_button.setEnabled(BibleFormat.get_availability(index))
def customInit(self): def customInit(self):
""" """

View File

@ -322,11 +322,12 @@ class BibleMediaItem(MediaManagerItem):
self.advancedVersionComboBox.addItem(bible) self.advancedVersionComboBox.addItem(bible)
self.advancedSecondComboBox.addItem(bible) self.advancedSecondComboBox.addItem(bible)
# set the default value # set the default value
book = QtCore.QSettings().value( bible = QtCore.QSettings().value(
self.settingsSection + u'/advanced bible', self.settingsSection + u'/advanced bible',
QtCore.QVariant(u'')).toString() QtCore.QVariant(u'')).toString()
find_and_set_in_combo_box(self.advancedVersionComboBox, book) if bible in bibles:
self.initialiseAdvancedBible(unicode(book)) find_and_set_in_combo_box(self.advancedVersionComboBox, bible)
self.initialiseAdvancedBible(unicode(bible))
def reloadBibles(self): def reloadBibles(self):
log.debug(u'Reloading Bibles') log.debug(u'Reloading Bibles')

View File

@ -66,7 +66,17 @@ class SongImportForm(OpenLPWizard):
self.formatStack.setCurrentIndex(0) self.formatStack.setCurrentIndex(0)
QtCore.QObject.connect(self.formatComboBox, QtCore.QObject.connect(self.formatComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'), QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.formatStack.setCurrentIndex) self.onCurrentIndexChanged)
def onCurrentIndexChanged(self, index):
"""
Called when the format combo box's index changed. We have to check if
the import is available and accordingly to disable or enable the next
button.
"""
self.formatStack.setCurrentIndex(index)
next_button = self.button(QtGui.QWizard.NextButton)
next_button.setEnabled(SongFormat.get_availability(index))
def customInit(self): def customInit(self):
""" """

View File

@ -283,19 +283,20 @@ class SongMediaItem(MediaManagerItem):
self.remoteTriggered = None self.remoteTriggered = None
self.remoteSong = -1 self.remoteSong = -1
def onRemoteEdit(self, songid): def onRemoteEdit(self, message):
""" """
Called by ServiceManager or SlideController by event passing Called by ServiceManager or SlideController by event passing
the Song Id in the payload along with an indicator to say which the Song Id in the payload along with an indicator to say which
type of display is required. type of display is required.
""" """
log.debug(u'onRemoteEdit %s' % songid) log.debug(u'onRemoteEdit %s' % message)
fields = songid.split(u':') remote_type, song_id = message.split(u':')
valid = self.parent.manager.get_object(Song, fields[1]) song_id = int(song_id)
valid = self.parent.manager.get_object(Song, song_id)
if valid: if valid:
self.remoteSong = fields[1] self.remoteSong = song_id
self.remoteTriggered = fields[0] self.remoteTriggered = remote_type
self.edit_song_form.loadSong(fields[1], (fields[0] == u'P')) self.edit_song_form.loadSong(song_id, (remote_type == u'P'))
self.edit_song_form.exec_() self.edit_song_form.exec_()
def onEditClick(self): def onEditClick(self):

View File

@ -39,12 +39,8 @@ if os.name == u'nt':
PAGE_AFTER = 5 PAGE_AFTER = 5
PAGE_BOTH = 6 PAGE_BOTH = 6
else: else:
try: import uno
import uno from com.sun.star.style.BreakType import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH
from com.sun.star.style.BreakType import PAGE_BEFORE, PAGE_AFTER, \
PAGE_BOTH
except ImportError:
pass
class OooImport(SongImport): class OooImport(SongImport):
""" """

View File

@ -73,6 +73,8 @@ class OpenLyricsExport(object):
u', '.join([author.display_name for author in song.authors])) u', '.join([author.display_name for author in song.authors]))
filename = re.sub( filename = re.sub(
r'[/\\?*|<>\[\]":<>+%]+', u'_', filename).strip(u'_') r'[/\\?*|<>\[\]":<>+%]+', u'_', filename).strip(u'_')
tree.write(os.path.join(self.save_path, filename), # Pass a file object, because lxml does not cope with some special
# characters in the path (see lp:757673 and lp:744337).
tree.write(open(os.path.join(self.save_path, filename), u'w'),
encoding=u'utf-8', xml_declaration=True, pretty_print=True) encoding=u'utf-8', xml_declaration=True, pretty_print=True)
return True return True

View File

@ -63,7 +63,9 @@ class OpenLyricsImport(SongImport):
self.import_wizard.incrementProgressBar( self.import_wizard.incrementProgressBar(
WizardStrings.ImportingType % os.path.basename(file_path)) WizardStrings.ImportingType % os.path.basename(file_path))
try: try:
parsed_file = etree.parse(file_path, parser) # Pass a file object, because lxml does not cope with some
# special characters in the path (see lp:757673 and lp:744337).
parsed_file = etree.parse(open(file_path, u'r'), parser)
xml = unicode(etree.tostring(parsed_file)) xml = unicode(etree.tostring(parsed_file))
if self.openLyrics.xml_to_song(xml) is None: if self.openLyrics.xml_to_song(xml) is None:
log.debug(u'File could not be imported: %s' % file_path) log.debug(u'File could not be imported: %s' % file_path)

View File

@ -33,7 +33,8 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, build_icon, translate, \ from openlp.core.lib import Plugin, StringContent, build_icon, translate, \
Receiver Receiver
from openlp.core.lib.db import Manager from openlp.core.lib.db import Manager
from openlp.core.lib.ui import UiStrings from openlp.core.lib.ui import UiStrings, base_action, icon_action
from openlp.core.utils.actions import ActionList
from openlp.plugins.songs.lib import clean_song, SongMediaItem, SongsTab from openlp.plugins.songs.lib import clean_song, SongMediaItem, SongsTab
from openlp.plugins.songs.lib.db import init_schema, Song from openlp.plugins.songs.lib.db import init_schema, Song
from openlp.plugins.songs.lib.importer import SongFormat from openlp.plugins.songs.lib.importer import SongFormat
@ -65,6 +66,10 @@ class SongsPlugin(Plugin):
log.info(u'Songs Initialising') log.info(u'Songs Initialising')
Plugin.initialise(self) Plugin.initialise(self)
self.toolsReindexItem.setVisible(True) self.toolsReindexItem.setVisible(True)
action_list = ActionList.get_instance()
action_list.add_action(self.SongImportItem, UiStrings.Import)
action_list.add_action(self.SongExportItem, UiStrings.Export)
action_list.add_action(self.toolsReindexItem, UiStrings.Tools)
self.mediaItem.displayResultsSong( self.mediaItem.displayResultsSong(
self.manager.get_all_objects(Song, order_by_ref=Song.search_title)) self.manager.get_all_objects(Song, order_by_ref=Song.search_title))
@ -78,10 +83,8 @@ class SongsPlugin(Plugin):
use it as their parent. use it as their parent.
""" """
# Main song import menu item - will eventually be the only one # Main song import menu item - will eventually be the only one
self.SongImportItem = QtGui.QAction(import_menu) self.SongImportItem = base_action(import_menu, u'SongImportItem')
self.SongImportItem.setObjectName(u'SongImportItem') self.SongImportItem.setText(translate('SongsPlugin', '&Song'))
self.SongImportItem.setText(translate(
'SongsPlugin', '&Song'))
self.SongImportItem.setToolTip(translate('SongsPlugin', self.SongImportItem.setToolTip(translate('SongsPlugin',
'Import songs using the import wizard.')) 'Import songs using the import wizard.'))
import_menu.addAction(self.SongImportItem) import_menu.addAction(self.SongImportItem)
@ -99,10 +102,8 @@ class SongsPlugin(Plugin):
use it as their parent. use it as their parent.
""" """
# Main song import menu item - will eventually be the only one # Main song import menu item - will eventually be the only one
self.SongExportItem = QtGui.QAction(export_menu) self.SongExportItem = base_action(export_menu, u'SongExportItem')
self.SongExportItem.setObjectName(u'SongExportItem') self.SongExportItem.setText(translate('SongsPlugin', '&Song'))
self.SongExportItem.setText(translate(
'SongsPlugin', '&Song'))
self.SongExportItem.setToolTip(translate('SongsPlugin', self.SongExportItem.setToolTip(translate('SongsPlugin',
'Exports songs using the export wizard.')) 'Exports songs using the export wizard.'))
export_menu.addAction(self.SongExportItem) export_menu.addAction(self.SongExportItem)
@ -120,9 +121,8 @@ class SongsPlugin(Plugin):
use it as their parent. use it as their parent.
""" """
log.info(u'add tools menu') log.info(u'add tools menu')
self.toolsReindexItem = QtGui.QAction(tools_menu) self.toolsReindexItem = icon_action(tools_menu, u'toolsReindexItem',
self.toolsReindexItem.setIcon(build_icon(u':/plugins/plugin_songs.png')) u':/plugins/plugin_songs.png')
self.toolsReindexItem.setObjectName(u'toolsReindexItem')
self.toolsReindexItem.setText( self.toolsReindexItem.setText(
translate('SongsPlugin', '&Re-index Songs')) translate('SongsPlugin', '&Re-index Songs'))
self.toolsReindexItem.setStatusTip( self.toolsReindexItem.setStatusTip(
@ -259,4 +259,8 @@ class SongsPlugin(Plugin):
log.info(u'Songs Finalising') log.info(u'Songs Finalising')
self.manager.finalise() self.manager.finalise()
self.toolsReindexItem.setVisible(False) self.toolsReindexItem.setVisible(False)
action_list = ActionList.get_instance()
action_list.remove_action(self.SongImportItem, UiStrings.Import)
action_list.remove_action(self.SongExportItem, UiStrings.Export)
action_list.remove_action(self.toolsReindexItem, UiStrings.Tools)
Plugin.finalise(self) Plugin.finalise(self)

View File

@ -32,6 +32,8 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, Receiver, build_icon, \ from openlp.core.lib import Plugin, StringContent, Receiver, build_icon, \
translate translate
from openlp.core.lib.db import Manager from openlp.core.lib.db import Manager
from openlp.core.lib.ui import base_action, shortcut_action, UiStrings
from openlp.core.utils.actions import ActionList
from openlp.plugins.songusage.forms import SongUsageDetailForm, \ from openlp.plugins.songusage.forms import SongUsageDetailForm, \
SongUsageDeleteForm SongUsageDeleteForm
from openlp.plugins.songusage.lib.db import init_schema, SongUsageItem from openlp.plugins.songusage.lib.db import init_schema, SongUsageItem
@ -63,30 +65,25 @@ class SongUsagePlugin(Plugin):
self.SongUsageMenu.setObjectName(u'SongUsageMenu') self.SongUsageMenu.setObjectName(u'SongUsageMenu')
self.SongUsageMenu.setTitle(translate( self.SongUsageMenu.setTitle(translate(
'SongUsagePlugin', '&Song Usage Tracking')) 'SongUsagePlugin', '&Song Usage Tracking'))
#SongUsage Delete # SongUsage Delete
self.SongUsageDelete = QtGui.QAction(tools_menu) self.SongUsageDelete = base_action(tools_menu, u'SongUsageDelete')
self.SongUsageDelete.setText(translate('SongUsagePlugin', self.SongUsageDelete.setText(translate('SongUsagePlugin',
'&Delete Tracking Data')) '&Delete Tracking Data'))
self.SongUsageDelete.setStatusTip(translate('SongUsagePlugin', self.SongUsageDelete.setStatusTip(translate('SongUsagePlugin',
'Delete song usage data up to a specified date.')) 'Delete song usage data up to a specified date.'))
self.SongUsageDelete.setObjectName(u'SongUsageDelete') # SongUsage Report
#SongUsage Report self.SongUsageReport = base_action(tools_menu, u'SongUsageReport')
self.SongUsageReport = QtGui.QAction(tools_menu)
self.SongUsageReport.setText( self.SongUsageReport.setText(
translate('SongUsagePlugin', '&Extract Tracking Data')) translate('SongUsagePlugin', '&Extract Tracking Data'))
self.SongUsageReport.setStatusTip( self.SongUsageReport.setStatusTip(
translate('SongUsagePlugin', 'Generate a report on song usage.')) translate('SongUsagePlugin', 'Generate a report on song usage.'))
self.SongUsageReport.setObjectName(u'SongUsageReport') # SongUsage activation
#SongUsage activation self.SongUsageStatus = shortcut_action(tools_menu, u'SongUsageStatus',
self.SongUsageStatus = QtGui.QAction(tools_menu) [QtCore.Qt.Key_F4], self.toggleSongUsageState, checked=False)
self.SongUsageStatus.setCheckable(True)
self.SongUsageStatus.setChecked(False)
self.SongUsageStatus.setText(translate( self.SongUsageStatus.setText(translate(
'SongUsagePlugin', 'Toggle Tracking')) 'SongUsagePlugin', 'Toggle Tracking'))
self.SongUsageStatus.setStatusTip(translate('SongUsagePlugin', self.SongUsageStatus.setStatusTip(translate('SongUsagePlugin',
'Toggle the tracking of song usage.')) 'Toggle the tracking of song usage.'))
self.SongUsageStatus.setShortcut(u'F4')
self.SongUsageStatus.setObjectName(u'SongUsageStatus')
#Add Menus together #Add Menus together
self.toolsMenu.addAction(self.SongUsageMenu.menuAction()) self.toolsMenu.addAction(self.SongUsageMenu.menuAction())
self.SongUsageMenu.addAction(self.SongUsageStatus) self.SongUsageMenu.addAction(self.SongUsageStatus)
@ -97,9 +94,6 @@ class SongUsagePlugin(Plugin):
QtCore.QObject.connect(self.SongUsageStatus, QtCore.QObject.connect(self.SongUsageStatus,
QtCore.SIGNAL(u'visibilityChanged(bool)'), QtCore.SIGNAL(u'visibilityChanged(bool)'),
self.SongUsageStatus.setChecked) self.SongUsageStatus.setChecked)
QtCore.QObject.connect(self.SongUsageStatus,
QtCore.SIGNAL(u'triggered(bool)'),
self.toggleSongUsageState)
QtCore.QObject.connect(self.SongUsageDelete, QtCore.QObject.connect(self.SongUsageDelete,
QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete) QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete)
QtCore.QObject.connect(self.SongUsageReport, QtCore.QObject.connect(self.SongUsageReport,
@ -116,6 +110,13 @@ class SongUsagePlugin(Plugin):
self.settingsSection + u'/active', self.settingsSection + u'/active',
QtCore.QVariant(False)).toBool() QtCore.QVariant(False)).toBool()
self.SongUsageStatus.setChecked(self.SongUsageActive) self.SongUsageStatus.setChecked(self.SongUsageActive)
action_list = ActionList.get_instance()
action_list.add_action(self.SongUsageDelete,
translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.SongUsageReport,
translate('SongUsagePlugin', 'Song Usage'))
action_list.add_action(self.SongUsageStatus,
translate('SongUsagePlugin', 'Song Usage'))
if self.manager is None: if self.manager is None:
self.manager = Manager(u'songusage', init_schema) self.manager = Manager(u'songusage', init_schema)
self.SongUsagedeleteform = SongUsageDeleteForm(self.manager, self.SongUsagedeleteform = SongUsageDeleteForm(self.manager,
@ -131,6 +132,13 @@ class SongUsagePlugin(Plugin):
self.manager.finalise() self.manager.finalise()
Plugin.finalise(self) Plugin.finalise(self)
self.SongUsageMenu.menuAction().setVisible(False) self.SongUsageMenu.menuAction().setVisible(False)
action_list = ActionList.get_instance()
action_list.remove_action(self.SongUsageDelete,
translate('SongUsagePlugin', 'Song Usage'))
action_list.remove_action(self.SongUsageReport,
translate('SongUsagePlugin', 'Song Usage'))
action_list.remove_action(self.SongUsageStatus,
translate('SongUsagePlugin', 'Song Usage'))
#stop any events being processed #stop any events being processed
self.SongUsageActive = False self.SongUsageActive = False

View File

@ -41,35 +41,35 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="shortcutLayout"> <layout class="QGridLayout" name="detailsLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="spacing"> <property name="spacing">
<number>8</number> <number>8</number>
</property> </property>
<property name="leftMargin"> <item row="0" column="0">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="defaultRadioButton"> <widget class="QRadioButton" name="defaultRadioButton">
<property name="text"> <property name="text">
<string>Default: None</string> <string>Default:</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="0">
<layout class="QHBoxLayout" name="customShortcutLayout"> <widget class="QRadioButton" name="customRadioButton">
<property name="text">
<string>Custom:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="shortcutLayout">
<property name="spacing"> <property name="spacing">
<number>8</number> <number>8</number>
</property> </property>
<item>
<widget class="QRadioButton" name="customRadioButton">
<property name="text">
<string>Custom:</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="shortcutPushButton"> <widget class="QPushButton" name="shortcutPushButton">
<property name="minimumSize"> <property name="minimumSize">
@ -83,7 +83,7 @@
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../images/openlp-2.qrc"> <iconset resource="../images/openlp-2.qrc">
<normaloff>:/system/system_settings.png</normaloff>:/system/system_settings.png</iconset> <normaloff>:/system/system_configure_shortcuts.png</normaloff>:/system/system_configure_shortcuts.png</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@ -110,21 +110,51 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item row="1" column="2">
<layout class="QHBoxLayout" name="alternateLayout">
<property name="spacing">
<number>8</number>
</property>
<item> <item>
<spacer name="customShortcutSpacer"> <widget class="QPushButton" name="alternatePushButton">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>None</string>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="icon">
<size> <iconset resource="../images/openlp-2.qrc">
<width>40</width> <normaloff>:/system/system_configure_shortcuts.png</normaloff>:/system/system_configure_shortcuts.png</iconset>
<height>20</height>
</size>
</property> </property>
</spacer> </widget>
</item>
<item>
<widget class="QToolButton" name="clearAlternateButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/system/clear_shortcut.png</normaloff>:/system/clear_shortcut.png</iconset>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="0" column="1">
<widget class="QLabel" name="shortcutLabel">
<property name="text">
<string>Ctrl+V</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="alternateLabel">
<property name="text">
<string>Shift+Ins</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>