openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #14307
[Merge] lp:~m2j/openlp/cleanups into lp:openlp
Meinert Jordan has proposed merging lp:~m2j/openlp/cleanups into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~m2j/openlp/cleanups/+merge/96225
Whatever I tried, I did not found any way, to reach a tree, which does not remove the reverted changes. Therefore I had to delete the branch and create a new one. So after much back and forth the same changes once again:
Description of the Change
This are some cleanups.
There were five methods to create a action in OpenLP, so I thought: Why not add a sixth method. ;)
Well, I was a bit surprised of the freeze as I was just about merging my editior into the OpenLP source tree. Therefore I didn't had the chance yet to go through the sources and replace the current action creation methods where it makes sense.
Some paths are handled through Pythons os.path instead of Qts methods (we use os.path at most places of the code so it is more consistent)
The path seperator in zip files is always a slash (/): http://www.pkware.com/documents/casestudies/APPNOTE.TXT
--
https://code.launchpad.net/~m2j/openlp/cleanups/+merge/96225
Your team OpenLP Core is requested to review the proposed merge of lp:~m2j/openlp/cleanups into lp:openlp.
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py 2011-12-30 21:40:13 +0000
+++ openlp/core/lib/mediamanageritem.py 2012-03-06 19:17:18 +0000
@@ -36,8 +36,8 @@
from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \
StringContent, build_icon, translate, Receiver, ListWidgetWithDnD
from openlp.core.lib.searchedit import SearchEdit
-from openlp.core.lib.ui import UiStrings, context_menu_action, \
- context_menu_separator, critical_error_message_box
+from openlp.core.lib.ui import UiStrings, create_widget_action, \
+ critical_error_message_box
log = logging.getLogger(__name__)
@@ -147,43 +147,6 @@
self.toolbar = OpenLPToolbar(self)
self.pageLayout.addWidget(self.toolbar)
- def addToolbarButton(
- self, title, tooltip, icon, slot=None, checkable=False):
- """
- A method to help developers easily add a button to the toolbar.
-
- ``title``
- The title of the button.
-
- ``tooltip``
- The tooltip to be displayed when the mouse hovers over the
- button.
-
- ``icon``
- The icon of the button. This can be an instance of QIcon, or a
- string containing either the absolute path to the image, or an
- internal resource path starting with ':/'.
-
- ``slot``
- The method to call when the button is clicked.
-
- ``checkable``
- If *True* the button has two, *off* and *on*, states. Default is
- *False*, which means the buttons has only one state.
- """
- # NB different order (when I broke this out, I didn't want to
- # break compatability), but it makes sense for the icon to
- # come before the tooltip (as you have to have an icon, but
- # not neccesarily a tooltip)
- return self.toolbar.addToolbarButton(title, icon, tooltip, slot,
- checkable)
-
- def addToolbarSeparator(self):
- """
- A very simple method to add a separator to the toolbar.
- """
- self.toolbar.addSeparator()
-
def setupUi(self):
"""
This method sets up the interface on the button. Plugin
@@ -208,40 +171,41 @@
toolbar_actions = []
## Import Button ##
if self.hasImportIcon:
- toolbar_actions.append([StringContent.Import,
+ toolbar_actions.append([u'Import', StringContent.Import,
u':/general/general_import.png', self.onImportClick])
## Load Button ##
if self.hasFileIcon:
- toolbar_actions.append([StringContent.Load,
+ toolbar_actions.append([u'Load', StringContent.Load,
u':/general/general_open.png', self.onFileClick])
## New Button ##
if self.hasNewIcon:
- toolbar_actions.append([StringContent.New,
+ toolbar_actions.append([u'New', StringContent.New,
u':/general/general_new.png', self.onNewClick])
## Edit Button ##
if self.hasEditIcon:
- toolbar_actions.append([StringContent.Edit,
+ toolbar_actions.append([u'Edit', StringContent.Edit,
u':/general/general_edit.png', self.onEditClick])
## Delete Button ##
if self.hasDeleteIcon:
- toolbar_actions.append([StringContent.Delete,
+ toolbar_actions.append([u'Delete', StringContent.Delete,
u':/general/general_delete.png', self.onDeleteClick])
## Preview ##
- toolbar_actions.append([StringContent.Preview,
+ toolbar_actions.append([u'Preview', StringContent.Preview,
u':/general/general_preview.png', self.onPreviewClick])
## Live Button ##
- toolbar_actions.append([StringContent.Live,
+ toolbar_actions.append([u'Live', StringContent.Live,
u':/general/general_live.png', self.onLiveClick])
## Add to service Button ##
- toolbar_actions.append([StringContent.Service,
+ toolbar_actions.append([u'Service', StringContent.Service,
u':/general/general_add.png', self.onAddClick])
for action in toolbar_actions:
if action[0] == StringContent.Preview:
- self.addToolbarSeparator()
- self.addToolbarButton(
- self.plugin.getString(action[0])[u'title'],
- self.plugin.getString(action[0])[u'tooltip'],
- action[1], action[2])
+ self.toolbar.addSeparator()
+ self.toolbar.addToolbarAction(
+ u'%s%sAction' % (self.plugin.name, action[0]),
+ text=self.plugin.getString(action[1])[u'title'], icon=action[2],
+ tooltip=self.plugin.getString(action[1])[u'tooltip'],
+ triggers=action[3])
def addListViewToToolBar(self):
"""
@@ -259,35 +223,37 @@
# define and add the context menu
self.listView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
if self.hasEditIcon:
- context_menu_action(
- self.listView, u':/general/general_edit.png',
- self.plugin.getString(StringContent.Edit)[u'title'],
- self.onEditClick)
- context_menu_separator(self.listView)
+ create_widget_action(self.listView,
+ text=self.plugin.getString(StringContent.Edit)[u'title'],
+ icon=u':/general/general_edit.png',
+ triggers=self.onEditClick)
+ create_widget_action(self.listView, separator=True)
if self.hasDeleteIcon:
- context_menu_action(
- self.listView, u':/general/general_delete.png',
- self.plugin.getString(StringContent.Delete)[u'title'],
- self.onDeleteClick, [QtCore.Qt.Key_Delete])
- context_menu_separator(self.listView)
- context_menu_action(
- self.listView, u':/general/general_preview.png',
- self.plugin.getString(StringContent.Preview)[u'title'],
- self.onPreviewClick, [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return])
- context_menu_action(
- self.listView, u':/general/general_live.png',
- self.plugin.getString(StringContent.Live)[u'title'],
- self.onLiveClick, [QtCore.Qt.ShiftModifier + QtCore.Qt.Key_Enter,
- QtCore.Qt.ShiftModifier + QtCore.Qt.Key_Return])
- context_menu_action(
- self.listView, u':/general/general_add.png',
- self.plugin.getString(StringContent.Service)[u'title'],
- self.onAddClick, [QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal])
+ create_widget_action(self.listView,
+ text=self.plugin.getString(StringContent.Delete)[u'title'],
+ icon=u':/general/general_delete.png',
+ shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteClick)
+ create_widget_action(self.listView, separator=True)
+ create_widget_action(self.listView,
+ text=self.plugin.getString(StringContent.Preview)[u'title'],
+ icon=u':/general/general_preview.png',
+ shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return],
+ triggers=self.onPreviewClick)
+ create_widget_action(self.listView,
+ text=self.plugin.getString(StringContent.Live)[u'title'],
+ icon=u':/general/general_live.png',
+ shortcuts=[QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Enter,
+ QtCore.Qt.ShiftModifier | QtCore.Qt.Key_Return],
+ triggers=self.onLiveClick)
+ create_widget_action(self.listView,
+ text=self.plugin.getString(StringContent.Service)[u'title'],
+ icon=u':/general/general_add.png',
+ shortcuts=[QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal],
+ triggers=self.onAddClick)
if self.addToServiceItem:
- context_menu_action(
- self.listView, u':/general/general_add.png',
- translate('OpenLP.MediaManagerItem',
- '&Add to selected Service Item'), self.onAddEditClick)
+ create_widget_action(self.listView, text=translate(
+ 'OpenLP.MediaManagerItem', '&Add to selected Service Item'),
+ icon=u':/general/general_add.png', triggers=self.onAddEditClick)
self.addCustomContextActions()
# Create the context menu and add all actions from the listView.
self.menu = QtGui.QMenu()
=== modified file 'openlp/core/lib/searchedit.py'
--- openlp/core/lib/searchedit.py 2011-12-27 10:33:55 +0000
+++ openlp/core/lib/searchedit.py 2012-03-06 19:17:18 +0000
@@ -30,7 +30,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon
-from openlp.core.lib.ui import icon_action
+from openlp.core.lib.ui import create_widget_action
log = logging.getLogger(__name__)
@@ -150,12 +150,8 @@
menu = QtGui.QMenu(self)
first = None
for identifier, icon, title in items:
- action = icon_action(menu, u'', icon)
- action.setText(title)
- action.setData(QtCore.QVariant(identifier))
- menu.addAction(action)
- QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'),
- self._onMenuActionTriggered)
+ action = create_widget_action(menu, text=title, icon=icon,
+ data=identifier, triggers=self._onMenuActionTriggered)
if first is None:
first = action
self._currentSearchType = identifier
=== modified file 'openlp/core/lib/spelltextedit.py'
--- openlp/core/lib/spelltextedit.py 2011-12-27 10:33:55 +0000
+++ openlp/core/lib/spelltextedit.py 2012-03-06 19:17:18 +0000
@@ -40,7 +40,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, FormattingTags
-from openlp.core.lib.ui import checkable_action
+from openlp.core.lib.ui import create_action
log = logging.getLogger(__name__)
@@ -90,9 +90,8 @@
lang_menu = QtGui.QMenu(
translate('OpenLP.SpellTextEdit', 'Language:'))
for lang in enchant.list_languages():
- action = checkable_action(
- lang_menu, lang, lang == self.dictionary.tag)
- action.setText(lang)
+ action = create_action(lang_menu, lang, text=lang,
+ checked=lang == self.dictionary.tag)
lang_menu.addAction(action)
popupMenu.insertSeparator(popupMenu.actions()[0])
popupMenu.insertMenu(popupMenu.actions()[0], lang_menu)
=== modified file 'openlp/core/lib/toolbar.py'
--- openlp/core/lib/toolbar.py 2011-12-27 10:33:55 +0000
+++ openlp/core/lib/toolbar.py 2012-03-06 19:17:18 +0000
@@ -31,7 +31,7 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import build_icon
+from openlp.core.lib.ui import create_widget_action
log = logging.getLogger(__name__)
@@ -46,122 +46,41 @@
"""
QtGui.QToolBar.__init__(self, parent)
# useful to be able to reuse button icons...
- self.icons = {}
self.setIconSize(QtCore.QSize(20, 20))
self.actions = {}
log.debug(u'Init done for %s' % parent.__class__.__name__)
- def addToolbarButton(self, title, icon, tooltip=None, slot=None,
- checkable=False, shortcuts=None, context=QtCore.Qt.WidgetShortcut):
+ def addToolbarAction(self, name, **kwargs):
"""
A method to help developers easily add a button to the toolbar.
-
- ``title``
- The title of the button.
-
- ``icon``
- The icon of the button. This can be an instance of QIcon, or a
- string containing either the absolute path to the image, or an
- internal resource path starting with ':/'.
-
- ``tooltip``
- A hint or tooltip for this button.
-
- ``slot``
- The method to run when this button is clicked.
-
- ``checkable``
- If *True* the button has two, *off* and *on*, states. Default is
- *False*, which means the buttons has only one state.
-
- ``shortcuts``
- The list of shortcuts for this action
-
- ``context``
- Specify the context in which this shortcut is valid
- """
- if icon:
- actionIcon = build_icon(icon)
- if slot and not checkable:
- newAction = self.addAction(actionIcon, title, slot)
+ A new QAction is created by calling ``create_action()``. The action is
+ added to the toolbar and the toolbar is set as parent.
+ For more details please look at openlp.core.lib.ui.create_action()
+ """
+ action = create_widget_action(self, name, **kwargs)
+ self.actions[name] = action
+ return action
+
+ def addToolbarWidget(self, widget):
+ """
+ Add a widget and store it's handle under the widgets object name.
+ """
+ action = self.addWidget(widget)
+ self.actions[unicode(widget.objectName())] = action
+
+ def setWidgetVisible(self, widgets, visible=True):
+ """
+ Set the visibitity for a widget or a list of widgets.
+
+ ``widget``
+ A list of string with widget object names.
+
+ ``visible``
+ The new state as bool.
+ """
+ for handle in widgets:
+ if handle in self.actions:
+ self.actions[handle].setVisible(visible)
else:
- newAction = self.addAction(actionIcon, title)
- self.icons[title] = actionIcon
- else:
- newAction = QtGui.QAction(title, self)
- self.addAction(newAction)
- QtCore.QObject.connect(newAction,
- QtCore.SIGNAL(u'triggered()'), slot)
- if tooltip:
- newAction.setToolTip(tooltip)
- if checkable:
- newAction.setCheckable(True)
- QtCore.QObject.connect(newAction,
- QtCore.SIGNAL(u'toggled(bool)'), slot)
- self.actions[title] = newAction
- if shortcuts is not None:
- newAction.setShortcuts(shortcuts)
- newAction.setShortcutContext(context)
- return newAction
-
- def addToolbarSeparator(self, handle):
- """
- Add a Separator bar to the toolbar and store it's Handle
- """
- action = self.addSeparator()
- self.actions[handle] = action
-
- def addToolbarWidget(self, handle, widget):
- """
- Add a Widget to the toolbar and store it's Handle
- """
- action = self.addWidget(widget)
- self.actions[handle] = action
-
- def getIconFromTitle(self, title):
- """
- Search through the list of icons for an icon with a particular title,
- and return that icon.
-
- ``title``
- The title of the icon to search for.
- """
- title = QtCore.QString(title)
- try:
- if self.icons[title]:
- return self.icons[title]
- except KeyError:
- log.exception(u'getIconFromTitle - no icon for %s' % title)
- return QtGui.QIcon()
-
- def makeWidgetsInvisible(self, widgets):
- """
- Hide a set of widgets.
-
- ``widgets``
- The list of names of widgets to be hidden.
- """
- for widget in widgets:
- self.actions[widget].setVisible(False)
-
- def makeWidgetsVisible(self, widgets):
- """
- Show a set of widgets.
-
- ``widgets``
- The list of names of widgets to be shown.
- """
- for widget in widgets:
- self.actions[widget].setVisible(True)
-
- def addPushButton(self, image_file=None, text=u''):
- """
- Adds a push button to the toolbar.
-
- Returns the push button
- """
- push_button = QtGui.QPushButton(build_icon(image_file), text)
- push_button.setCheckable(True)
- push_button.setFlat(True)
- self.addWidget(push_button)
- return push_button
+ log.warn(u'No handle "%s" in actions list.', unicode(handle))
+
=== modified file 'openlp/core/lib/ui.py'
--- openlp/core/lib/ui.py 2012-02-24 23:26:10 +0000
+++ openlp/core/lib/ui.py 2012-03-06 19:17:18 +0000
@@ -281,100 +281,102 @@
QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked)
return up_button, down_button
-def base_action(parent, name, category=None):
- """
- 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.setObjectName(name)
- if category is not None:
- action_list = ActionList.get_instance()
- action_list.add_action(action, category)
- return action
-
-def checkable_action(parent, name, checked=None, category=None):
- """
- Return a standard action with the checkable attribute set.
- """
- action = base_action(parent, name, category)
- action.setCheckable(True)
- if checked is not None:
- action.setChecked(checked)
- return action
-
-def icon_action(parent, name, icon, checked=None, category=None):
- """
- Return a standard action with an icon.
- """
- if checked is not None:
- action = checkable_action(parent, name, checked, category)
- else:
- action = base_action(parent, name, category)
- action.setIcon(build_icon(icon))
- return action
-
-def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None,
- category=None, context=QtCore.Qt.WindowShortcut):
- """
- Return a shortcut enabled action.
- """
- 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)
- if shortcuts:
- action.setShortcuts(shortcuts)
- action.setShortcutContext(context)
- action_list = ActionList.get_instance()
- action_list.add_action(action, category)
- QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), function)
- return action
-
-def context_menu_action(base, icon, text, slot, shortcuts=None, category=None,
- context=QtCore.Qt.WidgetShortcut):
- """
- Utility method to help build context menus.
-
- ``base``
- The parent menu to add this menu item to
+def create_action(parent, name, **kwargs):
+ """
+ Return an action with the object name set and the given parameters.
+
+ ``parent``
+ A QtCore.QObject for the actions parent (required).
+
+ ``name``
+ A string which is set as object name (required).
+
+ ``text``
+ A string for the action text.
``icon``
- An icon for this action
-
- ``text``
- The text to display for this action
-
- ``slot``
- The code to run when this action is triggered
+ Either a QIcon, a resource string, or a file location string for the
+ action icon.
+
+ ``tooltip``
+ A string for the action tool tip.
+
+ ``statustip``
+ A string for the action status tip.
+
+ ``checked``
+ A bool for the state. If ``None`` the Action is not checkable.
+
+ ``enabled``
+ False in case the action should be disabled.
+
+ ``visible``
+ False in case the action should be hidden.
+
+ ``separator``
+ True in case the action will be considered a separator.
+
+ ``data``
+ Data which is set as QVariant type.
``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.
+ A QList<QKeySequence> (or a list of strings) which are set as shortcuts.
``context``
- The context the shortcut is valid.
+ A context for the shortcut execution.
+
+ ``category``
+ A category the action should be listed in the shortcut dialog.
+
+ ``triggers``
+ A slot which is connected to the actions ``triggered()`` slot.
"""
- action = QtGui.QAction(text, base)
- if icon:
- action.setIcon(build_icon(icon))
- QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), slot)
- if shortcuts is not None:
- action.setShortcuts(shortcuts)
- action.setShortcutContext(context)
+ action = QtGui.QAction(parent)
+ action.setObjectName(name)
+ if kwargs.get(u'text'):
+ action.setText(kwargs.pop(u'text'))
+ if kwargs.get(u'icon'):
+ action.setIcon(build_icon(kwargs.pop(u'icon')))
+ if kwargs.get(u'tooltip'):
+ action.setToolTip(kwargs.pop(u'tooltip'))
+ if kwargs.get(u'statustip'):
+ action.setStatusTip(kwargs.pop(u'statustip'))
+ if kwargs.get(u'checked') is not None:
+ action.setCheckable(True)
+ action.setChecked(kwargs.pop(u'checked'))
+ if not kwargs.pop(u'enabled', True):
+ action.setEnabled(False)
+ if not kwargs.pop(u'visible', True):
+ action.setVisible(False)
+ if kwargs.pop(u'separator', False):
+ action.setSeparator(True)
+ if u'data' in kwargs:
+ action.setData(QtCore.QVariant(kwargs.pop(u'data')))
+ if kwargs.get(u'shortcuts'):
+ action.setShortcuts(kwargs.pop(u'shortcuts'))
+ if u'context' in kwargs:
+ action.setShortcutContext(kwargs.pop(u'context'))
+ if kwargs.get(u'category'):
action_list = ActionList.get_instance()
- action_list.add_action(action)
- base.addAction(action)
+ action_list.add_action(action, unicode(kwargs.pop(u'category')))
+ if kwargs.get(u'triggers'):
+ QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'),
+ kwargs.pop(u'triggers'))
+ for key in kwargs.keys():
+ if key not in [u'text', u'icon', u'tooltip', u'statustip', u'checked',
+ u'shortcuts', u'category', u'triggers']:
+ log.warn(u'Parameter %s was not consumed in create_action().', key)
+ return action
+
+def create_widget_action(parent, name=u'', **kwargs):
+ """
+ Return a new QAction by calling ``create_action(parent, name, **kwargs)``.
+ The shortcut context defaults to ``QtCore.Qt.WidgetShortcut`` and the action
+ is added to the parents action list.
+ """
+ kwargs.setdefault(u'context', QtCore.Qt.WidgetShortcut)
+ action = create_action(parent, name, **kwargs)
+ parent.addAction(action)
return action
def context_menu(base, icon, text):
@@ -394,18 +396,6 @@
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)
- base.addAction(action)
- return action
-
def add_widget_completer(cache, widget):
"""
Adds a text autocompleter to a widget.
=== modified file 'openlp/core/ui/exceptionform.py'
--- openlp/core/ui/exceptionform.py 2012-01-18 13:50:06 +0000
+++ openlp/core/ui/exceptionform.py 2012-03-06 19:17:18 +0000
@@ -150,7 +150,7 @@
translate('OpenLP.ExceptionForm',
'Text files (*.txt *.log *.text)'))
if filename:
- filename = unicode(QtCore.QDir.toNativeSeparators(filename))
+ filename = unicode(filename).replace(u'/', os.path.sep)
SettingsManager.set_last_dir(self.settingsSection, os.path.dirname(
filename))
report_text = report_text % self._createReport()
=== modified file 'openlp/core/ui/firsttimelanguageform.py'
--- openlp/core/ui/firsttimelanguageform.py 2011-12-27 10:33:55 +0000
+++ openlp/core/ui/firsttimelanguageform.py 2012-03-06 19:17:18 +0000
@@ -27,6 +27,7 @@
from PyQt4 import QtGui
+from openlp.core.lib.ui import create_action
from openlp.core.utils import LanguageManager
from firsttimelanguagedialog import Ui_FirstTimeLanguageDialog
@@ -55,8 +56,7 @@
LanguageManager.set_language(False, False)
else:
LanguageManager.auto_language = False
- action = QtGui.QAction(None)
- action.setObjectName(unicode(self.languageComboBox.currentText()))
+ action = create_action(None, self.languageComboBox.currentText())
LanguageManager.set_language(action, False)
return QtGui.QDialog.accept(self)
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2012-02-06 17:35:41 +0000
+++ openlp/core/ui/mainwindow.py 2012-03-06 19:17:18 +0000
@@ -36,8 +36,7 @@
from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, \
PluginManager, Receiver, translate, ImageManager, PluginStatus
-from openlp.core.lib.ui import UiStrings, base_action, checkable_action, \
- icon_action, shortcut_action
+from openlp.core.lib.ui import UiStrings, create_action
from openlp.core.lib import SlideLimits
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
ThemeManager, SlideController, PluginForm, MediaDockManager, \
@@ -179,75 +178,78 @@
action_list = ActionList.get_instance()
action_list.add_category(unicode(UiStrings().File),
CategoryOrder.standardMenu)
- self.fileNewItem = shortcut_action(mainWindow, u'fileNewItem',
- [QtGui.QKeySequence(u'Ctrl+N')],
- self.serviceManagerContents.onNewServiceClicked,
- u':/general/general_new.png', category=unicode(UiStrings().File))
- self.fileOpenItem = shortcut_action(mainWindow, u'fileOpenItem',
- [QtGui.QKeySequence(u'Ctrl+O')],
- self.serviceManagerContents.onLoadServiceClicked,
- u':/general/general_open.png', category=unicode(UiStrings().File))
- self.fileSaveItem = shortcut_action(mainWindow, u'fileSaveItem',
- [QtGui.QKeySequence(u'Ctrl+S')],
- self.serviceManagerContents.saveFile,
- u':/general/general_save.png', category=unicode(UiStrings().File))
- self.fileSaveAsItem = shortcut_action(mainWindow, u'fileSaveAsItem',
- [QtGui.QKeySequence(u'Ctrl+Shift+S')],
- self.serviceManagerContents.saveFileAs,
- category=unicode(UiStrings().File))
- self.printServiceOrderItem = shortcut_action(mainWindow,
- u'printServiceItem', [QtGui.QKeySequence(u'Ctrl+P')],
- self.serviceManagerContents.printServiceOrder,
- category=unicode(UiStrings().File))
- self.fileExitItem = shortcut_action(mainWindow, u'fileExitItem',
- [QtGui.QKeySequence(u'Alt+F4')], mainWindow.close,
- u':/system/system_exit.png', category=unicode(UiStrings().File))
+ self.fileNewItem = create_action(mainWindow, u'fileNewItem',
+ icon=u':/general/general_new.png',
+ shortcuts=[QtGui.QKeySequence(u'Ctrl+N')],
+ category=UiStrings().File,
+ triggers=self.serviceManagerContents.onNewServiceClicked)
+ self.fileOpenItem = create_action(mainWindow, u'fileOpenItem',
+ icon=u':/general/general_open.png',
+ shortcuts=[QtGui.QKeySequence(u'Ctrl+O')],
+ category=UiStrings().File,
+ triggers=self.serviceManagerContents.onLoadServiceClicked)
+ self.fileSaveItem = create_action(mainWindow, u'fileSaveItem',
+ icon=u':/general/general_save.png',
+ shortcuts=[QtGui.QKeySequence(u'Ctrl+S')],
+ category=UiStrings().File,
+ triggers=self.serviceManagerContents.saveFile)
+ self.fileSaveAsItem = create_action(mainWindow, u'fileSaveAsItem',
+ shortcuts=[QtGui.QKeySequence(u'Ctrl+Shift+S')],
+ category=UiStrings().File,
+ triggers=self.serviceManagerContents.saveFileAs)
+ self.printServiceOrderItem = create_action(mainWindow,
+ u'printServiceItem', shortcuts=[QtGui.QKeySequence(u'Ctrl+P')],
+ category=UiStrings().File,
+ triggers=self.serviceManagerContents.printServiceOrder)
+ self.fileExitItem = create_action(mainWindow, u'fileExitItem',
+ icon=u':/system/system_exit.png',
+ shortcuts=[QtGui.QKeySequence(u'Alt+F4')],
+ category=UiStrings().File, triggers=mainWindow.close)
action_list.add_category(unicode(UiStrings().Import),
CategoryOrder.standardMenu)
- self.importThemeItem = base_action(
- mainWindow, u'importThemeItem', unicode(UiStrings().Import))
- self.importLanguageItem = base_action(
- mainWindow, u'importLanguageItem')#, unicode(UiStrings().Import))
+ self.importThemeItem = create_action(mainWindow,
+ u'importThemeItem', category=UiStrings().Import)
+ self.importLanguageItem = create_action(mainWindow,
+ u'importLanguageItem')#, category=UiStrings().Import)
action_list.add_category(unicode(UiStrings().Export),
CategoryOrder.standardMenu)
- self.exportThemeItem = base_action(
- mainWindow, u'exportThemeItem', unicode(UiStrings().Export))
- self.exportLanguageItem = base_action(
- mainWindow, u'exportLanguageItem')#, unicode(UiStrings().Export))
+ self.exportThemeItem = create_action(mainWindow,
+ u'exportThemeItem', category=UiStrings().Export)
+ self.exportLanguageItem = create_action(mainWindow,
+ u'exportLanguageItem')#, category=UiStrings().Export)
action_list.add_category(unicode(UiStrings().View),
CategoryOrder.standardMenu)
- self.viewMediaManagerItem = shortcut_action(mainWindow,
- u'viewMediaManagerItem', [QtGui.QKeySequence(u'F8')],
- self.toggleMediaManager, u':/system/system_mediamanager.png',
- self.mediaManagerDock.isVisible(), unicode(UiStrings().View))
- self.viewThemeManagerItem = shortcut_action(mainWindow,
- u'viewThemeManagerItem', [QtGui.QKeySequence(u'F10')],
- self.toggleThemeManager, u':/system/system_thememanager.png',
- self.themeManagerDock.isVisible(), unicode(UiStrings().View))
- self.viewServiceManagerItem = shortcut_action(mainWindow,
- u'viewServiceManagerItem', [QtGui.QKeySequence(u'F9')],
- self.toggleServiceManager, u':/system/system_servicemanager.png',
- self.serviceManagerDock.isVisible(), unicode(UiStrings().View))
- self.viewPreviewPanel = shortcut_action(mainWindow,
- u'viewPreviewPanel', [QtGui.QKeySequence(u'F11')],
- self.setPreviewPanelVisibility, checked=previewVisible,
- category=unicode(UiStrings().View))
- self.viewLivePanel = shortcut_action(mainWindow, u'viewLivePanel',
- [QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility,
- checked=liveVisible, category=unicode(UiStrings().View))
- self.lockPanel = shortcut_action(mainWindow, u'lockPanel',
- None, self.setLockPanel,
- checked=panelLocked, category=None)
+ self.viewMediaManagerItem = create_action(mainWindow,
+ u'viewMediaManagerItem', shortcuts=[QtGui.QKeySequence(u'F8')],
+ icon=u':/system/system_mediamanager.png',
+ checked=self.mediaManagerDock.isVisible(),
+ category=UiStrings().View, triggers=self.toggleMediaManager)
+ self.viewThemeManagerItem = create_action(mainWindow,
+ u'viewThemeManagerItem', shortcuts=[QtGui.QKeySequence(u'F10')],
+ icon=u':/system/system_thememanager.png',
+ checked=self.themeManagerDock.isVisible(),
+ category=UiStrings().View, triggers=self.toggleThemeManager)
+ self.viewServiceManagerItem = create_action(mainWindow,
+ u'viewServiceManagerItem', shortcuts=[QtGui.QKeySequence(u'F9')],
+ icon=u':/system/system_servicemanager.png',
+ checked=self.serviceManagerDock.isVisible(),
+ category=UiStrings().View, triggers=self.toggleServiceManager)
+ self.viewPreviewPanel = create_action(mainWindow, u'viewPreviewPanel',
+ shortcuts=[QtGui.QKeySequence(u'F11')], checked=previewVisible,
+ category=UiStrings().View, triggers=self.setPreviewPanelVisibility)
+ self.viewLivePanel = create_action(mainWindow, u'viewLivePanel',
+ shortcuts=[QtGui.QKeySequence(u'F12')], checked=liveVisible,
+ category=UiStrings().View, triggers=self.setLivePanelVisibility)
+ self.lockPanel = create_action(mainWindow, u'lockPanel',
+ checked=panelLocked, triggers=self.setLockPanel)
action_list.add_category(unicode(UiStrings().ViewMode),
CategoryOrder.standardMenu)
- self.modeDefaultItem = checkable_action(
- mainWindow, u'modeDefaultItem',
- category=unicode(UiStrings().ViewMode))
- self.modeSetupItem = checkable_action(
- mainWindow, u'modeSetupItem',
- category=unicode(UiStrings().ViewMode))
- self.modeLiveItem = checkable_action(
- mainWindow, u'modeLiveItem', True, unicode(UiStrings().ViewMode))
+ self.modeDefaultItem = create_action(mainWindow, u'modeDefaultItem',
+ checked=False, category=UiStrings().ViewMode)
+ self.modeSetupItem = create_action(mainWindow, u'modeSetupItem',
+ checked=False, category=UiStrings().ViewMode)
+ self.modeLiveItem = create_action(mainWindow, u'modeLiveItem',
+ checked=True, category=UiStrings().ViewMode)
self.modeGroup = QtGui.QActionGroup(mainWindow)
self.modeGroup.addAction(self.modeDefaultItem)
self.modeGroup.addAction(self.modeSetupItem)
@@ -255,25 +257,27 @@
self.modeDefaultItem.setChecked(True)
action_list.add_category(unicode(UiStrings().Tools),
CategoryOrder.standardMenu)
- self.toolsAddToolItem = icon_action(mainWindow, u'toolsAddToolItem',
- u':/tools/tools_add.png', category=unicode(UiStrings().Tools))
- self.toolsOpenDataFolder = icon_action(mainWindow,
- u'toolsOpenDataFolder', u':/general/general_open.png',
- category=unicode(UiStrings().Tools))
- self.toolsFirstTimeWizard = icon_action(mainWindow,
- u'toolsFirstTimeWizard', u':/general/general_revert.png',
- category=unicode(UiStrings().Tools))
- self.updateThemeImages = base_action(mainWindow,
- u'updateThemeImages', category=unicode(UiStrings().Tools))
+ self.toolsAddToolItem = create_action(mainWindow,
+ u'toolsAddToolItem', icon=u':/tools/tools_add.png',
+ category=UiStrings().Tools)
+ self.toolsOpenDataFolder = create_action(mainWindow,
+ u'toolsOpenDataFolder', icon=u':/general/general_open.png',
+ category=UiStrings().Tools)
+ self.toolsFirstTimeWizard = create_action(mainWindow,
+ u'toolsFirstTimeWizard', icon=u':/general/general_revert.png',
+ category=UiStrings().Tools)
+ self.updateThemeImages = create_action(mainWindow,
+ u'updateThemeImages', category=UiStrings().Tools)
action_list.add_category(unicode(UiStrings().Settings),
CategoryOrder.standardMenu)
- self.settingsPluginListItem = shortcut_action(mainWindow,
- u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')],
- self.onPluginItemClicked, u':/system/settings_plugin_list.png',
- category=unicode(UiStrings().Settings))
+ self.settingsPluginListItem = create_action(mainWindow,
+ u'settingsPluginListItem',
+ icon=u':/system/settings_plugin_list.png',
+ shortcuts=[QtGui.QKeySequence(u'Alt+F7')],
+ category=UiStrings().Settings, triggers=self.onPluginItemClicked)
# i18n Language Items
- self.autoLanguageItem = checkable_action(mainWindow,
- u'autoLanguageItem', LanguageManager.auto_language)
+ self.autoLanguageItem = create_action(mainWindow, u'autoLanguageItem',
+ checked=LanguageManager.auto_language)
self.languageGroup = QtGui.QActionGroup(mainWindow)
self.languageGroup.setExclusive(True)
self.languageGroup.setObjectName(u'languageGroup')
@@ -281,44 +285,43 @@
qmList = LanguageManager.get_qm_list()
savedLanguage = LanguageManager.get_language()
for key in sorted(qmList.keys()):
- languageItem = checkable_action(
- mainWindow, key, qmList[key] == savedLanguage)
+ languageItem = create_action(mainWindow, key,
+ checked=qmList[key] == savedLanguage)
add_actions(self.languageGroup, [languageItem])
- self.settingsShortcutsItem = icon_action(mainWindow,
+ self.settingsShortcutsItem = create_action(mainWindow,
u'settingsShortcutsItem',
- u':/system/system_configure_shortcuts.png',
- category=unicode(UiStrings().Settings))
+ icon=u':/system/system_configure_shortcuts.png',
+ category=UiStrings().Settings)
# Formatting Tags were also known as display tags.
- self.formattingTagItem = icon_action(mainWindow,
- u'displayTagItem', u':/system/tag_editor.png',
- category=unicode(UiStrings().Settings))
- self.settingsConfigureItem = icon_action(mainWindow,
- u'settingsConfigureItem', u':/system/system_settings.png',
- category=unicode(UiStrings().Settings))
- self.settingsImportItem = base_action(mainWindow,
- u'settingsImportItem', category=unicode(UiStrings().Settings))
- self.settingsExportItem = base_action(mainWindow,
- u'settingsExportItem', category=unicode(UiStrings().Settings))
+ self.formattingTagItem = create_action(mainWindow,
+ u'displayTagItem', icon=u':/system/tag_editor.png',
+ category=UiStrings().Settings)
+ self.settingsConfigureItem = create_action(mainWindow,
+ u'settingsConfigureItem', icon=u':/system/system_settings.png',
+ category=UiStrings().Settings)
+ self.settingsImportItem = create_action(mainWindow,
+ u'settingsImportItem', category=UiStrings().Settings)
+ self.settingsExportItem = create_action(mainWindow,
+ u'settingsExportItem', category=UiStrings().Settings)
action_list.add_category(unicode(UiStrings().Help),
CategoryOrder.standardMenu)
- self.aboutItem = shortcut_action(mainWindow, u'aboutItem',
- [QtGui.QKeySequence(u'Ctrl+F1')], self.onAboutItemClicked,
- u':/system/system_about.png', category=unicode(UiStrings().Help))
+ self.aboutItem = create_action(mainWindow, u'aboutItem',
+ icon=u':/system/system_about.png',
+ shortcuts=[QtGui.QKeySequence(u'Ctrl+F1')],
+ category=UiStrings().Help, triggers=self.onAboutItemClicked)
if os.name == u'nt':
self.localHelpFile = os.path.join(
AppLocation.get_directory(AppLocation.AppDir), 'OpenLP.chm')
- self.offlineHelpItem = shortcut_action(
- mainWindow, u'offlineHelpItem', [QtGui.QKeySequence(u'F1')],
- self.onOfflineHelpClicked,
- u':/system/system_help_contents.png',
- category=unicode(UiStrings().Help))
- self.onlineHelpItem = shortcut_action(
- mainWindow, u'onlineHelpItem',
- [QtGui.QKeySequence(u'Alt+F1')], self.onOnlineHelpClicked,
- u':/system/system_online_help.png',
- category=unicode(UiStrings().Help))
- self.webSiteItem = base_action(
- mainWindow, u'webSiteItem', category=unicode(UiStrings().Help))
+ self.offlineHelpItem = create_action(mainWindow, u'offlineHelpItem',
+ icon=u':/system/system_help_contents.png',
+ shortcuts=[QtGui.QKeySequence(u'F1')],
+ category=UiStrings().Help, triggers=self.onOfflineHelpClicked)
+ self.onlineHelpItem = create_action(mainWindow, u'onlineHelpItem',
+ icon=u':/system/system_online_help.png',
+ shortcuts=[QtGui.QKeySequence(u'Alt+F1')],
+ category=UiStrings().Help, triggers=self.onOnlineHelpClicked)
+ self.webSiteItem = create_action(mainWindow,
+ u'webSiteItem', category=UiStrings().Help)
add_actions(self.fileImportMenu, (self.settingsImportItem, None,
self.importThemeItem, self.importLanguageItem))
add_actions(self.fileExportMenu, (self.settingsExportItem, None,
@@ -1378,27 +1381,24 @@
recentFileCount = QtCore.QSettings().value(
u'advanced/recent file count', QtCore.QVariant(4)).toInt()[0]
existingRecentFiles = [recentFile for recentFile in self.recentFiles
- if QtCore.QFile.exists(recentFile)]
+ if os.path.isfile(unicode(recentFile))]
recentFilesToDisplay = existingRecentFiles[0:recentFileCount]
self.recentFilesMenu.clear()
for fileId, filename in enumerate(recentFilesToDisplay):
log.debug('Recent file name: %s', filename)
- action = base_action(self, u'')
- action.setText(u'&%d %s' %
- (fileId + 1, QtCore.QFileInfo(filename).fileName()))
- action.setData(QtCore.QVariant(filename))
- self.connect(action, QtCore.SIGNAL(u'triggered()'),
- self.serviceManagerContents.onRecentServiceClicked)
+ action = create_action(self, u'',
+ text=u'&%d %s' % (fileId + 1, os.path.splitext(os.path.basename(
+ unicode(filename)))[0]), data=filename,
+ triggers=self.serviceManagerContents.onRecentServiceClicked)
self.recentFilesMenu.addAction(action)
- clearRecentFilesAction = base_action(self, u'')
- clearRecentFilesAction.setText(
- translate('OpenLP.MainWindow', 'Clear List',
- 'Clear List of recent files'))
- clearRecentFilesAction.setStatusTip(
- translate('OpenLP.MainWindow', 'Clear the list of recent files.'))
+ clearRecentFilesAction = create_action(self, u'',
+ text=translate('OpenLP.MainWindow', 'Clear List',
+ 'Clear List of recent files'),
+ statustip=translate('OpenLP.MainWindow',
+ 'Clear the list of recent files.'),
+ enabled=not self.recentFiles.isEmpty(),
+ triggers=self.recentFiles.clear)
add_actions(self.recentFilesMenu, (None, clearRecentFilesAction))
- self.connect(clearRecentFilesAction, QtCore.SIGNAL(u'triggered()'),
- self.recentFiles.clear)
clearRecentFilesAction.setEnabled(not self.recentFiles.isEmpty())
def addRecentFile(self, filename):
=== modified file 'openlp/core/ui/media/mediacontroller.py'
--- openlp/core/ui/media/mediacontroller.py 2012-03-03 22:36:46 +0000
+++ openlp/core/ui/media/mediacontroller.py 2012-03-06 19:17:18 +0000
@@ -204,18 +204,21 @@
controller.media_info = MediaInfo()
# Build a Media ToolBar
controller.mediabar = OpenLPToolbar(controller)
- controller.mediabar.addToolbarButton(
- u'media_playback_play', u':/slides/media_playback_start.png',
- translate('OpenLP.SlideController', 'Start playing media.'),
- controller.sendToPlugins)
- controller.mediabar.addToolbarButton(
- u'media_playback_pause', u':/slides/media_playback_pause.png',
- translate('OpenLP.SlideController', 'Pause playing media.'),
- controller.sendToPlugins)
- controller.mediabar.addToolbarButton(
- u'media_playback_stop', u':/slides/media_playback_stop.png',
- translate('OpenLP.SlideController', 'Stop playing media.'),
- controller.sendToPlugins)
+ controller.mediabar.addToolbarAction(u'playbackPlay',
+ text=u'media_playback_play',
+ icon=u':/slides/media_playback_start.png',
+ tooltip=translate('OpenLP.SlideController', 'Start playing media.'),
+ triggers=controller.sendToPlugins)
+ controller.mediabar.addToolbarAction(u'playbackPause',
+ text=u'media_playback_pause',
+ icon=u':/slides/media_playback_pause.png',
+ tooltip=translate('OpenLP.SlideController', 'Pause playing media.'),
+ triggers=controller.sendToPlugins)
+ controller.mediabar.addToolbarAction(u'playbackStop',
+ text=u'media_playback_stop',
+ icon=u':/slides/media_playback_stop.png',
+ tooltip=translate('OpenLP.SlideController', 'Stop playing media.'),
+ triggers=controller.sendToPlugins)
# Build the seekSlider.
controller.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
controller.seekSlider.setMaximum(1000)
@@ -223,9 +226,8 @@
controller.seekSlider.setToolTip(translate(
'OpenLP.SlideController', 'Video position.'))
controller.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
- controller.seekSlider.setObjectName(u'seek_slider')
- controller.mediabar.addToolbarWidget(u'Seek Slider',
- controller.seekSlider)
+ controller.seekSlider.setObjectName(u'seekSlider')
+ controller.mediabar.addToolbarWidget(controller.seekSlider)
# Build the volumeSlider.
controller.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
controller.volumeSlider.setTickInterval(10)
@@ -237,9 +239,8 @@
'OpenLP.SlideController', 'Audio Volume.'))
controller.volumeSlider.setValue(controller.media_info.volume)
controller.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24))
- controller.volumeSlider.setObjectName(u'volume_slider')
- controller.mediabar.addToolbarWidget(u'Audio Volume',
- controller.volumeSlider)
+ controller.volumeSlider.setObjectName(u'volumeSlider')
+ controller.mediabar.addToolbarWidget(controller.volumeSlider)
control_panel.addWidget(controller.mediabar)
controller.mediabar.setVisible(False)
# Signals
=== modified file 'openlp/core/ui/media/vlc.py'
--- openlp/core/ui/media/vlc.py 2011-12-08 20:51:44 +0000
+++ openlp/core/ui/media/vlc.py 2012-03-06 19:17:18 +0000
@@ -126,7 +126,7 @@
try:
_Ints = (int, long)
except NameError: # no long in Python 3+
- _Ints = int
+ _Ints = int
# Default instance. It is used to instanciate classes directly in the
# OO-wrapper.
=== modified file 'openlp/core/ui/media/vlcplayer.py'
--- openlp/core/ui/media/vlcplayer.py 2012-01-19 19:13:19 +0000
+++ openlp/core/ui/media/vlcplayer.py 2012-03-06 19:17:18 +0000
@@ -49,7 +49,7 @@
log = logging.getLogger(__name__)
-AUDIO_EXT = [
+AUDIO_EXT = [
u'*.mp3'
, u'*.wav'
, u'*.ogg'
=== modified file 'openlp/core/ui/media/webkitplayer.py'
--- openlp/core/ui/media/webkitplayer.py 2011-12-07 20:20:23 +0000
+++ openlp/core/ui/media/webkitplayer.py 2012-03-06 19:17:18 +0000
@@ -246,7 +246,7 @@
, u'*.swf'
]
-AUDIO_EXT = [
+AUDIO_EXT = [
u'*.mp3'
, u'*.ogg'
]
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2012-02-07 22:07:24 +0000
+++ openlp/core/ui/servicemanager.py 2012-03-06 19:17:18 +0000
@@ -41,7 +41,7 @@
ItemCapabilities, SettingsManager, translate, str_to_bool
from openlp.core.lib.theme import ThemeLevel
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
- context_menu_action, context_menu_separator, find_and_set_in_combo_box
+ create_widget_action, find_and_set_in_combo_box
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
from openlp.core.ui.printserviceform import PrintServiceForm
from openlp.core.utils import AppLocation, delete_file, split_filename
@@ -117,22 +117,23 @@
self.layout.setMargin(0)
# Create the top toolbar
self.toolbar = OpenLPToolbar(self)
- self.toolbar.addToolbarButton(
- UiStrings().NewService, u':/general/general_new.png',
- UiStrings().CreateService, self.onNewServiceClicked)
- self.toolbar.addToolbarButton(
- UiStrings().OpenService, u':/general/general_open.png',
- translate('OpenLP.ServiceManager', 'Load an existing service.'),
- self.onLoadServiceClicked)
- self.toolbar.addToolbarButton(
- UiStrings().SaveService, u':/general/general_save.png',
- translate('OpenLP.ServiceManager', 'Save this service.'),
- self.saveFile)
+ self.toolbar.addToolbarAction(u'newService',
+ text=UiStrings().NewService, icon=u':/general/general_new.png',
+ tooltip=UiStrings().CreateService,
+ triggers=self.onNewServiceClicked)
+ self.toolbar.addToolbarAction(u'openService',
+ text=UiStrings().OpenService, icon=u':/general/general_open.png',
+ tooltip=translate('OpenLP.ServiceManager',
+ 'Load an existing service.'), triggers=self.onLoadServiceClicked)
+ self.toolbar.addToolbarAction(u'saveService',
+ text=UiStrings().SaveService, icon=u':/general/general_save.png',
+ tooltip=translate('OpenLP.ServiceManager', 'Save this service.'),
+ triggers=self.saveFile)
self.toolbar.addSeparator()
self.themeLabel = QtGui.QLabel(u'%s:' % UiStrings().Theme, self)
self.themeLabel.setMargin(3)
self.themeLabel.setObjectName(u'themeLabel')
- self.toolbar.addToolbarWidget(u'ThemeLabel', self.themeLabel)
+ self.toolbar.addToolbarWidget(self.themeLabel)
self.themeComboBox = QtGui.QComboBox(self.toolbar)
self.themeComboBox.setToolTip(translate('OpenLP.ServiceManager',
'Select a theme for the service.'))
@@ -141,7 +142,7 @@
self.themeComboBox.setSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
self.themeComboBox.setObjectName(u'themeComboBox')
- self.toolbar.addToolbarWidget(u'ThemeWidget', self.themeComboBox)
+ self.toolbar.addToolbarWidget(self.themeComboBox)
self.toolbar.setObjectName(u'toolbar')
self.layout.addWidget(self.toolbar)
# Create the service manager list
@@ -168,99 +169,77 @@
self.layout.addWidget(self.serviceManagerList)
# Add the bottom toolbar
self.orderToolbar = OpenLPToolbar(self)
- self.serviceManagerList.moveTop = self.orderToolbar.addToolbarButton(
- translate('OpenLP.ServiceManager', 'Move to &top'),
- u':/services/service_top.png',
- translate('OpenLP.ServiceManager',
- 'Move item to the top of the service.'),
- self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home])
- self.serviceManagerList.moveTop.setObjectName(u'moveTop')
action_list = ActionList.get_instance()
action_list.add_category(
unicode(UiStrings().Service), CategoryOrder.standardToolbar)
- action_list.add_action(
- self.serviceManagerList.moveTop, unicode(UiStrings().Service))
- self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton(
- translate('OpenLP.ServiceManager', 'Move &up'),
- u':/services/service_up.png',
- translate('OpenLP.ServiceManager',
+ self.serviceManagerList.moveTop = self.orderToolbar.addToolbarAction(
+ u'moveTop', text=translate('OpenLP.ServiceManager', 'Move to &top'),
+ icon=u':/services/service_top.png', tooltip=translate(
+ 'OpenLP.ServiceManager', 'Move item to the top of the service.'),
+ shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service,
+ triggers=self.onServiceTop)
+ self.serviceManagerList.moveUp = self.orderToolbar.addToolbarAction(
+ u'moveUp', text=translate('OpenLP.ServiceManager', 'Move &up'),
+ icon=u':/services/service_up.png',
+ tooltip=translate( 'OpenLP.ServiceManager',
'Move item up one position in the service.'),
- self.onServiceUp, shortcuts=[QtCore.Qt.Key_PageUp])
- self.serviceManagerList.moveUp.setObjectName(u'moveUp')
- action_list.add_action(
- self.serviceManagerList.moveUp, unicode(UiStrings().Service))
- self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton(
- translate('OpenLP.ServiceManager', 'Move &down'),
- u':/services/service_down.png',
- translate('OpenLP.ServiceManager',
+ shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service,
+ triggers=self.onServiceUp)
+ self.serviceManagerList.moveDown = self.orderToolbar.addToolbarAction(
+ u'moveDown', text=translate('OpenLP.ServiceManager', 'Move &down'),
+ icon=u':/services/service_down.png',
+ tooltip=translate('OpenLP.ServiceManager',
'Move item down one position in the service.'),
- self.onServiceDown, shortcuts=[QtCore.Qt.Key_PageDown])
- self.serviceManagerList.moveDown.setObjectName(u'moveDown')
- action_list.add_action(
- self.serviceManagerList.moveDown, unicode(UiStrings().Service))
- self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton(
- translate('OpenLP.ServiceManager', 'Move to &bottom'),
- u':/services/service_bottom.png',
- translate('OpenLP.ServiceManager',
- 'Move item to the end of the service.'),
- self.onServiceEnd, shortcuts=[QtCore.Qt.Key_End])
- self.serviceManagerList.moveBottom.setObjectName(u'moveBottom')
- action_list.add_action(
- self.serviceManagerList.moveBottom, unicode(UiStrings().Service))
- self.serviceManagerList.down = self.orderToolbar.addToolbarButton(
- translate('OpenLP.ServiceManager', 'Move &down'),
- None,
- translate('OpenLP.ServiceManager',
- 'Moves the selection down the window.'),
- self.onMoveSelectionDown, shortcuts=[QtCore.Qt.Key_Down])
- self.serviceManagerList.down.setObjectName(u'down')
+ shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service,
+ triggers=self.onServiceDown)
+ self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarAction(
+ u'moveBottom',
+ text=translate('OpenLP.ServiceManager', 'Move to &bottom'),
+ icon=u':/services/service_bottom.png', tooltip=translate(
+ 'OpenLP.ServiceManager', 'Move item to the end of the service.'),
+ shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service,
+ triggers=self.onServiceEnd)
+ self.serviceManagerList.down = self.orderToolbar.addToolbarAction(
+ u'down', text=translate('OpenLP.ServiceManager', 'Move &down'),
+ tooltip=translate('OpenLP.ServiceManager',
+ 'Moves the selection down the window.'), visible=False,
+ shortcuts=[QtCore.Qt.Key_Down], triggers=self.onMoveSelectionDown)
action_list.add_action(self.serviceManagerList.down)
- self.serviceManagerList.down.setVisible(False)
- self.serviceManagerList.up = self.orderToolbar.addToolbarButton(
- translate('OpenLP.ServiceManager', 'Move up'),
- None,
- translate('OpenLP.ServiceManager',
- 'Moves the selection up the window.'),
- self.onMoveSelectionUp, shortcuts=[QtCore.Qt.Key_Up])
- self.serviceManagerList.up.setObjectName(u'up')
+ self.serviceManagerList.up = self.orderToolbar.addToolbarAction(
+ u'up', text=translate('OpenLP.ServiceManager', 'Move up'),
+ tooltip=translate('OpenLP.ServiceManager',
+ 'Moves the selection up the window.'), visible=False,
+ shortcuts=[QtCore.Qt.Key_Up], triggers=self.onMoveSelectionUp)
action_list.add_action(self.serviceManagerList.up)
- self.serviceManagerList.up.setVisible(False)
self.orderToolbar.addSeparator()
- self.serviceManagerList.delete = self.orderToolbar.addToolbarButton(
- translate('OpenLP.ServiceManager', '&Delete From Service'),
- u':/general/general_delete.png',
- translate('OpenLP.ServiceManager',
+ self.serviceManagerList.delete = self.orderToolbar.addToolbarAction(
+ u'delete',
+ text=translate('OpenLP.ServiceManager', '&Delete From Service'),
+ icon=u':/general/general_delete.png',
+ tooltip=translate('OpenLP.ServiceManager',
'Delete the selected item from the service.'),
- self.onDeleteFromService)
- self.orderToolbar.addSeparator()
- self.serviceManagerList.expand = self.orderToolbar.addToolbarButton(
- translate('OpenLP.ServiceManager', '&Expand all'),
- u':/services/service_expand_all.png',
- translate('OpenLP.ServiceManager',
- 'Expand all the service items.'),
- self.onExpandAll, shortcuts=[QtCore.Qt.Key_Plus])
- self.serviceManagerList.expand.setObjectName(u'expand')
- action_list.add_action(
- self.serviceManagerList.expand, unicode(UiStrings().Service))
- self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton(
- translate('OpenLP.ServiceManager', '&Collapse all'),
- u':/services/service_collapse_all.png',
- translate('OpenLP.ServiceManager',
- 'Collapse all the service items.'),
- self.onCollapseAll, shortcuts=[QtCore.Qt.Key_Minus])
- self.serviceManagerList.collapse.setObjectName(u'collapse')
- action_list.add_action(
- self.serviceManagerList.collapse, unicode(UiStrings().Service))
- self.orderToolbar.addSeparator()
- self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton(
- translate('OpenLP.ServiceManager', 'Go Live'),
- u':/general/general_live.png',
- translate('OpenLP.ServiceManager',
- 'Send the selected item to Live.'), self.makeLive,
- shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return])
- self.serviceManagerList.makeLive.setObjectName(u'orderToolbar')
- action_list.add_action(
- self.serviceManagerList.makeLive, unicode(UiStrings().Service))
+ triggers=self.onDeleteFromService)
+ self.orderToolbar.addSeparator()
+ self.serviceManagerList.expand = self.orderToolbar.addToolbarAction(
+ u'expand', text=translate('OpenLP.ServiceManager', '&Expand all'),
+ icon=u':/services/service_expand_all.png', tooltip=translate(
+ 'OpenLP.ServiceManager', 'Expand all the service items.'),
+ shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service,
+ triggers=self.onExpandAll)
+ self.serviceManagerList.collapse = self.orderToolbar.addToolbarAction(
+ u'collapse',
+ text=translate('OpenLP.ServiceManager', '&Collapse all'),
+ icon=u':/services/service_collapse_all.png', tooltip=translate(
+ 'OpenLP.ServiceManager', 'Collapse all the service items.'),
+ shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service,
+ triggers=self.onCollapseAll)
+ self.orderToolbar.addSeparator()
+ self.serviceManagerList.makeLive = self.orderToolbar.addToolbarAction(
+ u'makeLive', text=translate('OpenLP.ServiceManager', 'Go Live'),
+ icon=u':/general/general_live.png', tooltip=translate(
+ 'OpenLP.ServiceManager', 'Send the selected item to Live.'),
+ shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return],
+ category=UiStrings().Service, triggers=self.makeLive)
self.layout.addWidget(self.orderToolbar)
# Connect up our signals and slots
QtCore.QObject.connect(self.themeComboBox,
@@ -305,34 +284,32 @@
self.addToAction.setIcon(build_icon(u':/general/general_edit.png'))
# build the context menu
self.menu = QtGui.QMenu()
- self.editAction = context_menu_action(
- self.menu, u':/general/general_edit.png',
- translate('OpenLP.ServiceManager', '&Edit Item'), self.remoteEdit)
- self.maintainAction = context_menu_action(
- self.menu, u':/general/general_edit.png',
- translate('OpenLP.ServiceManager', '&Reorder Item'),
- self.onServiceItemEditForm)
- self.notesAction = context_menu_action(
- self.menu, u':/services/service_notes.png',
- translate('OpenLP.ServiceManager', '&Notes'),
- self.onServiceItemNoteForm)
- self.timeAction = context_menu_action(
- self.menu, u':/media/media_time.png',
- translate('OpenLP.ServiceManager', '&Start Time'),
- self.onStartTimeForm)
- self.deleteAction = context_menu_action(
- self.menu, u':/general/general_delete.png',
- translate('OpenLP.ServiceManager', '&Delete From Service'),
- self.onDeleteFromService)
- context_menu_separator(self.menu)
- self.previewAction = context_menu_action(
- self.menu, u':/general/general_preview.png',
- translate('OpenLP.ServiceManager', 'Show &Preview'),
- self.makePreview)
- self.liveAction = context_menu_action(
- self.menu, u':/general/general_live.png',
- translate('OpenLP.ServiceManager', 'Show &Live'), self.makeLive)
- context_menu_separator(self.menu)
+ self.editAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ServiceManager', '&Edit Item'),
+ icon=u':/general/general_edit.png', triggers=self.remoteEdit)
+ self.maintainAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ServiceManager', '&Reorder Item'),
+ icon=u':/general/general_edit.png',
+ triggers=self.onServiceItemEditForm)
+ self.notesAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ServiceManager', '&Notes'),
+ icon=u':/services/service_notes.png',
+ triggers=self.onServiceItemNoteForm)
+ self.timeAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ServiceManager', '&Start Time'),
+ icon=u':/media/media_time.png', triggers=self.onStartTimeForm)
+ self.deleteAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ServiceManager', '&Delete From Service'),
+ icon=u':/general/general_delete.png',
+ triggers=self.onDeleteFromService)
+ self.menu.addSeparator()
+ self.previewAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ServiceManager', 'Show &Preview'),
+ icon=u':/general/general_preview.png', triggers=self.makePreview)
+ self.liveAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ServiceManager', 'Show &Live'),
+ icon=u':/general/general_live.png', triggers=self.makeLive)
+ self.menu.addSeparator()
self.themeMenu = QtGui.QMenu(
translate('OpenLP.ServiceManager', '&Change Item Theme'))
self.menu.addMenu(self.themeMenu)
@@ -683,7 +660,7 @@
'File is not a valid service.\n'
'The content encoding is not UTF-8.'))
continue
- osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile))
+ osfile = ucsfile.replace(u'/', os.path.sep)
if not osfile.startswith(u'audio'):
osfile = os.path.split(osfile)[1]
log.debug(u'Extract file: %s', osfile)
@@ -1143,12 +1120,9 @@
sure the theme combo box is in the correct state.
"""
log.debug(u'themeChange')
- if self.mainwindow.renderer.theme_level == ThemeLevel.Global:
- self.toolbar.actions[u'ThemeLabel'].setVisible(False)
- self.toolbar.actions[u'ThemeWidget'].setVisible(False)
- else:
- self.toolbar.actions[u'ThemeLabel'].setVisible(True)
- self.toolbar.actions[u'ThemeWidget'].setVisible(True)
+ visible = self.mainwindow.renderer.theme_level == ThemeLevel.Global
+ self.themeLabel.setVisible(visible)
+ self.themeComboBox.setVisible(visible)
def regenerateServiceItems(self):
"""
@@ -1450,19 +1424,16 @@
themeGroup.setObjectName(u'themeGroup')
# Create a "Default" theme, which allows the user to reset the item's
# theme to the service theme or global theme.
- defaultTheme = context_menu_action(self.themeMenu, None,
- UiStrings().Default, self.onThemeChangeAction)
- defaultTheme.setCheckable(True)
+ defaultTheme = create_widget_action(self.themeMenu,
+ text=UiStrings().Default, checked=False,
+ triggers=self.onThemeChangeAction)
self.themeMenu.setDefaultAction(defaultTheme)
themeGroup.addAction(defaultTheme)
- context_menu_separator(self.themeMenu)
+ self.themeMenu.addSeparator()
for theme in theme_list:
self.themeComboBox.addItem(theme)
- themeAction = context_menu_action(self.themeMenu, None, theme,
- self.onThemeChangeAction)
- themeAction.setObjectName(theme)
- themeAction.setCheckable(True)
- themeGroup.addAction(themeAction)
+ themeGroup.addAction(create_widget_action(self.themeMenu, theme,
+ text=theme, checked=False, triggers=self.onThemeChangeAction))
find_and_set_in_combo_box(self.themeComboBox, self.service_theme)
self.mainwindow.renderer.set_service_theme(self.service_theme)
self.regenerateServiceItems()
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2012-02-25 13:39:12 +0000
+++ openlp/core/ui/slidecontroller.py 2012-03-06 19:17:18 +0000
@@ -34,7 +34,7 @@
from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, \
translate, build_icon, build_html, PluginManager, ServiceItem
-from openlp.core.lib.ui import UiStrings, shortcut_action
+from openlp.core.lib.ui import UiStrings, create_action
from openlp.core.lib import SlideLimits, ServiceItemAction
from openlp.core.ui import HideMode, MainDisplay, Display, ScreenList
from openlp.core.utils.actions import ActionList, CategoryOrder
@@ -92,16 +92,14 @@
self.imageManager = self.parent().imageManager
self.mediaController = self.parent().mediaController
self.loopList = [
- u'Play Slides Menu',
- u'Loop Separator',
- u'Image SpinBox'
- ]
- self.songEditList = [
- u'Edit Song',
- ]
- self.nextPreviousList = [
- u'Previous Slide',
- u'Next Slide'
+ u'playSlidesMenu',
+ u'loopSeparator',
+ u'delaySpinBox'
+ ]
+ self.audioList = [
+ u'songMenu',
+ u'audioPauseItem',
+ u'audioTimeLabel'
]
self.timer_id = 0
self.songEdit = False
@@ -123,10 +121,14 @@
self.typePrefix = u'live'
self.keypress_queue = deque()
self.keypress_loop = False
+ self.category = UiStrings().LiveToolbar
+ ActionList.get_instance().add_category(
+ unicode(self.category), CategoryOrder.standardToolbar)
else:
self.typeLabel.setText(UiStrings().Preview)
self.split = 0
self.typePrefix = u'preview'
+ self.category = None
self.typeLabel.setStyleSheet(u'font-weight: bold; font-size: 12pt;')
self.typeLabel.setAlignment(QtCore.Qt.AlignCenter)
self.panelLayout.addWidget(self.typeLabel)
@@ -169,72 +171,71 @@
sizeToolbarPolicy.setHeightForWidth(
self.toolbar.sizePolicy().hasHeightForWidth())
self.toolbar.setSizePolicy(sizeToolbarPolicy)
- self.previousItem = self.toolbar.addToolbarButton(
- u'Previous Slide',
- u':/slides/slide_previous.png',
- translate('OpenLP.SlideController', 'Move to previous.'),
- self.onSlideSelectedPrevious,
+ self.previousItem = create_action(self,
+ u'previousItem_' + self.typePrefix,
+ text=translate('OpenLP.SlideController', 'Previous Slide'),
+ icon=u':/slides/slide_previous.png',
+ tooltip=translate('OpenLP.SlideController', 'Move to previous.'),
shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp],
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.nextItem = self.toolbar.addToolbarButton(
- u'Next Slide',
- u':/slides/slide_next.png',
- translate('OpenLP.SlideController', 'Move to next.'),
- self.onSlideSelectedNext,
+ context=QtCore.Qt.WidgetWithChildrenShortcut,
+ category=self.category, triggers=self.onSlideSelectedPrevious)
+ self.toolbar.addAction(self.previousItem)
+ self.nextItem = create_action(self, u'nextItem_' + self.typePrefix,
+ text=translate('OpenLP.SlideController', 'Next Slide'),
+ icon=u':/slides/slide_next.png',
+ tooltip=translate('OpenLP.SlideController', 'Move to next.'),
shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown],
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.toolbar.addToolbarSeparator(u'Close Separator')
+ context=QtCore.Qt.WidgetWithChildrenShortcut,
+ category=self.category, triggers=self.onSlideSelectedNext)
+ self.toolbar.addAction(self.nextItem)
+ self.toolbar.addSeparator()
if self.isLive:
# Hide Menu
self.hideMenu = QtGui.QToolButton(self.toolbar)
+ self.hideMenu.setObjectName(u'hideMenu')
self.hideMenu.setText(translate('OpenLP.SlideController', 'Hide'))
self.hideMenu.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
- self.toolbar.addToolbarWidget(u'Hide Menu', self.hideMenu)
self.hideMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Hide'), self.toolbar))
- self.blankScreen = shortcut_action(self.hideMenu, u'blankScreen',
- [QtCore.Qt.Key_Period], self.onBlankDisplay,
- u':/slides/slide_blank.png', False,
- unicode(UiStrings().LiveToolbar))
- self.blankScreen.setText(
- translate('OpenLP.SlideController', 'Blank Screen'))
- self.themeScreen = shortcut_action(self.hideMenu, u'themeScreen',
- [QtGui.QKeySequence(u'T')], self.onThemeDisplay,
- u':/slides/slide_theme.png', False,
- unicode(UiStrings().LiveToolbar))
- self.themeScreen.setText(
- translate('OpenLP.SlideController', 'Blank to Theme'))
- self.desktopScreen = shortcut_action(self.hideMenu,
- u'desktopScreen', [QtGui.QKeySequence(u'D')],
- self.onHideDisplay, u':/slides/slide_desktop.png', False,
- unicode(UiStrings().LiveToolbar))
- self.desktopScreen.setText(
- translate('OpenLP.SlideController', 'Show Desktop'))
+ self.toolbar.addToolbarWidget(self.hideMenu)
+ self.blankScreen = create_action(self, u'blankScreen',
+ text=translate('OpenLP.SlideController', 'Blank Screen'),
+ icon=u':/slides/slide_blank.png', checked=False,
+ shortcuts=[QtCore.Qt.Key_Period],
+ category=self.category, triggers=self.onBlankDisplay)
+ self.themeScreen = create_action(self, u'themeScreen',
+ text=translate('OpenLP.SlideController', 'Blank to Theme'),
+ icon=u':/slides/slide_theme.png', checked=False,
+ shortcuts=[QtGui.QKeySequence(u'T')],
+ category=self.category, triggers=self.onThemeDisplay)
+ self.desktopScreen = create_action(self, u'desktopScreen',
+ text=translate('OpenLP.SlideController', 'Show Desktop'),
+ icon=u':/slides/slide_desktop.png', checked=False,
+ shortcuts=[QtGui.QKeySequence(u'D')],
+ category=self.category, triggers=self.onHideDisplay)
self.hideMenu.setDefaultAction(self.blankScreen)
self.hideMenu.menu().addAction(self.blankScreen)
self.hideMenu.menu().addAction(self.themeScreen)
self.hideMenu.menu().addAction(self.desktopScreen)
- self.toolbar.addToolbarSeparator(u'Loop Separator')
+ self.toolbar.addToolbarAction(u'loopSeparator', separator=True)
# Play Slides Menu
self.playSlidesMenu = QtGui.QToolButton(self.toolbar)
+ self.playSlidesMenu.setObjectName(u'playSlidesMenu')
self.playSlidesMenu.setText(translate('OpenLP.SlideController',
'Play Slides'))
self.playSlidesMenu.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
- self.toolbar.addToolbarWidget(u'Play Slides Menu',
- self.playSlidesMenu)
self.playSlidesMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Play Slides'),
self.toolbar))
- self.playSlidesLoop = shortcut_action(self.playSlidesMenu,
- u'playSlidesLoop', [], self.onPlaySlidesLoop,
- u':/media/media_time.png', False,
- unicode(UiStrings().LiveToolbar))
- self.playSlidesLoop.setText(UiStrings().PlaySlidesInLoop)
- self.playSlidesOnce = shortcut_action(self.playSlidesMenu,
- u'playSlidesOnce', [], self.onPlaySlidesOnce,
- u':/media/media_time.png', False,
- unicode(UiStrings().LiveToolbar))
- self.playSlidesOnce.setText(UiStrings().PlaySlidesToEnd)
+ self.toolbar.addToolbarWidget(self.playSlidesMenu)
+ self.playSlidesLoop = create_action(self, u'playSlidesLoop',
+ text=UiStrings().PlaySlidesInLoop,
+ icon=u':/media/media_time.png', checked=False, shortcuts=[],
+ category=self.category, triggers=self.onPlaySlidesLoop)
+ self.playSlidesOnce = create_action(self, u'playSlidesOnce',
+ text=UiStrings().PlaySlidesToEnd,
+ icon=u':/media/media_time.png', checked=False, shortcuts=[],
+ category=self.category, triggers=self.onPlaySlidesOnce)
if QtCore.QSettings().value(self.parent().generalSettingsSection +
u'/enable slide loop', QtCore.QVariant(True)).toBool():
self.playSlidesMenu.setDefaultAction(self.playSlidesLoop)
@@ -244,65 +245,60 @@
self.playSlidesMenu.menu().addAction(self.playSlidesOnce)
# Loop Delay Spinbox
self.delaySpinBox = QtGui.QSpinBox()
+ self.delaySpinBox.setObjectName(u'delaySpinBox')
self.delaySpinBox.setRange(1, 180)
- self.toolbar.addToolbarWidget(u'Image SpinBox', self.delaySpinBox)
self.delaySpinBox.setSuffix(UiStrings().Seconds)
self.delaySpinBox.setToolTip(translate('OpenLP.SlideController',
'Delay between slides in seconds.'))
+ self.toolbar.addToolbarWidget(self.delaySpinBox)
else:
- self.toolbar.addToolbarButton(
- # Does not need translating - control string.
- u'Go Live', u':/general/general_live.png',
- translate('OpenLP.SlideController', 'Move to live.'),
- self.onGoLive)
- self.toolbar.addToolbarButton(
- # Does not need translating - control string.
- u'Add to Service', u':/general/general_add.png',
- translate('OpenLP.SlideController', 'Add to Service.'),
- self.onPreviewAddToService)
- self.toolbar.addToolbarSeparator(u'Close Separator')
- self.toolbar.addToolbarButton(
- # Does not need translating - control string.
- u'Edit Song', u':/general/general_edit.png',
- translate('OpenLP.SlideController',
- 'Edit and reload song preview.'),
- self.onEditSong)
+ self.toolbar.addToolbarAction(u'goLive',
+ icon=u':/general/general_live.png',
+ tooltip=translate('OpenLP.SlideController', 'Move to live.'),
+ triggers=self.onGoLive)
+ self.toolbar.addToolbarAction(u'addToService',
+ icon=u':/general/general_add.png',
+ tooltip=translate('OpenLP.SlideController', 'Add to Service.'),
+ triggers=self.onPreviewAddToService)
+ self.toolbar.addSeparator()
+ self.toolbar.addToolbarAction(u'editSong',
+ icon=u':/general/general_edit.png',
+ tooltip=translate('OpenLP.SlideController',
+ 'Edit and reload song preview.'), triggers=self.onEditSong)
self.controllerLayout.addWidget(self.toolbar)
# Build the Media Toolbar
self.mediaController.add_controller_items(self, self.controllerLayout)
if self.isLive:
# Build the Song Toolbar
self.songMenu = QtGui.QToolButton(self.toolbar)
+ self.songMenu.setObjectName(u'songMenu')
self.songMenu.setText(translate('OpenLP.SlideController', 'Go To'))
self.songMenu.setPopupMode(QtGui.QToolButton.InstantPopup)
- self.toolbar.addToolbarWidget(u'Song Menu', self.songMenu)
self.songMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Go To'), self.toolbar))
+ self.toolbar.addToolbarWidget(self.songMenu)
# Stuff for items with background audio.
- self.audioPauseItem = QtGui.QToolButton(self.toolbar)
- self.audioPauseItem.setIcon(
- QtGui.QIcon(u':/slides/media_playback_pause.png'))
- self.audioPauseItem.setText(translate('OpenLP.SlideController',
- 'Pause audio.'))
- self.audioPauseItem.setCheckable(True)
- self.toolbar.addToolbarWidget(u'Pause Audio', self.audioPauseItem)
- QtCore.QObject.connect(self.audioPauseItem,
- QtCore.SIGNAL(u'clicked(bool)'), self.onAudioPauseClicked)
- self.audioPauseItem.setVisible(False)
+ self.audioPauseItem = self.toolbar.addToolbarAction(
+ u'audioPauseItem', icon=u':/slides/media_playback_pause.png',
+ text=translate('OpenLP.SlideController', 'Pause Audio'),
+ tooltip=translate('OpenLP.SlideController', 'Pause audio.'),
+ checked=False, visible=False, category=self.category,
+ triggers=self.onAudioPauseClicked)
self.audioMenu = QtGui.QMenu(
- translate('OpenLP.SlideController', 'Background Audio'),
- self.toolbar)
- self.nextTrackItem = shortcut_action(self.audioMenu,
- u'nextTrackItem', [], self.onNextTrackClicked,
- u':/slides/media_playback_next.png',
- category=unicode(UiStrings().LiveToolbar))
- self.nextTrackItem.setText(
- translate('OpenLP.SlideController', 'Next Track'))
+ translate('OpenLP.SlideController', 'Background Audio'), self)
+ self.audioPauseItem.setMenu(self.audioMenu)
+ self.audioPauseItem.setParent(self)
+ self.toolbar.widgetForAction(self.audioPauseItem).setPopupMode(
+ QtGui.QToolButton.MenuButtonPopup)
+ self.nextTrackItem = create_action(self, u'nextTrackItem',
+ text=translate('OpenLP.SlideController', 'Next Track'),
+ icon=u':/slides/media_playback_next.png', tooltip=translate(
+ 'OpenLP.SlideController', 'Go to next audio track.'),
+ category=self.category, context=QtCore.Qt.WindowShortcut,
+ triggers=self.onNextTrackClicked)
self.audioMenu.addAction(self.nextTrackItem)
self.trackMenu = self.audioMenu.addMenu(
translate('OpenLP.SlideController', 'Tracks'))
- self.audioPauseItem.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
- self.audioPauseItem.setMenu(self.audioMenu)
self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar)
self.audioTimeLabel.setAlignment(
QtCore.Qt.AlignCenter|QtCore.Qt.AlignHCenter)
@@ -316,10 +312,8 @@
u'border-width: 1; font-family: monospace; margin: 2px;'
)
self.audioTimeLabel.setObjectName(u'audioTimeLabel')
- self.toolbar.addToolbarWidget(
- u'Time Remaining', self.audioTimeLabel)
- self.toolbar.makeWidgetsInvisible([u'Song Menu', u'Pause Audio',
- u'Time Remaining'])
+ self.toolbar.addToolbarWidget(self.audioTimeLabel)
+ self.toolbar.setWidgetVisible(self.audioList, False)
# Screen preview area
self.previewFrame = QtGui.QFrame(self.splitter)
self.previewFrame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio))
@@ -364,89 +358,31 @@
self.shortcutTimer = QtCore.QTimer()
self.shortcutTimer.setObjectName(u'shortcutTimer')
self.shortcutTimer.setSingleShot(True)
- self.verseShortcut = shortcut_action(self, u'verseShortcut',
- [QtGui.QKeySequence(u'V')], self.slideShortcutActivated,
- category=unicode(UiStrings().LiveToolbar),
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.verseShortcut.setText(translate(
- 'OpenLP.SlideController', 'Go to "Verse"'))
- self.shortcut0 = shortcut_action(self, u'0',
- [QtGui.QKeySequence(u'0')], self.slideShortcutActivated,
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.shortcut1 = shortcut_action(self, u'1',
- [QtGui.QKeySequence(u'1')], self.slideShortcutActivated,
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.shortcut2 = shortcut_action(self, u'2',
- [QtGui.QKeySequence(u'2')], self.slideShortcutActivated,
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.shortcut3 = shortcut_action(self, u'3',
- [QtGui.QKeySequence(u'3')], self.slideShortcutActivated,
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.shortcut4 = shortcut_action(self, u'4',
- [QtGui.QKeySequence(u'4')], self.slideShortcutActivated,
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.shortcut5 = shortcut_action(self, u'5',
- [QtGui.QKeySequence(u'5')], self.slideShortcutActivated,
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.shortcut6 = shortcut_action(self, u'6',
- [QtGui.QKeySequence(u'6')], self.slideShortcutActivated,
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.shortcut7 = shortcut_action(self, u'7',
- [QtGui.QKeySequence(u'7')], self.slideShortcutActivated,
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.shortcut8 = shortcut_action(self, u'8',
- [QtGui.QKeySequence(u'8')], self.slideShortcutActivated,
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.shortcut9 = shortcut_action(self, u'9',
- [QtGui.QKeySequence(u'9')], self.slideShortcutActivated,
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.chorusShortcut = shortcut_action(self, u'chorusShortcut',
- [QtGui.QKeySequence(u'C')], self.slideShortcutActivated,
- category=unicode(UiStrings().LiveToolbar),
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.chorusShortcut.setText(translate(
- 'OpenLP.SlideController', 'Go to "Chorus"'))
- self.bridgeShortcut = shortcut_action(self, u'bridgeShortcut',
- [QtGui.QKeySequence(u'B')], self.slideShortcutActivated,
- category=unicode(UiStrings().LiveToolbar),
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.bridgeShortcut.setText(translate(
- 'OpenLP.SlideController', 'Go to "Bridge"'))
- self.preChorusShortcut = shortcut_action(self, u'preChorusShortcut',
- [QtGui.QKeySequence(u'P')], self.slideShortcutActivated,
- category=unicode(UiStrings().LiveToolbar),
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.preChorusShortcut.setText(translate(
- 'OpenLP.SlideController', 'Go to "Pre-Chorus"'))
- self.introShortcut = shortcut_action(self, u'introShortcut',
- [QtGui.QKeySequence(u'I')], self.slideShortcutActivated,
- category=unicode(UiStrings().LiveToolbar),
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.introShortcut.setText(translate(
- 'OpenLP.SlideController', 'Go to "Intro"'))
- self.endingShortcut = shortcut_action(self, u'endingShortcut',
- [QtGui.QKeySequence(u'E')], self.slideShortcutActivated,
- category=unicode(UiStrings().LiveToolbar),
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.endingShortcut.setText(translate(
- 'OpenLP.SlideController', 'Go to "Ending"'))
- self.otherShortcut = shortcut_action(self, u'otherShortcut',
- [QtGui.QKeySequence(u'O')], self.slideShortcutActivated,
- category=unicode(UiStrings().LiveToolbar),
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.otherShortcut.setText(translate(
- 'OpenLP.SlideController', 'Go to "Other"'))
- self.previewListWidget.addActions([
- self.shortcut0, self.shortcut1, self.shortcut2, self.shortcut3,
- self.shortcut4, self.shortcut5, self.shortcut6, self.shortcut7,
- self.shortcut8, self.shortcut9, self.verseShortcut,
- self.chorusShortcut, self.bridgeShortcut,
- self.preChorusShortcut, self.introShortcut, self.endingShortcut,
- self.otherShortcut
- ])
+ shortcuts = [{u'key': u'V', u'configurable': True,
+ u'text': translate('OpenLP.SlideController', 'Go to "Verse"')},
+ {u'key': u'C', u'configurable': True,
+ u'text': translate('OpenLP.SlideController', 'Go to "Chorus"')},
+ {u'key': u'B', u'configurable': True,
+ u'text': translate('OpenLP.SlideController', 'Go to "Bridge"')},
+ {u'key': u'P', u'configurable': True,
+ u'text': translate('OpenLP.SlideController',
+ 'Go to "Pre-Chorus"')},
+ {u'key': u'I', u'configurable': True,
+ u'text': translate('OpenLP.SlideController', 'Go to "Intro"')},
+ {u'key': u'E', u'configurable': True,
+ u'text': translate('OpenLP.SlideController', 'Go to "Ending"')},
+ {u'key': u'O', u'configurable': True,
+ u'text': translate('OpenLP.SlideController', 'Go to "Other"')}]
+ shortcuts += [{u'key': unicode(number)} for number in range(0, 10)]
+ self.previewListWidget.addActions([create_action(self,
+ u'shortcutAction_%s' % s[u'key'], text=s.get(u'text'),
+ shortcuts=[QtGui.QKeySequence(s[u'key'])],
+ context=QtCore.Qt.WidgetWithChildrenShortcut,
+ category=self.category if s.get(u'configurable') else None,
+ triggers=self._slideShortcutActivated) for s in shortcuts])
QtCore.QObject.connect(
self.shortcutTimer, QtCore.SIGNAL(u'timeout()'),
- self.slideShortcutActivated)
+ self._slideShortcutActivated)
# Signals
QtCore.QObject.connect(self.previewListWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
@@ -457,20 +393,18 @@
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_toggle_display'),
self.toggleDisplay)
- self.toolbar.makeWidgetsInvisible(self.loopList)
+ self.toolbar.setWidgetVisible(self.loopList, False)
else:
QtCore.QObject.connect(self.previewListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
self.onGoLiveClick)
- self.toolbar.makeWidgetsInvisible(self.songEditList)
+ self.toolbar.setWidgetVisible([u'editSong'], False)
if self.isLive:
self.setLiveHotkeys(self)
self.__addActionsToWidget(self.previewListWidget)
else:
- self.setPreviewHotkeys()
self.previewListWidget.addActions(
- [self.nextItem,
- self.previousItem])
+ [self.nextItem, self.previousItem])
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix),
self.onStopLoop)
@@ -496,7 +430,7 @@
QtCore.SIGNAL(u'slidecontroller_update_slide_limits'),
self.updateSlideLimits)
- def slideShortcutActivated(self):
+ def _slideShortcutActivated(self):
"""
Called, when a shortcut has been activated to jump to a chorus, verse,
etc.
@@ -512,52 +446,38 @@
SONGS_PLUGIN_AVAILABLE = True
except ImportError:
SONGS_PLUGIN_AVAILABLE = False
- verse_type = unicode(self.sender().objectName())
- if verse_type.startswith(u'verseShortcut'):
- if SONGS_PLUGIN_AVAILABLE:
+ sender_name = unicode(self.sender().objectName())
+ verse_type = sender_name[15:] \
+ if sender_name[:15] == u'shortcutAction_' else u''
+ if SONGS_PLUGIN_AVAILABLE:
+ if verse_type == u'V':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Verse]
- else:
- self.current_shortcut = u'V'
- elif verse_type.startswith(u'chorusShortcut'):
- if SONGS_PLUGIN_AVAILABLE:
+ elif verse_type == u'C':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Chorus]
- else:
- self.current_shortcut = u'C'
- elif verse_type.startswith(u'bridgeShortcut'):
- if SONGS_PLUGIN_AVAILABLE:
+ elif verse_type == u'B':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Bridge]
- else:
- self.current_shortcut = u'B'
- elif verse_type.startswith(u'preChorusShortcut'):
- if SONGS_PLUGIN_AVAILABLE:
+ elif verse_type == u'P':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.PreChorus]
- else:
- self.current_shortcut = u'P'
- elif verse_type.startswith(u'introShortcut'):
- if SONGS_PLUGIN_AVAILABLE:
+ elif verse_type == u'I':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Intro]
- else:
- self.current_shortcut = u'I'
- elif verse_type.startswith(u'endingShortcut'):
- if SONGS_PLUGIN_AVAILABLE:
+ elif verse_type == u'E':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Ending]
- else:
- self.current_shortcut = u'E'
- elif verse_type.startswith(u'otherShortcut'):
- if SONGS_PLUGIN_AVAILABLE:
+ elif verse_type == u'O':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Other]
- else:
- self.current_shortcut = u'O'
+ elif verse_type.isnumeric():
+ self.current_shortcut += verse_type
+ self.current_shortcut = self.current_shortcut.upper()
elif verse_type.isnumeric():
self.current_shortcut += verse_type
- self.current_shortcut = self.current_shortcut.upper()
+ elif verse_type:
+ self.current_shortcut = verse_type
keys = self.slideList.keys()
matches = [match for match in keys
if match.startswith(self.current_shortcut)]
@@ -566,7 +486,7 @@
self.current_shortcut = u''
self.__checkUpdateSelectedSlide(self.slideList[matches[0]])
self.slideSelected()
- elif verse_type != u'shortcutTimer':
+ elif sender_name != u'shortcutTimer':
# Start the time as we did not have any match.
self.shortcutTimer.start(350)
else:
@@ -580,39 +500,22 @@
# Reset the shortcut.
self.current_shortcut = u''
- def setPreviewHotkeys(self):
- self.previousItem.setObjectName(u'previousItemPreview')
- self.nextItem.setObjectName(u'nextItemPreview')
- action_list = ActionList.get_instance()
- action_list.add_action(self.previousItem)
- action_list.add_action(self.nextItem)
-
def setLiveHotkeys(self, parent=None):
- self.previousItem.setObjectName(u'previousItemLive')
- self.nextItem.setObjectName(u'nextItemLive')
- action_list = ActionList.get_instance()
- action_list.add_category(
- unicode(UiStrings().LiveToolbar), CategoryOrder.standardToolbar)
- action_list.add_action(self.previousItem)
- action_list.add_action(self.nextItem)
- self.previousService = shortcut_action(parent, u'previousService',
- [QtCore.Qt.Key_Left], self.servicePrevious,
- category=unicode(UiStrings().LiveToolbar),
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.previousService.setText(
- translate('OpenLP.SlideController', 'Previous Service'))
- self.nextService = shortcut_action(parent, 'nextService',
- [QtCore.Qt.Key_Right], self.serviceNext,
- category=unicode(UiStrings().LiveToolbar),
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.nextService.setText(
- translate('OpenLP.SlideController', 'Next Service'))
- self.escapeItem = shortcut_action(parent, 'escapeItem',
- [QtCore.Qt.Key_Escape], self.liveEscape,
- category=unicode(UiStrings().LiveToolbar),
- context=QtCore.Qt.WidgetWithChildrenShortcut)
- self.escapeItem.setText(
- translate('OpenLP.SlideController', 'Escape Item'))
+ self.previousService = create_action(parent, u'previousService',
+ text=translate('OpenLP.SlideController', 'Previous Service'),
+ shortcuts=[QtCore.Qt.Key_Left],
+ context=QtCore.Qt.WidgetWithChildrenShortcut,
+ category=self.category, triggers=self.servicePrevious)
+ self.nextService = create_action(parent, 'nextService',
+ text=translate('OpenLP.SlideController', 'Next Service'),
+ shortcuts=[QtCore.Qt.Key_Right],
+ context=QtCore.Qt.WidgetWithChildrenShortcut,
+ category=self.category, triggers=self.serviceNext)
+ self.escapeItem = create_action(parent, 'escapeItem',
+ text=translate('OpenLP.SlideController', 'Escape Item'),
+ shortcuts=[QtCore.Qt.Key_Escape],
+ context=QtCore.Qt.WidgetWithChildrenShortcut,
+ category=self.category, triggers=self.liveEscape)
def liveEscape(self):
self.display.setVisible(False)
@@ -779,9 +682,9 @@
# Work-around for OS X, hide and then show the toolbar
# See bug #791050
self.toolbar.hide()
- self.mediabar.setVisible(False)
- self.toolbar.makeWidgetsInvisible([u'Song Menu'])
- self.toolbar.makeWidgetsInvisible(self.loopList)
+ self.mediabar.hide()
+ self.songMenu.hide()
+ self.toolbar.setWidgetVisible(self.loopList, False)
# Reset the button
self.playSlidesOnce.setChecked(False)
self.playSlidesOnce.setIcon(build_icon(u':/media/media_time.png'))
@@ -791,17 +694,16 @@
if QtCore.QSettings().value(
self.parent().songsSettingsSection + u'/display songbar',
QtCore.QVariant(True)).toBool() and len(self.slideList) > 0:
- self.toolbar.makeWidgetsVisible([u'Song Menu'])
+ self.songMenu.show()
if item.is_capable(ItemCapabilities.CanLoop) and \
len(item.get_frames()) > 1:
- self.toolbar.makeWidgetsVisible(self.loopList)
+ self.toolbar.setWidgetVisible(self.loopList)
if item.is_media():
- self.mediabar.setVisible(True)
- self.toolbar.makeWidgetsInvisible(self.nextPreviousList)
- else:
- # Work-around for OS X, hide and then show the toolbar
- # See bug #791050
- self.toolbar.makeWidgetsVisible(self.nextPreviousList)
+ self.mediabar.show()
+ self.previousItem.setVisible(not item.is_media())
+ self.nextItem.setVisible(not item.is_media())
+ # Work-around for OS X, hide and then show the toolbar
+ # See bug #791050
self.toolbar.show()
def enablePreviewToolBar(self, item):
@@ -811,17 +713,16 @@
# Work-around for OS X, hide and then show the toolbar
# See bug #791050
self.toolbar.hide()
- self.mediabar.setVisible(False)
- self.toolbar.makeWidgetsInvisible(self.songEditList)
+ self.mediabar.hide()
+ self.toolbar.setWidgetVisible([u'editSong'], False)
if item.is_capable(ItemCapabilities.CanEdit) and item.from_plugin:
- self.toolbar.makeWidgetsVisible(self.songEditList)
+ self.toolbar.setWidgetVisible([u'editSong'])
elif item.is_media():
- self.mediabar.setVisible(True)
- self.toolbar.makeWidgetsInvisible(self.nextPreviousList)
- if not item.is_media():
- # Work-around for OS X, hide and then show the toolbar
- # See bug #791050
- self.toolbar.makeWidgetsVisible(self.nextPreviousList)
+ self.mediabar.show()
+ self.previousItem.setVisible(not item.is_media())
+ self.nextItem.setVisible(not item.is_media())
+ # Work-around for OS X, hide and then show the toolbar
+ # See bug #791050
self.toolbar.show()
def refreshServiceItem(self):
@@ -966,7 +867,7 @@
self.slideList[unicode(row)] = row - 1
text.append(unicode(row))
self.previewListWidget.setItem(framenumber, 0, item)
- if not slideHeight:
+ if slideHeight:
self.previewListWidget.setRowHeight(framenumber, slideHeight)
self.previewListWidget.setVerticalHeaderLabels(text)
if self.serviceItem.is_text():
@@ -1181,7 +1082,7 @@
"""
row = self.previewListWidget.currentRow()
self.selectedRow = 0
- if row > -1 and row < self.previewListWidget.rowCount():
+ if -1 < row < self.previewListWidget.rowCount():
if self.serviceItem.is_command():
if self.isLive and not start:
Receiver.send_message(
@@ -1317,7 +1218,7 @@
"""
Stop the timer loop running
"""
- if self.timer_id != 0:
+ if self.timer_id:
self.killTimer(self.timer_id)
self.timer_id = 0
@@ -1364,12 +1265,7 @@
self.onToggleLoop()
def setAudioItemsVisibility(self, visible):
- if visible:
- self.toolbar.makeWidgetsVisible(
- [u'Song Menu', u'Pause Audio', u'Time Remaining'])
- else:
- self.toolbar.makeWidgetsInvisible(
- [u'Song Menu', u'Pause Audio', u'Time Remaining'])
+ self.toolbar.setWidgetVisible(self.audioList, visible)
def onAudioPauseClicked(self, checked):
if not self.audioPauseItem.isVisible():
@@ -1423,7 +1319,7 @@
If preview copy slide item to live
"""
row = self.previewListWidget.currentRow()
- if row > -1 and row < self.previewListWidget.rowCount():
+ if -1 < row < self.previewListWidget.rowCount():
if self.serviceItem.from_service:
Receiver.send_message('servicemanager_preview_live',
u'%s:%s' % (self.serviceItem._uuid, row))
=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py 2012-01-18 13:50:06 +0000
+++ openlp/core/ui/thememanager.py 2012-03-06 19:17:18 +0000
@@ -41,7 +41,7 @@
from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, \
BackgroundGradientType
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
- context_menu_action, context_menu_separator
+ create_widget_action
from openlp.core.theme import Theme
from openlp.core.ui import FileRenameForm, ThemeForm
from openlp.core.utils import AppLocation, delete_file, get_filesystem_encoding
@@ -64,32 +64,32 @@
self.layout.setMargin(0)
self.layout.setObjectName(u'layout')
self.toolbar = OpenLPToolbar(self)
- self.toolbar.addToolbarButton(UiStrings().NewTheme,
- u':/themes/theme_new.png',
- translate('OpenLP.ThemeManager', 'Create a new theme.'),
- self.onAddTheme)
- self.toolbar.addToolbarButton(
- translate('OpenLP.ThemeManager', 'Edit Theme'),
- u':/themes/theme_edit.png',
- translate('OpenLP.ThemeManager', 'Edit a theme.'),
- self.onEditTheme)
- self.deleteToolbarAction = self.toolbar.addToolbarButton(
- translate('OpenLP.ThemeManager', 'Delete Theme'),
- u':/general/general_delete.png',
- translate('OpenLP.ThemeManager', 'Delete a theme.'),
- self.onDeleteTheme)
+ self.toolbar.setObjectName(u'toolbar')
+ self.toolbar.addToolbarAction(u'newTheme',
+ text=UiStrings().NewTheme, icon=u':/themes/theme_new.png',
+ tooltip=translate('OpenLP.ThemeManager', 'Create a new theme.'),
+ triggers=self.onAddTheme)
+ self.toolbar.addToolbarAction(u'editTheme',
+ text=translate('OpenLP.ThemeManager', 'Edit Theme'),
+ icon=u':/themes/theme_edit.png',
+ tooltip=translate('OpenLP.ThemeManager', 'Edit a theme.'),
+ triggers=self.onEditTheme)
+ self.deleteToolbarAction = self.toolbar.addToolbarAction(u'deleteTheme',
+ text=translate('OpenLP.ThemeManager', 'Delete Theme'),
+ icon=u':/general/general_delete.png',
+ tooltip=translate('OpenLP.ThemeManager', 'Delete a theme.'),
+ triggers=self.onDeleteTheme)
self.toolbar.addSeparator()
- self.toolbar.addToolbarButton(
- translate('OpenLP.ThemeManager', 'Import Theme'),
- u':/general/general_import.png',
- translate('OpenLP.ThemeManager', 'Import a theme.'),
- self.onImportTheme)
- self.toolbar.addToolbarButton(
- translate('OpenLP.ThemeManager', 'Export Theme'),
- u':/general/general_export.png',
- translate('OpenLP.ThemeManager', 'Export a theme.'),
- self.onExportTheme)
- self.toolbar.setObjectName(u'toolbar')
+ self.toolbar.addToolbarAction(u'importTheme',
+ text=translate('OpenLP.ThemeManager', 'Import Theme'),
+ icon=u':/general/general_import.png',
+ tooltip=translate('OpenLP.ThemeManager', 'Import a theme.'),
+ triggers=self.onImportTheme)
+ self.toolbar.addToolbarAction(u'exportTheme',
+ text=translate('OpenLP.ThemeManager', 'Export Theme'),
+ icon=u':/general/general_export.png',
+ tooltip=translate('OpenLP.ThemeManager', 'Export a theme.'),
+ triggers=self.onExportTheme)
self.layout.addWidget(self.toolbar)
self.themeWidget = QtGui.QWidgetAction(self.toolbar)
self.themeWidget.setObjectName(u'themeWidget')
@@ -105,29 +105,26 @@
self.contextMenu)
# build the context menu
self.menu = QtGui.QMenu()
- self.editAction = context_menu_action(
- self.menu, u':/themes/theme_edit.png',
- translate('OpenLP.ThemeManager', '&Edit Theme'), self.onEditTheme)
- self.copyAction = context_menu_action(
- self.menu, u':/themes/theme_edit.png',
- translate('OpenLP.ThemeManager', '&Copy Theme'), self.onCopyTheme)
- self.renameAction = context_menu_action(
- self.menu, u':/themes/theme_edit.png',
- translate('OpenLP.ThemeManager', '&Rename Theme'),
- self.onRenameTheme)
- self.deleteAction = context_menu_action(
- self.menu, u':/general/general_delete.png',
- translate('OpenLP.ThemeManager', '&Delete Theme'),
- self.onDeleteTheme)
- context_menu_separator(self.menu)
- self.globalAction = context_menu_action(
- self.menu, u':/general/general_export.png',
- translate('OpenLP.ThemeManager', 'Set As &Global Default'),
- self.changeGlobalFromScreen)
- self.exportAction = context_menu_action(
- self.menu, u':/general/general_export.png',
- translate('OpenLP.ThemeManager', '&Export Theme'),
- self.onExportTheme)
+ self.editAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ThemeManager', '&Edit Theme'),
+ icon=u':/themes/theme_edit.png', triggers=self.onEditTheme)
+ self.copyAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ThemeManager', '&Copy Theme'),
+ icon=u':/themes/theme_edit.png', triggers=self.onCopyTheme)
+ self.renameAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ThemeManager', '&Rename Theme'),
+ icon=u':/themes/theme_edit.png', triggers=self.onRenameTheme)
+ self.deleteAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ThemeManager', '&Delete Theme'),
+ icon=u':/general/general_delete.png', triggers=self.onDeleteTheme)
+ self.menu.addSeparator()
+ self.globalAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ThemeManager', 'Set As &Global Default'),
+ icon=u':/general/general_export.png',
+ triggers=self.changeGlobalFromScreen)
+ self.exportAction = create_widget_action(self.menu,
+ text=translate('OpenLP.ThemeManager', '&Export Theme'),
+ icon=u':/general/general_export.png', triggers=self.onExportTheme)
# Signals
QtCore.QObject.connect(self.themeListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
@@ -544,7 +541,7 @@
log.exception(u'Theme file contains non utf-8 filename'
u' "%s"' % name.decode(u'utf-8', u'replace'))
raise Exception(u'validation')
- uname = unicode(QtCore.QDir.toNativeSeparators(uname))
+ uname = uname.replace(u'/', os.path.sep)
splitname = uname.split(os.path.sep)
if splitname[-1] == u'' or len(splitname) == 1:
# is directory or preview file
=== modified file 'openlp/core/ui/themestab.py'
--- openlp/core/ui/themestab.py 2011-12-27 10:33:55 +0000
+++ openlp/core/ui/themestab.py 2012-03-06 19:17:18 +0000
@@ -39,7 +39,7 @@
self.mainwindow = mainwindow
generalTranslated = translate('OpenLP.ThemesTab', 'Themes')
SettingsTab.__init__(self, parent, u'Themes', generalTranslated)
- self.icon_path = u':/themes/theme_new.png'
+ self.icon_path = u':/themes/theme_new.png'
def setupUi(self):
self.setObjectName(u'ThemesTab')
=== modified file 'openlp/core/utils/actions.py'
--- openlp/core/utils/actions.py 2011-12-31 17:36:58 +0000
+++ openlp/core/utils/actions.py 2012-03-06 19:17:18 +0000
@@ -281,7 +281,7 @@
return
self.categories[category].actions.remove(action)
# Remove empty categories.
- if len(self.categories[category].actions) == 0:
+ if not self.categories[category].actions:
self.categories.remove(category)
shortcuts = map(unicode,
map(QtGui.QKeySequence.toString, action.shortcuts()))
@@ -354,18 +354,31 @@
``action``
The action which wants to use a particular shortcut.
"""
+ local = action.shortcutContext() in \
+ [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]
+ affected_actions = filter(lambda a: isinstance(a, QtGui.QAction),
+ self.getAllChildObjects(action.parent())) if local else []
for existing_action in existing_actions:
if action is existing_action:
continue
- if existing_action.parent() is action.parent():
- return False
- if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut,
- QtCore.Qt.ApplicationShortcut]:
- return False
- if action.shortcutContext() in [QtCore.Qt.WindowShortcut,
- QtCore.Qt.ApplicationShortcut]:
+ if not local or existing_action in affected_actions:
+ return False
+ if existing_action.shortcutContext() \
+ in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]:
+ return False
+ elif action in self.getAllChildObjects(existing_action.parent()):
return False
return True
+
+ def getAllChildObjects(self, qobject):
+ """
+ Goes recursively through the children of ``qobject`` and returns a list
+ of all child objects.
+ """
+ children = [child for child in qobject.children()]
+ for child in qobject.children():
+ children.append(self.getAllChildObjects(child))
+ return children
class CategoryOrder(object):
=== modified file 'openlp/plugins/alerts/alertsplugin.py'
--- openlp/plugins/alerts/alertsplugin.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/alerts/alertsplugin.py 2012-03-06 19:17:18 +0000
@@ -31,7 +31,7 @@
from openlp.core.lib import Plugin, StringContent, build_icon, translate
from openlp.core.lib.db import Manager
-from openlp.core.lib.ui import icon_action, UiStrings
+from openlp.core.lib.ui import create_action, UiStrings
from openlp.core.lib.theme import VerticalType
from openlp.core.utils.actions import ActionList
from openlp.plugins.alerts.lib import AlertsManager, AlertsTab
@@ -133,16 +133,12 @@
use it as their parent.
"""
log.info(u'add tools menu')
- self.toolsAlertItem = icon_action(tools_menu, u'toolsAlertItem',
- u':/plugins/plugin_alerts.png')
- self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert'))
- self.toolsAlertItem.setStatusTip(
- translate('AlertsPlugin', 'Show an alert message.'))
- self.toolsAlertItem.setShortcut(u'F7')
+ self.toolsAlertItem = create_action(tools_menu, u'toolsAlertItem',
+ text=translate('AlertsPlugin', '&Alert'),
+ icon=u':/plugins/plugin_alerts.png',
+ statustip=translate('AlertsPlugin', 'Show an alert message.'),
+ visible=False, shortcuts=[u'F7'], triggers=self.onAlertsTrigger)
self.serviceManager.mainwindow.toolsMenu.addAction(self.toolsAlertItem)
- QtCore.QObject.connect(self.toolsAlertItem,
- QtCore.SIGNAL(u'triggered()'), self.onAlertsTrigger)
- self.toolsAlertItem.setVisible(False)
def initialise(self):
log.info(u'Alerts Initialising')
=== modified file 'openlp/plugins/bibles/bibleplugin.py'
--- openlp/plugins/bibles/bibleplugin.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/bibles/bibleplugin.py 2012-03-06 19:17:18 +0000
@@ -30,7 +30,7 @@
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, build_icon, translate
-from openlp.core.lib.ui import base_action, UiStrings
+from openlp.core.lib.ui import create_action, UiStrings
from openlp.core.utils.actions import ActionList
from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
from openlp.plugins.bibles.forms import BibleUpgradeForm
@@ -93,19 +93,16 @@
self.onToolsUpgradeItemTriggered()
def addImportMenuItem(self, import_menu):
- self.importBibleItem = base_action(import_menu, u'importBibleItem')
- self.importBibleItem.setText(translate('BiblesPlugin', '&Bible'))
+ self.importBibleItem = create_action(import_menu, u'importBibleItem',
+ text=translate('BiblesPlugin', '&Bible'), visible=False,
+ triggers=self.onBibleImportClick)
import_menu.addAction(self.importBibleItem)
- # signals and slots
- QtCore.QObject.connect(self.importBibleItem,
- QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick)
- self.importBibleItem.setVisible(False)
def addExportMenuItem(self, export_menu):
- self.exportBibleItem = base_action(export_menu, u'exportBibleItem')
- self.exportBibleItem.setText(translate('BiblesPlugin', '&Bible'))
+ self.exportBibleItem = create_action(export_menu, u'exportBibleItem',
+ text=translate('BiblesPlugin', '&Bible'),
+ visible=False)
export_menu.addAction(self.exportBibleItem)
- self.exportBibleItem.setVisible(False)
def addToolsMenuItem(self, tools_menu):
"""
@@ -117,17 +114,12 @@
use it as their parent.
"""
log.debug(u'add tools menu')
- self.toolsUpgradeItem = QtGui.QAction(tools_menu)
- self.toolsUpgradeItem.setObjectName(u'toolsUpgradeItem')
- self.toolsUpgradeItem.setText(
- translate('BiblesPlugin', '&Upgrade older Bibles'))
- self.toolsUpgradeItem.setStatusTip(
- translate('BiblesPlugin', 'Upgrade the Bible databases to the '
- 'latest format.'))
+ self.toolsUpgradeItem = create_action(tools_menu, u'toolsUpgradeItem',
+ text=translate('BiblesPlugin', '&Upgrade older Bibles'),
+ statustip=translate('BiblesPlugin',
+ 'Upgrade the Bible databases to the latest format.'),
+ visible=False, triggers=self.onToolsUpgradeItemTriggered)
tools_menu.addAction(self.toolsUpgradeItem)
- QtCore.QObject.connect(self.toolsUpgradeItem,
- QtCore.SIGNAL(u'triggered()'), self.onToolsUpgradeItemTriggered)
- self.toolsUpgradeItem.setVisible(False)
def onToolsUpgradeItemTriggered(self):
"""
=== modified file 'openlp/plugins/bibles/lib/__init__.py'
--- openlp/plugins/bibles/lib/__init__.py 2012-02-05 19:20:01 +0000
+++ openlp/plugins/bibles/lib/__init__.py 2012-03-06 19:17:18 +0000
@@ -89,7 +89,7 @@
while u'||' in source_string:
source_string = source_string.replace(u'||', u'|')
if role != u'e':
- REFERENCE_SEPARATORS[u'sep_%s_display' % role] = \
+ REFERENCE_SEPARATORS[u'sep_%s_display' % role] = \
source_string.split(u'|')[0]
# escape reserved characters
for character in u'\\.^$*+?{}[]()':
=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
--- openlp/plugins/custom/lib/mediaitem.py 2012-01-18 13:50:06 +0000
+++ openlp/plugins/custom/lib/mediaitem.py 2012-03-06 19:17:18 +0000
@@ -68,7 +68,7 @@
self.manager = plugin.manager
def addEndHeaderBar(self):
- self.addToolbarSeparator()
+ self.toolbar.addSeparator()
self.addSearchToToolBar()
# Signals and slots
QtCore.QObject.connect(self.searchTextEdit,
=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py 2012-01-18 13:50:06 +0000
+++ openlp/plugins/images/lib/mediaitem.py 2012-03-06 19:17:18 +0000
@@ -89,11 +89,11 @@
self.listView.addAction(self.replaceAction)
def addEndHeaderBar(self):
- self.replaceAction = self.addToolbarButton(u'', u'',
- u':/slides/slide_blank.png', self.onReplaceClick, False)
- self.resetAction = self.addToolbarButton(u'', u'',
- u':/system/system_close.png', self.onResetClick, False)
- self.resetAction.setVisible(False)
+ self.replaceAction = self.toolbar.addToolbarAction(u'replaceAction',
+ icon=u':/slides/slide_blank.png', triggers=self.onReplaceClick)
+ self.resetAction = self.toolbar.addToolbarAction(u'resetAction',
+ icon=u':/system/system_close.png', visible=False,
+ triggers=self.onResetClick)
def onDeleteClick(self):
"""
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py 2012-01-18 13:50:06 +0000
+++ openlp/plugins/media/lib/mediaitem.py 2012-03-06 19:17:18 +0000
@@ -118,11 +118,11 @@
def addEndHeaderBar(self):
# Replace backgrounds do not work at present so remove functionality.
- self.replaceAction = self.addToolbarButton(u'', u'',
- u':/slides/slide_blank.png', self.onReplaceClick, False)
- self.resetAction = self.addToolbarButton(u'', u'',
- u':/system/system_close.png', self.onResetClick, False)
- self.resetAction.setVisible(False)
+ self.replaceAction = self.toolbar.addToolbarAction(u'replaceAction',
+ icon=u':/slides/slide_blank.png', triggers=self.onReplaceClick)
+ self.resetAction = self.toolbar.addToolbarAction(u'resetAction',
+ icon=u':/system/system_close.png', visible=False,
+ triggers=self.onResetClick)
self.mediaWidget = QtGui.QWidget(self)
self.mediaWidget.setObjectName(u'mediaWidget')
self.displayLayout = QtGui.QFormLayout(self.mediaWidget)
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2012-02-26 21:27:05 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2012-03-06 19:17:18 +0000
@@ -36,8 +36,7 @@
from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
translate, check_item_selected, PluginStatus, create_separated_list
-from openlp.core.lib.ui import UiStrings, context_menu_action, \
- context_menu_separator
+from openlp.core.lib.ui import UiStrings, create_action, create_widget_action
from openlp.core.utils import AppLocation
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \
SongImportForm, SongExportForm
@@ -99,10 +98,11 @@
self.plugin.manager.save_object(song, True)
def addEndHeaderBar(self):
- self.addToolbarSeparator()
+ self.toolbar.addSeparator()
## Song Maintenance Button ##
- self.maintenanceAction = self.addToolbarButton(u'', u'',
- ':/songs/song_maintenance.png', self.onSongMaintenanceClick)
+ self.maintenanceAction = self.toolbar.addToolbarAction(
+ u'maintenanceAction', icon=':/songs/song_maintenance.png',
+ triggers=self.onSongMaintenanceClick)
self.addSearchToToolBar()
# Signals and slots
QtCore.QObject.connect(Receiver.get_receiver(),
@@ -122,11 +122,10 @@
self.onSearchTextButtonClick)
def addCustomContextActions(self):
- context_menu_separator(self.listView)
- context_menu_action(
- self.listView, u':/general/general_clone.png',
- translate('OpenLP.MediaManagerItem',
- '&Clone'), self.onCloneClick)
+ create_widget_action(self.listView, separator=True)
+ create_widget_action(self.listView,
+ text=translate('OpenLP.MediaManagerItem', '&Clone'),
+ icon=u':/general/general_clone.png', triggers=self.onCloneClick)
def onFocus(self):
self.searchTextEdit.setFocus()
=== modified file 'openlp/plugins/songs/lib/opensongimport.py'
--- openlp/plugins/songs/lib/opensongimport.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/songs/lib/opensongimport.py 2012-03-06 19:17:18 +0000
@@ -238,7 +238,7 @@
verse_tag = match.group(1)
verse_num = match.group(2)
if not len(verse_tag):
- verse_tag = VerseType.Tags[VerseType.Verse]
+ verse_tag = VerseType.Tags[VerseType.Verse]
else:
# Assume it's no.1 if there are no digits
verse_tag = verse_def
=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/songs/songsplugin.py 2012-03-06 19:17:18 +0000
@@ -34,7 +34,7 @@
from openlp.core.lib import Plugin, StringContent, build_icon, translate, \
Receiver
from openlp.core.lib.db import Manager
-from openlp.core.lib.ui import UiStrings, base_action, icon_action
+from openlp.core.lib.ui import UiStrings, create_action
from openlp.core.utils.actions import ActionList
from openlp.plugins.songs.lib import clean_song, upgrade, SongMediaItem, \
SongsTab
@@ -93,14 +93,12 @@
use it as their parent.
"""
# Main song import menu item - will eventually be the only one
- self.songImportItem = base_action(import_menu, u'songImportItem')
- self.songImportItem.setText(translate('SongsPlugin', '&Song'))
- self.songImportItem.setToolTip(translate('SongsPlugin',
- 'Import songs using the import wizard.'))
+ self.songImportItem = create_action(import_menu, u'songImportItem',
+ text=translate('SongsPlugin', '&Song'),
+ tooltip=translate('SongsPlugin',
+ 'Import songs using the import wizard.'),
+ triggers=self.onSongImportItemClicked)
import_menu.addAction(self.songImportItem)
- # Signals and slots
- QtCore.QObject.connect(self.songImportItem,
- QtCore.SIGNAL(u'triggered()'), self.onSongImportItemClicked)
def addExportMenuItem(self, export_menu):
"""
@@ -112,14 +110,12 @@
use it as their parent.
"""
# Main song import menu item - will eventually be the only one
- self.songExportItem = base_action(export_menu, u'songExportItem')
- self.songExportItem.setText(translate('SongsPlugin', '&Song'))
- self.songExportItem.setToolTip(translate('SongsPlugin',
- 'Exports songs using the export wizard.'))
+ self.songExportItem = create_action(export_menu, u'songExportItem',
+ text=translate('SongsPlugin', '&Song'),
+ tooltip=translate('SongsPlugin',
+ 'Exports songs using the export wizard.'),
+ triggers=self.onSongExportItemClicked)
export_menu.addAction(self.songExportItem)
- # Signals and slots
- QtCore.QObject.connect(self.songExportItem,
- QtCore.SIGNAL(u'triggered()'), self.onSongExportItemClicked)
def addToolsMenuItem(self, tools_menu):
"""
@@ -131,17 +127,13 @@
use it as their parent.
"""
log.info(u'add tools menu')
- self.toolsReindexItem = icon_action(tools_menu, u'toolsReindexItem',
- u':/plugins/plugin_songs.png')
- self.toolsReindexItem.setText(
- translate('SongsPlugin', '&Re-index Songs'))
- self.toolsReindexItem.setStatusTip(
- translate('SongsPlugin', 'Re-index the songs database to improve '
- 'searching and ordering.'))
+ self.toolsReindexItem = create_action(tools_menu, u'toolsReindexItem',
+ text=translate('SongsPlugin', '&Re-index Songs'),
+ icon=u':/plugins/plugin_songs.png',
+ statustip=translate('SongsPlugin',
+ 'Re-index the songs database to improve searching and ordering.'),
+ visible=False, triggers=self.onToolsReindexItemTriggered)
tools_menu.addAction(self.toolsReindexItem)
- QtCore.QObject.connect(self.toolsReindexItem,
- QtCore.SIGNAL(u'triggered()'), self.onToolsReindexItemTriggered)
- self.toolsReindexItem.setVisible(False)
def onToolsReindexItemTriggered(self):
"""
=== modified file 'openlp/plugins/songusage/songusageplugin.py'
--- openlp/plugins/songusage/songusageplugin.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/songusage/songusageplugin.py 2012-03-06 19:17:18 +0000
@@ -33,7 +33,7 @@
from openlp.core.lib import Plugin, StringContent, Receiver, build_icon, \
translate
from openlp.core.lib.db import Manager
-from openlp.core.lib.ui import base_action, shortcut_action
+from openlp.core.lib.ui import create_action
from openlp.core.utils.actions import ActionList
from openlp.plugins.songusage.forms import SongUsageDetailForm, \
SongUsageDeleteForm
@@ -73,24 +73,24 @@
self.songUsageMenu.setTitle(translate(
'SongUsagePlugin', '&Song Usage Tracking'))
# SongUsage Delete
- self.songUsageDelete = base_action(tools_menu, u'songUsageDelete')
- self.songUsageDelete.setText(translate('SongUsagePlugin',
- '&Delete Tracking Data'))
- self.songUsageDelete.setStatusTip(translate('SongUsagePlugin',
- 'Delete song usage data up to a specified date.'))
+ self.songUsageDelete = create_action(tools_menu, u'songUsageDelete',
+ text=translate('SongUsagePlugin', '&Delete Tracking Data'),
+ statustip=translate('SongUsagePlugin',
+ 'Delete song usage data up to a specified date.'),
+ triggers=self.onSongUsageDelete)
# SongUsage Report
- self.songUsageReport = base_action(tools_menu, u'songUsageReport')
- self.songUsageReport.setText(
- translate('SongUsagePlugin', '&Extract Tracking Data'))
- self.songUsageReport.setStatusTip(
- translate('SongUsagePlugin', 'Generate a report on song usage.'))
+ self.songUsageReport = create_action(tools_menu, u'songUsageReport',
+ text=translate('SongUsagePlugin', '&Extract Tracking Data'),
+ statustip=translate('SongUsagePlugin',
+ 'Generate a report on song usage.'),
+ triggers=self.onSongUsageReport)
# SongUsage activation
- self.songUsageStatus = shortcut_action(tools_menu, u'songUsageStatus',
- [QtCore.Qt.Key_F4], self.toggleSongUsageState, checked=False)
- self.songUsageStatus.setText(translate(
- 'SongUsagePlugin', 'Toggle Tracking'))
- self.songUsageStatus.setStatusTip(translate('SongUsagePlugin',
- 'Toggle the tracking of song usage.'))
+ self.songUsageStatus = create_action(tools_menu, u'songUsageStatus',
+ text=translate('SongUsagePlugin', 'Toggle Tracking'),
+ statustip=translate('SongUsagePlugin',
+ 'Toggle the tracking of song usage.'), checked=False,
+ shortcuts=[QtCore.Qt.Key_F4],
+ triggers=self.toggleSongUsageState)
# Add Menus together
self.toolsMenu.addAction(self.songUsageMenu.menuAction())
self.songUsageMenu.addAction(self.songUsageStatus)
@@ -114,10 +114,6 @@
QtCore.QObject.connect(self.songUsageActiveButton,
QtCore.SIGNAL(u'toggled(bool)'),
self.toggleSongUsageState)
- QtCore.QObject.connect(self.songUsageDelete,
- QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete)
- QtCore.QObject.connect(self.songUsageReport,
- QtCore.SIGNAL(u'triggered()'), self.onSongUsageReport)
self.songUsageMenu.menuAction().setVisible(False)
def initialise(self):
Follow ups