From 19138cd9e5b42652473e331cd866252cd3e4150b Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 29 Mar 2011 15:56:49 +0200 Subject: [PATCH 01/76] started reworking shortcuts --- openlp/core/lib/ui.py | 2 + openlp/core/ui/mainwindow.py | 63 ++++++++---------- openlp/core/ui/servicemanager.py | 2 +- openlp/core/ui/shortcutlistform.py | 95 +++++++++++++++++++-------- openlp/core/ui/slidecontroller.py | 3 +- openlp/core/utils/actions.py | 11 ++++ openlp/plugins/alerts/alertsplugin.py | 8 ++- 7 files changed, 116 insertions(+), 68 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index c1a9f8b35..6aa06bfcc 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -31,6 +31,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, Receiver, translate +from openlp.core.utils.actions import actionList log = logging.getLogger(__name__) @@ -265,6 +266,7 @@ def icon_action(parent, name, icon, checked=None): else: action = base_action(parent, name) action.setIcon(build_icon(icon)) + #actionList.add_action(action, name) return action def shortcut_action(parent, text, shortcuts, function): diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 594c6cc91..98144bfa3 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -38,7 +38,8 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ThemeManager, SlideController, PluginForm, MediaDockManager, \ ShortcutListForm, DisplayTagForm from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ - ActionList, get_application_version + get_application_version +from openlp.core.utils.actions import actionList log = logging.getLogger(__name__) @@ -163,53 +164,52 @@ class Ui_MainWindow(object): # Create the menu items self.FileNewItem = icon_action(mainWindow, u'FileNewItem', u':/general/general_new.png') - mainWindow.actionList.add_action(self.FileNewItem, u'File') + actionList.add_action(self.FileNewItem, u'File') self.FileOpenItem = icon_action(mainWindow, u'FileOpenItem', u':/general/general_open.png') - mainWindow.actionList.add_action(self.FileOpenItem, u'File') + actionList.add_action(self.FileOpenItem, u'File') self.FileSaveItem = icon_action(mainWindow, u'FileSaveItem', u':/general/general_save.png') - mainWindow.actionList.add_action(self.FileSaveItem, u'File') + actionList.add_action(self.FileSaveItem, u'File') self.FileSaveAsItem = base_action(mainWindow, u'FileSaveAsItem') - mainWindow.actionList.add_action(self.FileSaveAsItem, u'File') + actionList.add_action(self.FileSaveAsItem, u'File') self.printServiceOrderItem = base_action( mainWindow, u'printServiceItem') - mainWindow.actionList.add_action( - self.printServiceOrderItem, u'Print Service Order') + actionList.add_action(self.printServiceOrderItem, u'File') self.FileExitItem = icon_action(mainWindow, u'FileExitItem', u':/system/system_exit.png') - mainWindow.actionList.add_action(self.FileExitItem, u'File') + actionList.add_action(self.FileExitItem, u'File') self.ImportThemeItem = base_action(mainWindow, u'ImportThemeItem') - mainWindow.actionList.add_action(self.ImportThemeItem, u'Import') + actionList.add_action(self.ImportThemeItem, u'Import') self.ImportLanguageItem = base_action(mainWindow, u'ImportLanguageItem') - mainWindow.actionList.add_action(self.ImportLanguageItem, u'Import') + actionList.add_action(self.ImportLanguageItem, u'Import') self.ExportThemeItem = base_action(mainWindow, u'ExportThemeItem') - mainWindow.actionList.add_action(self.ExportThemeItem, u'Export') + actionList.add_action(self.ExportThemeItem, u'Export') self.ExportLanguageItem = base_action(mainWindow, u'ExportLanguageItem') - mainWindow.actionList.add_action(self.ExportLanguageItem, u'Export') + actionList.add_action(self.ExportLanguageItem, u'Export') self.ViewMediaManagerItem = icon_action(mainWindow, u'ViewMediaManagerItem', u':/system/system_mediamanager.png', self.mediaManagerDock.isVisible()) self.ViewThemeManagerItem = icon_action(mainWindow, u'ViewThemeManagerItem', u':/system/system_thememanager.png', self.themeManagerDock.isVisible()) - mainWindow.actionList.add_action(self.ViewMediaManagerItem, u'View') + actionList.add_action(self.ViewMediaManagerItem, u'View') self.ViewServiceManagerItem = icon_action(mainWindow, u'ViewServiceManagerItem', u':/system/system_servicemanager.png', self.serviceManagerDock.isVisible()) - mainWindow.actionList.add_action(self.ViewServiceManagerItem, u'View') + actionList.add_action(self.ViewServiceManagerItem, u'View') self.ViewPreviewPanel = checkable_action(mainWindow, u'ViewPreviewPanel', previewVisible) - mainWindow.actionList.add_action(self.ViewPreviewPanel, u'View') + actionList.add_action(self.ViewPreviewPanel, u'View') self.ViewLivePanel = checkable_action(mainWindow, u'ViewLivePanel', liveVisible) - mainWindow.actionList.add_action(self.ViewLivePanel, u'View') + actionList.add_action(self.ViewLivePanel, u'View') self.ModeDefaultItem = checkable_action(mainWindow, u'ModeDefaultItem') - mainWindow.actionList.add_action(self.ModeDefaultItem, u'View Mode') + actionList.add_action(self.ModeDefaultItem, u'View Mode') self.ModeSetupItem = checkable_action(mainWindow, u'ModeLiveItem') - mainWindow.actionList.add_action(self.ModeSetupItem, u'View Mode') + actionList.add_action(self.ModeSetupItem, u'View Mode') self.ModeLiveItem = checkable_action(mainWindow, u'ModeLiveItem', True) - mainWindow.actionList.add_action(self.ModeLiveItem, u'View Mode') + actionList.add_action(self.ModeLiveItem, u'View Mode') self.ModeGroup = QtGui.QActionGroup(mainWindow) self.ModeGroup.addAction(self.ModeDefaultItem) self.ModeGroup.addAction(self.ModeSetupItem) @@ -217,18 +217,18 @@ class Ui_MainWindow(object): self.ModeDefaultItem.setChecked(True) self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem', u':/tools/tools_add.png') - mainWindow.actionList.add_action(self.ToolsAddToolItem, u'Tools') + actionList.add_action(self.ToolsAddToolItem, u'Tools') self.ToolsOpenDataFolder = icon_action(mainWindow, u'ToolsOpenDataFolder', u':/general/general_open.png') - mainWindow.actionList.add_action(self.ToolsOpenDataFolder, u'Tools') + actionList.add_action(self.ToolsOpenDataFolder, u'Tools') self.settingsPluginListItem = icon_action(mainWindow, u'settingsPluginListItem', u':/system/settings_plugin_list.png') - mainWindow.actionList.add_action(self.settingsPluginListItem, + actionList.add_action(self.settingsPluginListItem, u'Settings') # i18n Language Items self.AutoLanguageItem = checkable_action(mainWindow, u'AutoLanguageItem', LanguageManager.auto_language) - mainWindow.actionList.add_action(self.AutoLanguageItem, u'Settings') + actionList.add_action(self.AutoLanguageItem, u'Settings') self.LanguageGroup = QtGui.QActionGroup(mainWindow) self.LanguageGroup.setExclusive(True) self.LanguageGroup.setObjectName(u'LanguageGroup') @@ -246,19 +246,19 @@ class Ui_MainWindow(object): u'DisplayTagItem', u':/system/tag_editor.png') self.SettingsConfigureItem = icon_action(mainWindow, u'SettingsConfigureItem', u':/system/system_settings.png') - mainWindow.actionList.add_action(self.SettingsShortcutsItem, + actionList.add_action(self.SettingsShortcutsItem, u'Settings') self.HelpDocumentationItem = icon_action(mainWindow, u'HelpDocumentationItem', u':/system/system_help_contents.png') self.HelpDocumentationItem.setEnabled(False) - mainWindow.actionList.add_action(self.HelpDocumentationItem, u'Help') + actionList.add_action(self.HelpDocumentationItem, u'Help') self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem', u':/system/system_about.png') - mainWindow.actionList.add_action(self.HelpAboutItem, u'Help') + actionList.add_action(self.HelpAboutItem, u'Help') self.HelpOnlineHelpItem = base_action(mainWindow, u'HelpOnlineHelpItem') - mainWindow.actionList.add_action(self.HelpOnlineHelpItem, u'Help') + actionList.add_action(self.HelpOnlineHelpItem, u'Help') self.helpWebSiteItem = base_action(mainWindow, u'helpWebSiteItem') - mainWindow.actionList.add_action(self.helpWebSiteItem, u'Help') + actionList.add_action(self.helpWebSiteItem, u'Help') add_actions(self.FileImportMenu, (self.ImportThemeItem, self.ImportLanguageItem)) add_actions(self.FileExportMenu, @@ -301,7 +301,6 @@ class Ui_MainWindow(object): self.ToolsAddToolItem.setVisible(False) self.ImportLanguageItem.setVisible(False) self.ExportLanguageItem.setVisible(False) - self.SettingsShortcutsItem.setVisible(False) self.HelpDocumentationItem.setVisible(False) def retranslateUi(self, mainWindow): @@ -467,8 +466,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ log.info(u'MainWindow loaded') - actionList = ActionList() - def __init__(self, screens, application): """ This constructor sets up the interface, the various managers, and the @@ -476,7 +473,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ QtGui.QMainWindow.__init__(self) self.screens = screens - self.application = application # Set up settings sections for the main application # (not for use by plugins) @@ -485,7 +481,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.serviceSettingsSection = u'servicemanager' self.songsSettingsSection = u'songs' self.serviceNotSaved = False - self.actionList = ActionList() self.settingsmanager = SettingsManager(screens) self.aboutForm = AboutForm(self) self.settingsForm = SettingsForm(self.screens, self, self) @@ -777,7 +772,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Show the shortcuts dialog """ - self.shortcutForm.exec_(self.actionList) + self.shortcutForm.exec_() def onModeDefaultItemClicked(self): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 168ad8a8c..1d5321e01 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -40,6 +40,7 @@ from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ split_filename +from openlp.core.utils.actions import actionList class ServiceManagerList(QtGui.QTreeWidget): """ @@ -315,7 +316,6 @@ class ServiceManager(QtGui.QWidget): self.configUpdated() def setServiceHotkeys(self): - actionList = self.mainwindow.actionList actionList.add_action(self.serviceManagerList.moveDown, u'Service') actionList.add_action(self.serviceManagerList.moveUp, u'Service') actionList.add_action(self.serviceManagerList.moveTop, u'Service') diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index e87ba3ada..a61dd41ed 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -30,6 +30,7 @@ import re from PyQt4 import QtCore, QtGui from openlp.core.utils import translate +from openlp.core.utils.actions import actionList from shortcutlistdialog import Ui_ShortcutListDialog REMOVE_AMPERSAND = re.compile(r'&{1}') @@ -40,21 +41,24 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ The shortcut list dialog """ - - def __init__(self, parent): - """ - Do some initialisation stuff - """ +#TODO: do not close on ESC +#TODO: ability to remove actions +#TODO: Save shortcuts +#TODO: doc + def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) - self.actionList = None - self.captureShortcut = False + self.assingedShortcuts = [] + self.shortcutButton.setText(u'') QtCore.QObject.connect(self.shortcutButton, QtCore.SIGNAL(u'toggled(bool)'), self.onShortcutButtonClicked) + QtCore.QObject.connect(self.treeWidget, + QtCore.SIGNAL(u'itemPressed(QTreeWidgetItem*, int)'), + self.onItemPressed) def keyReleaseEvent(self, event): Qt = QtCore.Qt - if not self.captureShortcut: + if not self.shortcutButton.isChecked(): return key = event.key() if key == Qt.Key_Shift or key == Qt.Key_Control or \ @@ -68,45 +72,80 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier: key_string = u'Shift+' + key_string key_sequence = QtGui.QKeySequence(key_string) - existing_key = QtGui.QKeySequence(u'Ctrl+Shift+F8') - if key_sequence == existing_key: - QtGui.QMessageBox.warning( - self, + if key_sequence in self.assingedShortcuts: + QtGui.QMessageBox.warning(self, translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'), unicode(translate('OpenLP.ShortcutListDialog', 'The shortcut ' - '"%s" is already assigned to another action, please ' - 'use a different shortcut.')) % key_sequence.toString(), + '"%s" is already assigned to another action, please ' + 'use a different shortcut.')) % key_sequence.toString(), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok), QtGui.QMessageBox.Ok ) else: self.shortcutButton.setText(key_sequence.toString()) - self.shortcutButton.setChecked(False) - self.captureShortcut = False + self.shortcutButton.setChecked(False) - def exec_(self, actionList): - self.actionList = actionList - self.refreshActions() + def exec_(self): + # The dialog is opened the first time + if self.treeWidget.topLevelItemCount() == 0: + QtCore.QObject.connect(actionList.signal, + QtCore.SIGNAL(u'addedAction()'), self.initialiseActionList) + self.initialiseActionList() + self.refreshActionList() return QtGui.QDialog.exec_(self) - def refreshActions(self): - self.treeWidget.clear() - for category in self.actionList.categories: - item = QtGui.QTreeWidgetItem([category.name]) - for action in category.actions: + def refreshActionList(self): + self.assingedShortcuts = [] + iterator = QtGui.QTreeWidgetItemIterator(self.treeWidget) + while iterator.value(): + treewidgetItem = iterator.value() + action = treewidgetItem.data(0, QtCore.Qt.UserRole).toPyObject() + if action is not None: actionText = REMOVE_AMPERSAND.sub('', unicode(action.text())) - if (len(action.shortcuts()) == 2): + if len(action.shortcuts()) == 2: shortcutText = action.shortcuts()[0].toString() alternateText = action.shortcuts()[1].toString() else: shortcutText = action.shortcut().toString() alternateText = u'' - actionItem = QtGui.QTreeWidgetItem( - [actionText, shortcutText, alternateText]) + self.assingedShortcuts.extend(action.shortcuts()) + treewidgetItem.setText(0, actionText) + treewidgetItem.setText(1, shortcutText) + treewidgetItem.setText(2, alternateText) + iterator += 1 + + def initialiseActionList(self): + for category in actionList.categories: + item = QtGui.QTreeWidgetItem([category.name]) + for action in category.actions: + actionItem = QtGui.QTreeWidgetItem() actionItem.setIcon(0, action.icon()) + actionItem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(action)) item.addChild(actionItem) item.setExpanded(True) self.treeWidget.addTopLevelItem(item) def onShortcutButtonClicked(self, toggled): - self.captureShortcut = toggled + if toggled: + return + item = self.treeWidget.currentItem() + action = item.data(0, QtCore.Qt.UserRole).toPyObject() + if action is None: + return + # TODO: Sort out which shortcuts should be kept. + action.setShortcuts(QtGui.QKeySequence(self.shortcutButton.text())) + self.refreshActionList() + + def onItemPressed(self, item, column): + item = self.treeWidget.currentItem() + action = item.data(0, QtCore.Qt.UserRole).toPyObject() + if action is None: + text = u'' + else: + if len(action.shortcuts()) == 0: + text = u'' + elif len(action.shortcuts()) == 2 and column == 2: + text = action.shortcuts()[1].toString() + else: + text = action.shortcuts()[0].toString() + self.shortcutButton.setText(text) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 232653326..1ae84e950 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -34,6 +34,7 @@ from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \ ItemCapabilities, translate from openlp.core.lib.ui import icon_action, UiStrings, shortcut_action from openlp.core.ui import HideMode, MainDisplay +from openlp.core.utils.actions import actionList log = logging.getLogger(__name__) @@ -362,14 +363,12 @@ class SlideController(QtGui.QWidget): QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged) def setPreviewHotkeys(self, parent=None): - actionList = self.parent.actionList self.previousItem.setShortcuts([QtCore.Qt.Key_Up, 0]) actionList.add_action(self.previousItem, u'Preview') self.nextItem.setShortcuts([QtCore.Qt.Key_Down, 0]) actionList.add_action(self.nextItem, u'Preview') def setLiveHotkeys(self, parent=None): - actionList = self.parent.actionList self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp]) self.previousItem.setShortcutContext( QtCore.Qt.WidgetWithChildrenShortcut) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 41ae41f4b..ba4a7b40d 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -27,6 +27,8 @@ The :mod:`~openlp.core.utils.actions` module provides action list classes used by the shortcuts system. """ +from PyQt4 import QtCore + class ActionCategory(object): """ The :class:`~openlp.core.utils.ActionCategory` class encapsulates a @@ -173,6 +175,7 @@ class ActionList(object): """ def __init__(self): self.categories = CategoryList() + self.signal = Emit() def add_action(self, action, category=u'Default', weight=None): if category not in self.categories: @@ -181,3 +184,11 @@ class ActionList(object): self.categories[category].actions.append(action) else: self.categories[category].actions.add(action, weight) + self.signal.emit(QtCore.SIGNAL(u'addedAction()')) + + +class Emit(QtCore.QObject): + def __init__(self): + QtCore.QObject.__init__(self) + +actionList = ActionList() diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index db0ba3b7e..2d22d2d5a 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -30,6 +30,8 @@ from PyQt4 import QtCore, QtGui 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 +from openlp.core.utils.actions import actionList from openlp.plugins.alerts.lib import AlertsManager, AlertsTab from openlp.plugins.alerts.lib.db import init_schema from openlp.plugins.alerts.forms import AlertForm @@ -58,9 +60,9 @@ class AlertsPlugin(Plugin): use it as their parent. """ log.info(u'add tools menu') - self.toolsAlertItem = QtGui.QAction(tools_menu) - self.toolsAlertItem.setIcon(build_icon(u':/plugins/plugin_alerts.png')) - self.toolsAlertItem.setObjectName(u'toolsAlertItem') + self.toolsAlertItem = icon_action(tools_menu, u'toolsAlertItem', + u':/plugins/plugin_alerts.png') + actionList.add_action(self.toolsAlertItem, u'Extra') self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert')) self.toolsAlertItem.setStatusTip( translate('AlertsPlugin', 'Show an alert message.')) From d9c2d92c8c4265975c7860bfc7fd5aba26c1bac1 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 29 Mar 2011 18:44:36 +0200 Subject: [PATCH 02/76] --- openlp/core/lib/ui.py | 24 +++--- openlp/core/ui/mainwindow.py | 104 +++++++++++--------------- openlp/core/ui/shortcutlistform.py | 15 +++- openlp/core/ui/slidecontroller.py | 23 +++--- openlp/core/utils/__init__.py | 6 +- openlp/core/utils/actions.py | 2 +- openlp/plugins/alerts/alertsplugin.py | 3 +- 7 files changed, 90 insertions(+), 87 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 6aa06bfcc..86def01d8 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -239,41 +239,47 @@ def create_up_down_push_button_set(parent): QtCore.SIGNAL(u'clicked()'), parent.onDownButtonClicked) return up_button, down_button -def base_action(parent, name): +def base_action(parent, name, category=None): """ Return the most basic action with the object name set. """ action = QtGui.QAction(parent) action.setObjectName(name) + if category is not None: + actionList.add_action(action, category) return action -def checkable_action(parent, name, checked=None): +def checkable_action(parent, name, checked=None, category=None): """ Return a standard action with the checkable attribute set. """ - action = base_action(parent, name) + 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): +def icon_action(parent, name, icon, checked=None, category=None): """ Return a standard action with an icon. + + ``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. """ if checked is not None: - action = checkable_action(parent, name, checked) + action = checkable_action(parent, name, checked, category) else: - action = base_action(parent, name) + action = base_action(parent, name, category) action.setIcon(build_icon(icon)) - #actionList.add_action(action, name) return action -def shortcut_action(parent, text, shortcuts, function): +def shortcut_action(parent, text, shortcuts, function, category=None): """ Return a shortcut enabled action. """ - action = QtGui.QAction(text, parent) + action = base_action(parent, text, category) action.setShortcuts(shortcuts) action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index ed06d3931..c37db0b97 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -39,7 +39,7 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ShortcutListForm, DisplayTagForm from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ get_application_version -from openlp.core.utils.actions import actionList +#from openlp.core.utils.actions import actionList log = logging.getLogger(__name__) @@ -163,72 +163,60 @@ class Ui_MainWindow(object): self.themeManagerDock) # Create the menu items self.FileNewItem = icon_action(mainWindow, u'FileNewItem', - u':/general/general_new.png') - actionList.add_action(self.FileNewItem, u'File') + u':/general/general_new.png', category=u'File') self.FileOpenItem = icon_action(mainWindow, u'FileOpenItem', - u':/general/general_open.png') - actionList.add_action(self.FileOpenItem, u'File') + u':/general/general_open.png', category=u'File') self.FileSaveItem = icon_action(mainWindow, u'FileSaveItem', - u':/general/general_save.png') - actionList.add_action(self.FileSaveItem, u'File') - self.FileSaveAsItem = base_action(mainWindow, u'FileSaveAsItem') - actionList.add_action(self.FileSaveAsItem, u'File') + u':/general/general_save.png', category=u'File') + self.FileSaveAsItem = base_action( + mainWindow, u'FileSaveAsItem', u'File') self.printServiceOrderItem = base_action( - mainWindow, u'printServiceItem') - actionList.add_action(self.printServiceOrderItem, u'File') + mainWindow, u'printServiceItem', u'File') self.FileExitItem = icon_action(mainWindow, u'FileExitItem', - u':/system/system_exit.png') - actionList.add_action(self.FileExitItem, u'File') - self.ImportThemeItem = base_action(mainWindow, u'ImportThemeItem') - actionList.add_action(self.ImportThemeItem, u'Import') - self.ImportLanguageItem = base_action(mainWindow, u'ImportLanguageItem') - actionList.add_action(self.ImportLanguageItem, u'Import') - self.ExportThemeItem = base_action(mainWindow, u'ExportThemeItem') - actionList.add_action(self.ExportThemeItem, u'Export') - self.ExportLanguageItem = base_action(mainWindow, u'ExportLanguageItem') - actionList.add_action(self.ExportLanguageItem, u'Export') + u':/system/system_exit.png', category=u'File') + self.ImportThemeItem = base_action( + mainWindow, u'ImportThemeItem', u'Import') + self.ImportLanguageItem = base_action( + mainWindow, u'ImportLanguageItem', u'Import') + self.ExportThemeItem = base_action( + mainWindow, u'ExportThemeItem', u'Export') + self.ExportLanguageItem = base_action( + mainWindow, u'ExportLanguageItem', u'Export') self.ViewMediaManagerItem = icon_action(mainWindow, u'ViewMediaManagerItem', u':/system/system_mediamanager.png', - self.mediaManagerDock.isVisible()) + self.mediaManagerDock.isVisible(), u'View') self.ViewThemeManagerItem = icon_action(mainWindow, u'ViewThemeManagerItem', u':/system/system_thememanager.png', - self.themeManagerDock.isVisible()) - actionList.add_action(self.ViewMediaManagerItem, u'View') + self.themeManagerDock.isVisible(), u'View') self.ViewServiceManagerItem = icon_action(mainWindow, u'ViewServiceManagerItem', u':/system/system_servicemanager.png', - self.serviceManagerDock.isVisible()) - actionList.add_action(self.ViewServiceManagerItem, u'View') + self.serviceManagerDock.isVisible(), u'View') self.ViewPreviewPanel = checkable_action(mainWindow, - u'ViewPreviewPanel', previewVisible) - actionList.add_action(self.ViewPreviewPanel, u'View') - self.ViewLivePanel = checkable_action(mainWindow, u'ViewLivePanel', - liveVisible) - actionList.add_action(self.ViewLivePanel, u'View') - self.ModeDefaultItem = checkable_action(mainWindow, u'ModeDefaultItem') - actionList.add_action(self.ModeDefaultItem, u'View Mode') - self.ModeSetupItem = checkable_action(mainWindow, u'ModeLiveItem') - actionList.add_action(self.ModeSetupItem, u'View Mode') - self.ModeLiveItem = checkable_action(mainWindow, u'ModeLiveItem', True) - actionList.add_action(self.ModeLiveItem, u'View Mode') + u'ViewPreviewPanel', previewVisible, u'View') + self.ViewLivePanel = checkable_action( + mainWindow, u'ViewLivePanel', liveVisible, u'View') + self.ModeDefaultItem = checkable_action( + mainWindow, u'ModeDefaultItem', category=u'View Mode') + self.ModeSetupItem = checkable_action( + mainWindow, u'ModeLiveItem', category=u'View Mode') + self.ModeLiveItem = checkable_action( + mainWindow, u'ModeLiveItem', True, u'View Mode') self.ModeGroup = QtGui.QActionGroup(mainWindow) self.ModeGroup.addAction(self.ModeDefaultItem) self.ModeGroup.addAction(self.ModeSetupItem) self.ModeGroup.addAction(self.ModeLiveItem) self.ModeDefaultItem.setChecked(True) self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem', - u':/tools/tools_add.png') - actionList.add_action(self.ToolsAddToolItem, u'Tools') - self.ToolsOpenDataFolder = icon_action(mainWindow, - u'ToolsOpenDataFolder', u':/general/general_open.png') - actionList.add_action(self.ToolsOpenDataFolder, u'Tools') + u':/tools/tools_add.png', category=u'Tools') + self.ToolsOpenDataFolder = icon_action(mainWindow, u'ToolsOpenDataFolder', + u':/general/general_open.png', category=u'Tools') self.settingsPluginListItem = icon_action(mainWindow, - u'settingsPluginListItem', u':/system/settings_plugin_list.png') - actionList.add_action(self.settingsPluginListItem, - u'Settings') + u'settingsPluginListItem', u':/system/settings_plugin_list.png', + category=u'Settings') # i18n Language Items self.AutoLanguageItem = checkable_action(mainWindow, u'AutoLanguageItem', LanguageManager.auto_language) - actionList.add_action(self.AutoLanguageItem, u'Settings') + #actionList.add_action(self.AutoLanguageItem, u'Settings') self.LanguageGroup = QtGui.QActionGroup(mainWindow) self.LanguageGroup.setExclusive(True) self.LanguageGroup.setObjectName(u'LanguageGroup') @@ -241,24 +229,22 @@ class Ui_MainWindow(object): add_actions(self.LanguageGroup, [languageItem]) self.SettingsShortcutsItem = icon_action(mainWindow, u'SettingsShortcutsItem', - u':/system/system_configure_shortcuts.png') + u':/system/system_configure_shortcuts.png', category=u'Settings') self.DisplayTagItem = icon_action(mainWindow, - u'DisplayTagItem', u':/system/tag_editor.png') + u'DisplayTagItem', u':/system/tag_editor.png', category=u'Settings') self.SettingsConfigureItem = icon_action(mainWindow, - u'SettingsConfigureItem', u':/system/system_settings.png') - actionList.add_action(self.SettingsShortcutsItem, - u'Settings') + u'SettingsConfigureItem', u':/system/system_settings.png', + category=u'Settings') self.HelpDocumentationItem = icon_action(mainWindow, - u'HelpDocumentationItem', u':/system/system_help_contents.png') + u'HelpDocumentationItem', u':/system/system_help_contents.png', + category=None)#u'Help') self.HelpDocumentationItem.setEnabled(False) - actionList.add_action(self.HelpDocumentationItem, u'Help') self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem', - u':/system/system_about.png') - actionList.add_action(self.HelpAboutItem, u'Help') - self.HelpOnlineHelpItem = base_action(mainWindow, u'HelpOnlineHelpItem') - actionList.add_action(self.HelpOnlineHelpItem, u'Help') - self.helpWebSiteItem = base_action(mainWindow, u'helpWebSiteItem') - actionList.add_action(self.helpWebSiteItem, u'Help') + u':/system/system_about.png', category=None)#u'Help') + self.HelpOnlineHelpItem = base_action( + mainWindow, u'HelpOnlineHelpItem', category=u'Help') + self.helpWebSiteItem = base_action( + mainWindow, u'helpWebSiteItem', category=u'Help') add_actions(self.FileImportMenu, (self.ImportThemeItem, self.ImportLanguageItem)) add_actions(self.FileExportMenu, diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index a61dd41ed..071482f95 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -45,6 +45,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): #TODO: ability to remove actions #TODO: Save shortcuts #TODO: doc +#TODO: Fix Preview/Live controller (have the same shortcut) def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) @@ -89,7 +90,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): # The dialog is opened the first time if self.treeWidget.topLevelItemCount() == 0: QtCore.QObject.connect(actionList.signal, - QtCore.SIGNAL(u'addedAction()'), self.initialiseActionList) + QtCore.SIGNAL(u'addedAction()'), self.asdf) self.initialiseActionList() self.refreshActionList() return QtGui.QDialog.exec_(self) @@ -125,6 +126,18 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): item.setExpanded(True) self.treeWidget.addTopLevelItem(item) + def asdf(self, action, category): + print action + for category in actionList.categories: + item = QtGui.QTreeWidgetItem([category.name]) + for action in category.actions: + actionItem = QtGui.QTreeWidgetItem() + actionItem.setIcon(0, action.icon()) + actionItem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(action)) + item.addChild(actionItem) + item.setExpanded(True) + self.treeWidget.addTopLevelItem(item) + def onShortcutButtonClicked(self, toggled): if toggled: return diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 1ae84e950..cafbec198 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -156,15 +156,15 @@ class SlideController(QtGui.QWidget): self.hideMenu.setMenu(QtGui.QMenu( translate('OpenLP.SlideController', 'Hide'), self.toolbar)) self.blankScreen = icon_action(self.hideMenu, u'Blank Screen', - u':/slides/slide_blank.png', False) + u':/slides/slide_blank.png', False, u'Live Toolbar') self.blankScreen.setText( translate('OpenLP.SlideController', 'Blank Screen')) self.themeScreen = icon_action(self.hideMenu, u'Blank Theme', - u':/slides/slide_theme.png', False) + u':/slides/slide_theme.png', False, u'Live Toolbar') self.themeScreen.setText( translate('OpenLP.SlideController', 'Blank to Theme')) self.desktopScreen = icon_action(self.hideMenu, u'Desktop Screen', - u':/slides/slide_desktop.png', False) + u':/slides/slide_desktop.png', False, u'Live Toolbar') self.desktopScreen.setText( translate('OpenLP.SlideController', 'Show Desktop')) self.hideMenu.setDefaultAction(self.blankScreen) @@ -364,30 +364,27 @@ class SlideController(QtGui.QWidget): def setPreviewHotkeys(self, parent=None): self.previousItem.setShortcuts([QtCore.Qt.Key_Up, 0]) - actionList.add_action(self.previousItem, u'Preview') + actionList.add_action(self.previousItem, u'Preview Toolbar') self.nextItem.setShortcuts([QtCore.Qt.Key_Down, 0]) - actionList.add_action(self.nextItem, u'Preview') + actionList.add_action(self.nextItem, u'Preview Toolbar') def setLiveHotkeys(self, parent=None): self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp]) self.previousItem.setShortcutContext( QtCore.Qt.WidgetWithChildrenShortcut) - actionList.add_action(self.previousItem, u'Live') + actionList.add_action(self.previousItem, u'Live Toolbar') self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown]) self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) - actionList.add_action(self.nextItem, u'Live') + actionList.add_action(self.nextItem, u'Live Toolbar') self.previousService = shortcut_action(parent, translate('OpenLP.SlideController', 'Previous Service'), - [QtCore.Qt.Key_Left, 0], self.servicePrevious) - actionList.add_action(self.previousService, u'Live') + [QtCore.Qt.Key_Left, 0], self.servicePrevious, u'Live Toolbar') self.nextService = shortcut_action(parent, translate('OpenLP.SlideController', 'Next Service'), - [QtCore.Qt.Key_Right, 0], self.serviceNext) - actionList.add_action(self.nextService, u'Live') + [QtCore.Qt.Key_Right, 0], self.serviceNext, u'Live Toolbar') self.escapeItem = shortcut_action(parent, translate('OpenLP.SlideController', 'Escape Item'), - [QtCore.Qt.Key_Escape, 0], self.liveEscape) - actionList.add_action(self.escapeItem, u'Live') + [QtCore.Qt.Key_Escape, 0], self.liveEscape, u'Live Toolbar') def liveEscape(self): self.display.setVisible(False) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 3c639297e..1bc7037ae 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -495,7 +495,7 @@ def get_uno_instance(resolver): from languagemanager import LanguageManager from actions import ActionList -__all__ = [u'AppLocation', u'check_latest_version', u'add_actions', - u'get_filesystem_encoding', u'LanguageManager', u'ActionList', - u'get_web_page', u'file_is_unicode', u'string_is_unicode', +__all__ = [u'AppLocation', u'get_application_version', u'check_latest_version', + u'add_actions', u'get_filesystem_encoding', u'LanguageManager', + u'ActionList', u'get_web_page', u'file_is_unicode', u'string_is_unicode', u'get_uno_command', u'get_uno_instance', u'delete_file'] diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index ba4a7b40d..b592c9a69 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -184,7 +184,7 @@ class ActionList(object): self.categories[category].actions.append(action) else: self.categories[category].actions.add(action, weight) - self.signal.emit(QtCore.SIGNAL(u'addedAction()')) + self.signal.emit(QtCore.SIGNAL(u'addedAction(QtGui.QAction, QString)'), action, QtCore.QString(category)) class Emit(QtCore.QObject): diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 2d22d2d5a..c397fb9c4 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -62,7 +62,6 @@ class AlertsPlugin(Plugin): log.info(u'add tools menu') self.toolsAlertItem = icon_action(tools_menu, u'toolsAlertItem', u':/plugins/plugin_alerts.png') - actionList.add_action(self.toolsAlertItem, u'Extra') self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert')) self.toolsAlertItem.setStatusTip( translate('AlertsPlugin', 'Show an alert message.')) @@ -76,6 +75,7 @@ class AlertsPlugin(Plugin): log.info(u'Alerts Initialising') Plugin.initialise(self) self.toolsAlertItem.setVisible(True) + actionList.add_action(self.toolsAlertItem, u'Tools') self.liveController.alertTab = self.settings_tab def finalise(self): @@ -86,6 +86,7 @@ class AlertsPlugin(Plugin): self.manager.finalise() Plugin.finalise(self) self.toolsAlertItem.setVisible(False) + #TODO: remove the action from the actionList def toggleAlertsState(self): self.alertsActive = not self.alertsActive From b9b0cbbe9c3492f3aa6403f09cea64631d789455 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 29 Mar 2011 21:52:21 +0200 Subject: [PATCH 03/76] removed things, as this did not work --- openlp/core/ui/mainwindow.py | 6 +-- openlp/core/ui/shortcutlistdialog.py | 2 + openlp/core/ui/shortcutlistform.py | 58 +++++++++++++++------------- openlp/core/utils/actions.py | 9 ----- openlp/plugins/songs/songsplugin.py | 14 +++---- 5 files changed, 43 insertions(+), 46 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index c37db0b97..cf58dedd8 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -177,11 +177,11 @@ class Ui_MainWindow(object): self.ImportThemeItem = base_action( mainWindow, u'ImportThemeItem', u'Import') self.ImportLanguageItem = base_action( - mainWindow, u'ImportLanguageItem', u'Import') + mainWindow, u'ImportLanguageItem')#, u'Import') self.ExportThemeItem = base_action( mainWindow, u'ExportThemeItem', u'Export') self.ExportLanguageItem = base_action( - mainWindow, u'ExportLanguageItem', u'Export') + mainWindow, u'ExportLanguageItem')#, u'Export') self.ViewMediaManagerItem = icon_action(mainWindow, u'ViewMediaManagerItem', u':/system/system_mediamanager.png', self.mediaManagerDock.isVisible(), u'View') @@ -240,7 +240,7 @@ class Ui_MainWindow(object): category=None)#u'Help') self.HelpDocumentationItem.setEnabled(False) self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem', - u':/system/system_about.png', category=None)#u'Help') + u':/system/system_about.png', category=u'Help') self.HelpOnlineHelpItem = base_action( mainWindow, u'HelpOnlineHelpItem', category=u'Help') self.helpWebSiteItem = base_action( diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 4e5b9e270..4e0d7d144 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -30,6 +30,7 @@ from openlp.core.lib import translate, build_icon class Ui_ShortcutListDialog(object): def setupUi(self, shortcutListDialog): + shortcutListDialog.resize(440, 450) shortcutListDialog.setObjectName(u'shortcutListDialog') self.dialogLayout = QtGui.QVBoxLayout(shortcutListDialog) self.dialogLayout.setObjectName(u'dialogLayout') @@ -52,6 +53,7 @@ class Ui_ShortcutListDialog(object): build_icon(u':/system/system_configure_shortcuts.png')) self.shortcutButton.setCheckable(True) self.shortcutButton.setObjectName(u'shortcutButton') + self.shortcutButton.setFixedSize(150, 30) self.customLayout.addWidget(self.shortcutButton) self.clearShortcutButton = QtGui.QToolButton(shortcutListDialog) self.clearShortcutButton.setIcon( diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 83b5de84b..4d785cfc0 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -41,10 +41,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ The shortcut list dialog """ -#TODO: do not close on ESC -#TODO: ability to remove actions -#TODO: Save shortcuts -#TODO: doc +#TODO: do not close on ESC, ability to remove actions, save/load shortcuts, docs #TODO: Fix Preview/Live controller (have the same shortcut) def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) @@ -87,21 +84,17 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.shortcutButton.setChecked(False) def exec_(self): - # The dialog is opened the first time - if self.treeWidget.topLevelItemCount() == 0: - QtCore.QObject.connect(actionList.signal, - QtCore.SIGNAL(u'addedAction()'), self.initialiseActionList) - self.initialiseActionList() self.refreshActionList() return QtGui.QDialog.exec_(self) def refreshActionList(self): + # As refreshing does not work, the check does not work either. self.assingedShortcuts = [] - iterator = QtGui.QTreeWidgetItemIterator(self.treeWidget) - while iterator.value(): - treewidgetItem = iterator.value() - action = treewidgetItem.data(0, QtCore.Qt.UserRole).toPyObject() - if action is not None: + #self.treeWidget.clear() + for category in actionList.categories: + item = QtGui.QTreeWidgetItem([category.name]) + for action in category.actions: + self.assingedShortcuts.extend(action.shortcuts()) actionText = REMOVE_AMPERSAND.sub('', unicode(action.text())) if len(action.shortcuts()) == 2: shortcutText = action.shortcuts()[0].toString() @@ -109,19 +102,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): else: shortcutText = action.shortcut().toString() alternateText = u'' - self.assingedShortcuts.extend(action.shortcuts()) - treewidgetItem.setText(0, actionText) - treewidgetItem.setText(1, shortcutText) - treewidgetItem.setText(2, alternateText) - iterator += 1 - - def initialiseActionList(self): - for category in actionList.categories: - item = QtGui.QTreeWidgetItem([category.name]) - for action in category.actions: - actionItem = QtGui.QTreeWidgetItem() + actionItem = QtGui.QTreeWidgetItem( + [actionText, shortcutText, alternateText]) actionItem.setIcon(0, action.icon()) - actionItem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(action)) + actionItem.setData(0, + QtCore.Qt.UserRole, QtCore.QVariant(action)) item.addChild(actionItem) item.setExpanded(True) self.treeWidget.addTopLevelItem(item) @@ -135,13 +120,16 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): return # TODO: Sort out which shortcuts should be kept. action.setShortcuts(QtGui.QKeySequence(self.shortcutButton.text())) + item.setText(1, self.shortcutButton.text()) self.refreshActionList() def onItemPressed(self, item, column): item = self.treeWidget.currentItem() action = item.data(0, QtCore.Qt.UserRole).toPyObject() + self.shortcutButton.setEnabled(action is not None) if action is None: text = u'' + self.shortcutButton.setChecked(False) else: if len(action.shortcuts()) == 0: text = u'' @@ -150,3 +138,21 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): else: text = action.shortcuts()[0].toString() self.shortcutButton.setText(text) + + def saveShortcuts(self): + """ + Save the shortcuts. + """ + settings = QtCore.QSettings() + settings.beginGroup(u'shortcuts') + # TODO: Save shortcuts + settings.endGroup() + + def loadShortcuts(self): + """ + Load the shortcuts. + """ + settings = QtCore.QSettings() + settings.beginGroup(u'shortcuts') + # TODO: Load shortcuts + settings.endGroup() diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index ba4a7b40d..69aeb14b4 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -27,8 +27,6 @@ The :mod:`~openlp.core.utils.actions` module provides action list classes used by the shortcuts system. """ -from PyQt4 import QtCore - class ActionCategory(object): """ The :class:`~openlp.core.utils.ActionCategory` class encapsulates a @@ -175,7 +173,6 @@ class ActionList(object): """ def __init__(self): self.categories = CategoryList() - self.signal = Emit() def add_action(self, action, category=u'Default', weight=None): if category not in self.categories: @@ -184,11 +181,5 @@ class ActionList(object): self.categories[category].actions.append(action) else: self.categories[category].actions.add(action, weight) - self.signal.emit(QtCore.SIGNAL(u'addedAction()')) - - -class Emit(QtCore.QObject): - def __init__(self): - QtCore.QObject.__init__(self) actionList = ActionList() diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 1260a832b..e1731bc01 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui 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 +from openlp.core.lib.ui import UiStrings, base_action, icon_action from openlp.plugins.songs.lib import clean_song, SongMediaItem, SongsTab from openlp.plugins.songs.lib.db import init_schema, Song from openlp.plugins.songs.lib.importer import SongFormat @@ -78,8 +78,8 @@ class SongsPlugin(Plugin): use it as their parent. """ # Main song import menu item - will eventually be the only one - self.SongImportItem = QtGui.QAction(import_menu) - self.SongImportItem.setObjectName(u'SongImportItem') + self.SongImportItem = base_action( + import_menu, u'SongImportItem', u'Import') self.SongImportItem.setText(translate( 'SongsPlugin', '&Song')) self.SongImportItem.setToolTip(translate('SongsPlugin', @@ -99,8 +99,7 @@ class SongsPlugin(Plugin): use it as their parent. """ # Main song import menu item - will eventually be the only one - self.SongExportItem = QtGui.QAction(export_menu) - self.SongExportItem.setObjectName(u'SongExportItem') + self.SongExportItem = base_action(export_menu, u'SongExportItem', u'Export') self.SongExportItem.setText(translate( 'SongsPlugin', '&Song')) self.SongExportItem.setToolTip(translate('SongsPlugin', @@ -120,9 +119,8 @@ class SongsPlugin(Plugin): use it as their parent. """ log.info(u'add tools menu') - self.toolsReindexItem = QtGui.QAction(tools_menu) - self.toolsReindexItem.setIcon(build_icon(u':/plugins/plugin_songs.png')) - self.toolsReindexItem.setObjectName(u'toolsReindexItem') + self.toolsReindexItem = icon_action(tools_menu, u'toolsReindexItem', + u':/plugins/plugin_songs.png', category=u'Tools') self.toolsReindexItem.setText( translate('SongsPlugin', '&Re-index Songs')) self.toolsReindexItem.setStatusTip( From e20fd7d85d62707d3b6e78858aaa0174fc0ccba4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 29 Mar 2011 21:58:04 +0200 Subject: [PATCH 04/76] clean up --- openlp/core/ui/mainwindow.py | 2 -- openlp/core/ui/shortcutlistform.py | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index cf58dedd8..f4cec4ae7 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -39,7 +39,6 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ShortcutListForm, DisplayTagForm from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ get_application_version -#from openlp.core.utils.actions import actionList log = logging.getLogger(__name__) @@ -216,7 +215,6 @@ class Ui_MainWindow(object): # i18n Language Items self.AutoLanguageItem = checkable_action(mainWindow, u'AutoLanguageItem', LanguageManager.auto_language) - #actionList.add_action(self.AutoLanguageItem, u'Settings') self.LanguageGroup = QtGui.QActionGroup(mainWindow) self.LanguageGroup.setExclusive(True) self.LanguageGroup.setObjectName(u'LanguageGroup') diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 4d785cfc0..2dbb57f2d 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -41,8 +41,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ The shortcut list dialog """ -#TODO: do not close on ESC, ability to remove actions, save/load shortcuts, docs -#TODO: Fix Preview/Live controller (have the same shortcut) +#TODO: do not close on ESC, ability to remove actions (e. g. reindex tool) +#TODO: save/load shortcuts, docs +#TODO: Fix Preview/Live controller (have the same shortcut), make sure + def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) From 9b939bb9624eca001999b65b87adcc9987ecf070 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 30 Mar 2011 12:12:39 +0200 Subject: [PATCH 05/76] fixed reloading --- openlp/core/ui/shortcutlistform.py | 5 ++--- openlp/core/utils/actions.py | 12 +++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 2dbb57f2d..b524c5d06 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -90,12 +90,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): return QtGui.QDialog.exec_(self) def refreshActionList(self): - # As refreshing does not work, the check does not work either. self.assingedShortcuts = [] - #self.treeWidget.clear() + self.treeWidget.clear() for category in actionList.categories: item = QtGui.QTreeWidgetItem([category.name]) - for action in category.actions: + for action, default in category.actions: self.assingedShortcuts.extend(action.shortcuts()) actionText = REMOVE_AMPERSAND.sub('', unicode(action.text())) if len(action.shortcuts()) == 2: diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 69aeb14b4..cbfa3a488 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -27,9 +27,9 @@ The :mod:`~openlp.core.utils.actions` module provides action list classes used by the shortcuts system. """ -class ActionCategory(object): +class Category(object): """ - The :class:`~openlp.core.utils.ActionCategory` class encapsulates a + The :class:`~openlp.core.utils.Category` class encapsulates a category for the :class:`~openlp.core.utils.CategoryList` class. """ def __init__(self, name, weight=0): @@ -67,10 +67,11 @@ class CategoryActionList(object): Python 3 "next" method. """ if self.index >= len(self.actions): + self.index = 0 raise StopIteration else: self.index += 1 - return self.actions[self.index - 1][1] + return self.actions[self.index - 1][1:] def next(self): """ @@ -91,7 +92,7 @@ class CategoryActionList(object): self.add(name, weight) def add(self, action, weight=0): - self.actions.append((weight, action)) + self.actions.append((weight, action, action.shortcuts())) self.actions.sort(key=lambda act: act[0]) @@ -126,6 +127,7 @@ class CategoryList(object): Python 3 "next" method for iterator. """ if self.index >= len(self.categories): + self.index = 0 raise StopIteration else: self.index += 1 @@ -153,7 +155,7 @@ class CategoryList(object): self.add(name, weight) def add(self, name, weight=0, actions=None): - category = ActionCategory(name, weight) + category = Category(name, weight) if actions: for action in actions: if isinstance(action, tuple): From fe92842c6b656610190791221b99c87d31898f1a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 30 Mar 2011 12:27:27 +0200 Subject: [PATCH 06/76] added ability to remove actions --- openlp/core/ui/shortcutlistform.py | 4 ++-- openlp/core/utils/actions.py | 17 ++++++++++++++--- openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/songs/songsplugin.py | 14 ++++++++++---- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index b524c5d06..fd5a53813 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -41,7 +41,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ The shortcut list dialog """ -#TODO: do not close on ESC, ability to remove actions (e. g. reindex tool) +#TODO: do not close on ESC #TODO: save/load shortcuts, docs #TODO: Fix Preview/Live controller (have the same shortcut), make sure @@ -94,7 +94,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.treeWidget.clear() for category in actionList.categories: item = QtGui.QTreeWidgetItem([category.name]) - for action, default in category.actions: + for action in category.actions: self.assingedShortcuts.extend(action.shortcuts()) actionText = REMOVE_AMPERSAND.sub('', unicode(action.text())) if len(action.shortcuts()) == 2: diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index cbfa3a488..8887a7e30 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -71,7 +71,7 @@ class CategoryActionList(object): raise StopIteration else: self.index += 1 - return self.actions[self.index - 1][1:] + return self.actions[self.index - 1][1] def next(self): """ @@ -92,9 +92,15 @@ class CategoryActionList(object): self.add(name, weight) def add(self, action, weight=0): - self.actions.append((weight, action, action.shortcuts())) + self.actions.append((weight, action)) self.actions.sort(key=lambda act: act[0]) + def remove(self, remove_action): + for action in self.actions: + if action[1] == remove_action: + self.actions.remove(action) + return + class CategoryList(object): """ @@ -176,7 +182,7 @@ class ActionList(object): def __init__(self): self.categories = CategoryList() - def add_action(self, action, category=u'Default', weight=None): + def add_action(self, action, category, weight=None): if category not in self.categories: self.categories.append(category) if weight is None: @@ -184,4 +190,9 @@ class ActionList(object): else: self.categories[category].actions.add(action, weight) + def remove_action(self, action, category): + if category not in self.categories: + return + self.categories[category].actions.remove(action) + actionList = ActionList() diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index c397fb9c4..a10d56a20 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -86,7 +86,7 @@ class AlertsPlugin(Plugin): self.manager.finalise() Plugin.finalise(self) self.toolsAlertItem.setVisible(False) - #TODO: remove the action from the actionList + actionList.remove_action(self.toolsAlertItem, u'Tools') def toggleAlertsState(self): self.alertsActive = not self.alertsActive diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index e1731bc01..e5ce25906 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -34,6 +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.utils.actions import actionList from openlp.plugins.songs.lib import clean_song, SongMediaItem, SongsTab from openlp.plugins.songs.lib.db import init_schema, Song from openlp.plugins.songs.lib.importer import SongFormat @@ -65,6 +66,9 @@ class SongsPlugin(Plugin): log.info(u'Songs Initialising') Plugin.initialise(self) self.toolsReindexItem.setVisible(True) + actionList.add_action(self.SongImportItem, u'Import') + actionList.add_action(self.SongExportItem, u'Export') + actionList.add_action(self.toolsReindexItem, u'Tools') self.mediaItem.displayResultsSong( self.manager.get_all_objects(Song, order_by_ref=Song.search_title)) @@ -78,8 +82,7 @@ class SongsPlugin(Plugin): use it as their parent. """ # Main song import menu item - will eventually be the only one - self.SongImportItem = base_action( - import_menu, u'SongImportItem', u'Import') + self.SongImportItem = base_action(import_menu, u'SongImportItem') self.SongImportItem.setText(translate( 'SongsPlugin', '&Song')) self.SongImportItem.setToolTip(translate('SongsPlugin', @@ -99,7 +102,7 @@ class SongsPlugin(Plugin): use it as their parent. """ # Main song import menu item - will eventually be the only one - self.SongExportItem = base_action(export_menu, u'SongExportItem', u'Export') + self.SongExportItem = base_action(export_menu, u'SongExportItem') self.SongExportItem.setText(translate( 'SongsPlugin', '&Song')) self.SongExportItem.setToolTip(translate('SongsPlugin', @@ -120,7 +123,7 @@ class SongsPlugin(Plugin): """ log.info(u'add tools menu') self.toolsReindexItem = icon_action(tools_menu, u'toolsReindexItem', - u':/plugins/plugin_songs.png', category=u'Tools') + u':/plugins/plugin_songs.png') self.toolsReindexItem.setText( translate('SongsPlugin', '&Re-index Songs')) self.toolsReindexItem.setStatusTip( @@ -257,4 +260,7 @@ class SongsPlugin(Plugin): log.info(u'Songs Finalising') self.manager.finalise() self.toolsReindexItem.setVisible(False) + actionList.remove_action(self.SongImportItem, u'Import') + actionList.remove_action(self.SongExportItem, u'Export') + actionList.remove_action(self.toolsReindexItem, u'Tools') Plugin.finalise(self) From 5ef0cc12c09cf523b8fa3563d41fc9f3261e692a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 30 Mar 2011 18:34:40 +0200 Subject: [PATCH 07/76] started working on saving/loading shortcuts --- openlp/core/ui/mainwindow.py | 3 +- openlp/core/ui/shortcutlistdialog.py | 11 ------ openlp/core/ui/shortcutlistform.py | 55 ++++++++++++++++++++-------- openlp/core/utils/actions.py | 7 ++-- 4 files changed, 45 insertions(+), 31 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index f4cec4ae7..d0f6338e3 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -761,7 +761,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Show the shortcuts dialog """ - self.shortcutForm.exec_() + if self.shortcutForm.exec_(): + self.shortcutForm.saveShortcuts() def onModeDefaultItemClicked(self): """ diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 4e0d7d144..467fb0534 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -39,15 +39,8 @@ class Ui_ShortcutListDialog(object): self.treeWidget.setObjectName(u'treeWidget') self.treeWidget.setColumnCount(3) self.dialogLayout.addWidget(self.treeWidget) - self.defaultButton = QtGui.QRadioButton(shortcutListDialog) - self.defaultButton.setChecked(True) - self.defaultButton.setObjectName(u'defaultButton') - self.dialogLayout.addWidget(self.defaultButton) self.customLayout = QtGui.QHBoxLayout() self.customLayout.setObjectName(u'customLayout') - self.customButton = QtGui.QRadioButton(shortcutListDialog) - self.customButton.setObjectName(u'customButton') - self.customLayout.addWidget(self.customButton) self.shortcutButton = QtGui.QPushButton(shortcutListDialog) self.shortcutButton.setIcon( build_icon(u':/system/system_configure_shortcuts.png')) @@ -82,9 +75,5 @@ class Ui_ShortcutListDialog(object): translate('OpenLP.ShortcutListDialog', 'Action'), translate('OpenLP.ShortcutListDialog', 'Shortcut'), translate('OpenLP.ShortcutListDialog', 'Alternate')]) - self.defaultButton.setText( - translate('OpenLP.ShortcutListDialog', 'Default: %s')) - self.customButton.setText( - translate('OpenLP.ShortcutListDialog', 'Custom:')) self.shortcutButton.setText( translate('OpenLP.ShortcutListDialog', 'None')) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index fd5a53813..127569f24 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -49,6 +49,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): QtGui.QDialog.__init__(self, parent) self.setupUi(self) self.assingedShortcuts = [] + self.column = -1 self.shortcutButton.setText(u'') QtCore.QObject.connect(self.shortcutButton, QtCore.SIGNAL(u'toggled(bool)'), self.onShortcutButtonClicked) @@ -119,25 +120,40 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): action = item.data(0, QtCore.Qt.UserRole).toPyObject() if action is None: return - # TODO: Sort out which shortcuts should be kept. - action.setShortcuts(QtGui.QKeySequence(self.shortcutButton.text())) - item.setText(1, self.shortcutButton.text()) - self.refreshActionList() + shortcuts = [] + if self.column == 1: + # We are changing the primary shortcut. + shortcuts.append(QtGui.QKeySequence(self.shortcutButton.text())) + if len(action.shortcuts()) == 2: + shortcuts.append(action.shortcuts()[1]) + else: + shortcuts.append(0) + item.setText(1, self.shortcutButton.text()) + elif self.column == 2: + # We are changing the secondary shortcut. + if len(action.shortcuts()) == 1: + shortcuts.append(action.shortcuts()[0]) + else: + shortcuts.append(0) + shortcuts.append(QtGui.QKeySequence(self.shortcutButton.text())) + item.setText(2, self.shortcutButton.text()) + else: + return + action.setShortcuts(shortcuts) def onItemPressed(self, item, column): + self.column = column item = self.treeWidget.currentItem() action = item.data(0, QtCore.Qt.UserRole).toPyObject() - self.shortcutButton.setEnabled(action is not None) - if action is None: - text = u'' - self.shortcutButton.setChecked(False) - else: - if len(action.shortcuts()) == 0: - text = u'' - elif len(action.shortcuts()) == 2 and column == 2: - text = action.shortcuts()[1].toString() - else: - text = action.shortcuts()[0].toString() + self.shortcutButton.setEnabled(True) + text = u'' + if action is None or column not in [1, 2] or \ + len(action.shortcuts()) == 0: + self.shortcutButton.setEnabled(False) + elif column == 1: + text = action.shortcuts()[0].toString() + elif len(action.shortcuts()) == 2: + text = action.shortcuts()[1].toString() self.shortcutButton.setText(text) def saveShortcuts(self): @@ -146,7 +162,12 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') - # TODO: Save shortcuts + for category in actionList.categories: + break + for action in category.actions: + if action.defaultShortcuts != action.shortcuts(): + settings.setValue(action.text(), + QtCore.QVariant(action.shortcuts())) settings.endGroup() def loadShortcuts(self): @@ -155,5 +176,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') + for shortcut in settings.allKeys(): + pass # TODO: Load shortcuts settings.endGroup() diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 8887a7e30..d94ee1511 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -27,9 +27,9 @@ The :mod:`~openlp.core.utils.actions` module provides action list classes used by the shortcuts system. """ -class Category(object): +class ActionCategory(object): """ - The :class:`~openlp.core.utils.Category` class encapsulates a + The :class:`~openlp.core.utils.ActionCategory` class encapsulates a category for the :class:`~openlp.core.utils.CategoryList` class. """ def __init__(self, name, weight=0): @@ -161,7 +161,7 @@ class CategoryList(object): self.add(name, weight) def add(self, name, weight=0, actions=None): - category = Category(name, weight) + category = ActionCategory(name, weight) if actions: for action in actions: if isinstance(action, tuple): @@ -185,6 +185,7 @@ class ActionList(object): def add_action(self, action, category, weight=None): if category not in self.categories: self.categories.append(category) + action.defaultShortcuts = action.shortcuts() if weight is None: self.categories[category].actions.append(action) else: From 772bd8eb66daa57a0c9b8759cbad4b11e22f9282 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 30 Mar 2011 19:50:36 +0200 Subject: [PATCH 08/76] basic saving and loading of shortcuts --- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/shortcutlistform.py | 33 +++++++++--------------------- openlp/core/utils/actions.py | 12 +++++++++++ 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d0f6338e3..1fdf0fd76 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -762,7 +762,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Show the shortcuts dialog """ if self.shortcutForm.exec_(): - self.shortcutForm.saveShortcuts() + self.shortcutForm.save() def onModeDefaultItemClicked(self): """ diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 127569f24..15c6c53e5 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -87,10 +87,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.shortcutButton.setChecked(False) def exec_(self): - self.refreshActionList() + self.reloadActionList() return QtGui.QDialog.exec_(self) - def refreshActionList(self): + def reloadActionList(self): self.assingedShortcuts = [] self.treeWidget.clear() for category in actionList.categories: @@ -147,36 +147,23 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): action = item.data(0, QtCore.Qt.UserRole).toPyObject() self.shortcutButton.setEnabled(True) text = u'' - if action is None or column not in [1, 2] or \ - len(action.shortcuts()) == 0: + if action is None or column not in [1, 2]: self.shortcutButton.setEnabled(False) - elif column == 1: + elif column == 1 and len(action.shortcuts()) != 0: text = action.shortcuts()[0].toString() - elif len(action.shortcuts()) == 2: + elif len(action.shortcuts()) == 2 and len(action.shortcuts()) != 0: text = action.shortcuts()[1].toString() self.shortcutButton.setText(text) - def saveShortcuts(self): + def save(self): """ - Save the shortcuts. + Save the shortcuts. **Note**, that we do not have to load the shortcuts, + as they are loaded in :class:`~openlp.core.utils.ActionList`. """ settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') for category in actionList.categories: - break for action in category.actions: - if action.defaultShortcuts != action.shortcuts(): - settings.setValue(action.text(), - QtCore.QVariant(action.shortcuts())) - settings.endGroup() - - def loadShortcuts(self): - """ - Load the shortcuts. - """ - settings = QtCore.QSettings() - settings.beginGroup(u'shortcuts') - for shortcut in settings.allKeys(): - pass - # TODO: Load shortcuts + settings.setValue( + action.objectName(), QtCore.QVariant(action.shortcuts())) settings.endGroup() diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index d94ee1511..6b7df6817 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -27,6 +27,10 @@ The :mod:`~openlp.core.utils.actions` module provides action list classes used by the shortcuts system. """ +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import translate + class ActionCategory(object): """ The :class:`~openlp.core.utils.ActionCategory` class encapsulates a @@ -190,6 +194,14 @@ class ActionList(object): self.categories[category].actions.append(action) else: self.categories[category].actions.add(action, weight) + # Load the shortcut from the config. + settings = QtCore.QSettings() + settings.beginGroup(u'shortcuts') + shortcuts = settings.value(action.objectName(), + QtCore.QVariant(action.shortcuts())).toStringList() + action.setShortcuts( + [QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) + settings.endGroup() def remove_action(self, action, category): if category not in self.categories: From bf2a9d338b25dbce73ed0c3f4ec2a2724e9a2b96 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 30 Mar 2011 20:12:05 +0200 Subject: [PATCH 09/76] clean up --- openlp/core/lib/ui.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 86def01d8..44bf7c0dd 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -242,6 +242,11 @@ def create_up_down_push_button_set(parent): 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) @@ -262,11 +267,6 @@ def checkable_action(parent, name, checked=None, category=None): def icon_action(parent, name, icon, checked=None, category=None): """ Return a standard action with an icon. - - ``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. """ if checked is not None: action = checkable_action(parent, name, checked, category) From fb78350a44f421e3bb8b4b3184e51eeb2194fc61 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 30 Mar 2011 20:27:33 +0200 Subject: [PATCH 10/76] added bible actions --- openlp/plugins/bibles/bibleplugin.py | 16 +++++++++------- openlp/plugins/songs/songsplugin.py | 6 ++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 4f677f211..86d751e9a 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -29,6 +29,8 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate +from openlp.core.lib.ui import base_action +from openlp.core.utils.actions import actionList from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem log = logging.getLogger(__name__) @@ -50,6 +52,9 @@ class BiblePlugin(Plugin): self.manager = BibleManager(self) Plugin.initialise(self) self.importBibleItem.setVisible(True) + actionList.add_action(self.importBibleItem, u'Import') + # Do not add the action to the list yet. + #actionList.add_action(self.exportBibleItem, u'Export') # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) @@ -64,21 +69,18 @@ class BiblePlugin(Plugin): self.exportBibleItem.setVisible(False) def addImportMenuItem(self, import_menu): - self.importBibleItem = QtGui.QAction(import_menu) - self.importBibleItem.setObjectName(u'importBibleItem') + self.importBibleItem = base_action(import_menu, u'importBibleItem') + self.importBibleItem.setText(translate('BiblesPlugin', '&Bible')) import_menu.addAction(self.importBibleItem) - self.importBibleItem.setText( - translate('BiblesPlugin', '&Bible')) # 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 = QtGui.QAction(export_menu) - self.exportBibleItem.setObjectName(u'exportBibleItem') - export_menu.addAction(self.exportBibleItem) + self.exportBibleItem = base_action(export_menu, u'exportBibleItem') self.exportBibleItem.setText(translate('BiblesPlugin', '&Bible')) + export_menu.addAction(self.exportBibleItem) self.exportBibleItem.setVisible(False) def onBibleImportClick(self): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index e5ce25906..12462428e 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -83,8 +83,7 @@ class SongsPlugin(Plugin): """ # 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.setText(translate('SongsPlugin', '&Song')) self.SongImportItem.setToolTip(translate('SongsPlugin', 'Import songs using the import wizard.')) import_menu.addAction(self.SongImportItem) @@ -103,8 +102,7 @@ class SongsPlugin(Plugin): """ # 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.setText(translate('SongsPlugin', '&Song')) self.SongExportItem.setToolTip(translate('SongsPlugin', 'Exports songs using the export wizard.')) export_menu.addAction(self.SongExportItem) From bba2f2c604245e959dd27d336950624e095454e9 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 30 Mar 2011 20:52:21 +0200 Subject: [PATCH 11/76] docs --- openlp/core/ui/shortcutlistform.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 15c6c53e5..97d21bebf 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -42,9 +42,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): The shortcut list dialog """ #TODO: do not close on ESC -#TODO: save/load shortcuts, docs -#TODO: Fix Preview/Live controller (have the same shortcut), make sure - +#TODO: Fix Preview/Live controller (have the same shortcut) +#TODO: double click event +#TODO: refresh self.assingedShortcuts def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) @@ -91,6 +91,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): return QtGui.QDialog.exec_(self) def reloadActionList(self): + """ + Reload the ``treeWidget`` list to add new and remove old actions. + """ self.assingedShortcuts = [] self.treeWidget.clear() for category in actionList.categories: @@ -114,6 +117,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.treeWidget.addTopLevelItem(item) def onShortcutButtonClicked(self, toggled): + """ + Save the new shortcut to the action if the button is unchanged. + """ if toggled: return item = self.treeWidget.currentItem() @@ -142,6 +148,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): action.setShortcuts(shortcuts) def onItemPressed(self, item, column): + """ + A item has been pressed. We adjust the button's text to the action's + shortcut which is encapsulate in the item. + """ self.column = column item = self.treeWidget.currentItem() action = item.data(0, QtCore.Qt.UserRole).toPyObject() From 4ca738e9b3bfd8753a8d78a31c86ea5d182ff1d8 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 31 Mar 2011 10:43:19 +0200 Subject: [PATCH 12/76] staticmethod for adding/removing actions --- openlp/core/lib/ui.py | 4 ++-- openlp/core/ui/servicemanager.py | 20 ++++++++++---------- openlp/core/ui/shortcutlistform.py | 6 +++--- openlp/core/ui/slidecontroller.py | 10 +++++----- openlp/core/utils/actions.py | 23 +++++++++++------------ openlp/plugins/alerts/alertsplugin.py | 6 +++--- openlp/plugins/bibles/bibleplugin.py | 6 +++--- openlp/plugins/songs/songsplugin.py | 14 +++++++------- 8 files changed, 44 insertions(+), 45 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 44bf7c0dd..a298d803b 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon, Receiver, translate -from openlp.core.utils.actions import actionList +from openlp.core.utils.actions import ActionList log = logging.getLogger(__name__) @@ -251,7 +251,7 @@ def base_action(parent, name, category=None): action = QtGui.QAction(parent) action.setObjectName(name) if category is not None: - actionList.add_action(action, category) + ActionList.add_action(action, category) return action def checkable_action(parent, name, checked=None, category=None): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 1d5321e01..4bdd647ed 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -40,7 +40,7 @@ from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ split_filename -from openlp.core.utils.actions import actionList +from openlp.core.utils.actions import ActionList class ServiceManagerList(QtGui.QTreeWidget): """ @@ -316,15 +316,15 @@ class ServiceManager(QtGui.QWidget): self.configUpdated() def setServiceHotkeys(self): - actionList.add_action(self.serviceManagerList.moveDown, u'Service') - actionList.add_action(self.serviceManagerList.moveUp, u'Service') - actionList.add_action(self.serviceManagerList.moveTop, u'Service') - actionList.add_action(self.serviceManagerList.moveBottom, u'Service') - actionList.add_action(self.serviceManagerList.makeLive, u'Service') - actionList.add_action(self.serviceManagerList.up, u'Service') - actionList.add_action(self.serviceManagerList.down, u'Service') - actionList.add_action(self.serviceManagerList.expand, u'Service') - actionList.add_action(self.serviceManagerList.collapse, u'Service') + ActionList.add_action(self.serviceManagerList.moveDown, u'Service') + ActionList.add_action(self.serviceManagerList.moveUp, u'Service') + ActionList.add_action(self.serviceManagerList.moveTop, u'Service') + ActionList.add_action(self.serviceManagerList.moveBottom, u'Service') + ActionList.add_action(self.serviceManagerList.makeLive, u'Service') + ActionList.add_action(self.serviceManagerList.up, u'Service') + ActionList.add_action(self.serviceManagerList.down, u'Service') + ActionList.add_action(self.serviceManagerList.expand, u'Service') + ActionList.add_action(self.serviceManagerList.collapse, u'Service') def setModified(self, modified=True): diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 97d21bebf..8ba78a876 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -30,7 +30,7 @@ import re from PyQt4 import QtCore, QtGui from openlp.core.utils import translate -from openlp.core.utils.actions import actionList +from openlp.core.utils.actions import ActionList from shortcutlistdialog import Ui_ShortcutListDialog REMOVE_AMPERSAND = re.compile(r'&{1}') @@ -96,7 +96,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ self.assingedShortcuts = [] self.treeWidget.clear() - for category in actionList.categories: + for category in ActionList.categories: item = QtGui.QTreeWidgetItem([category.name]) for action in category.actions: self.assingedShortcuts.extend(action.shortcuts()) @@ -172,7 +172,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') - for category in actionList.categories: + for category in ActionList.categories: for action in category.actions: settings.setValue( action.objectName(), QtCore.QVariant(action.shortcuts())) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index cafbec198..bc478463c 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -34,7 +34,7 @@ from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \ ItemCapabilities, translate from openlp.core.lib.ui import icon_action, UiStrings, shortcut_action from openlp.core.ui import HideMode, MainDisplay -from openlp.core.utils.actions import actionList +from openlp.core.utils.actions import ActionList log = logging.getLogger(__name__) @@ -364,18 +364,18 @@ class SlideController(QtGui.QWidget): def setPreviewHotkeys(self, parent=None): self.previousItem.setShortcuts([QtCore.Qt.Key_Up, 0]) - actionList.add_action(self.previousItem, u'Preview Toolbar') + ActionList.add_action(self.previousItem, u'Preview Toolbar') self.nextItem.setShortcuts([QtCore.Qt.Key_Down, 0]) - actionList.add_action(self.nextItem, u'Preview Toolbar') + ActionList.add_action(self.nextItem, u'Preview Toolbar') def setLiveHotkeys(self, parent=None): self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp]) self.previousItem.setShortcutContext( QtCore.Qt.WidgetWithChildrenShortcut) - actionList.add_action(self.previousItem, u'Live Toolbar') + ActionList.add_action(self.previousItem, u'Live Toolbar') self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown]) self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) - actionList.add_action(self.nextItem, u'Live Toolbar') + ActionList.add_action(self.nextItem, u'Live Toolbar') self.previousService = shortcut_action(parent, translate('OpenLP.SlideController', 'Previous Service'), [QtCore.Qt.Key_Left, 0], self.servicePrevious, u'Live Toolbar') diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 6b7df6817..e71aee672 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -183,17 +183,17 @@ class ActionList(object): has a weight by which it is sorted when iterating through the list of actions or categories. """ - def __init__(self): - self.categories = CategoryList() + categories = CategoryList() - def add_action(self, action, category, weight=None): - if category not in self.categories: - self.categories.append(category) + @staticmethod + def add_action(action, category, weight=None): + if category not in ActionList.categories: + ActionList.categories.append(category) action.defaultShortcuts = action.shortcuts() if weight is None: - self.categories[category].actions.append(action) + ActionList.categories[category].actions.append(action) else: - self.categories[category].actions.add(action, weight) + ActionList.categories[category].actions.add(action, weight) # Load the shortcut from the config. settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') @@ -203,9 +203,8 @@ class ActionList(object): [QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) settings.endGroup() - def remove_action(self, action, category): - if category not in self.categories: + @staticmethod + def remove_action(action, category): + if category not in ActionList.categories: return - self.categories[category].actions.remove(action) - -actionList = ActionList() + ActionList.categories[category].actions.remove(action) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index a10d56a20..45e1969f4 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui 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 -from openlp.core.utils.actions import actionList +from openlp.core.utils.actions import ActionList from openlp.plugins.alerts.lib import AlertsManager, AlertsTab from openlp.plugins.alerts.lib.db import init_schema from openlp.plugins.alerts.forms import AlertForm @@ -75,7 +75,7 @@ class AlertsPlugin(Plugin): log.info(u'Alerts Initialising') Plugin.initialise(self) self.toolsAlertItem.setVisible(True) - actionList.add_action(self.toolsAlertItem, u'Tools') + ActionList.add_action(self.toolsAlertItem, u'Tools') self.liveController.alertTab = self.settings_tab def finalise(self): @@ -86,7 +86,7 @@ class AlertsPlugin(Plugin): self.manager.finalise() Plugin.finalise(self) self.toolsAlertItem.setVisible(False) - actionList.remove_action(self.toolsAlertItem, u'Tools') + ActionList.remove_action(self.toolsAlertItem, u'Tools') def toggleAlertsState(self): self.alertsActive = not self.alertsActive diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 86d751e9a..1396d4550 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -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 -from openlp.core.utils.actions import actionList +from openlp.core.utils.actions import ActionList from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem log = logging.getLogger(__name__) @@ -52,9 +52,9 @@ class BiblePlugin(Plugin): self.manager = BibleManager(self) Plugin.initialise(self) self.importBibleItem.setVisible(True) - actionList.add_action(self.importBibleItem, u'Import') + ActionList.add_action(self.importBibleItem, u'Import') # Do not add the action to the list yet. - #actionList.add_action(self.exportBibleItem, u'Export') + #ActionList.add_action(self.exportBibleItem, u'Export') # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 12462428e..de0714d5e 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -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.utils.actions import actionList +from openlp.core.utils.actions import ActionList from openlp.plugins.songs.lib import clean_song, SongMediaItem, SongsTab from openlp.plugins.songs.lib.db import init_schema, Song from openlp.plugins.songs.lib.importer import SongFormat @@ -66,9 +66,9 @@ class SongsPlugin(Plugin): log.info(u'Songs Initialising') Plugin.initialise(self) self.toolsReindexItem.setVisible(True) - actionList.add_action(self.SongImportItem, u'Import') - actionList.add_action(self.SongExportItem, u'Export') - actionList.add_action(self.toolsReindexItem, u'Tools') + ActionList.add_action(self.SongImportItem, u'Import') + ActionList.add_action(self.SongExportItem, u'Export') + ActionList.add_action(self.toolsReindexItem, u'Tools') self.mediaItem.displayResultsSong( self.manager.get_all_objects(Song, order_by_ref=Song.search_title)) @@ -258,7 +258,7 @@ class SongsPlugin(Plugin): log.info(u'Songs Finalising') self.manager.finalise() self.toolsReindexItem.setVisible(False) - actionList.remove_action(self.SongImportItem, u'Import') - actionList.remove_action(self.SongExportItem, u'Export') - actionList.remove_action(self.toolsReindexItem, u'Tools') + ActionList.remove_action(self.SongImportItem, u'Import') + ActionList.remove_action(self.SongExportItem, u'Export') + ActionList.remove_action(self.toolsReindexItem, u'Tools') Plugin.finalise(self) From 0c9b839e916e1b310be7e78e150be48f16bfdd52 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 31 Mar 2011 14:50:38 +0200 Subject: [PATCH 13/76] check if shortcut is already assigned, refreshing list, double click event, started resetting the selected action --- openlp/core/ui/shortcutlistform.py | 86 ++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 23 deletions(-) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 8ba78a876..4746ae3f7 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -42,9 +42,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): The shortcut list dialog """ #TODO: do not close on ESC -#TODO: Fix Preview/Live controller (have the same shortcut) -#TODO: double click event -#TODO: refresh self.assingedShortcuts +#TODO: Fix Preview/Live controller (have the same shortcut def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) @@ -56,6 +54,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): QtCore.QObject.connect(self.treeWidget, QtCore.SIGNAL(u'itemPressed(QTreeWidgetItem*, int)'), self.onItemPressed) + QtCore.QObject.connect(self.treeWidget, + QtCore.SIGNAL(u'itemDoubleClicked(QTreeWidgetItem*, int)'), + self.onItemDoubleClicked) + QtCore.QObject.connect(self.clearShortcutButton, + QtCore.SIGNAL(u'clicked(bool)'), self.onClearShortcutButtonClicked) def keyReleaseEvent(self, event): Qt = QtCore.Qt @@ -87,34 +90,50 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.shortcutButton.setChecked(False) def exec_(self): - self.reloadActionList() + self.reloadShortcutList() return QtGui.QDialog.exec_(self) - def reloadActionList(self): + def reloadShortcutList(self): """ Reload the ``treeWidget`` list to add new and remove old actions. """ - self.assingedShortcuts = [] self.treeWidget.clear() for category in ActionList.categories: item = QtGui.QTreeWidgetItem([category.name]) for action in category.actions: - self.assingedShortcuts.extend(action.shortcuts()) actionText = REMOVE_AMPERSAND.sub('', unicode(action.text())) - if len(action.shortcuts()) == 2: - shortcutText = action.shortcuts()[0].toString() - alternateText = action.shortcuts()[1].toString() - else: - shortcutText = action.shortcut().toString() - alternateText = u'' - actionItem = QtGui.QTreeWidgetItem( - [actionText, shortcutText, alternateText]) + actionItem = QtGui.QTreeWidgetItem([actionText]) actionItem.setIcon(0, action.icon()) actionItem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(action)) item.addChild(actionItem) item.setExpanded(True) self.treeWidget.addTopLevelItem(item) + self.refreshShortcutList() + + def refreshShortcutList(self): + """ + This refreshes the item's shortcuts shown in the list. Note, this + neither adds new actions nor removes old actions. + """ + self.assingedShortcuts = [] + iterator = QtGui.QTreeWidgetItemIterator(self.treeWidget) + while iterator.value(): + item = iterator.value() + iterator += 1 + action = item.data(0, QtCore.Qt.UserRole).toPyObject() + if action is None: + continue + self.assingedShortcuts.extend(action.shortcuts()) + if len(action.shortcuts()) == 0: + item.setText(1, u'') + item.setText(2, u'') + elif len(action.shortcuts()) == 1: + item.setText(1, action.shortcuts()[0].toString()) + item.setText(2, u'') + else: + item.setText(1, action.shortcuts()[0].toString()) + item.setText(2, action.shortcuts()[1].toString()) def onShortcutButtonClicked(self, toggled): """ @@ -127,25 +146,30 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if action is None: return shortcuts = [] + # We are changing the primary shortcut. if self.column == 1: - # We are changing the primary shortcut. shortcuts.append(QtGui.QKeySequence(self.shortcutButton.text())) if len(action.shortcuts()) == 2: shortcuts.append(action.shortcuts()[1]) - else: - shortcuts.append(0) - item.setText(1, self.shortcutButton.text()) + # We are changing the secondary shortcut. elif self.column == 2: - # We are changing the secondary shortcut. if len(action.shortcuts()) == 1: shortcuts.append(action.shortcuts()[0]) - else: - shortcuts.append(0) shortcuts.append(QtGui.QKeySequence(self.shortcutButton.text())) - item.setText(2, self.shortcutButton.text()) else: return action.setShortcuts(shortcuts) + self.refreshShortcutList() + + def onItemDoubleClicked(self, item, column): + """ + """ + item = self.treeWidget.currentItem() + action = item.data(0, QtCore.Qt.UserRole).toPyObject() + self.shortcutButton.setChecked(True) + if action is None or column not in [1, 2]: + self.shortcutButton.setChecked(False) + self.onItemPressed(item, column) def onItemPressed(self, item, column): """ @@ -165,6 +189,22 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): text = action.shortcuts()[1].toString() self.shortcutButton.setText(text) + def onClearShortcutButtonClicked(self, toggled): + """ + Restore the defaults of this + """ + item = self.treeWidget.currentItem() + if item is None: + return + action = item.data(0, QtCore.Qt.UserRole).toPyObject() + if action is None: + return + #FIXME: defaultShortcuts + action.setShortcuts(action.defaultShortcuts) + self.shortcutButton.setChecked(False) + self.shortcutButton.setText(u'') + self.refreshShortcutList() + def save(self): """ Save the shortcuts. **Note**, that we do not have to load the shortcuts, From b17ad266728d9032af9ae42529d6007b86a6f063 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 31 Mar 2011 20:53:50 +0200 Subject: [PATCH 14/76] make sure we save the default shortcut --- openlp/core/lib/toolbar.py | 15 ++--- openlp/core/lib/ui.py | 17 ++++- openlp/core/ui/mainwindow.py | 103 ++++++++++++------------------ openlp/core/ui/servicemanager.py | 53 +++++++-------- openlp/core/ui/slidecontroller.py | 27 ++++---- openlp/core/utils/actions.py | 2 - 6 files changed, 107 insertions(+), 110 deletions(-) diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index d5d2fa4f8..44149cd85 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -51,8 +51,7 @@ class OpenLPToolbar(QtGui.QToolBar): log.debug(u'Init done for %s' % parent.__class__.__name__) def addToolbarButton(self, title, icon, tooltip=None, slot=None, - checkable=False, shortcut=0, alternate=0, - context=QtCore.Qt.WidgetShortcut): + checkable=False, shortcuts=None, context=QtCore.Qt.WidgetShortcut): """ A method to help developers easily add a button to the toolbar. @@ -74,11 +73,8 @@ class OpenLPToolbar(QtGui.QToolBar): If *True* the button has two, *off* and *on*, states. Default is *False*, which means the buttons has only one state. - ``shortcut`` - The primary shortcut for this action - - ``alternate`` - The alternate shortcut for this action + ``shortcuts`` + The list of shortcuts for this action ``context`` Specify the context in which this shortcut is valid @@ -103,8 +99,9 @@ class OpenLPToolbar(QtGui.QToolBar): QtCore.QObject.connect(newAction, QtCore.SIGNAL(u'toggled(bool)'), slot) self.actions[title] = newAction - newAction.setShortcuts([shortcut, alternate]) - newAction.setShortcutContext(context) + if shortcuts is not None: + newAction.setShortcuts(shortcuts) + newAction.setShortcutContext(context) return newAction def addToolbarSeparator(self, handle): diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index a298d803b..c6f7dd070 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -275,13 +275,26 @@ def icon_action(parent, name, icon, checked=None, category=None): action.setIcon(build_icon(icon)) return action -def shortcut_action(parent, text, shortcuts, function, category=None): +def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, + category=None): """ Return a shortcut enabled action. """ - action = base_action(parent, text, category) + # We cannot use the base_action, icon_action and the like, as we must not + # add the action to the actionList before the shortcut has been set + # (when we add the action to the list, the default shortcut is saved, to be + # able restore the shortcut). + action = QtGui.QAction(parent) + action.setObjectName(name) + if icon is not None: + action.setIcon(build_icon(icon)) + if checked is not None: + action.setCheckable(True) + action.setChecked(checked) action.setShortcuts(shortcuts) action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) + if category is not None: + ActionList.add_action(action, category) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) return action diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 1fdf0fd76..14bed4712 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \ SettingsManager, PluginManager, Receiver, translate from openlp.core.lib.ui import UiStrings, base_action, checkable_action, \ - icon_action + icon_action, shortcut_action from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ThemeManager, SlideController, PluginForm, MediaDockManager, \ ShortcutListForm, DisplayTagForm @@ -161,18 +161,32 @@ class Ui_MainWindow(object): mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.themeManagerDock) # Create the menu items - self.FileNewItem = icon_action(mainWindow, u'FileNewItem', + self.FileNewItem = shortcut_action(mainWindow, u'FileNewItem', + [QtGui.QKeySequence(u'Ctrl+N')], + self.ServiceManagerContents.onNewServiceClicked, u':/general/general_new.png', category=u'File') - self.FileOpenItem = icon_action(mainWindow, u'FileOpenItem', + self.FileNewItem.setShortcutContext(QtCore.Qt.WindowShortcut) + self.FileOpenItem = shortcut_action(mainWindow, u'FileOpenItem', + [QtGui.QKeySequence(u'Ctrl+O')], + self.ServiceManagerContents.onLoadServiceClicked, u':/general/general_open.png', category=u'File') - self.FileSaveItem = icon_action(mainWindow, u'FileSaveItem', + self.FileOpenItem.setShortcutContext(QtCore.Qt.WindowShortcut) + self.FileSaveItem = shortcut_action(mainWindow, u'FileSaveItem', + [QtGui.QKeySequence(u'Ctrl+S')], + self.ServiceManagerContents.saveFile, u':/general/general_save.png', category=u'File') - self.FileSaveAsItem = base_action( - mainWindow, u'FileSaveAsItem', u'File') - self.printServiceOrderItem = base_action( - mainWindow, u'printServiceItem', u'File') - self.FileExitItem = icon_action(mainWindow, u'FileExitItem', + self.FileSaveItem.setShortcutContext(QtCore.Qt.WindowShortcut) + self.FileSaveAsItem = shortcut_action(mainWindow, u'FileSaveAsItem', + [QtGui.QKeySequence(u'Ctrl+Shift+S')], + self.ServiceManagerContents.saveFileAs, category=u'File') + self.FileSaveAsItem.setShortcutContext(QtCore.Qt.WindowShortcut) + self.printServiceOrderItem = shortcut_action(mainWindow, + u'printServiceItem', [QtGui.QKeySequence(u'Ctrl+P')], + self.ServiceManagerContents.printServiceOrder, category=u'File') + self.FileExitItem = shortcut_action(mainWindow, u'FileExitItem', + [QtGui.QKeySequence(u'Alt+F4')], mainWindow.close, u':/system/system_exit.png', category=u'File') + self.FileSaveAsItem.setShortcutContext(QtCore.Qt.WindowShortcut) self.ImportThemeItem = base_action( mainWindow, u'ImportThemeItem', u'Import') self.ImportLanguageItem = base_action( @@ -181,15 +195,21 @@ class Ui_MainWindow(object): mainWindow, u'ExportThemeItem', u'Export') self.ExportLanguageItem = base_action( mainWindow, u'ExportLanguageItem')#, u'Export') - self.ViewMediaManagerItem = icon_action(mainWindow, - u'ViewMediaManagerItem', u':/system/system_mediamanager.png', + self.ViewMediaManagerItem = shortcut_action(mainWindow, + u'ViewMediaManagerItem', [QtGui.QKeySequence(u'F8')], + self.toggleMediaManager, u':/system/system_mediamanager.png', self.mediaManagerDock.isVisible(), u'View') - self.ViewThemeManagerItem = icon_action(mainWindow, - u'ViewThemeManagerItem', u':/system/system_thememanager.png', + self.FileSaveAsItem.setShortcutContext(QtCore.Qt.WindowShortcut) + self.ViewThemeManagerItem = shortcut_action(mainWindow, + u'ViewThemeManagerItem', [QtGui.QKeySequence(u'F9')], + self.toggleThemeManager, u':/system/system_thememanager.png', self.themeManagerDock.isVisible(), u'View') - self.ViewServiceManagerItem = icon_action(mainWindow, - u'ViewServiceManagerItem', u':/system/system_servicemanager.png', + self.FileSaveAsItem.setShortcutContext(QtCore.Qt.WindowShortcut) + self.ViewServiceManagerItem = shortcut_action(mainWindow, + u'ViewServiceManagerItem', [QtGui.QKeySequence(u'F10')], + self.toggleServiceManager, u':/system/system_servicemanager.png', self.serviceManagerDock.isVisible(), u'View') + self.FileSaveAsItem.setShortcutContext(QtCore.Qt.WindowShortcut) self.ViewPreviewPanel = checkable_action(mainWindow, u'ViewPreviewPanel', previewVisible, u'View') self.ViewLivePanel = checkable_action( @@ -278,8 +298,6 @@ class Ui_MainWindow(object): # Connect up some signals and slots QtCore.QObject.connect(self.FileMenu, QtCore.SIGNAL(u'aboutToShow()'), self.updateFileMenu) - QtCore.QObject.connect(self.FileExitItem, - QtCore.SIGNAL(u'triggered()'), mainWindow.close) QtCore.QMetaObject.connectSlotsByName(mainWindow) # Hide the entry, as it does not have any functionality yet. self.ToolsAddToolItem.setVisible(False) @@ -312,36 +330,27 @@ class Ui_MainWindow(object): self.FileNewItem.setText(translate('OpenLP.MainWindow', '&New')) self.FileNewItem.setToolTip(UiStrings.NewService) self.FileNewItem.setStatusTip(UiStrings.CreateService) - self.FileNewItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+N')) self.FileOpenItem.setText(translate('OpenLP.MainWindow', '&Open')) self.FileOpenItem.setToolTip(UiStrings.OpenService) self.FileOpenItem.setStatusTip( translate('OpenLP.MainWindow', 'Open an existing service.')) - self.FileOpenItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+O')) self.FileSaveItem.setText(translate('OpenLP.MainWindow', '&Save')) self.FileSaveItem.setToolTip(UiStrings.SaveService) self.FileSaveItem.setStatusTip( translate('OpenLP.MainWindow', 'Save the current service to disk.')) - self.FileSaveItem.setShortcut(translate('OpenLP.MainWindow', 'Ctrl+S')) self.FileSaveAsItem.setText( translate('OpenLP.MainWindow', 'Save &As...')) self.FileSaveAsItem.setToolTip( translate('OpenLP.MainWindow', 'Save Service As')) self.FileSaveAsItem.setStatusTip(translate('OpenLP.MainWindow', 'Save the current service under a new name.')) - self.FileSaveAsItem.setShortcut( - translate('OpenLP.MainWindow', 'Ctrl+Shift+S')) self.printServiceOrderItem.setText(UiStrings.PrintServiceOrder) self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', 'Print the current Service Order.')) - self.printServiceOrderItem.setShortcut( - translate('OpenLP.MainWindow', 'Ctrl+P')) self.FileExitItem.setText( translate('OpenLP.MainWindow', 'E&xit')) self.FileExitItem.setStatusTip( translate('OpenLP.MainWindow', 'Quit OpenLP')) - self.FileExitItem.setShortcut( - translate('OpenLP.MainWindow', 'Alt+F4')) self.ImportThemeItem.setText( translate('OpenLP.MainWindow', '&Theme')) self.ImportLanguageItem.setText( @@ -362,24 +371,18 @@ class Ui_MainWindow(object): translate('OpenLP.MainWindow', 'Toggle Media Manager')) self.ViewMediaManagerItem.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the media manager.')) - self.ViewMediaManagerItem.setShortcut( - translate('OpenLP.MainWindow', 'F8')) self.ViewThemeManagerItem.setText( translate('OpenLP.MainWindow', '&Theme Manager')) self.ViewThemeManagerItem.setToolTip( translate('OpenLP.MainWindow', 'Toggle Theme Manager')) self.ViewThemeManagerItem.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the theme manager.')) - self.ViewThemeManagerItem.setShortcut( - translate('OpenLP.MainWindow', 'F10')) self.ViewServiceManagerItem.setText( translate('OpenLP.MainWindow', '&Service Manager')) self.ViewServiceManagerItem.setToolTip( translate('OpenLP.MainWindow', 'Toggle Service Manager')) self.ViewServiceManagerItem.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the service manager.')) - self.ViewServiceManagerItem.setShortcut( - translate('OpenLP.MainWindow', 'F9')) self.ViewPreviewPanel.setText( translate('OpenLP.MainWindow', '&Preview Panel')) self.ViewPreviewPanel.setToolTip( @@ -409,6 +412,7 @@ class Ui_MainWindow(object): translate('OpenLP.MainWindow', 'More information about OpenLP')) self.HelpAboutItem.setShortcut( translate('OpenLP.MainWindow', 'Ctrl+F1')) + print self.HelpAboutItem.shortcuts() self.HelpOnlineHelpItem.setText( translate('OpenLP.MainWindow', '&Online Help')) # Uncomment after 1.9.5 beta string freeze @@ -490,12 +494,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.ExportThemeItem, QtCore.SIGNAL(u'triggered()'), self.themeManagerContents.onExportTheme) - QtCore.QObject.connect(self.ViewMediaManagerItem, - QtCore.SIGNAL(u'triggered(bool)'), self.toggleMediaManager) - QtCore.QObject.connect(self.ViewServiceManagerItem, - QtCore.SIGNAL(u'triggered(bool)'), self.toggleServiceManager) - QtCore.QObject.connect(self.ViewThemeManagerItem, - QtCore.SIGNAL(u'triggered(bool)'), self.toggleThemeManager) QtCore.QObject.connect(self.ViewPreviewPanel, QtCore.SIGNAL(u'toggled(bool)'), self.setPreviewPanelVisibility) QtCore.QObject.connect(self.ViewLivePanel, @@ -525,20 +523,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.SIGNAL(u'triggered()'), self.onSettingsConfigureItemClicked) QtCore.QObject.connect(self.SettingsShortcutsItem, QtCore.SIGNAL(u'triggered()'), self.onSettingsShortcutsItemClicked) - QtCore.QObject.connect(self.FileNewItem, QtCore.SIGNAL(u'triggered()'), - self.ServiceManagerContents.onNewServiceClicked) - QtCore.QObject.connect(self.FileOpenItem, - QtCore.SIGNAL(u'triggered()'), - self.ServiceManagerContents.onLoadServiceClicked) - QtCore.QObject.connect(self.FileSaveItem, - QtCore.SIGNAL(u'triggered()'), - self.ServiceManagerContents.saveFile) - QtCore.QObject.connect(self.FileSaveAsItem, - QtCore.SIGNAL(u'triggered()'), - self.ServiceManagerContents.saveFileAs) - QtCore.QObject.connect(self.printServiceOrderItem, - QtCore.SIGNAL(u'triggered()'), - self.ServiceManagerContents.printServiceOrder) # i18n set signals for languages self.LanguageGroup.triggered.connect(LanguageManager.set_language) QtCore.QObject.connect(self.ModeDefaultItem, @@ -909,17 +893,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): unicode(translate('OpenLP.MainWindow', 'Default Theme: %s')) % theme) - def toggleMediaManager(self, visible): - if self.mediaManagerDock.isVisible() != visible: - self.mediaManagerDock.setVisible(visible) + def toggleMediaManager(self): + self.mediaManagerDock.setVisible(not self.mediaManagerDock.isVisible()) - def toggleServiceManager(self, visible): - if self.serviceManagerDock.isVisible() != visible: - self.serviceManagerDock.setVisible(visible) + def toggleServiceManager(self): + self.serviceManagerDock.setVisible(not self.serviceManagerDock.isVisible()) - def toggleThemeManager(self, visible): - if self.themeManagerDock.isVisible() != visible: - self.themeManagerDock.setVisible(visible) + def toggleThemeManager(self): + self.themeManagerDock.setVisible(not self.themeManagerDock.isVisible()) def setPreviewPanelVisibility(self, visible): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 4bdd647ed..3ed477485 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -165,38 +165,50 @@ class ServiceManager(QtGui.QWidget): u':/services/service_top.png', translate('OpenLP.ServiceManager', 'Move item to the top of the service.'), - self.onServiceTop, shortcut=QtCore.Qt.Key_Home) + self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home]) + self.serviceManagerList.moveTop.setObjectName(u'moveTop') + ActionList.add_action(self.serviceManagerList.moveTop, u'Service') self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &up'), u':/services/service_up.png', translate('OpenLP.ServiceManager', 'Move item up one position in the service.'), - self.onServiceUp, shortcut=QtCore.Qt.Key_PageUp) + self.onServiceUp, shortcuts=[QtCore.Qt.Key_PageUp]) + self.serviceManagerList.moveUp.setObjectName(u'moveUp') + ActionList.add_action(self.serviceManagerList.moveUp, u'Service') self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &down'), u':/services/service_down.png', translate('OpenLP.ServiceManager', 'Move item down one position in the service.'), - self.onServiceDown, shortcut=QtCore.Qt.Key_PageDown) + self.onServiceDown, shortcuts=[QtCore.Qt.Key_PageDown]) + self.serviceManagerList.moveDown.setObjectName(u'moveDown') + ActionList.add_action(self.serviceManagerList.moveDown, u'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, shortcut=QtCore.Qt.Key_End) + self.onServiceEnd, shortcuts=[QtCore.Qt.Key_End]) + self.serviceManagerList.moveBottom.setObjectName(u'moveBottom') + ActionList.add_action(self.serviceManagerList.moveBottom, u'Service') self.serviceManagerList.down = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &down'), None, translate('OpenLP.ServiceManager', 'Moves the selection down the window.'), - self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Down) + self.onMoveSelectionDown, shortcuts=[QtCore.Qt.Key_Down]) + self.serviceManagerList.down.setObjectName(u'down') + ActionList.add_action(self.serviceManagerList.down, u'Service') self.serviceManagerList.down.setVisible(False) self.serviceManagerList.up = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move up'), None, translate('OpenLP.ServiceManager', 'Moves the selection up the window.'), - self.onMoveSelectionUp, shortcut=QtCore.Qt.Key_Up) + self.onMoveSelectionUp, shortcuts=[QtCore.Qt.Key_Up]) + self.serviceManagerList.up.setObjectName(u'up') + ActionList.add_action(self.serviceManagerList.up, u'Service') self.serviceManagerList.up.setVisible(False) self.orderToolbar.addSeparator() self.serviceManagerList.delete = self.orderToolbar.addToolbarButton( @@ -211,22 +223,26 @@ class ServiceManager(QtGui.QWidget): u':/services/service_expand_all.png', translate('OpenLP.ServiceManager', 'Expand all the service items.'), - self.onExpandAll, shortcut=QtCore.Qt.Key_Plus) + self.onExpandAll, shortcuts=[QtCore.Qt.Key_Plus]) + self.serviceManagerList.expand.setObjectName(u'expand') + ActionList.add_action(self.serviceManagerList.expand, u'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, shortcut=QtCore.Qt.Key_Minus) + self.onCollapseAll, shortcuts=[QtCore.Qt.Key_Minus]) + self.serviceManagerList.collapse.setObjectName(u'collapse') + ActionList.add_action(self.serviceManagerList.collapse, u'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, shortcut=QtCore.Qt.Key_Enter, - alternate=QtCore.Qt.Key_Return) - self.orderToolbar.setObjectName(u'orderToolbar') + 'Send the selected item to Live.'), self.makeLive, + shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]) + self.serviceManagerList.makeLive.setObjectName(u'orderToolbar') + ActionList.add_action(self.serviceManagerList.makeLive, u'Service') self.layout.addWidget(self.orderToolbar) # Connect up our signals and slots QtCore.QObject.connect(self.themeComboBox, @@ -301,7 +317,6 @@ class ServiceManager(QtGui.QWidget): self.themeMenu = QtGui.QMenu( translate('OpenLP.ServiceManager', '&Change Item Theme')) self.menu.addMenu(self.themeMenu) - self.setServiceHotkeys() self.serviceManagerList.addActions( [self.serviceManagerList.moveDown, self.serviceManagerList.moveUp, @@ -315,18 +330,6 @@ class ServiceManager(QtGui.QWidget): ]) self.configUpdated() - def setServiceHotkeys(self): - ActionList.add_action(self.serviceManagerList.moveDown, u'Service') - ActionList.add_action(self.serviceManagerList.moveUp, u'Service') - ActionList.add_action(self.serviceManagerList.moveTop, u'Service') - ActionList.add_action(self.serviceManagerList.moveBottom, u'Service') - ActionList.add_action(self.serviceManagerList.makeLive, u'Service') - ActionList.add_action(self.serviceManagerList.up, u'Service') - ActionList.add_action(self.serviceManagerList.down, u'Service') - ActionList.add_action(self.serviceManagerList.expand, u'Service') - ActionList.add_action(self.serviceManagerList.collapse, u'Service') - - def setModified(self, modified=True): """ Setter for property "modified". Sets whether or not the current service diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index bc478463c..e9d748ad5 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -142,11 +142,13 @@ class SlideController(QtGui.QWidget): u':/slides/slide_previous.png', translate('OpenLP.SlideController', 'Move to previous'), self.onSlideSelectedPrevious) + self.previousItem.setObjectName(u'previousItem') self.nextItem = self.toolbar.addToolbarButton( translate('OpenLP.SlideController', 'Next Slide'), u':/slides/slide_next.png', translate('OpenLP.SlideController', 'Move to next'), self.onSlideSelectedNext) + self.nextItem.setObjectName(u'nextItem') self.toolbar.addToolbarSeparator(u'Close Separator') if self.isLive: self.hideMenu = QtGui.QToolButton(self.toolbar) @@ -363,9 +365,9 @@ class SlideController(QtGui.QWidget): QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged) def setPreviewHotkeys(self, parent=None): - self.previousItem.setShortcuts([QtCore.Qt.Key_Up, 0]) + self.previousItem.setShortcuts([QtCore.Qt.Key_Up]) ActionList.add_action(self.previousItem, u'Preview Toolbar') - self.nextItem.setShortcuts([QtCore.Qt.Key_Down, 0]) + self.nextItem.setShortcuts([QtCore.Qt.Key_Down]) ActionList.add_action(self.nextItem, u'Preview Toolbar') def setLiveHotkeys(self, parent=None): @@ -376,15 +378,18 @@ class SlideController(QtGui.QWidget): self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown]) self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) ActionList.add_action(self.nextItem, u'Live Toolbar') - self.previousService = shortcut_action(parent, - translate('OpenLP.SlideController', 'Previous Service'), - [QtCore.Qt.Key_Left, 0], self.servicePrevious, u'Live Toolbar') - self.nextService = shortcut_action(parent, - translate('OpenLP.SlideController', 'Next Service'), - [QtCore.Qt.Key_Right, 0], self.serviceNext, u'Live Toolbar') - self.escapeItem = shortcut_action(parent, - translate('OpenLP.SlideController', 'Escape Item'), - [QtCore.Qt.Key_Escape, 0], self.liveEscape, u'Live Toolbar') + self.previousService = shortcut_action(parent, u'previousService', + [QtCore.Qt.Key_Left], self.servicePrevious, u'Live Toolbar') + self.previousService.setText( + translate('OpenLP.SlideController', 'Previous Service')) + self.nextService = shortcut_action(parent, 'nextService', + [QtCore.Qt.Key_Right], self.serviceNext, u'Live Toolbar') + self.nextService.setText( + translate('OpenLP.SlideController', 'Next Service')) + self.escapeItem = shortcut_action(parent, 'escapeItem', + [QtCore.Qt.Key_Escape], self.liveEscape, u'Live Toolbar') + self.escapeItem.setText( + translate('OpenLP.SlideController', 'Escape Item')) def liveEscape(self): self.display.setVisible(False) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index e71aee672..34bc72173 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -29,8 +29,6 @@ by the shortcuts system. """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate - class ActionCategory(object): """ The :class:`~openlp.core.utils.ActionCategory` class encapsulates a From df4de23df09486908a5daf69b454f48be0fe3395 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 1 Apr 2011 16:28:25 +0200 Subject: [PATCH 15/76] Added Theme, Blank, Desktop shortcuts, further clean ups Fixes: https://launchpad.net/bugs/739779 --- openlp/core/lib/searchedit.py | 3 +- openlp/core/lib/ui.py | 22 ++++---- openlp/core/ui/mainwindow.py | 59 ++++++++------------- openlp/core/ui/shortcutlistform.py | 47 +++++++++++----- openlp/core/ui/slidecontroller.py | 39 ++++++++------ openlp/core/utils/actions.py | 8 +++ openlp/plugins/songusage/songusageplugin.py | 30 +++++------ 7 files changed, 113 insertions(+), 95 deletions(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 4841d76dc..41699256f 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -29,6 +29,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon +from openlp.core.lib.ui import icon_action log = logging.getLogger(__name__) @@ -132,7 +133,7 @@ class SearchEdit(QtGui.QLineEdit): menu = QtGui.QMenu(self) first = None for identifier, icon, title in items: - action = QtGui.QAction(build_icon(icon), title, menu) + action = icon_action(menu, title, icon) action.setData(QtCore.QVariant(identifier)) menu.addAction(action) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index c6f7dd070..a02041cad 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -280,21 +280,17 @@ def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, """ Return a shortcut enabled action. """ - # We cannot use the base_action, icon_action and the like, as we must not - # add the action to the actionList before the shortcut has been set - # (when we add the action to the list, the default shortcut is saved, to be - # able restore the shortcut). - action = QtGui.QAction(parent) - action.setObjectName(name) if icon is not None: - action.setIcon(build_icon(icon)) - if checked is not None: - action.setCheckable(True) - action.setChecked(checked) + action = icon_action(parent, name, icon, checked, category) + elif checked is not None: + action = checkable_action(parent, name, checked, category) + else: + action = base_action(parent, name, category) action.setShortcuts(shortcuts) - action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) - if category is not None: - ActionList.add_action(action, category) + action.setShortcutContext(QtCore.Qt.WindowShortcut) + # We have to save the default shortcut again, as the action's shortcut was + # set after adding the shortcut to the action list. + action.defaultShortcuts = action.shortcuts() QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) return action diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 14bed4712..458e8814f 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -165,28 +165,23 @@ class Ui_MainWindow(object): [QtGui.QKeySequence(u'Ctrl+N')], self.ServiceManagerContents.onNewServiceClicked, u':/general/general_new.png', category=u'File') - self.FileNewItem.setShortcutContext(QtCore.Qt.WindowShortcut) self.FileOpenItem = shortcut_action(mainWindow, u'FileOpenItem', [QtGui.QKeySequence(u'Ctrl+O')], self.ServiceManagerContents.onLoadServiceClicked, u':/general/general_open.png', category=u'File') - self.FileOpenItem.setShortcutContext(QtCore.Qt.WindowShortcut) self.FileSaveItem = shortcut_action(mainWindow, u'FileSaveItem', [QtGui.QKeySequence(u'Ctrl+S')], self.ServiceManagerContents.saveFile, u':/general/general_save.png', category=u'File') - self.FileSaveItem.setShortcutContext(QtCore.Qt.WindowShortcut) self.FileSaveAsItem = shortcut_action(mainWindow, u'FileSaveAsItem', [QtGui.QKeySequence(u'Ctrl+Shift+S')], self.ServiceManagerContents.saveFileAs, category=u'File') - self.FileSaveAsItem.setShortcutContext(QtCore.Qt.WindowShortcut) self.printServiceOrderItem = shortcut_action(mainWindow, u'printServiceItem', [QtGui.QKeySequence(u'Ctrl+P')], self.ServiceManagerContents.printServiceOrder, category=u'File') self.FileExitItem = shortcut_action(mainWindow, u'FileExitItem', [QtGui.QKeySequence(u'Alt+F4')], mainWindow.close, u':/system/system_exit.png', category=u'File') - self.FileSaveAsItem.setShortcutContext(QtCore.Qt.WindowShortcut) self.ImportThemeItem = base_action( mainWindow, u'ImportThemeItem', u'Import') self.ImportLanguageItem = base_action( @@ -199,21 +194,20 @@ class Ui_MainWindow(object): u'ViewMediaManagerItem', [QtGui.QKeySequence(u'F8')], self.toggleMediaManager, u':/system/system_mediamanager.png', self.mediaManagerDock.isVisible(), u'View') - self.FileSaveAsItem.setShortcutContext(QtCore.Qt.WindowShortcut) self.ViewThemeManagerItem = shortcut_action(mainWindow, - u'ViewThemeManagerItem', [QtGui.QKeySequence(u'F9')], + u'ViewThemeManagerItem', [QtGui.QKeySequence(u'F10')], self.toggleThemeManager, u':/system/system_thememanager.png', self.themeManagerDock.isVisible(), u'View') - self.FileSaveAsItem.setShortcutContext(QtCore.Qt.WindowShortcut) self.ViewServiceManagerItem = shortcut_action(mainWindow, - u'ViewServiceManagerItem', [QtGui.QKeySequence(u'F10')], + u'ViewServiceManagerItem', [QtGui.QKeySequence(u'F9')], self.toggleServiceManager, u':/system/system_servicemanager.png', self.serviceManagerDock.isVisible(), u'View') - self.FileSaveAsItem.setShortcutContext(QtCore.Qt.WindowShortcut) - self.ViewPreviewPanel = checkable_action(mainWindow, - u'ViewPreviewPanel', previewVisible, u'View') - self.ViewLivePanel = checkable_action( - mainWindow, u'ViewLivePanel', liveVisible, u'View') + self.ViewPreviewPanel = shortcut_action(mainWindow, + u'ViewPreviewPanel', [QtGui.QKeySequence(u'F11')], + self.setPreviewPanelVisibility, checked=previewVisible, category=u'View') + self.ViewLivePanel = shortcut_action(mainWindow, u'ViewLivePanel', + [QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility, + checked=liveVisible, category=u'View') self.ModeDefaultItem = checkable_action( mainWindow, u'ModeDefaultItem', category=u'View Mode') self.ModeSetupItem = checkable_action( @@ -229,8 +223,9 @@ class Ui_MainWindow(object): u':/tools/tools_add.png', category=u'Tools') self.ToolsOpenDataFolder = icon_action(mainWindow, u'ToolsOpenDataFolder', u':/general/general_open.png', category=u'Tools') - self.settingsPluginListItem = icon_action(mainWindow, - u'settingsPluginListItem', u':/system/settings_plugin_list.png', + self.settingsPluginListItem = shortcut_action(mainWindow, + u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')], + self.onPluginItemClicked, u':/system/settings_plugin_list.png', category=u'Settings') # i18n Language Items self.AutoLanguageItem = checkable_action(mainWindow, @@ -257,7 +252,8 @@ class Ui_MainWindow(object): u'HelpDocumentationItem', u':/system/system_help_contents.png', category=None)#u'Help') self.HelpDocumentationItem.setEnabled(False) - self.HelpAboutItem = icon_action(mainWindow, u'HelpAboutItem', + self.HelpAboutItem = shortcut_action(mainWindow, u'HelpAboutItem', + [QtGui.QKeySequence(u'Ctrl+F1')], self.onHelpAboutItemClicked, u':/system/system_about.png', category=u'Help') self.HelpOnlineHelpItem = base_action( mainWindow, u'HelpOnlineHelpItem', category=u'Help') @@ -389,30 +385,21 @@ class Ui_MainWindow(object): translate('OpenLP.MainWindow', 'Toggle Preview Panel')) self.ViewPreviewPanel.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the preview panel.')) - self.ViewPreviewPanel.setShortcut( - translate('OpenLP.MainWindow', 'F11')) self.ViewLivePanel.setText( translate('OpenLP.MainWindow', '&Live Panel')) self.ViewLivePanel.setToolTip( translate('OpenLP.MainWindow', 'Toggle Live Panel')) self.ViewLivePanel.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the live panel.')) - self.ViewLivePanel.setShortcut( - translate('OpenLP.MainWindow', 'F12')) self.settingsPluginListItem.setText(translate('OpenLP.MainWindow', '&Plugin List')) self.settingsPluginListItem.setStatusTip( translate('OpenLP.MainWindow', 'List the Plugins')) - self.settingsPluginListItem.setShortcut( - translate('OpenLP.MainWindow', 'Alt+F7')) self.HelpDocumentationItem.setText( translate('OpenLP.MainWindow', '&User Guide')) self.HelpAboutItem.setText(translate('OpenLP.MainWindow', '&About')) self.HelpAboutItem.setStatusTip( translate('OpenLP.MainWindow', 'More information about OpenLP')) - self.HelpAboutItem.setShortcut( - translate('OpenLP.MainWindow', 'Ctrl+F1')) - print self.HelpAboutItem.shortcuts() self.HelpOnlineHelpItem.setText( translate('OpenLP.MainWindow', '&Online Help')) # Uncomment after 1.9.5 beta string freeze @@ -494,10 +481,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.ExportThemeItem, QtCore.SIGNAL(u'triggered()'), self.themeManagerContents.onExportTheme) - QtCore.QObject.connect(self.ViewPreviewPanel, - QtCore.SIGNAL(u'toggled(bool)'), self.setPreviewPanelVisibility) - QtCore.QObject.connect(self.ViewLivePanel, - QtCore.SIGNAL(u'toggled(bool)'), self.setLivePanelVisibility) QtCore.QObject.connect(self.mediaManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'), self.ViewMediaManagerItem.setChecked) @@ -511,12 +494,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked) QtCore.QObject.connect(self.HelpOnlineHelpItem, QtCore.SIGNAL(u'triggered()'), self.onHelpOnLineHelpClicked) - QtCore.QObject.connect(self.HelpAboutItem, - QtCore.SIGNAL(u'triggered()'), self.onHelpAboutItemClicked) QtCore.QObject.connect(self.ToolsOpenDataFolder, QtCore.SIGNAL(u'triggered()'), self.onToolsOpenDataFolderClicked) - QtCore.QObject.connect(self.settingsPluginListItem, - QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked) QtCore.QObject.connect(self.DisplayTagItem, QtCore.SIGNAL(u'triggered()'), self.onDisplayTagItemClicked) QtCore.QObject.connect(self.SettingsConfigureItem, @@ -902,7 +881,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def toggleThemeManager(self): self.themeManagerDock.setVisible(not self.themeManagerDock.isVisible()) - def setPreviewPanelVisibility(self, visible): + def setPreviewPanelVisibility(self, visible=None): """ Sets the visibility of the preview panel including saving the setting and updating the menu. @@ -912,12 +891,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): True - Visible False - Hidden """ + if visible is None: + visible = self.ViewPreviewPanel.isVisible() self.previewController.panel.setVisible(visible) QtCore.QSettings().setValue(u'user interface/preview panel', QtCore.QVariant(visible)) self.ViewPreviewPanel.setChecked(visible) - def setLivePanelVisibility(self, visible): + def setLivePanelVisibility(self, visible=None): """ Sets the visibility of the live panel including saving the setting and updating the menu. @@ -927,6 +908,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): True - Visible False - Hidden """ + if visible is None: + visible = self.ViewLivePanel.isVisible() self.liveController.panel.setVisible(visible) QtCore.QSettings().setValue(u'user interface/live panel', QtCore.QVariant(visible)) @@ -984,8 +967,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.FileMenu.addSeparator() for fileId, filename in enumerate(recentFilesToDisplay): log.debug('Recent file name: %s', filename) - action = QtGui.QAction(u'&%d %s' % (fileId + 1, - QtCore.QFileInfo(filename).fileName()), self) + action = base_action(self, u'&%d %s' % (fileId + 1, + QtCore.QFileInfo(filename).fileName())) action.setData(QtCore.QVariant(filename)) self.connect(action, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onRecentServiceClicked) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 4746ae3f7..e350009cd 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -42,13 +42,13 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): The shortcut list dialog """ #TODO: do not close on ESC -#TODO: Fix Preview/Live controller (have the same shortcut +#TODO: Fix Preview/Live controller (have the same shortcut) def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) - self.assingedShortcuts = [] self.column = -1 self.shortcutButton.setText(u'') + self.shortcutButton.setEnabled(False) QtCore.QObject.connect(self.shortcutButton, QtCore.SIGNAL(u'toggled(bool)'), self.onShortcutButtonClicked) QtCore.QObject.connect(self.treeWidget, @@ -76,7 +76,27 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier: key_string = u'Shift+' + key_string key_sequence = QtGui.QKeySequence(key_string) - if key_sequence in self.assingedShortcuts: + # The item/action we are attempting to change. + changing_item = self.treeWidget.currentItem() + changing_action = changing_item.data(0, QtCore.Qt.UserRole).toPyObject() + shortcut_valid = True + for category in ActionList.categories: + for action in category.actions: + shortcuts = action.shortcuts() + if key_sequence not in shortcuts: + continue + if action is changing_action: + continue + # Have the same parentWidget, thus they cannot have the same + # shortcut. + #TODO: Does not fully work right now. + if action.parentWidget() is changing_action.parentWidget(): + shortcut_valid = False + if action.shortcutContext() == QtCore.Qt.WindowShortcut: + shortcut_valid = False + if changing_action.shortcutContext() == QtCore.Qt.WindowShortcut: + shortcut_valid = False + if not shortcut_valid: QtGui.QMessageBox.warning(self, translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'), unicode(translate('OpenLP.ShortcutListDialog', 'The shortcut ' @@ -91,6 +111,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): def exec_(self): self.reloadShortcutList() + self.shortcutButton.setChecked(False) + self.shortcutButton.setEnabled(False) + self.shortcutButton.setText(u'') return QtGui.QDialog.exec_(self) def reloadShortcutList(self): @@ -116,7 +139,6 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): This refreshes the item's shortcuts shown in the list. Note, this neither adds new actions nor removes old actions. """ - self.assingedShortcuts = [] iterator = QtGui.QTreeWidgetItemIterator(self.treeWidget) while iterator.value(): item = iterator.value() @@ -124,7 +146,6 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): action = item.data(0, QtCore.Qt.UserRole).toPyObject() if action is None: continue - self.assingedShortcuts.extend(action.shortcuts()) if len(action.shortcuts()) == 0: item.setText(1, u'') item.setText(2, u'') @@ -142,6 +163,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if toggled: return item = self.treeWidget.currentItem() + if item is None: + return action = item.data(0, QtCore.Qt.UserRole).toPyObject() if action is None: return @@ -163,12 +186,13 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): def onItemDoubleClicked(self, item, column): """ + A item has been double clicked. ``The shortcutButton`` will be checked + and the item's shortcut will be displayed. """ - item = self.treeWidget.currentItem() action = item.data(0, QtCore.Qt.UserRole).toPyObject() + if action is None: + return self.shortcutButton.setChecked(True) - if action is None or column not in [1, 2]: - self.shortcutButton.setChecked(False) self.onItemPressed(item, column) def onItemPressed(self, item, column): @@ -177,11 +201,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): shortcut which is encapsulate in the item. """ self.column = column - item = self.treeWidget.currentItem() action = item.data(0, QtCore.Qt.UserRole).toPyObject() self.shortcutButton.setEnabled(True) text = u'' if action is None or column not in [1, 2]: + self.shortcutButton.setChecked(False) self.shortcutButton.setEnabled(False) elif column == 1 and len(action.shortcuts()) != 0: text = action.shortcuts()[0].toString() @@ -194,16 +218,15 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): Restore the defaults of this """ item = self.treeWidget.currentItem() + self.shortcutButton.setChecked(False) if item is None: return action = item.data(0, QtCore.Qt.UserRole).toPyObject() if action is None: return - #FIXME: defaultShortcuts action.setShortcuts(action.defaultShortcuts) - self.shortcutButton.setChecked(False) - self.shortcutButton.setText(u'') self.refreshShortcutList() + self.onItemPressed(item, self.column) def save(self): """ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index e9d748ad5..750ada7cd 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -157,16 +157,20 @@ class SlideController(QtGui.QWidget): self.toolbar.addToolbarWidget(u'Hide Menu', self.hideMenu) self.hideMenu.setMenu(QtGui.QMenu( translate('OpenLP.SlideController', 'Hide'), self.toolbar)) - self.blankScreen = icon_action(self.hideMenu, u'Blank Screen', + self.blankScreen = shortcut_action(self.hideMenu, u'blankScreen', + [QtCore.Qt.Key_Period], self.onBlankDisplay, u':/slides/slide_blank.png', False, u'Live Toolbar') self.blankScreen.setText( translate('OpenLP.SlideController', 'Blank Screen')) - self.themeScreen = icon_action(self.hideMenu, u'Blank Theme', + self.themeScreen = shortcut_action(self.hideMenu, u'themeScreen', + [QtGui.QKeySequence(u'T')], self.onThemeDisplay, u':/slides/slide_theme.png', False, u'Live Toolbar') self.themeScreen.setText( translate('OpenLP.SlideController', 'Blank to Theme')) - self.desktopScreen = icon_action(self.hideMenu, u'Desktop Screen', - u':/slides/slide_desktop.png', False, u'Live Toolbar') + self.desktopScreen = shortcut_action(self.hideMenu, + u'desktopScreen', [QtGui.QKeySequence(u'D')], + self.onHideDisplay, u':/slides/slide_desktop.png', False, + u'Live Toolbar') self.desktopScreen.setText( translate('OpenLP.SlideController', 'Show Desktop')) self.hideMenu.setDefaultAction(self.blankScreen) @@ -294,12 +298,6 @@ class SlideController(QtGui.QWidget): QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) if self.isLive: - QtCore.QObject.connect(self.blankScreen, - QtCore.SIGNAL(u'triggered(bool)'), self.onBlankDisplay) - QtCore.QObject.connect(self.themeScreen, - QtCore.SIGNAL(u'triggered(bool)'), self.onThemeDisplay) - QtCore.QObject.connect(self.desktopScreen, - QtCore.SIGNAL(u'triggered(bool)'), self.onHideDisplay) QtCore.QObject.connect(self.volumeSlider, QtCore.SIGNAL(u'sliderReleased()'), self.mediaVolume) QtCore.QObject.connect(Receiver.get_receiver(), @@ -380,14 +378,17 @@ class SlideController(QtGui.QWidget): ActionList.add_action(self.nextItem, u'Live Toolbar') self.previousService = shortcut_action(parent, u'previousService', [QtCore.Qt.Key_Left], self.servicePrevious, u'Live Toolbar') + self.previousService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.previousService.setText( translate('OpenLP.SlideController', 'Previous Service')) self.nextService = shortcut_action(parent, 'nextService', [QtCore.Qt.Key_Right], self.serviceNext, u'Live Toolbar') + self.nextService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.nextService.setText( translate('OpenLP.SlideController', 'Next Service')) self.escapeItem = shortcut_action(parent, 'escapeItem', [QtCore.Qt.Key_Escape], self.liveEscape, u'Live Toolbar') + self.escapeItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.escapeItem.setText( translate('OpenLP.SlideController', 'Escape Item')) @@ -742,10 +743,12 @@ class SlideController(QtGui.QWidget): """ self.onBlankDisplay(False) - def onBlankDisplay(self, checked): + def onBlankDisplay(self, checked=None): """ Handle the blank screen button actions """ + if checked is None: + checked = self.blankScreen.isChecked() log.debug(u'onBlankDisplay %s' % checked) self.hideMenu.setDefaultAction(self.blankScreen) self.blankScreen.setChecked(checked) @@ -763,10 +766,12 @@ class SlideController(QtGui.QWidget): self.blankPlugin(checked) self.updatePreview() - def onThemeDisplay(self, checked): + def onThemeDisplay(self, checked=None): """ Handle the Theme screen button """ + if checked is None: + checked = self.themeScreen.isChecked() log.debug(u'onThemeDisplay %s' % checked) self.hideMenu.setDefaultAction(self.themeScreen) self.blankScreen.setChecked(False) @@ -784,10 +789,12 @@ class SlideController(QtGui.QWidget): self.blankPlugin(checked) self.updatePreview() - def onHideDisplay(self, checked): + def onHideDisplay(self, checked=None): """ Handle the Hide screen button """ + if checked is None: + checked = self.desktopScreen.isChecked() log.debug(u'onHideDisplay %s' % checked) self.hideMenu.setDefaultAction(self.desktopScreen) self.blankScreen.setChecked(False) @@ -1102,11 +1109,11 @@ class SlideController(QtGui.QWidget): screen hide attributes """ blank = None - if self.blankScreen.isChecked: + if self.blankScreen.isChecked(): blank = self.blankScreen - if self.themeScreen.isChecked: + if self.themeScreen.isChecked(): blank = self.themeScreen - if self.desktopScreen.isChecked: + if self.desktopScreen.isChecked(): blank = self.desktopScreen if blank: blank.setChecked(False) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 34bc72173..7421db30e 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -173,6 +173,11 @@ class CategoryList(object): self.categories.append(category) self.categories.sort(key=lambda cat: cat.weight) + def remove(self, name): + for category in self.categories: + if category.name == name: + self.categories.remove(category) + class ActionList(object): """ @@ -206,3 +211,6 @@ class ActionList(object): if category not in ActionList.categories: return ActionList.categories[category].actions.remove(action) + # Remove empty categories. + if len(ActionList.categories[category].actions) == 0: + ActionList.categories.remove(category) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 8ff40373a..2e55a23c0 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -32,6 +32,8 @@ from PyQt4 import QtCore, QtGui 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.utils.actions import ActionList from openlp.plugins.songusage.forms import SongUsageDetailForm, \ SongUsageDeleteForm from openlp.plugins.songusage.lib.db import init_schema, SongUsageItem @@ -63,30 +65,25 @@ class SongUsagePlugin(Plugin): self.SongUsageMenu.setObjectName(u'SongUsageMenu') self.SongUsageMenu.setTitle(translate( 'SongUsagePlugin', '&Song Usage Tracking')) - #SongUsage Delete - self.SongUsageDelete = QtGui.QAction(tools_menu) + # 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.setObjectName(u'SongUsageDelete') - #SongUsage Report - self.SongUsageReport = QtGui.QAction(tools_menu) + # 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.setObjectName(u'SongUsageReport') - #SongUsage activation - self.SongUsageStatus = QtGui.QAction(tools_menu) - self.SongUsageStatus.setCheckable(True) - self.SongUsageStatus.setChecked(False) + # 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.setShortcut(u'F4') - self.SongUsageStatus.setObjectName(u'SongUsageStatus') #Add Menus together self.toolsMenu.addAction(self.SongUsageMenu.menuAction()) self.SongUsageMenu.addAction(self.SongUsageStatus) @@ -97,9 +94,6 @@ class SongUsagePlugin(Plugin): QtCore.QObject.connect(self.SongUsageStatus, QtCore.SIGNAL(u'visibilityChanged(bool)'), self.SongUsageStatus.setChecked) - QtCore.QObject.connect(self.SongUsageStatus, - QtCore.SIGNAL(u'triggered(bool)'), - self.toggleSongUsageState) QtCore.QObject.connect(self.SongUsageDelete, QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete) QtCore.QObject.connect(self.SongUsageReport, @@ -116,6 +110,9 @@ class SongUsagePlugin(Plugin): self.settingsSection + u'/active', QtCore.QVariant(False)).toBool() self.SongUsageStatus.setChecked(self.SongUsageActive) + ActionList.add_action(self.SongUsageDelete, u'Song Usage') + ActionList.add_action(self.SongUsageReport, u'Song Usage') + ActionList.add_action(self.SongUsageStatus, u'Song Usage') if self.manager is None: self.manager = Manager(u'songusage', init_schema) self.SongUsagedeleteform = SongUsageDeleteForm(self.manager, @@ -131,6 +128,9 @@ class SongUsagePlugin(Plugin): self.manager.finalise() Plugin.finalise(self) self.SongUsageMenu.menuAction().setVisible(False) + ActionList.remove_action(self.SongUsageDelete, u'Song Usage') + ActionList.remove_action(self.SongUsageReport, u'Song Usage') + ActionList.remove_action(self.SongUsageStatus, u'Song Usage') #stop any events being processed self.SongUsageActive = False From 1a493b1fc8da490d0cd7783188f79c02caeb83cd Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 1 Apr 2011 18:53:39 +0200 Subject: [PATCH 16/76] possible fix for not working 'move selection down' --- openlp/core/ui/slidecontroller.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 750ada7cd..9f486518b 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -32,7 +32,7 @@ from PyQt4.phonon import Phonon from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \ ItemCapabilities, translate -from openlp.core.lib.ui import icon_action, UiStrings, shortcut_action +from openlp.core.lib.ui import UiStrings, shortcut_action from openlp.core.ui import HideMode, MainDisplay from openlp.core.utils.actions import ActionList @@ -143,12 +143,17 @@ class SlideController(QtGui.QWidget): translate('OpenLP.SlideController', 'Move to previous'), self.onSlideSelectedPrevious) self.previousItem.setObjectName(u'previousItem') + self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp]) + self.previousItem.setShortcutContext( + QtCore.Qt.WidgetWithChildrenShortcut) self.nextItem = self.toolbar.addToolbarButton( translate('OpenLP.SlideController', 'Next Slide'), u':/slides/slide_next.png', translate('OpenLP.SlideController', 'Move to next'), self.onSlideSelectedNext) self.nextItem.setObjectName(u'nextItem') + self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown]) + self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.toolbar.addToolbarSeparator(u'Close Separator') if self.isLive: self.hideMenu = QtGui.QToolButton(self.toolbar) @@ -363,18 +368,11 @@ class SlideController(QtGui.QWidget): QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged) def setPreviewHotkeys(self, parent=None): - self.previousItem.setShortcuts([QtCore.Qt.Key_Up]) ActionList.add_action(self.previousItem, u'Preview Toolbar') - self.nextItem.setShortcuts([QtCore.Qt.Key_Down]) ActionList.add_action(self.nextItem, u'Preview Toolbar') def setLiveHotkeys(self, parent=None): - self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp]) - self.previousItem.setShortcutContext( - QtCore.Qt.WidgetWithChildrenShortcut) ActionList.add_action(self.previousItem, u'Live Toolbar') - self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown]) - self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) ActionList.add_action(self.nextItem, u'Live Toolbar') self.previousService = shortcut_action(parent, u'previousService', [QtCore.Qt.Key_Left], self.servicePrevious, u'Live Toolbar') From 4badce0205e1f29d69f2074bbd2bb30d934cf9d7 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 2 Apr 2011 15:08:54 +0200 Subject: [PATCH 17/76] fixed actions which did not have a parent which caused the check to fail --- openlp/core/lib/toolbar.py | 3 +-- openlp/core/ui/shortcutlistform.py | 11 ++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index 44149cd85..d2b37df51 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -79,7 +79,6 @@ class OpenLPToolbar(QtGui.QToolBar): ``context`` Specify the context in which this shortcut is valid """ - newAction = None if icon: actionIcon = build_icon(icon) if slot and not checkable: @@ -88,7 +87,7 @@ class OpenLPToolbar(QtGui.QToolBar): newAction = self.addAction(actionIcon, title) self.icons[title] = actionIcon else: - newAction = QtGui.QAction(title, newAction) + newAction = QtGui.QAction(title, self) self.addAction(newAction) QtCore.QObject.connect(newAction, QtCore.SIGNAL(u'triggered()'), slot) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index e350009cd..bd4fb8ab6 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -42,7 +42,6 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): The shortcut list dialog """ #TODO: do not close on ESC -#TODO: Fix Preview/Live controller (have the same shortcut) def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) @@ -89,12 +88,13 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): continue # Have the same parentWidget, thus they cannot have the same # shortcut. - #TODO: Does not fully work right now. - if action.parentWidget() is changing_action.parentWidget(): + if action.parent() is changing_action.parent(): shortcut_valid = False - if action.shortcutContext() == QtCore.Qt.WindowShortcut: + if action.shortcutContext() in [QtCore.Qt.WindowShortcut, + QtCore.Qt.ApplicationShortcut]: shortcut_valid = False - if changing_action.shortcutContext() == QtCore.Qt.WindowShortcut: + if changing_action.shortcutContext() in \ + [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: shortcut_valid = False if not shortcut_valid: QtGui.QMessageBox.warning(self, @@ -193,6 +193,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if action is None: return self.shortcutButton.setChecked(True) + self.shortcutButton.setFocus(QtCore.Qt.OtherFocusReason) self.onItemPressed(item, column) def onItemPressed(self, item, column): From 7260f91825cd8a9c8bf2567dcd7d88b789b9fc1c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 2 Apr 2011 16:22:08 +0200 Subject: [PATCH 18/76] restore butto nnow works --- openlp/core/ui/shortcutlistdialog.py | 2 +- openlp/core/ui/shortcutlistform.py | 32 +++++++++++++++++++++++++++- openlp/core/ui/slidecontroller.py | 15 ++++++------- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 467fb0534..5f8936628 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -58,7 +58,7 @@ class Ui_ShortcutListDialog(object): self.dialogLayout.addLayout(self.customLayout) self.buttonBox = QtGui.QDialogButtonBox(shortcutListDialog) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Reset) + QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.RestoreDefaults) self.buttonBox.setObjectName(u'buttonBox') self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(shortcutListDialog) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index bd4fb8ab6..14aa1d009 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -41,7 +41,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ The shortcut list dialog """ -#TODO: do not close on ESC + def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) @@ -58,6 +58,16 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.onItemDoubleClicked) QtCore.QObject.connect(self.clearShortcutButton, QtCore.SIGNAL(u'clicked(bool)'), self.onClearShortcutButtonClicked) + QtCore.QObject.connect(self.buttonBox, + QtCore.SIGNAL(u'clicked(QAbstractButton*)'), + self.onRestoreDefaultsClicked) + + def keyPressEvent(self, event): + if self.shortcutButton.isChecked(): + event.ignore() + elif event.key() == QtCore.Qt.Key_Escape: + event.accept() + self.close() def keyReleaseEvent(self, event): Qt = QtCore.Qt @@ -229,6 +239,26 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.refreshShortcutList() self.onItemPressed(item, self.column) + def onRestoreDefaultsClicked(self, button): + """ + Restores all default shortcuts. + """ + if self.buttonBox.buttonRole(button) != QtGui.QDialogButtonBox.ResetRole: + return + if QtGui.QMessageBox.question(self, + translate('OpenLP.ShortcutListDialog', 'Restore Default Shortcuts'), + translate('OpenLP.ShortcutListDialog', 'Do you want to restore all ' + 'shortcuts to their defaults?'), QtGui.QMessageBox.StandardButtons( + QtGui.QMessageBox.Yes | + QtGui.QMessageBox.No)) == QtGui.QMessageBox.No: + return + self.shortcutButton.setChecked(False) + self.shortcutButton.setText(u'') + for category in ActionList.categories: + for action in category.actions: + action.setShortcuts(action.defaultShortcuts) + self.refreshShortcutList() + def save(self): """ Save the shortcuts. **Note**, that we do not have to load the shortcuts, diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 9f486518b..1ec2e1772 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -141,19 +141,18 @@ class SlideController(QtGui.QWidget): translate('OpenLP.SlideController', 'Previous Slide'), u':/slides/slide_previous.png', translate('OpenLP.SlideController', 'Move to previous'), - self.onSlideSelectedPrevious) - self.previousItem.setObjectName(u'previousItem') - self.previousItem.setShortcuts([QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp]) - self.previousItem.setShortcutContext( - QtCore.Qt.WidgetWithChildrenShortcut) + self.onSlideSelectedPrevious, + shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], + context=QtCore.Qt.WidgetWithChildrenShortcut) + self.previousItem.setObjectName(u'previousItem') self.nextItem = self.toolbar.addToolbarButton( translate('OpenLP.SlideController', 'Next Slide'), u':/slides/slide_next.png', translate('OpenLP.SlideController', 'Move to next'), - self.onSlideSelectedNext) + self.onSlideSelectedNext, + shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], + context=QtCore.Qt.WidgetWithChildrenShortcut) self.nextItem.setObjectName(u'nextItem') - self.nextItem.setShortcuts([QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown]) - self.nextItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.toolbar.addToolbarSeparator(u'Close Separator') if self.isLive: self.hideMenu = QtGui.QToolButton(self.toolbar) From e3d822f07ad30f72b99f21410039438639faf56a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 2 Apr 2011 17:37:14 +0200 Subject: [PATCH 19/76] fixed strange save bug --- openlp/core/lib/ui.py | 17 +++++++++-------- openlp/core/ui/slidecontroller.py | 6 ++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index a02041cad..9f24da96c 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -280,17 +280,18 @@ def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, """ Return a shortcut enabled action. """ + action = QtGui.QAction(parent) + action.setObjectName(name) if icon is not None: - action = icon_action(parent, name, icon, checked, category) - elif checked is not None: - action = checkable_action(parent, name, checked, category) - else: - action = base_action(parent, name, category) + action.setIcon(build_icon(icon)) + if checked is not None: + action.setCheckable(True) + action.setChecked(checked) + action.setCheckable(True) action.setShortcuts(shortcuts) action.setShortcutContext(QtCore.Qt.WindowShortcut) - # We have to save the default shortcut again, as the action's shortcut was - # set after adding the shortcut to the action list. - action.defaultShortcuts = action.shortcuts() + if category is not None: + ActionList.add_action(action, category) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) return action diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 1ec2e1772..3fe27f4d9 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -144,7 +144,6 @@ class SlideController(QtGui.QWidget): self.onSlideSelectedPrevious, shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], context=QtCore.Qt.WidgetWithChildrenShortcut) - self.previousItem.setObjectName(u'previousItem') self.nextItem = self.toolbar.addToolbarButton( translate('OpenLP.SlideController', 'Next Slide'), u':/slides/slide_next.png', @@ -152,7 +151,6 @@ class SlideController(QtGui.QWidget): self.onSlideSelectedNext, shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], context=QtCore.Qt.WidgetWithChildrenShortcut) - self.nextItem.setObjectName(u'nextItem') self.toolbar.addToolbarSeparator(u'Close Separator') if self.isLive: self.hideMenu = QtGui.QToolButton(self.toolbar) @@ -367,10 +365,14 @@ class SlideController(QtGui.QWidget): QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged) def setPreviewHotkeys(self, parent=None): + self.previousItem.setObjectName(u'previousItemPreview') + self.nextItem.setObjectName(u'nextItemPreview') ActionList.add_action(self.previousItem, u'Preview Toolbar') ActionList.add_action(self.nextItem, u'Preview Toolbar') def setLiveHotkeys(self, parent=None): + self.previousItem.setObjectName(u'previousItemLive') + self.nextItem.setObjectName(u'nextItemLive') ActionList.add_action(self.previousItem, u'Live Toolbar') ActionList.add_action(self.nextItem, u'Live Toolbar') self.previousService = shortcut_action(parent, u'previousService', From 958155e7d75d8a86a90f0e4de1e33f9641520c37 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 2 Apr 2011 17:45:00 +0200 Subject: [PATCH 20/76] fixed alternate shortcut --- openlp/core/ui/shortcutlistform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 14aa1d009..80b9652a0 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -186,7 +186,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): shortcuts.append(action.shortcuts()[1]) # We are changing the secondary shortcut. elif self.column == 2: - if len(action.shortcuts()) == 1: + if len(action.shortcuts()) != 0: shortcuts.append(action.shortcuts()[0]) shortcuts.append(QtGui.QKeySequence(self.shortcutButton.text())) else: From 61068e26a6dce8bc7f577b716777cf3c56ef23eb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 2 Apr 2011 18:14:43 +0200 Subject: [PATCH 21/76] removed cancel button --- openlp/core/ui/shortcutlistdialog.py | 4 ++-- openlp/core/ui/shortcutlistform.py | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 5f8936628..a4bcc359e 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -57,8 +57,8 @@ class Ui_ShortcutListDialog(object): self.customLayout.addStretch() self.dialogLayout.addLayout(self.customLayout) self.buttonBox = QtGui.QDialogButtonBox(shortcutListDialog) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.RestoreDefaults) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok | + QtGui.QDialogButtonBox.RestoreDefaults) self.buttonBox.setObjectName(u'buttonBox') self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(shortcutListDialog) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 80b9652a0..84aea006a 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -63,11 +63,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.onRestoreDefaultsClicked) def keyPressEvent(self, event): - if self.shortcutButton.isChecked(): - event.ignore() - elif event.key() == QtCore.Qt.Key_Escape: - event.accept() - self.close() + event.ignore() def keyReleaseEvent(self, event): Qt = QtCore.Qt From 28b83aadaed1c66eecb628152956414a379f0f19 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 3 Apr 2011 13:36:43 +0200 Subject: [PATCH 22/76] translate categories --- openlp/core/lib/ui.py | 8 +++ openlp/core/ui/mainwindow.py | 63 +++++++++++---------- openlp/core/ui/servicemanager.py | 23 +++++--- openlp/core/ui/slidecontroller.py | 20 +++---- openlp/core/utils/actions.py | 2 + openlp/plugins/alerts/alertsplugin.py | 4 +- openlp/plugins/bibles/bibleplugin.py | 8 ++- openlp/plugins/songs/songsplugin.py | 12 ++-- openlp/plugins/songusage/songusageplugin.py | 20 ++++--- 9 files changed, 94 insertions(+), 66 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 9f24da96c..15309edc9 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -56,8 +56,10 @@ class UiStrings(object): EmptyField = translate('OpenLP.Ui', 'Empty Field') Error = translate('OpenLP.Ui', 'Error') Export = translate('OpenLP.Ui', 'Export') + File = translate('OpenLP.Ui', 'File') FontSizePtUnit = translate('OpenLP.Ui', 'pt', 'Abbreviated font pointsize unit') + Help = translate('OpenLP.Ui', 'Help') Hours = translate('OpenLP.Ui', 'h', 'The abbreviated unit for hours') Image = translate('OpenLP.Ui', 'Image') Import = translate('OpenLP.Ui', 'Import') @@ -65,6 +67,7 @@ class UiStrings(object): Live = translate('OpenLP.Ui', 'Live') LiveBGError = translate('OpenLP.Ui', 'Live Background Error') LivePanel = translate('OpenLP.Ui', 'Live Panel') + LiveToolbar = translate('OpenLP.Ui', 'Live Toolbar') Load = translate('OpenLP.Ui', 'Load') Minutes = translate('OpenLP.Ui', 'm', 'The abbreviated unit for minutes') Middle = translate('OpenLP.Ui', 'Middle') @@ -82,6 +85,7 @@ class UiStrings(object): OpenService = translate('OpenLP.Ui', 'Open Service') Preview = translate('OpenLP.Ui', 'Preview') PreviewPanel = translate('OpenLP.Ui', 'Preview Panel') + PreviewToolbar = translate('OpenLP.Ui', 'Preview Toolbar') PrintServiceOrder = translate('OpenLP.Ui', 'Print Service Order') ReplaceBG = translate('OpenLP.Ui', 'Replace Background') ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background') @@ -92,13 +96,17 @@ class UiStrings(object): Search = translate('OpenLP.Ui', 'Search') SelectDelete = translate('OpenLP.Ui', 'You must select an item to delete.') SelectEdit = translate('OpenLP.Ui', 'You must select an item to edit.') + Settings = translate('OpenLP.Ui', 'Settings') SaveService = translate('OpenLP.Ui', 'Save Service') Service = translate('OpenLP.Ui', 'Service') StartTimeCode = unicode(translate('OpenLP.Ui', 'Start %s')) Theme = translate('OpenLP.Ui', 'Theme', 'Singular') Themes = translate('OpenLP.Ui', 'Themes', 'Plural') + Tools = translate('OpenLP.Ui', 'Tools') Top = translate('OpenLP.Ui', 'Top') Version = translate('OpenLP.Ui', 'Version') + View = translate('OpenLP.Ui', 'View') + ViewMode = translate('OpenLP.Ui', 'View Model') def add_welcome_page(parent, image): """ diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 458e8814f..bb6d105b9 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -164,69 +164,72 @@ class Ui_MainWindow(object): self.FileNewItem = shortcut_action(mainWindow, u'FileNewItem', [QtGui.QKeySequence(u'Ctrl+N')], self.ServiceManagerContents.onNewServiceClicked, - u':/general/general_new.png', category=u'File') + u':/general/general_new.png', category=UiStrings.File) self.FileOpenItem = shortcut_action(mainWindow, u'FileOpenItem', [QtGui.QKeySequence(u'Ctrl+O')], self.ServiceManagerContents.onLoadServiceClicked, - u':/general/general_open.png', category=u'File') + u':/general/general_open.png', category=UiStrings.File) self.FileSaveItem = shortcut_action(mainWindow, u'FileSaveItem', [QtGui.QKeySequence(u'Ctrl+S')], self.ServiceManagerContents.saveFile, - u':/general/general_save.png', category=u'File') + u':/general/general_save.png', category=UiStrings.File) self.FileSaveAsItem = shortcut_action(mainWindow, u'FileSaveAsItem', [QtGui.QKeySequence(u'Ctrl+Shift+S')], - self.ServiceManagerContents.saveFileAs, category=u'File') + self.ServiceManagerContents.saveFileAs, category=UiStrings.File) self.printServiceOrderItem = shortcut_action(mainWindow, u'printServiceItem', [QtGui.QKeySequence(u'Ctrl+P')], - self.ServiceManagerContents.printServiceOrder, category=u'File') + self.ServiceManagerContents.printServiceOrder, + category=UiStrings.File) self.FileExitItem = shortcut_action(mainWindow, u'FileExitItem', [QtGui.QKeySequence(u'Alt+F4')], mainWindow.close, - u':/system/system_exit.png', category=u'File') + u':/system/system_exit.png', category=UiStrings.File) self.ImportThemeItem = base_action( - mainWindow, u'ImportThemeItem', u'Import') + mainWindow, u'ImportThemeItem', UiStrings.Import) self.ImportLanguageItem = base_action( - mainWindow, u'ImportLanguageItem')#, u'Import') + mainWindow, u'ImportLanguageItem')#, UiStrings.Import) self.ExportThemeItem = base_action( - mainWindow, u'ExportThemeItem', u'Export') + mainWindow, u'ExportThemeItem', UiStrings.Export) self.ExportLanguageItem = base_action( - mainWindow, u'ExportLanguageItem')#, u'Export') + mainWindow, u'ExportLanguageItem')#, UiStrings.Export) self.ViewMediaManagerItem = shortcut_action(mainWindow, u'ViewMediaManagerItem', [QtGui.QKeySequence(u'F8')], self.toggleMediaManager, u':/system/system_mediamanager.png', - self.mediaManagerDock.isVisible(), u'View') + self.mediaManagerDock.isVisible(), UiStrings.View) self.ViewThemeManagerItem = shortcut_action(mainWindow, u'ViewThemeManagerItem', [QtGui.QKeySequence(u'F10')], self.toggleThemeManager, u':/system/system_thememanager.png', - self.themeManagerDock.isVisible(), u'View') + self.themeManagerDock.isVisible(), UiStrings.View) self.ViewServiceManagerItem = shortcut_action(mainWindow, u'ViewServiceManagerItem', [QtGui.QKeySequence(u'F9')], self.toggleServiceManager, u':/system/system_servicemanager.png', - self.serviceManagerDock.isVisible(), u'View') + self.serviceManagerDock.isVisible(), UiStrings.View) self.ViewPreviewPanel = shortcut_action(mainWindow, u'ViewPreviewPanel', [QtGui.QKeySequence(u'F11')], - self.setPreviewPanelVisibility, checked=previewVisible, category=u'View') + self.setPreviewPanelVisibility, checked=previewVisible, + category=UiStrings.View) self.ViewLivePanel = shortcut_action(mainWindow, u'ViewLivePanel', [QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility, - checked=liveVisible, category=u'View') + checked=liveVisible, category=UiStrings.View) self.ModeDefaultItem = checkable_action( - mainWindow, u'ModeDefaultItem', category=u'View Mode') + mainWindow, u'ModeDefaultItem', category=UiStrings.ViewMode) self.ModeSetupItem = checkable_action( - mainWindow, u'ModeLiveItem', category=u'View Mode') + mainWindow, u'ModeLiveItem', category=UiStrings.ViewMode) self.ModeLiveItem = checkable_action( - mainWindow, u'ModeLiveItem', True, u'View Mode') + mainWindow, u'ModeLiveItem', True, UiStrings.ViewMode) self.ModeGroup = QtGui.QActionGroup(mainWindow) self.ModeGroup.addAction(self.ModeDefaultItem) self.ModeGroup.addAction(self.ModeSetupItem) self.ModeGroup.addAction(self.ModeLiveItem) self.ModeDefaultItem.setChecked(True) self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem', - u':/tools/tools_add.png', category=u'Tools') - self.ToolsOpenDataFolder = icon_action(mainWindow, u'ToolsOpenDataFolder', - u':/general/general_open.png', category=u'Tools') + u':/tools/tools_add.png', category=UiStrings.Tools) + self.ToolsOpenDataFolder = icon_action(mainWindow, + u'ToolsOpenDataFolder', u':/general/general_open.png', + category=UiStrings.Tools) self.settingsPluginListItem = shortcut_action(mainWindow, u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')], self.onPluginItemClicked, u':/system/settings_plugin_list.png', - category=u'Settings') + category=UiStrings.Settings) # i18n Language Items self.AutoLanguageItem = checkable_action(mainWindow, u'AutoLanguageItem', LanguageManager.auto_language) @@ -242,23 +245,25 @@ class Ui_MainWindow(object): add_actions(self.LanguageGroup, [languageItem]) self.SettingsShortcutsItem = icon_action(mainWindow, u'SettingsShortcutsItem', - u':/system/system_configure_shortcuts.png', category=u'Settings') + u':/system/system_configure_shortcuts.png', + category=UiStrings.Settings) self.DisplayTagItem = icon_action(mainWindow, - u'DisplayTagItem', u':/system/tag_editor.png', category=u'Settings') + u'DisplayTagItem', u':/system/tag_editor.png', + category=UiStrings.Settings) self.SettingsConfigureItem = icon_action(mainWindow, u'SettingsConfigureItem', u':/system/system_settings.png', - category=u'Settings') + category=UiStrings.Settings) self.HelpDocumentationItem = icon_action(mainWindow, u'HelpDocumentationItem', u':/system/system_help_contents.png', - category=None)#u'Help') + category=None)#UiStrings.Help) self.HelpDocumentationItem.setEnabled(False) self.HelpAboutItem = shortcut_action(mainWindow, u'HelpAboutItem', [QtGui.QKeySequence(u'Ctrl+F1')], self.onHelpAboutItemClicked, - u':/system/system_about.png', category=u'Help') + u':/system/system_about.png', category=UiStrings.Help) self.HelpOnlineHelpItem = base_action( - mainWindow, u'HelpOnlineHelpItem', category=u'Help') + mainWindow, u'HelpOnlineHelpItem', category=UiStrings.Help) self.helpWebSiteItem = base_action( - mainWindow, u'helpWebSiteItem', category=u'Help') + mainWindow, u'helpWebSiteItem', category=UiStrings.Help) add_actions(self.FileImportMenu, (self.ImportThemeItem, self.ImportLanguageItem)) add_actions(self.FileExportMenu, diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 8d6062ab1..9daa1d8a2 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -167,7 +167,8 @@ class ServiceManager(QtGui.QWidget): 'Move item to the top of the service.'), self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home]) self.serviceManagerList.moveTop.setObjectName(u'moveTop') - ActionList.add_action(self.serviceManagerList.moveTop, u'Service') + ActionList.add_action( + self.serviceManagerList.moveTop, UiStrings.Service) self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &up'), u':/services/service_up.png', @@ -175,7 +176,7 @@ class ServiceManager(QtGui.QWidget): 'Move item up one position in the service.'), self.onServiceUp, shortcuts=[QtCore.Qt.Key_PageUp]) self.serviceManagerList.moveUp.setObjectName(u'moveUp') - ActionList.add_action(self.serviceManagerList.moveUp, u'Service') + ActionList.add_action(self.serviceManagerList.moveUp, UiStrings.Service) self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &down'), u':/services/service_down.png', @@ -183,7 +184,8 @@ class ServiceManager(QtGui.QWidget): 'Move item down one position in the service.'), self.onServiceDown, shortcuts=[QtCore.Qt.Key_PageDown]) self.serviceManagerList.moveDown.setObjectName(u'moveDown') - ActionList.add_action(self.serviceManagerList.moveDown, u'Service') + ActionList.add_action( + self.serviceManagerList.moveDown, UiStrings.Service) self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move to &bottom'), u':/services/service_bottom.png', @@ -191,7 +193,8 @@ class ServiceManager(QtGui.QWidget): 'Move item to the end of the service.'), self.onServiceEnd, shortcuts=[QtCore.Qt.Key_End]) self.serviceManagerList.moveBottom.setObjectName(u'moveBottom') - ActionList.add_action(self.serviceManagerList.moveBottom, u'Service') + ActionList.add_action( + self.serviceManagerList.moveBottom, UiStrings.Service) self.serviceManagerList.down = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &down'), None, @@ -199,7 +202,7 @@ class ServiceManager(QtGui.QWidget): 'Moves the selection down the window.'), self.onMoveSelectionDown, shortcuts=[QtCore.Qt.Key_Down]) self.serviceManagerList.down.setObjectName(u'down') - ActionList.add_action(self.serviceManagerList.down, u'Service') + ActionList.add_action(self.serviceManagerList.down, UiStrings.Service) self.serviceManagerList.down.setVisible(False) self.serviceManagerList.up = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move up'), @@ -208,7 +211,7 @@ class ServiceManager(QtGui.QWidget): 'Moves the selection up the window.'), self.onMoveSelectionUp, shortcuts=[QtCore.Qt.Key_Up]) self.serviceManagerList.up.setObjectName(u'up') - ActionList.add_action(self.serviceManagerList.up, u'Service') + ActionList.add_action(self.serviceManagerList.up, UiStrings.Service) self.serviceManagerList.up.setVisible(False) self.orderToolbar.addSeparator() self.serviceManagerList.delete = self.orderToolbar.addToolbarButton( @@ -225,7 +228,7 @@ class ServiceManager(QtGui.QWidget): 'Expand all the service items.'), self.onExpandAll, shortcuts=[QtCore.Qt.Key_Plus]) self.serviceManagerList.expand.setObjectName(u'expand') - ActionList.add_action(self.serviceManagerList.expand, u'Service') + ActionList.add_action(self.serviceManagerList.expand, UiStrings.Service) self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', '&Collapse all'), u':/services/service_collapse_all.png', @@ -233,7 +236,8 @@ class ServiceManager(QtGui.QWidget): 'Collapse all the service items.'), self.onCollapseAll, shortcuts=[QtCore.Qt.Key_Minus]) self.serviceManagerList.collapse.setObjectName(u'collapse') - ActionList.add_action(self.serviceManagerList.collapse, u'Service') + ActionList.add_action( + self.serviceManagerList.collapse, UiStrings.Service) self.orderToolbar.addSeparator() self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Go Live'), @@ -242,7 +246,8 @@ class ServiceManager(QtGui.QWidget): 'Send the selected item to Live.'), self.makeLive, shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]) self.serviceManagerList.makeLive.setObjectName(u'orderToolbar') - ActionList.add_action(self.serviceManagerList.makeLive, u'Service') + ActionList.add_action( + self.serviceManagerList.makeLive, UiStrings.Service) self.layout.addWidget(self.orderToolbar) # Connect up our signals and slots QtCore.QObject.connect(self.themeComboBox, diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 3fe27f4d9..af94eb425 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -161,18 +161,18 @@ class SlideController(QtGui.QWidget): 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, u'Live Toolbar') + u':/slides/slide_blank.png', False, 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, u'Live Toolbar') + u':/slides/slide_theme.png', False, 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, - u'Live Toolbar') + UiStrings.LiveToolbar) self.desktopScreen.setText( translate('OpenLP.SlideController', 'Show Desktop')) self.hideMenu.setDefaultAction(self.blankScreen) @@ -367,26 +367,26 @@ class SlideController(QtGui.QWidget): def setPreviewHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') - ActionList.add_action(self.previousItem, u'Preview Toolbar') - ActionList.add_action(self.nextItem, u'Preview Toolbar') + ActionList.add_action(self.previousItem, UiStrings.PreviewToolbar) + ActionList.add_action(self.nextItem, UiStrings.PreviewToolbar) def setLiveHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemLive') self.nextItem.setObjectName(u'nextItemLive') - ActionList.add_action(self.previousItem, u'Live Toolbar') - ActionList.add_action(self.nextItem, u'Live Toolbar') + ActionList.add_action(self.previousItem, UiStrings.LiveToolbar) + ActionList.add_action(self.nextItem, UiStrings.LiveToolbar) self.previousService = shortcut_action(parent, u'previousService', - [QtCore.Qt.Key_Left], self.servicePrevious, u'Live Toolbar') + [QtCore.Qt.Key_Left], self.servicePrevious, UiStrings.LiveToolbar) self.previousService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.previousService.setText( translate('OpenLP.SlideController', 'Previous Service')) self.nextService = shortcut_action(parent, 'nextService', - [QtCore.Qt.Key_Right], self.serviceNext, u'Live Toolbar') + [QtCore.Qt.Key_Right], self.serviceNext, UiStrings.LiveToolbar) self.nextService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.nextService.setText( translate('OpenLP.SlideController', 'Next Service')) self.escapeItem = shortcut_action(parent, 'escapeItem', - [QtCore.Qt.Key_Escape], self.liveEscape, u'Live Toolbar') + [QtCore.Qt.Key_Escape], self.liveEscape, UiStrings.LiveToolbar) self.escapeItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.escapeItem.setText( translate('OpenLP.SlideController', 'Escape Item')) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 7421db30e..04cb1f091 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -190,6 +190,7 @@ class ActionList(object): @staticmethod def add_action(action, category, weight=None): + category = unicode(category) if category not in ActionList.categories: ActionList.categories.append(category) action.defaultShortcuts = action.shortcuts() @@ -208,6 +209,7 @@ class ActionList(object): @staticmethod def remove_action(action, category): + category = unicode(category) if category not in ActionList.categories: return ActionList.categories[category].actions.remove(action) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 45e1969f4..d564a9754 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -30,7 +30,7 @@ from PyQt4 import QtCore, QtGui 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 +from openlp.core.lib.ui import icon_action, UiStrings from openlp.core.utils.actions import ActionList from openlp.plugins.alerts.lib import AlertsManager, AlertsTab from openlp.plugins.alerts.lib.db import init_schema @@ -75,7 +75,7 @@ class AlertsPlugin(Plugin): log.info(u'Alerts Initialising') Plugin.initialise(self) self.toolsAlertItem.setVisible(True) - ActionList.add_action(self.toolsAlertItem, u'Tools') + ActionList.add_action(self.toolsAlertItem, UiStrings.Tools) self.liveController.alertTab = self.settings_tab def finalise(self): diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 1396d4550..60be388ba 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -29,7 +29,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate -from openlp.core.lib.ui import base_action +from openlp.core.lib.ui import base_action, UiStrings from openlp.core.utils.actions import ActionList from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem @@ -52,9 +52,9 @@ class BiblePlugin(Plugin): self.manager = BibleManager(self) Plugin.initialise(self) self.importBibleItem.setVisible(True) - ActionList.add_action(self.importBibleItem, u'Import') + ActionList.add_action(self.importBibleItem, UiStrings.Import) # Do not add the action to the list yet. - #ActionList.add_action(self.exportBibleItem, u'Export') + #ActionList.add_action(self.exportBibleItem, UiStrings.Export) # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) @@ -65,7 +65,9 @@ class BiblePlugin(Plugin): log.info(u'Plugin Finalise') self.manager.finalise() Plugin.finalise(self) + ActionList.remove_action(self.importBibleItem, UiStrings.Import) self.importBibleItem.setVisible(False) + #ActionList.remove_action(self.exportBibleItem, UiStrings.Export) self.exportBibleItem.setVisible(False) def addImportMenuItem(self, import_menu): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index de0714d5e..a3230ff7f 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -66,9 +66,9 @@ class SongsPlugin(Plugin): log.info(u'Songs Initialising') Plugin.initialise(self) self.toolsReindexItem.setVisible(True) - ActionList.add_action(self.SongImportItem, u'Import') - ActionList.add_action(self.SongExportItem, u'Export') - ActionList.add_action(self.toolsReindexItem, u'Tools') + ActionList.add_action(self.SongImportItem, UiStrings.Import) + ActionList.add_action(self.SongExportItem, UiStrings.Export) + ActionList.add_action(self.toolsReindexItem, UiStrings.Tools) self.mediaItem.displayResultsSong( self.manager.get_all_objects(Song, order_by_ref=Song.search_title)) @@ -258,7 +258,7 @@ class SongsPlugin(Plugin): log.info(u'Songs Finalising') self.manager.finalise() self.toolsReindexItem.setVisible(False) - ActionList.remove_action(self.SongImportItem, u'Import') - ActionList.remove_action(self.SongExportItem, u'Export') - ActionList.remove_action(self.toolsReindexItem, u'Tools') + ActionList.remove_action(self.SongImportItem, UiStrings.Import) + ActionList.remove_action(self.SongExportItem, UiStrings.Export) + ActionList.remove_action(self.toolsReindexItem, UiStrings.Tools) Plugin.finalise(self) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 2e55a23c0..b0a545ad8 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui 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 base_action, shortcut_action, UiStrings from openlp.core.utils.actions import ActionList from openlp.plugins.songusage.forms import SongUsageDetailForm, \ SongUsageDeleteForm @@ -110,9 +110,12 @@ class SongUsagePlugin(Plugin): self.settingsSection + u'/active', QtCore.QVariant(False)).toBool() self.SongUsageStatus.setChecked(self.SongUsageActive) - ActionList.add_action(self.SongUsageDelete, u'Song Usage') - ActionList.add_action(self.SongUsageReport, u'Song Usage') - ActionList.add_action(self.SongUsageStatus, u'Song Usage') + ActionList.add_action(self.SongUsageDelete, + translate('SongUsagePlugin', 'Song Usage')) + ActionList.add_action(self.SongUsageReport, + translate('SongUsagePlugin', 'Song Usage')) + ActionList.add_action(self.SongUsageStatus, + translate('SongUsagePlugin', 'Song Usage')) if self.manager is None: self.manager = Manager(u'songusage', init_schema) self.SongUsagedeleteform = SongUsageDeleteForm(self.manager, @@ -128,9 +131,12 @@ class SongUsagePlugin(Plugin): self.manager.finalise() Plugin.finalise(self) self.SongUsageMenu.menuAction().setVisible(False) - ActionList.remove_action(self.SongUsageDelete, u'Song Usage') - ActionList.remove_action(self.SongUsageReport, u'Song Usage') - ActionList.remove_action(self.SongUsageStatus, u'Song Usage') + ActionList.remove_action(self.SongUsageDelete, + translate('SongUsagePlugin', 'Song Usage')) + ActionList.remove_action(self.SongUsageReport, + translate('SongUsagePlugin', 'Song Usage')) + ActionList.remove_action(self.SongUsageStatus, + translate('SongUsagePlugin', 'Song Usage')) #stop any events being processed self.SongUsageActive = False From 0a5b3b2c2d460f06eacd6bb3debbc17fc3b4f5fc Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 3 Apr 2011 15:24:51 +0200 Subject: [PATCH 23/76] --- openlp/core/lib/ui.py | 1 - openlp/core/ui/shortcutlistdialog.py | 17 +++++-- openlp/core/ui/shortcutlistform.py | 70 ++++++++++++++++++---------- 3 files changed, 59 insertions(+), 29 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 15309edc9..029bb34df 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -295,7 +295,6 @@ def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, if checked is not None: action.setCheckable(True) action.setChecked(checked) - action.setCheckable(True) action.setShortcuts(shortcuts) action.setShortcutContext(QtCore.Qt.WindowShortcut) if category is not None: diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index a4bcc359e..1004014d6 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -34,6 +34,9 @@ class Ui_ShortcutListDialog(object): shortcutListDialog.setObjectName(u'shortcutListDialog') self.dialogLayout = QtGui.QVBoxLayout(shortcutListDialog) self.dialogLayout.setObjectName(u'dialogLayout') + self.descriptionLabel = QtGui.QLabel(shortcutListDialog); + self.descriptionLabel.setObjectName(u'descriptionLabel') + self.dialogLayout.addWidget(self.descriptionLabel) self.treeWidget = QtGui.QTreeWidget(shortcutListDialog) self.treeWidget.setAlternatingRowColors(True) self.treeWidget.setObjectName(u'treeWidget') @@ -57,8 +60,8 @@ class Ui_ShortcutListDialog(object): self.customLayout.addStretch() self.dialogLayout.addLayout(self.customLayout) self.buttonBox = QtGui.QDialogButtonBox(shortcutListDialog) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok | - QtGui.QDialogButtonBox.RestoreDefaults) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | + QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.RestoreDefaults) self.buttonBox.setObjectName(u'buttonBox') self.dialogLayout.addWidget(self.buttonBox) self.retranslateUi(shortcutListDialog) @@ -71,9 +74,15 @@ class Ui_ShortcutListDialog(object): def retranslateUi(self, shortcutListDialog): shortcutListDialog.setWindowTitle( translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts')) + self.descriptionLabel.setText(translate('OpenLP.ShortcutListDialog', + 'Select an action and click the button below to start capturing ' + 'a new shortcut.')) self.treeWidget.setHeaderLabels([ translate('OpenLP.ShortcutListDialog', 'Action'), translate('OpenLP.ShortcutListDialog', 'Shortcut'), translate('OpenLP.ShortcutListDialog', 'Alternate')]) - self.shortcutButton.setText( - translate('OpenLP.ShortcutListDialog', 'None')) + self.shortcutButton.setToolTip( + translate('OpenLP.ShortcutListDialog', 'Capture shortcut.')) + self.clearShortcutButton.setToolTip( + translate('OpenLP.ShortcutListDialog', + 'Restore the default shortcut(s) of this action.')) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 84aea006a..58b42a351 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -46,6 +46,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): QtGui.QDialog.__init__(self, parent) self.setupUi(self) self.column = -1 + self.changedActions = {} self.shortcutButton.setText(u'') self.shortcutButton.setEnabled(False) QtCore.QObject.connect(self.shortcutButton, @@ -63,7 +64,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.onRestoreDefaultsClicked) def keyPressEvent(self, event): - event.ignore() + if self.shortcutButton.isChecked(): + event.ignore() + elif event.key() == QtCore.Qt.Key_Escape: + event.accept() + self.close() def keyReleaseEvent(self, event): Qt = QtCore.Qt @@ -87,7 +92,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): shortcut_valid = True for category in ActionList.categories: for action in category.actions: - shortcuts = action.shortcuts() + shortcuts = self._actionShortcuts(action) if key_sequence not in shortcuts: continue if action is changing_action: @@ -116,6 +121,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.shortcutButton.setChecked(False) def exec_(self): + self.changedActions = {} self.reloadShortcutList() self.shortcutButton.setChecked(False) self.shortcutButton.setEnabled(False) @@ -152,15 +158,16 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): action = item.data(0, QtCore.Qt.UserRole).toPyObject() if action is None: continue - if len(action.shortcuts()) == 0: + shortcuts = self._actionShortcuts(action) + if len(shortcuts) == 0: item.setText(1, u'') item.setText(2, u'') - elif len(action.shortcuts()) == 1: - item.setText(1, action.shortcuts()[0].toString()) + elif len(shortcuts) == 1: + item.setText(1, shortcuts[0].toString()) item.setText(2, u'') else: - item.setText(1, action.shortcuts()[0].toString()) - item.setText(2, action.shortcuts()[1].toString()) + item.setText(1, shortcuts[0].toString()) + item.setText(2, shortcuts[1].toString()) def onShortcutButtonClicked(self, toggled): """ @@ -174,20 +181,21 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): action = item.data(0, QtCore.Qt.UserRole).toPyObject() if action is None: return - shortcuts = [] + shortcuts = self._actionShortcuts(action) + new_shortcuts = [] # We are changing the primary shortcut. - if self.column == 1: - shortcuts.append(QtGui.QKeySequence(self.shortcutButton.text())) - if len(action.shortcuts()) == 2: - shortcuts.append(action.shortcuts()[1]) + if self.column in [0, 1]: + new_shortcuts.append(QtGui.QKeySequence(self.shortcutButton.text())) + if len(shortcuts) == 2: + new_shortcuts.append(shortcuts[1]) # We are changing the secondary shortcut. elif self.column == 2: - if len(action.shortcuts()) != 0: - shortcuts.append(action.shortcuts()[0]) - shortcuts.append(QtGui.QKeySequence(self.shortcutButton.text())) + if len(shortcuts) != 0: + new_shortcuts.append(shortcuts[0]) + new_shortcuts.append(QtGui.QKeySequence(self.shortcutButton.text())) else: return - action.setShortcuts(shortcuts) + self.changedActions[action] = new_shortcuts self.refreshShortcutList() def onItemDoubleClicked(self, item, column): @@ -209,15 +217,17 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ self.column = column action = item.data(0, QtCore.Qt.UserRole).toPyObject() - self.shortcutButton.setEnabled(True) text = u'' - if action is None or column not in [1, 2]: + if action is None:# or column not in [1, 2]: self.shortcutButton.setChecked(False) self.shortcutButton.setEnabled(False) - elif column == 1 and len(action.shortcuts()) != 0: - text = action.shortcuts()[0].toString() - elif len(action.shortcuts()) == 2 and len(action.shortcuts()) != 0: - text = action.shortcuts()[1].toString() + else: + self.shortcutButton.setEnabled(True) + shortcuts = self._actionShortcuts(action) + if column != 2 and len(shortcuts) != 0: + text = shortcuts[0].toString() + elif len(shortcuts) == 2: + text = shortcuts[1].toString() self.shortcutButton.setText(text) def onClearShortcutButtonClicked(self, toggled): @@ -231,7 +241,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): action = item.data(0, QtCore.Qt.UserRole).toPyObject() if action is None: return - action.setShortcuts(action.defaultShortcuts) + self.changedActions[action] = action.defaultShortcuts self.refreshShortcutList() self.onItemPressed(item, self.column) @@ -252,7 +262,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.shortcutButton.setText(u'') for category in ActionList.categories: for action in category.actions: - action.setShortcuts(action.defaultShortcuts) + self.changedActions[action] = action.defaultShortcuts self.refreshShortcutList() def save(self): @@ -264,6 +274,18 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): settings.beginGroup(u'shortcuts') for category in ActionList.categories: for action in category.actions: + if self.changedActions .has_key(action): + action.setShortcuts(self.changedActions[action]) settings.setValue( action.objectName(), QtCore.QVariant(action.shortcuts())) settings.endGroup() + + def _actionShortcuts(self, action): + """ + This returns the shortcuts for the given ``action``, which also includes + those shortcuts which are not yet assigned to an action (as changes are + applied when closing the dialog). + """ + if self.changedActions.has_key(action): + return self.changedActions[action] + return action.shortcuts() From 65f134ab1b6ce8993359b2346a8fe1d5c7d46c06 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 3 Apr 2011 15:36:59 +0200 Subject: [PATCH 24/76] removed fix (I'll deal with this in another branch) --- openlp/core/ui/slidecontroller.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index af94eb425..66c26da3b 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -1108,11 +1108,11 @@ class SlideController(QtGui.QWidget): screen hide attributes """ blank = None - if self.blankScreen.isChecked(): + if self.blankScreen.isChecked: blank = self.blankScreen - if self.themeScreen.isChecked(): + if self.themeScreen.isChecked: blank = self.themeScreen - if self.desktopScreen.isChecked(): + if self.desktopScreen.isChecked: blank = self.desktopScreen if blank: blank.setChecked(False) From dfc2eed1f4206fd57529351574188445c85c3317 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 3 Apr 2011 16:20:55 +0200 Subject: [PATCH 25/76] adapted latest merge --- openlp/core/lib/__init__.py | 4 +++- openlp/core/ui/servicemanager.py | 4 ++-- openlp/core/ui/shortcutlistform.py | 8 +++++++- openlp/core/utils/actions.py | 30 ++++++++++++++++++++++++++---- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index e62cb3e44..0f0fcca5e 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -186,8 +186,9 @@ def context_menu_action(base, icon, text, slot, shortcuts=None): if icon: action.setIcon(build_icon(icon)) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot) - if shortcuts: + if shortcuts is not None: action.setShortcuts(shortcuts) + ActionList.add_action(action) return action def context_menu(base, icon, text): @@ -343,3 +344,4 @@ from dockwidget import OpenLPDockWidget from renderer import Renderer from rendermanager import RenderManager from mediamanageritem import MediaManagerItem +from openlp.core.utils.actions import ActionList diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 3ea3f1a6b..fc20d0f2d 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -202,7 +202,7 @@ class ServiceManager(QtGui.QWidget): 'Moves the selection down the window.'), self.onMoveSelectionDown, shortcuts=[QtCore.Qt.Key_Down]) self.serviceManagerList.down.setObjectName(u'down') - ActionList.add_action(self.serviceManagerList.down, UiStrings.Service) + ActionList.add_action(self.serviceManagerList.down) self.serviceManagerList.down.setVisible(False) self.serviceManagerList.up = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move up'), @@ -211,7 +211,7 @@ class ServiceManager(QtGui.QWidget): 'Moves the selection up the window.'), self.onMoveSelectionUp, shortcuts=[QtCore.Qt.Key_Up]) self.serviceManagerList.up.setObjectName(u'up') - ActionList.add_action(self.serviceManagerList.up, UiStrings.Service) + ActionList.add_action(self.serviceManagerList.up) self.serviceManagerList.up.setVisible(False) self.orderToolbar.addSeparator() self.serviceManagerList.delete = self.orderToolbar.addToolbarButton( diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 58b42a351..5251ac314 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -134,6 +134,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ self.treeWidget.clear() for category in ActionList.categories: + # Check if the category is for internal use only. + if category.name is None: + continue item = QtGui.QTreeWidgetItem([category.name]) for action in category.actions: actionText = REMOVE_AMPERSAND.sub('', unicode(action.text())) @@ -218,7 +221,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.column = column action = item.data(0, QtCore.Qt.UserRole).toPyObject() text = u'' - if action is None:# or column not in [1, 2]: + if action is None: self.shortcutButton.setChecked(False) self.shortcutButton.setEnabled(False) else: @@ -273,6 +276,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') for category in ActionList.categories: + # Check if the category is for internal use only. + if category.name is None: + continue for action in category.actions: if self.changedActions .has_key(action): action.setShortcuts(self.changedActions[action]) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 04cb1f091..efac7b1bd 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -189,8 +189,26 @@ class ActionList(object): categories = CategoryList() @staticmethod - def add_action(action, category, weight=None): - category = unicode(category) + def add_action(action, category=None, weight=None): + """ + Add an action to the list of actions. + + ``action`` + The action to add (QAction). + + ``category`` + The category this action belongs to. The category can be a QString + or python unicode string. **Note**, if the category is ``None``, the + category and its actions are being hidden in the shortcut dialog. + However, if they are added, it is possible to avoid assigning + shortcuts twice, which is important. + + ``weight`` + The weight specifies how important a category is. However, this only + has an impact on the order the categories are displayed. + """ + if category is not None: + category = unicode(category) if category not in ActionList.categories: ActionList.categories.append(category) action.defaultShortcuts = action.shortcuts() @@ -198,6 +216,9 @@ class ActionList(object): ActionList.categories[category].actions.append(action) else: ActionList.categories[category].actions.add(action, weight) + if category is None: + # Stop here, as this action is not configurable. + return # Load the shortcut from the config. settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') @@ -208,8 +229,9 @@ class ActionList(object): settings.endGroup() @staticmethod - def remove_action(action, category): - category = unicode(category) + def remove_action(action, category=None): + if category is not None: + category = unicode(category) if category not in ActionList.categories: return ActionList.categories[category].actions.remove(action) From 84605fb43054fadcd4c9690147bf8b62f9f8d9bd Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 4 Apr 2011 16:38:17 +0200 Subject: [PATCH 26/76] fixed wrong context of shortcuts; moved functions --- openlp/core/lib/__init__.py | 53 --------------------- openlp/core/lib/mediamanageritem.py | 23 +++++---- openlp/core/lib/ui.py | 72 +++++++++++++++++++++++++++-- openlp/core/ui/servicemanager.py | 8 ++-- 4 files changed, 85 insertions(+), 71 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 0f0fcca5e..491f3e652 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -166,59 +166,6 @@ def build_icon(icon): QtGui.QIcon.Normal, QtGui.QIcon.Off) return button_icon -def context_menu_action(base, icon, text, slot, shortcuts=None): - """ - Utility method to help build context menus for plugins - - ``base`` - The parent menu to add this menu item to - - ``icon`` - An icon for this action - - ``text`` - The text to display for this action - - ``slot`` - The code to run when this action is triggered - """ - action = QtGui.QAction(text, base) - if icon: - action.setIcon(build_icon(icon)) - QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot) - if shortcuts is not None: - action.setShortcuts(shortcuts) - ActionList.add_action(action) - return action - -def context_menu(base, icon, text): - """ - Utility method to help build context menus for plugins - - ``base`` - The parent object to add this menu to - - ``icon`` - An icon for this menu - - ``text`` - The text to display for this menu - """ - action = QtGui.QMenu(text, base) - action.setIcon(build_icon(icon)) - return action - -def context_menu_separator(base): - """ - Add a separator to a context menu - - ``base`` - The menu object to add the separator to - """ - action = QtGui.QAction(u'', base) - action.setSeparator(True) - return action - def image_to_byte(image): """ Resize an image to fit on the current screen for the web and returns diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 63132b141..13277876d 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -31,10 +31,10 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import context_menu_action, context_menu_separator, \ - SettingsManager, OpenLPToolbar, ServiceItem, StringContent, build_icon, \ - translate, Receiver, ListWidgetWithDnD -from openlp.core.lib.ui import UiStrings +from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \ + StringContent, build_icon, translate, Receiver, ListWidgetWithDnD +from openlp.core.lib.ui import UiStrings, context_menu_action, \ + context_menu_separator log = logging.getLogger(__name__) @@ -260,39 +260,42 @@ class MediaManagerItem(QtGui.QWidget): context_menu_action( self.listView, u':/general/general_edit.png', self.plugin.getString(StringContent.Edit)[u'title'], - self.onEditClick)) + self.onEditClick, context=QtCore.Qt.WidgetShortcut)) self.listView.addAction(context_menu_separator(self.listView)) if self.hasDeleteIcon: self.listView.addAction( context_menu_action( self.listView, u':/general/general_delete.png', self.plugin.getString(StringContent.Delete)[u'title'], - self.onDeleteClick, [QtCore.Qt.Key_Delete])) + self.onDeleteClick, [QtCore.Qt.Key_Delete], + context=QtCore.Qt.WidgetShortcut)) self.listView.addAction(context_menu_separator(self.listView)) self.listView.addAction( context_menu_action( self.listView, u':/general/general_preview.png', self.plugin.getString(StringContent.Preview)[u'title'], - self.onPreviewClick, [QtCore.Qt.Key_Enter])) + self.onPreviewClick, [QtCore.Qt.Key_Enter], + context=QtCore.Qt.WidgetShortcut)) self.listView.addAction( 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])) + QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut)) self.listView.addAction( 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])) + self.onAddClick, [QtCore.Qt.Key_Plus, QtCore.Qt.Key_Equal], + context=QtCore.Qt.WidgetShortcut)) if self.addToServiceItem: self.listView.addAction( context_menu_action( self.listView, u':/general/general_add.png', translate('OpenLP.MediaManagerItem', '&Add to selected Service Item'), - self.onAddEditClick)) + self.onAddEditClick, context=QtCore.Qt.WidgetShortcut)) QtCore.QObject.connect(self.listView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onClickPressed) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 029bb34df..35ea23497 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -284,7 +284,7 @@ def icon_action(parent, name, icon, checked=None, category=None): return action def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, - category=None): + category=None, context=QtCore.Qt.WindowShortcut): """ Return a shortcut enabled action. """ @@ -296,12 +296,76 @@ def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, action.setCheckable(True) action.setChecked(checked) action.setShortcuts(shortcuts) - action.setShortcutContext(QtCore.Qt.WindowShortcut) - if category is not None: - ActionList.add_action(action, category) + action.setShortcutContext(context) + ActionList.add_action(action, category) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) return action +def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, + context=QtCore.Qt.WindowShortcut): + """ + Utility method to help build context menus for plugins + + ``base`` + The parent menu to add this menu item to + + ``icon`` + An icon for this action + + ``text`` + The text to display for this action + + ``slot`` + The code to run when this action is triggered + + ``shortcuts`` + The action's shortcuts. + + ``category`` + The category the shortcut should be listed in the shortcut dialog. If + left to None, then the action will be hidden in the shortcut dialog. + + ``context`` + The context the shortcut is valid. + """ + action = QtGui.QAction(text, base) + if icon: + action.setIcon(build_icon(icon)) + QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot) + if shortcuts is not None: + action.setShortcuts(shortcuts) + action.setShortcutContext(context) + ActionList.add_action(action) + return action + +def context_menu(base, icon, text): + """ + Utility method to help build context menus for plugins + + ``base`` + The parent object to add this menu to + + ``icon`` + An icon for this menu + + ``text`` + The text to display for this menu + """ + action = QtGui.QMenu(text, base) + action.setIcon(build_icon(icon)) + return action + +def context_menu_separator(base): + """ + Add a separator to a context menu + + ``base`` + The menu object to add the separator to + """ + action = QtGui.QAction(u'', base) + action.setSeparator(True) + return action + def add_widget_completer(cache, widget): """ Adds a text autocompleter to a widget. diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index fc20d0f2d..caecaca50 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -32,10 +32,10 @@ log = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \ - Receiver, build_icon, ItemCapabilities, SettingsManager, translate +from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \ + ItemCapabilities, SettingsManager, translate from openlp.core.lib.theme import ThemeLevel -from openlp.core.lib.ui import UiStrings, critical_error_message_box +from openlp.core.lib.ui import UiStrings, critical_error_message_box, context_menu_action from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ @@ -1267,7 +1267,7 @@ class ServiceManager(QtGui.QWidget): for theme in theme_list: self.themeComboBox.addItem(theme) action = context_menu_action(self.serviceManagerList, None, theme, - self.onThemeChangeAction) + self.onThemeChangeAction, context=QtCore.Qt.WidgetShortcut) self.themeMenu.addAction(action) index = self.themeComboBox.findText(self.service_theme, QtCore.Qt.MatchExactly) From 4a6be382ff3689cd52da8c330536293055ec5be5 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 4 Apr 2011 18:15:38 +0200 Subject: [PATCH 27/76] fixed empty texts --- openlp/core/lib/searchedit.py | 3 ++- openlp/core/ui/mainwindow.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 41699256f..d32961ef9 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -133,7 +133,8 @@ class SearchEdit(QtGui.QLineEdit): menu = QtGui.QMenu(self) first = None for identifier, icon, title in items: - action = icon_action(menu, title, icon) + 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)'), diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index bb6d105b9..ab712a57d 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -972,8 +972,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.FileMenu.addSeparator() for fileId, filename in enumerate(recentFilesToDisplay): log.debug('Recent file name: %s', filename) - action = base_action(self, u'&%d %s' % (fileId + 1, - QtCore.QFileInfo(filename).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) From 38c939362455d330663da881762f6b94198ea3bf Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 4 Apr 2011 19:33:42 +0200 Subject: [PATCH 28/76] expand categories --- openlp/core/ui/shortcutlistform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 5251ac314..a99b7c3bb 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -145,8 +145,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): actionItem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(action)) item.addChild(actionItem) - item.setExpanded(True) self.treeWidget.addTopLevelItem(item) + item.setExpanded(True) self.refreshShortcutList() def refreshShortcutList(self): From 3bfe9ec77c8e430018d2dcafa34b20ff1eb1e9aa Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Apr 2011 21:14:02 +0200 Subject: [PATCH 29/76] --- openlp/core/ui/printservicedialog.py | 4 + openlp/core/ui/printserviceform.py | 107 ++++++++++++++++++--------- 2 files changed, 77 insertions(+), 34 deletions(-) diff --git a/openlp/core/ui/printservicedialog.py b/openlp/core/ui/printservicedialog.py index 97f4b4060..b669c83ec 100644 --- a/openlp/core/ui/printservicedialog.py +++ b/openlp/core/ui/printservicedialog.py @@ -132,6 +132,8 @@ class Ui_PrintServiceDialog(object): self.groupLayout = QtGui.QVBoxLayout() self.slideTextCheckBox = QtGui.QCheckBox() self.groupLayout.addWidget(self.slideTextCheckBox) + self.pageBreakAfterText = QtGui.QCheckBox() + self.groupLayout.addWidget(self.pageBreakAfterText) self.notesCheckBox = QtGui.QCheckBox() self.groupLayout.addWidget(self.notesCheckBox) self.metaDataCheckBox = QtGui.QCheckBox() @@ -149,6 +151,8 @@ class Ui_PrintServiceDialog(object): printServiceDialog.setWindowTitle(UiStrings.PrintServiceOrder) self.slideTextCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include slide text if available')) + self.pageBreakAfterText.setText(translate('OpenLP.PrintServiceForm', + 'break')) self.notesCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include service item notes')) self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceForm', diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 4e0f018a4..03febc067 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -26,6 +26,7 @@ import datetime from PyQt4 import QtCore, QtGui +from lxml import html from openlp.core.lib import translate from openlp.core.lib.ui import UiStrings @@ -50,6 +51,10 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): settings.beginGroup(u'advanced') self.slideTextCheckBox.setChecked(settings.value( u'print slide text', QtCore.QVariant(False)).toBool()) + self.pageBreakAfterText.setChecked(settings.value( + u'enable page break', QtCore.QVariant(False)).toBool()) + if not self.slideTextCheckBox.isChecked(): + self.pageBreakAfterText.setDisabled(True) self.metaDataCheckBox.setChecked(settings.value( u'print file meta data', QtCore.QVariant(False)).toBool()) self.notesCheckBox.setChecked(settings.value( @@ -76,6 +81,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): QtCore.SIGNAL(u'triggered()'), self.copyText) QtCore.QObject.connect(self.htmlCopy, QtCore.SIGNAL(u'triggered()'), self.copyHtmlText) + QtCore.QObject.connect(self.slideTextCheckBox, + QtCore.SIGNAL(u'stateChanged(int)'), + self.onSlideTextCheckBoxChanged) self.updatePreviewText() def toggleOptions(self, checked): @@ -93,57 +101,80 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): """ Creates the html text and updates the html of *self.document*. """ - text = u'' - if self.titleLineEdit.text(): - text += u'

%s

' % unicode(self.titleLineEdit.text()) - for item in self.serviceManager.serviceItems: + html_data = html.fromstring( + u'%s' % unicode(self.titleLineEdit.text())) + html_data.append(html.Element(u'body')) + html_data.body.append(html.fromstring( + u'

%s

' % unicode(self.titleLineEdit.text()))) + for index, item in enumerate(self.serviceManager.serviceItems): item = item[u'service_item'] + div = html.Element(u'div') # Add the title of the service item. - text += u'

%s

' % (item.icon, - item.get_display_title()) - # Add slide text of the service item. + item_title = html.Element(u'h3') + icon = html.Element(u'img') + icon.set(u'src', item.icon) + item_title.append(icon) + item_title.append( + html.fromstring(u' %s' % item.get_display_title())) + div.append(item_title) if self.slideTextCheckBox.isChecked(): + # Add the text of the service item. if item.is_text(): - # Add the text of the service item. - verse = None + verse_def = None for slide in item.get_frames(): - if not verse: - text += u'

' + slide[u'html'] - verse = slide[u'verseTag'] - elif verse != slide[u'verseTag']: - text += u'<\p>

' + slide[u'html'] - verse = slide[u'verseTag'] + if not verse_def or verse_def != slide[u'verseTag']: + p = html.Element(u'p') + div.append(p) else: - text += u'
' + slide[u'html'] - text += u'

' + p.append(html.Element(u'br')) + p.append(html.fromstring( + u'%s' % slide[u'html'])) + verse_def = slide[u'verseTag'] + # Break the page before the div element. + if index != 0 and self.pageBreakAfterText.isChecked(): + div.set(u'style', u'page-break-before:always') + # Add the image names of the service item. elif item.is_image(): - # Add the image names of the service item. - text += u'
    ' + ol = html.Element(u'ol') for slide in range(len(item.get_frames())): - text += u'
  1. %s

  2. ' % \ - item.get_frame_title(slide) - text += u'
' + li = html.Element(u'li') + li.text = item.get_frame_title(slide) + ol.append(li) + div.append(ol) + # add footer if item.foot_text: - # add footer - text += u'

%s

' % item.foot_text + div.append(html.fromstring(item.foot_text)) # Add service items' notes. if self.notesCheckBox.isChecked(): if item.notes: - text += u'

%s

%s' % (translate( - 'OpenLP.ServiceManager', 'Notes:'), - item.notes.replace(u'\n', u'
')) + p = html.Element(u'p') + strong = html.Element(u'strong') + strong.text = unicode( + translate('OpenLP.ServiceManager', 'Notes:')) + p.append(strong) + p.append(html.fromstring(u'%s' % + item.notes.replace(u'\n', u'
'))) + div.append(p) # Add play length of media files. if item.is_media() and self.metaDataCheckBox.isChecked(): tme = item.media_length if item.end_time > 0: tme = item.end_time - item.start_time - text += u'

%s %s

' % (translate( - 'OpenLP.ServiceManager', u'Playing time:'), - unicode(datetime.timedelta(seconds=tme))) - if self.footerTextEdit.toPlainText(): - text += u'

%s

%s' % (translate('OpenLP.ServiceManager', - u'Custom Service Notes:'), self.footerTextEdit.toPlainText()) - self.document.setHtml(text) + p = html.fromstring(u'

%s

' % + translate('OpenLP.ServiceManager', 'Playing time:')) + p.append(html.fromstring(u'%s' % + unicode(datetime.timedelta(seconds=tme)))) + div.append(p) + html_data.body.append(div) + # Add the custom service notes: + if self.footerTextEdit.toPlainText(): + html_data.append(html.fromstring(u'

%

' % + translate('OpenLP.ServiceManager', u'Custom Service Notes:'))) + html_data.append(html.fromstring( + u'%s' % self.footerTextEdit.toPlainText())) + for div in html_data.body: + print len(div), html.tostring(div), u'\n' + self.document.setHtml(html.tostring(html_data)) self.previewWidget.updatePreview() def paintRequested(self, printer): @@ -232,6 +263,12 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): else: self.copyTextButton.setText(UiStrings.CopyToText) + def onSlideTextCheckBoxChanged(self, state): + """ + The ``slideTextCheckBox`` checkbox was either checked or unchecked. + """ + self.pageBreakAfterText.setDisabled(state == QtCore.Qt.Unchecked) + def saveOptions(self): """ Save the settings and close the dialog. @@ -241,6 +278,8 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): settings.beginGroup(u'advanced') settings.setValue(u'print slide text', QtCore.QVariant(self.slideTextCheckBox.isChecked())) + settings.setValue(u'enable page break', + QtCore.QVariant(self.pageBreakAfterText.isChecked())) settings.setValue(u'print file meta data', QtCore.QVariant(self.metaDataCheckBox.isChecked())) settings.setValue(u'print notes', From 9b04385f347bed26d50d61586679b10cf5185bf7 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 6 Apr 2011 23:54:47 +0100 Subject: [PATCH 30/76] Blanking and switching between song and ppt and back --- openlp/core/ui/slidecontroller.py | 39 ++++++++----------- openlp/plugins/bibles/lib/mediaitem.py | 1 + .../presentations/lib/messagelistener.py | 18 ++++++--- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 232653326..eec5d3a19 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -569,19 +569,18 @@ class SlideController(QtGui.QWidget): self.onStopLoop() # If old item was a command tell it to stop if self.serviceItem: - if self.serviceItem.is_command(): + oldItem = self.serviceItem + self.serviceItem = None + if oldItem.is_command(): Receiver.send_message(u'%s_stop' % - self.serviceItem.name.lower(), [serviceItem, self.isLive]) - if self.serviceItem.is_media(): + oldItem.name.lower(), [oldItem, self.isLive]) + if oldItem.is_media(): self.onMediaClose() - if self.isLive: - if serviceItem.is_capable(ItemCapabilities.ProvidesOwnDisplay): - self._forceUnblank() - blanked = self.blankScreen.isChecked() - else: - blanked = False + if self.isLive and oldItem.is_capable( + ItemCapabilities.ProvidesOwnDisplay): + self._resetBlank() Receiver.send_message(u'%s_start' % serviceItem.name.lower(), - [serviceItem, self.isLive, blanked, slideno]) + [serviceItem, self.isLive, self.display.hideMode, slideno]) self.slideList = {} width = self.parent.controlSplitter.sizes()[self.split] self.serviceItem = serviceItem @@ -1095,20 +1094,14 @@ class SlideController(QtGui.QWidget): self.slidePreview.clear() self.slidePreview.show() - def _forceUnblank(self): + def _resetBlank(self): """ Used by command items which provide their own displays to reset the screen hide attributes """ - blank = None - if self.blankScreen.isChecked: - blank = self.blankScreen - if self.themeScreen.isChecked: - blank = self.themeScreen - if self.desktopScreen.isChecked: - blank = self.desktopScreen - if blank: - blank.setChecked(False) - self.hideMenu.setDefaultAction(blank) - QtCore.QSettings().remove( - self.parent.generalSettingsSection + u'/screen blank') + if self.blankScreen.isChecked(): + self.onBlankDisplay(True) + elif self.themeScreen.isChecked(): + self.onThemeDisplay(True) + elif self.desktopScreen.isChecked(): + self.onHideDisplay(True) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index a9694fd0c..9c45b85f8 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -58,6 +58,7 @@ class BibleMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, plugin, icon) # Place to store the search results for both bibles. self.settings = self.parent.settings_tab + self.quickPreviewAllowed = True self.search_results = {} self.second_search_results = {} QtCore.QObject.connect(Receiver.get_receiver(), diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index b86219f42..728a154f8 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -49,7 +49,7 @@ class Controller(object): self.doc = None log.info(u'%s controller loaded' % live) - def add_handler(self, controller, file, is_blank): + def add_handler(self, controller, file, hide_mode): """ Add a handler, which is an instance of a presentation and slidecontroller combination. If the slidecontroller has a display @@ -66,9 +66,17 @@ class Controller(object): return if self.is_live: self.doc.start_presentation() - if is_blank: + if hide_mode == HideMode.Screen: + Receiver.send_message(u'maindisplay_hide', HideMode.Screen) + self.stop() + elif hide_mode == HideMode.Theme: + Receiver.send_message(u'maindisplay_hide', HideMode.Theme) self.blank() - Receiver.send_message(u'maindisplay_hide', HideMode.Screen) + elif hide_mode == HideMode.Blank: + Receiver.send_message(u'maindisplay_hide', HideMode.Screen) + self.blank() + else: + Receiver.send_message(u'maindisplay_hide', HideMode.Screen) self.doc.slidenumber = 0 def activate(self): @@ -261,7 +269,7 @@ class MessageListener(object): is_live = message[1] item = message[0] log.debug(u'Startup called with message %s' % message) - is_blank = message[2] + hide_mode = message[2] file = os.path.join(item.get_frame_path(), item.get_frame_title()) self.handler = item.title @@ -273,7 +281,7 @@ class MessageListener(object): controller = self.live_handler else: controller = self.preview_handler - controller.add_handler(self.controllers[self.handler], file, is_blank) + controller.add_handler(self.controllers[self.handler], file, hide_mode) def slide(self, message): """ From 9b84319c249cf09b66e90d7f28c7eb38c5afe134 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 7 Apr 2011 16:26:29 +0200 Subject: [PATCH 31/76] added new dialog from superfly + few own changes --- openlp/core/ui/shortcutlistdialog.py | 109 ++++++++++++++++---------- openlp/core/ui/shortcutlistform.py | 62 ++++++++------- resources/forms/shortcutlistdialog.ui | 80 +++++++++++++------ 3 files changed, 158 insertions(+), 93 deletions(-) diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 83f897bd8..6531a1a19 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -30,44 +30,71 @@ from openlp.core.lib import translate, build_icon class Ui_ShortcutListDialog(object): def setupUi(self, shortcutListDialog): - shortcutListDialog.resize(440, 450) - shortcutListDialog.setObjectName(u'shortcutListDialog') - self.dialogLayout = QtGui.QVBoxLayout(shortcutListDialog) - self.dialogLayout.setObjectName(u'dialogLayout') - self.descriptionLabel = QtGui.QLabel(shortcutListDialog) - self.descriptionLabel.setObjectName(u'descriptionLabel') - self.descriptionLabel.setWordWrap(True) - self.dialogLayout.addWidget(self.descriptionLabel) + shortcutListDialog.setObjectName("shortcutListDialog") + shortcutListDialog.resize(500, 438) + self.shortcutListLayout = QtGui.QVBoxLayout(shortcutListDialog) + self.shortcutListLayout.setSpacing(8) + self.shortcutListLayout.setMargin(8) + self.shortcutListLayout.setObjectName("shortcutListLayout") self.treeWidget = QtGui.QTreeWidget(shortcutListDialog) self.treeWidget.setAlternatingRowColors(True) - self.treeWidget.setObjectName(u'treeWidget') + self.treeWidget.setObjectName("treeWidget") self.treeWidget.setColumnCount(3) - self.dialogLayout.addWidget(self.treeWidget) - self.customLayout = QtGui.QHBoxLayout() - self.customLayout.setObjectName(u'customLayout') - self.shortcutButtonLabel = QtGui.QLabel(shortcutListDialog) - self.shortcutButtonLabel.setObjectName(u'descriptionLabel') - self.customLayout.addWidget(self.shortcutButtonLabel) - self.shortcutButton = QtGui.QPushButton(shortcutListDialog) - self.shortcutButton.setIcon( - build_icon(u':/system/system_configure_shortcuts.png')) - self.shortcutButton.setCheckable(True) - self.shortcutButton.setObjectName(u'shortcutButton') - self.shortcutButton.setFixedSize(150, 30) - self.customLayout.addWidget(self.shortcutButton) - self.clearShortcutButton = QtGui.QToolButton(shortcutListDialog) - self.clearShortcutButton.setIcon( - build_icon(u':/system/clear_shortcut.png')) - self.clearShortcutButton.setAutoRaise(True) - self.clearShortcutButton.setObjectName(u'clearShortcutButton') - self.customLayout.addWidget(self.clearShortcutButton) - self.customLayout.addStretch() - self.dialogLayout.addLayout(self.customLayout) + self.shortcutListLayout.addWidget(self.treeWidget) + self.detailsLayout = QtGui.QGridLayout() + self.detailsLayout.setSpacing(8) + self.detailsLayout.setContentsMargins(-1, 0, -1, -1) + self.detailsLayout.setObjectName("detailsLayout") + self.defaultRadioButton = QtGui.QRadioButton(shortcutListDialog) + self.defaultRadioButton.setChecked(True) + self.defaultRadioButton.setObjectName("defaultRadioButton") + self.detailsLayout.addWidget(self.defaultRadioButton, 0, 0, 1, 1) + self.customRadioButton = QtGui.QRadioButton(shortcutListDialog) + self.customRadioButton.setObjectName("customRadioButton") + self.detailsLayout.addWidget(self.customRadioButton, 1, 0, 1, 1) + self.primaryLayout = QtGui.QHBoxLayout() + self.primaryLayout.setSpacing(8) + self.primaryLayout.setObjectName("primaryLayout") + self.primaryPushButton = QtGui.QPushButton(shortcutListDialog) + self.primaryPushButton.setMinimumSize(QtCore.QSize(84, 0)) + self.primaryPushButton.setIcon(build_icon(u':/system/system_configure_shortcuts.png')) + self.primaryPushButton.setCheckable(True) + self.primaryPushButton.setChecked(False) + self.primaryPushButton.setObjectName("primaryPushButton") + self.primaryLayout.addWidget(self.primaryPushButton) + self.clearPrimaryButton = QtGui.QToolButton(shortcutListDialog) + self.clearPrimaryButton.setMinimumSize(QtCore.QSize(0, 16)) + self.clearPrimaryButton.setText("") + self.clearPrimaryButton.setIcon(build_icon(u':/system/clear_shortcut.png')) + self.clearPrimaryButton.setObjectName("clearPrimaryButton") + self.primaryLayout.addWidget(self.clearPrimaryButton) + self.detailsLayout.addLayout(self.primaryLayout, 1, 1, 1, 1) + self.alternateLayout = QtGui.QHBoxLayout() + self.alternateLayout.setSpacing(8) + self.alternateLayout.setObjectName("alternateLayout") + self.alternatePushButton = QtGui.QPushButton(shortcutListDialog) + self.alternatePushButton.setIcon(build_icon(u':/system/system_configure_shortcuts.png')) + self.alternatePushButton.setObjectName("alternatePushButton") + self.alternateLayout.addWidget(self.alternatePushButton) + self.clearAlternateButton = QtGui.QToolButton(shortcutListDialog) + self.clearAlternateButton.setText("") + self.clearAlternateButton.setIcon(build_icon(u':/system/clear_shortcut.png')) + self.clearAlternateButton.setObjectName("clearAlternateButton") + self.alternateLayout.addWidget(self.clearAlternateButton) + self.detailsLayout.addLayout(self.alternateLayout, 1, 2, 1, 1) + self.primaryLabel = QtGui.QLabel(shortcutListDialog) + self.primaryLabel.setObjectName("primaryLabel") + self.detailsLayout.addWidget(self.primaryLabel, 0, 1, 1, 1) + self.alternateLabel = QtGui.QLabel(shortcutListDialog) + self.alternateLabel.setObjectName("alternateLabel") + self.detailsLayout.addWidget(self.alternateLabel, 0, 2, 1, 1) + self.shortcutListLayout.addLayout(self.detailsLayout) self.buttonBox = QtGui.QDialogButtonBox(shortcutListDialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.RestoreDefaults) - self.buttonBox.setObjectName(u'buttonBox') - self.dialogLayout.addWidget(self.buttonBox) + QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Reset) + self.buttonBox.setObjectName("buttonBox") + self.shortcutListLayout.addWidget(self.buttonBox) self.retranslateUi(shortcutListDialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), shortcutListDialog.accept) @@ -78,15 +105,17 @@ class Ui_ShortcutListDialog(object): def retranslateUi(self, shortcutListDialog): shortcutListDialog.setWindowTitle( translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts')) - self.descriptionLabel.setText(translate('OpenLP.ShortcutListDialog', - 'Select an action and click the button below to start capturing ' - 'a new shortcut.')) + #self.descriptionLabel.setText(translate('OpenLP.ShortcutListDialog', + #'Select an action and click the button below to start capturing ' + #'a new shortcut.')) self.treeWidget.setHeaderLabels([ translate('OpenLP.ShortcutListDialog', 'Action'), translate('OpenLP.ShortcutListDialog', 'Shortcut'), translate('OpenLP.ShortcutListDialog', 'Alternate')]) - self.shortcutButtonLabel.setText( + self.primaryPushButton.setText( translate('OpenLP.ShortcutListDialog', 'Capture shortcut:')) - self.clearShortcutButton.setToolTip( - translate('OpenLP.ShortcutListDialog', - 'Restore the default shortcut(s) of this action.')) + self.alternatePushButton.setText( + translate('OpenLP.ShortcutListDialog', 'Capture shortcut:')) + #self.clearShortcutButton.setToolTip( + #translate('OpenLP.ShortcutListDialog', + #'Restore the default shortcut(s) of this action.')) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index a99b7c3bb..00e216c2a 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -47,24 +47,28 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.setupUi(self) self.column = -1 self.changedActions = {} - self.shortcutButton.setText(u'') - self.shortcutButton.setEnabled(False) - QtCore.QObject.connect(self.shortcutButton, - QtCore.SIGNAL(u'toggled(bool)'), self.onShortcutButtonClicked) + self.primaryPushButton.setText(u'') + self.alternatePushButton.setText(u'') + self.primaryPushButton.setEnabled(False) + self.alternatePushButton.setEnabled(False) + QtCore.QObject.connect(self.primaryPushButton, + QtCore.SIGNAL(u'toggled(bool)'), self.onPrimaryPushButtonClicked) QtCore.QObject.connect(self.treeWidget, QtCore.SIGNAL(u'itemPressed(QTreeWidgetItem*, int)'), self.onItemPressed) QtCore.QObject.connect(self.treeWidget, QtCore.SIGNAL(u'itemDoubleClicked(QTreeWidgetItem*, int)'), self.onItemDoubleClicked) - QtCore.QObject.connect(self.clearShortcutButton, - QtCore.SIGNAL(u'clicked(bool)'), self.onClearShortcutButtonClicked) + QtCore.QObject.connect(self.clearPrimaryButton, + QtCore.SIGNAL(u'clicked(bool)'), self.onClearPrimaryButtonClicked) +# QtCore.QObject.connect(self.clearShortcutButton, +# QtCore.SIGNAL(u'clicked(bool)'), self.onClearPrimaryButtonClicked) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onRestoreDefaultsClicked) def keyPressEvent(self, event): - if self.shortcutButton.isChecked(): + if self.primaryPushButton.isChecked(): event.ignore() elif event.key() == QtCore.Qt.Key_Escape: event.accept() @@ -72,7 +76,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): def keyReleaseEvent(self, event): Qt = QtCore.Qt - if not self.shortcutButton.isChecked(): + if not self.primaryPushButton.isChecked(): return key = event.key() if key == Qt.Key_Shift or key == Qt.Key_Control or \ @@ -117,15 +121,15 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): QtGui.QMessageBox.Ok ) else: - self.shortcutButton.setText(key_sequence.toString()) - self.shortcutButton.setChecked(False) + self.primaryPushButton.setText(key_sequence.toString()) + self.primaryPushButton.setChecked(False) def exec_(self): self.changedActions = {} self.reloadShortcutList() - self.shortcutButton.setChecked(False) - self.shortcutButton.setEnabled(False) - self.shortcutButton.setText(u'') + self.primaryPushButton.setChecked(False) + self.primaryPushButton.setEnabled(False) + self.primaryPushButton.setText(u'') return QtGui.QDialog.exec_(self) def reloadShortcutList(self): @@ -172,7 +176,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): item.setText(1, shortcuts[0].toString()) item.setText(2, shortcuts[1].toString()) - def onShortcutButtonClicked(self, toggled): + def onPrimaryPushButtonClicked(self, toggled): """ Save the new shortcut to the action if the button is unchanged. """ @@ -188,14 +192,16 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): new_shortcuts = [] # We are changing the primary shortcut. if self.column in [0, 1]: - new_shortcuts.append(QtGui.QKeySequence(self.shortcutButton.text())) + new_shortcuts.append( + QtGui.QKeySequence(self.primaryPushButton.text())) if len(shortcuts) == 2: new_shortcuts.append(shortcuts[1]) # We are changing the secondary shortcut. elif self.column == 2: if len(shortcuts) != 0: new_shortcuts.append(shortcuts[0]) - new_shortcuts.append(QtGui.QKeySequence(self.shortcutButton.text())) + new_shortcuts.append( + QtGui.QKeySequence(self.primaryPushButton.text())) else: return self.changedActions[action] = new_shortcuts @@ -203,14 +209,14 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): def onItemDoubleClicked(self, item, column): """ - A item has been double clicked. ``The shortcutButton`` will be checked - and the item's shortcut will be displayed. + A item has been double clicked. ``The primaryPushButton`` will be + checked and the item's shortcut will be displayed. """ action = item.data(0, QtCore.Qt.UserRole).toPyObject() if action is None: return - self.shortcutButton.setChecked(True) - self.shortcutButton.setFocus(QtCore.Qt.OtherFocusReason) + self.primaryPushButton.setChecked(True) + self.primaryPushButton.setFocus(QtCore.Qt.OtherFocusReason) self.onItemPressed(item, column) def onItemPressed(self, item, column): @@ -222,23 +228,23 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): action = item.data(0, QtCore.Qt.UserRole).toPyObject() text = u'' if action is None: - self.shortcutButton.setChecked(False) - self.shortcutButton.setEnabled(False) + self.primaryPushButton.setChecked(False) + self.primaryPushButton.setEnabled(False) else: - self.shortcutButton.setEnabled(True) + self.primaryPushButton.setEnabled(True) shortcuts = self._actionShortcuts(action) if column != 2 and len(shortcuts) != 0: text = shortcuts[0].toString() elif len(shortcuts) == 2: text = shortcuts[1].toString() - self.shortcutButton.setText(text) + self.primaryPushButton.setText(text) - def onClearShortcutButtonClicked(self, toggled): + def onClearPrimaryButtonClicked(self, toggled): """ Restore the defaults of this """ item = self.treeWidget.currentItem() - self.shortcutButton.setChecked(False) + self.primaryPushButton.setChecked(False) if item is None: return action = item.data(0, QtCore.Qt.UserRole).toPyObject() @@ -261,8 +267,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == QtGui.QMessageBox.No: return - self.shortcutButton.setChecked(False) - self.shortcutButton.setText(u'') + self.primaryPushButton.setChecked(False) + self.primaryPushButton.setText(u'') for category in ActionList.categories: for action in category.actions: self.changedActions[action] = action.defaultShortcuts diff --git a/resources/forms/shortcutlistdialog.ui b/resources/forms/shortcutlistdialog.ui index 519925560..9a5c599d1 100644 --- a/resources/forms/shortcutlistdialog.ui +++ b/resources/forms/shortcutlistdialog.ui @@ -41,35 +41,35 @@ - + + + 0 + 8 - - 0 - - + - Default: None + Default: true - - + + + + Custom: + + + + + 8 - - - - Custom: - - - @@ -83,7 +83,7 @@ - :/system/system_settings.png:/system/system_settings.png + :/system/system_configure_shortcuts.png:/system/system_configure_shortcuts.png true @@ -110,21 +110,51 @@ + + + + + + 8 + - - - Qt::Horizontal + + + None - - - 40 - 20 - + + + :/system/system_configure_shortcuts.png:/system/system_configure_shortcuts.png - + + + + + + + + + + :/system/clear_shortcut.png:/system/clear_shortcut.png + + + + + + Ctrl+V + + + + + + + Shift+Ins + + + From dab699371cea47a8cbc2f6fb4ec9c926e4ac195c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 7 Apr 2011 17:37:07 +0200 Subject: [PATCH 32/76] integrated second button(s), clean ups --- openlp/core/ui/shortcutlistdialog.py | 74 +++++------ openlp/core/ui/shortcutlistform.py | 175 +++++++++++++++++---------- 2 files changed, 150 insertions(+), 99 deletions(-) diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 6531a1a19..b5dffd936 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -30,70 +30,67 @@ from openlp.core.lib import translate, build_icon class Ui_ShortcutListDialog(object): def setupUi(self, shortcutListDialog): - shortcutListDialog.setObjectName("shortcutListDialog") + shortcutListDialog.setObjectName(u'shortcutListDialog') shortcutListDialog.resize(500, 438) self.shortcutListLayout = QtGui.QVBoxLayout(shortcutListDialog) - self.shortcutListLayout.setSpacing(8) - self.shortcutListLayout.setMargin(8) - self.shortcutListLayout.setObjectName("shortcutListLayout") + self.shortcutListLayout.setObjectName(u'shortcutListLayout') self.treeWidget = QtGui.QTreeWidget(shortcutListDialog) + self.treeWidget.setObjectName(u'treeWidget') self.treeWidget.setAlternatingRowColors(True) - self.treeWidget.setObjectName("treeWidget") self.treeWidget.setColumnCount(3) self.shortcutListLayout.addWidget(self.treeWidget) self.detailsLayout = QtGui.QGridLayout() - self.detailsLayout.setSpacing(8) + self.detailsLayout.setObjectName(u'detailsLayout') self.detailsLayout.setContentsMargins(-1, 0, -1, -1) - self.detailsLayout.setObjectName("detailsLayout") self.defaultRadioButton = QtGui.QRadioButton(shortcutListDialog) + self.defaultRadioButton.setObjectName(u'defaultRadioButton') self.defaultRadioButton.setChecked(True) - self.defaultRadioButton.setObjectName("defaultRadioButton") self.detailsLayout.addWidget(self.defaultRadioButton, 0, 0, 1, 1) self.customRadioButton = QtGui.QRadioButton(shortcutListDialog) - self.customRadioButton.setObjectName("customRadioButton") + self.customRadioButton.setObjectName(u'customRadioButton') self.detailsLayout.addWidget(self.customRadioButton, 1, 0, 1, 1) self.primaryLayout = QtGui.QHBoxLayout() - self.primaryLayout.setSpacing(8) - self.primaryLayout.setObjectName("primaryLayout") + self.primaryLayout.setObjectName(u'primaryLayout') self.primaryPushButton = QtGui.QPushButton(shortcutListDialog) + self.primaryPushButton.setObjectName(u'primaryPushButton') self.primaryPushButton.setMinimumSize(QtCore.QSize(84, 0)) - self.primaryPushButton.setIcon(build_icon(u':/system/system_configure_shortcuts.png')) + self.primaryPushButton.setIcon( + build_icon(u':/system/system_configure_shortcuts.png')) self.primaryPushButton.setCheckable(True) - self.primaryPushButton.setChecked(False) - self.primaryPushButton.setObjectName("primaryPushButton") self.primaryLayout.addWidget(self.primaryPushButton) self.clearPrimaryButton = QtGui.QToolButton(shortcutListDialog) + self.clearPrimaryButton.setObjectName(u'clearPrimaryButton') self.clearPrimaryButton.setMinimumSize(QtCore.QSize(0, 16)) - self.clearPrimaryButton.setText("") - self.clearPrimaryButton.setIcon(build_icon(u':/system/clear_shortcut.png')) - self.clearPrimaryButton.setObjectName("clearPrimaryButton") + self.clearPrimaryButton.setIcon( + build_icon(u':/system/clear_shortcut.png')) self.primaryLayout.addWidget(self.clearPrimaryButton) self.detailsLayout.addLayout(self.primaryLayout, 1, 1, 1, 1) self.alternateLayout = QtGui.QHBoxLayout() - self.alternateLayout.setSpacing(8) - self.alternateLayout.setObjectName("alternateLayout") + self.alternateLayout.setObjectName(u'alternateLayout') self.alternatePushButton = QtGui.QPushButton(shortcutListDialog) - self.alternatePushButton.setIcon(build_icon(u':/system/system_configure_shortcuts.png')) - self.alternatePushButton.setObjectName("alternatePushButton") + self.alternatePushButton.setObjectName(u'alternatePushButton') + self.alternatePushButton.setCheckable(True) + self.alternatePushButton.setIcon( + build_icon(u':/system/system_configure_shortcuts.png')) self.alternateLayout.addWidget(self.alternatePushButton) self.clearAlternateButton = QtGui.QToolButton(shortcutListDialog) - self.clearAlternateButton.setText("") - self.clearAlternateButton.setIcon(build_icon(u':/system/clear_shortcut.png')) - self.clearAlternateButton.setObjectName("clearAlternateButton") + self.clearAlternateButton.setObjectName(u'clearAlternateButton') + self.clearAlternateButton.setIcon( + build_icon(u':/system/clear_shortcut.png')) self.alternateLayout.addWidget(self.clearAlternateButton) self.detailsLayout.addLayout(self.alternateLayout, 1, 2, 1, 1) self.primaryLabel = QtGui.QLabel(shortcutListDialog) - self.primaryLabel.setObjectName("primaryLabel") + self.primaryLabel.setObjectName(u'primaryLabel') self.detailsLayout.addWidget(self.primaryLabel, 0, 1, 1, 1) self.alternateLabel = QtGui.QLabel(shortcutListDialog) - self.alternateLabel.setObjectName("alternateLabel") + self.alternateLabel.setObjectName(u'alternateLabel') self.detailsLayout.addWidget(self.alternateLabel, 0, 2, 1, 1) self.shortcutListLayout.addLayout(self.detailsLayout) self.buttonBox = QtGui.QDialogButtonBox(shortcutListDialog) + self.buttonBox.setObjectName(u'buttonBox') self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | - QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Reset) - self.buttonBox.setObjectName("buttonBox") + QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.RestoreDefaults) self.shortcutListLayout.addWidget(self.buttonBox) self.retranslateUi(shortcutListDialog) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), @@ -112,10 +109,17 @@ class Ui_ShortcutListDialog(object): translate('OpenLP.ShortcutListDialog', 'Action'), translate('OpenLP.ShortcutListDialog', 'Shortcut'), translate('OpenLP.ShortcutListDialog', 'Alternate')]) - self.primaryPushButton.setText( - translate('OpenLP.ShortcutListDialog', 'Capture shortcut:')) - self.alternatePushButton.setText( - translate('OpenLP.ShortcutListDialog', 'Capture shortcut:')) - #self.clearShortcutButton.setToolTip( - #translate('OpenLP.ShortcutListDialog', - #'Restore the default shortcut(s) of this action.')) + self.defaultRadioButton.setText( + translate('OpenLP.ShortcutListDialog', 'Default')) + self.customRadioButton.setText( + translate('OpenLP.ShortcutListDialog', 'Custom')) + self.primaryPushButton.setToolTip( + translate('OpenLP.ShortcutListDialog', 'Capture shortcut.')) + self.alternatePushButton.setToolTip( + translate('OpenLP.ShortcutListDialog', 'Capture shortcut.')) + self.clearPrimaryButton.setToolTip( + translate('OpenLP.ShortcutListDialog', + 'Restore the default shortcut(s) of this action.')) + self.clearAlternateButton.setToolTip( + translate('OpenLP.ShortcutListDialog', + 'Restore the default shortcut(s) of this action.')) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 00e216c2a..cda8cfc5d 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -45,14 +45,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) - self.column = -1 self.changedActions = {} - self.primaryPushButton.setText(u'') - self.alternatePushButton.setText(u'') - self.primaryPushButton.setEnabled(False) - self.alternatePushButton.setEnabled(False) QtCore.QObject.connect(self.primaryPushButton, QtCore.SIGNAL(u'toggled(bool)'), self.onPrimaryPushButtonClicked) + QtCore.QObject.connect(self.alternatePushButton, + QtCore.SIGNAL(u'toggled(bool)'), self.onAlternatePushButtonClicked) QtCore.QObject.connect(self.treeWidget, QtCore.SIGNAL(u'itemPressed(QTreeWidgetItem*, int)'), self.onItemPressed) @@ -61,14 +58,15 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.onItemDoubleClicked) QtCore.QObject.connect(self.clearPrimaryButton, QtCore.SIGNAL(u'clicked(bool)'), self.onClearPrimaryButtonClicked) -# QtCore.QObject.connect(self.clearShortcutButton, -# QtCore.SIGNAL(u'clicked(bool)'), self.onClearPrimaryButtonClicked) + QtCore.QObject.connect(self.clearAlternateButton, + QtCore.SIGNAL(u'clicked(bool)'), self.onClearAlternateButtonClicked) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onRestoreDefaultsClicked) def keyPressEvent(self, event): - if self.primaryPushButton.isChecked(): + if self.primaryPushButton.isChecked() or \ + self.alternatePushButton.isChecked(): event.ignore() elif event.key() == QtCore.Qt.Key_Escape: event.accept() @@ -76,7 +74,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): def keyReleaseEvent(self, event): Qt = QtCore.Qt - if not self.primaryPushButton.isChecked(): + if not self.primaryPushButton.isChecked() and \ + not self.alternatePushButton.isChecked(): return key = event.key() if key == Qt.Key_Shift or key == Qt.Key_Control or \ @@ -90,9 +89,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier: key_string = u'Shift+' + key_string key_sequence = QtGui.QKeySequence(key_string) - # The item/action we are attempting to change. - changing_item = self.treeWidget.currentItem() - changing_action = changing_item.data(0, QtCore.Qt.UserRole).toPyObject() + # The action we are attempting to change. + changing_action = self._currentItemAction() shortcut_valid = True for category in ActionList.categories: for action in category.actions: @@ -100,11 +98,18 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if key_sequence not in shortcuts: continue if action is changing_action: - continue - # Have the same parentWidget, thus they cannot have the same - # shortcut. + if self.primaryPushButton.isChecked() and \ + shortcuts.index(key_sequence) == 0: + continue + if self.alternatePushButton.isChecked() and \ + shortcuts.index(key_sequence) == 1: + continue + # Have the same parent, thus they cannot have the same shortcut. if action.parent() is changing_action.parent(): shortcut_valid = False + # The new shortcut is already assigned, but if both shortcuts + # are only valid in a different widget the new shortcut is + # vaild, because they will not interfere. if action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: shortcut_valid = False @@ -121,8 +126,12 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): QtGui.QMessageBox.Ok ) else: - self.primaryPushButton.setText(key_sequence.toString()) - self.primaryPushButton.setChecked(False) + if self.primaryPushButton.isChecked(): + self.primaryPushButton.setText(key_sequence.toString()) + self.primaryPushButton.setChecked(False) + elif self.alternatePushButton.isChecked(): + self.alternatePushButton.setText(key_sequence.toString()) + self.alternatePushButton.setChecked(False) def exec_(self): self.changedActions = {} @@ -130,6 +139,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.primaryPushButton.setChecked(False) self.primaryPushButton.setEnabled(False) self.primaryPushButton.setText(u'') + self.alternatePushButton.setChecked(False) + self.alternatePushButton.setEnabled(False) + self.alternatePushButton.setText(u'') return QtGui.QDialog.exec_(self) def reloadShortcutList(self): @@ -162,7 +174,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): while iterator.value(): item = iterator.value() iterator += 1 - action = item.data(0, QtCore.Qt.UserRole).toPyObject() + action = self._currentItemAction(item) if action is None: continue shortcuts = self._actionShortcuts(action) @@ -181,29 +193,35 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): Save the new shortcut to the action if the button is unchanged. """ if toggled: + self.alternatePushButton.setChecked(False) return - item = self.treeWidget.currentItem() - if item is None: - return - action = item.data(0, QtCore.Qt.UserRole).toPyObject() + action = self._currentItemAction() if action is None: return shortcuts = self._actionShortcuts(action) new_shortcuts = [] - # We are changing the primary shortcut. - if self.column in [0, 1]: - new_shortcuts.append( - QtGui.QKeySequence(self.primaryPushButton.text())) - if len(shortcuts) == 2: - new_shortcuts.append(shortcuts[1]) - # We are changing the secondary shortcut. - elif self.column == 2: - if len(shortcuts) != 0: - new_shortcuts.append(shortcuts[0]) - new_shortcuts.append( - QtGui.QKeySequence(self.primaryPushButton.text())) - else: + new_shortcuts.append( + QtGui.QKeySequence(self.primaryPushButton.text())) + if len(shortcuts) == 2: + new_shortcuts.append(shortcuts[1]) + self.changedActions[action] = new_shortcuts + self.refreshShortcutList() + + def onAlternatePushButtonClicked(self, toggled): + """ + """ + if toggled: + self.primaryPushButton.setChecked(False) return + action = self._currentItemAction() + if action is None: + return + shortcuts = self._actionShortcuts(action) + new_shortcuts = [] + if len(shortcuts) != 0: + new_shortcuts.append(shortcuts[0]) + new_shortcuts.append( + QtGui.QKeySequence(self.alternatePushButton.text())) self.changedActions[action] = new_shortcuts self.refreshShortcutList() @@ -212,47 +230,39 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): A item has been double clicked. ``The primaryPushButton`` will be checked and the item's shortcut will be displayed. """ - action = item.data(0, QtCore.Qt.UserRole).toPyObject() + action = self._currentItemAction(item) if action is None: return - self.primaryPushButton.setChecked(True) - self.primaryPushButton.setFocus(QtCore.Qt.OtherFocusReason) - self.onItemPressed(item, column) + self.primaryPushButton.setChecked(column in [0, 1]) + self.alternatePushButton.setChecked(column not in [0, 1]) + if column in [0, 1]: + self.primaryPushButton.setFocus(QtCore.Qt.OtherFocusReason) + else: + self.alternatePushButton.setFocus(QtCore.Qt.OtherFocusReason) + self.onItemPressed() - def onItemPressed(self, item, column): + def onItemPressed(self, item=None, column=-1): """ A item has been pressed. We adjust the button's text to the action's shortcut which is encapsulate in the item. """ - self.column = column - action = item.data(0, QtCore.Qt.UserRole).toPyObject() - text = u'' + action = self._currentItemAction(item) + self.primaryPushButton.setEnabled(action is not None) + self.alternatePushButton.setEnabled(action is not None) + primary_text = u'' + alternate_text = u'' if action is None: self.primaryPushButton.setChecked(False) - self.primaryPushButton.setEnabled(False) + self.alternatePushButton.setChecked(False) else: - self.primaryPushButton.setEnabled(True) shortcuts = self._actionShortcuts(action) - if column != 2 and len(shortcuts) != 0: - text = shortcuts[0].toString() + if len(shortcuts) == 1: + primary_text = shortcuts[0].toString() elif len(shortcuts) == 2: - text = shortcuts[1].toString() - self.primaryPushButton.setText(text) - - def onClearPrimaryButtonClicked(self, toggled): - """ - Restore the defaults of this - """ - item = self.treeWidget.currentItem() - self.primaryPushButton.setChecked(False) - if item is None: - return - action = item.data(0, QtCore.Qt.UserRole).toPyObject() - if action is None: - return - self.changedActions[action] = action.defaultShortcuts - self.refreshShortcutList() - self.onItemPressed(item, self.column) + primary_text = shortcuts[0].toString() + alternate_text = shortcuts[1].toString() + self.primaryPushButton.setText(primary_text) + self.alternatePushButton.setText(alternate_text) def onRestoreDefaultsClicked(self, button): """ @@ -269,6 +279,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): return self.primaryPushButton.setChecked(False) self.primaryPushButton.setText(u'') + self.alternatePushButton.setChecked(False) + self.alternatePushButton.setText(u'') for category in ActionList.categories: for action in category.actions: self.changedActions[action] = action.defaultShortcuts @@ -292,6 +304,30 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): action.objectName(), QtCore.QVariant(action.shortcuts())) settings.endGroup() + def onClearPrimaryButtonClicked(self, toggled): + """ + Restore the defaults of this action. + """ + self._clearButtonClicked(self.primaryPushButton) + + def onClearAlternateButtonClicked(self, toggled): + """ + Restore the defaults of this action. + """ + self._clearButtonClicked(self.alternatePushButton) + + def _clearButtonClicked(self, button): + """ + Restore the defaults of this action. The given button will be unchecked. + """ + button.setChecked(False) + action = self._currentItemAction() + if action is None: + return + self.changedActions[action] = action.defaultShortcuts + self.refreshShortcutList() + self.onItemPressed() + def _actionShortcuts(self, action): """ This returns the shortcuts for the given ``action``, which also includes @@ -301,3 +337,14 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if self.changedActions.has_key(action): return self.changedActions[action] return action.shortcuts() + + def _currentItemAction(self, item=None): + """ + Returns the action of the current item if no item is given, otherwise + we return the action of the given item. + """ + if item is None: + item = self.treeWidget.currentItem() + if item is None: + return + return item.data(0, QtCore.Qt.UserRole).toPyObject() From 78a9c89025d09cb4fbca38ae5a75266d6dff74e2 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 7 Apr 2011 23:57:12 +0100 Subject: [PATCH 33/76] Fix stuttering powerpoint start --- openlp/core/ui/slidecontroller.py | 6 +++--- .../plugins/presentations/lib/messagelistener.py | 14 +++++++++----- .../presentations/lib/powerpointcontroller.py | 11 +++++------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index eec5d3a19..ccdb1f17c 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -646,7 +646,7 @@ class SlideController(QtGui.QWidget): self.display.buildHtml(self.serviceItem) if serviceItem.is_media(): self.onMediaStart(serviceItem) - self.onSlideSelected() + self.onSlideSelected(True) self.previewListWidget.setFocus() Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix, [serviceItem]) @@ -833,7 +833,7 @@ class SlideController(QtGui.QWidget): % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) - def onSlideSelected(self): + def onSlideSelected(self, start=False): """ Generate the preview when you click on a slide. if this is the Live Controller also display on the screen @@ -842,7 +842,7 @@ class SlideController(QtGui.QWidget): self.selectedRow = 0 if row > -1 and row < self.previewListWidget.rowCount(): if self.serviceItem.is_command(): - if self.isLive: + if self.isLive and not start: Receiver.send_message( u'%s_slide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive, row]) diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 728a154f8..4f9268b3e 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -49,7 +49,7 @@ class Controller(object): self.doc = None log.info(u'%s controller loaded' % live) - def add_handler(self, controller, file, hide_mode): + def add_handler(self, controller, file, hide_mode, slide_no): """ Add a handler, which is an instance of a presentation and slidecontroller combination. If the slidecontroller has a display @@ -64,8 +64,8 @@ class Controller(object): # Display error message to user # Inform slidecontroller that the action failed? return + self.doc.slidenumber = slide_no if self.is_live: - self.doc.start_presentation() if hide_mode == HideMode.Screen: Receiver.send_message(u'maindisplay_hide', HideMode.Screen) self.stop() @@ -73,11 +73,14 @@ class Controller(object): Receiver.send_message(u'maindisplay_hide', HideMode.Theme) self.blank() elif hide_mode == HideMode.Blank: - Receiver.send_message(u'maindisplay_hide', HideMode.Screen) + Receiver.send_message(u'maindisplay_hide', HideMode.Blank) self.blank() else: + self.doc.start_presentation() Receiver.send_message(u'maindisplay_hide', HideMode.Screen) - self.doc.slidenumber = 0 + self.doc.slidenumber = 0 + if slide_no > 1: + self.slide(slide_no) def activate(self): """ @@ -281,7 +284,8 @@ class MessageListener(object): controller = self.live_handler else: controller = self.preview_handler - controller.add_handler(self.controllers[self.handler], file, hide_mode) + controller.add_handler(self.controllers[self.handler], file, hide_mode, + message[3]) def slide(self, message): """ diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 793b0b75d..a02bc841a 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -251,14 +251,13 @@ class PowerpointDocument(PresentationDocument): win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88) except win32ui.error: dpi = 96 - self.presentation.SlideShowSettings.Run() - self.presentation.SlideShowWindow.View.GotoSlide(1) rendermanager = self.controller.plugin.renderManager rect = rendermanager.screens.current[u'size'] - self.presentation.SlideShowWindow.Top = rect.y() * 72 / dpi - self.presentation.SlideShowWindow.Height = rect.height() * 72 / dpi - self.presentation.SlideShowWindow.Left = rect.x() * 72 / dpi - self.presentation.SlideShowWindow.Width = rect.width() * 72 / dpi + ppt_window = self.presentation.SlideShowSettings.Run() + ppt_window.Top = rect.y() * 72 / dpi + ppt_window.Height = rect.height() * 72 / dpi + ppt_window.Left = rect.x() * 72 / dpi + ppt_window.Width = rect.width() * 72 / dpi def get_slide_number(self): """ From ea5e0d65cc5209db530012416f867e1920d8d879 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 8 Apr 2011 08:25:02 +0200 Subject: [PATCH 34/76] --- openlp/core/ui/shortcutlistdialog.py | 4 +- openlp/core/ui/shortcutlistform.py | 68 ++++++++++++++++++---------- 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index b5dffd936..a5050ab25 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -119,7 +119,7 @@ class Ui_ShortcutListDialog(object): translate('OpenLP.ShortcutListDialog', 'Capture shortcut.')) self.clearPrimaryButton.setToolTip( translate('OpenLP.ShortcutListDialog', - 'Restore the default shortcut(s) of this action.')) + 'Restore the default shortcut of this action.')) self.clearAlternateButton.setToolTip( translate('OpenLP.ShortcutListDialog', - 'Restore the default shortcut(s) of this action.')) + 'Restore the default shortcut of this action.')) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index cda8cfc5d..9b20fd9d2 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -127,21 +127,17 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): ) else: if self.primaryPushButton.isChecked(): - self.primaryPushButton.setText(key_sequence.toString()) - self.primaryPushButton.setChecked(False) + self._adjustButton(self.primaryPushButton, + checked=False, text=key_sequence.toString()) elif self.alternatePushButton.isChecked(): - self.alternatePushButton.setText(key_sequence.toString()) - self.alternatePushButton.setChecked(False) + self._adjustButton(self.alternatePushButton, + checked=False, text=key_sequence.toString()) def exec_(self): self.changedActions = {} self.reloadShortcutList() - self.primaryPushButton.setChecked(False) - self.primaryPushButton.setEnabled(False) - self.primaryPushButton.setText(u'') - self.alternatePushButton.setChecked(False) - self.alternatePushButton.setEnabled(False) - self.alternatePushButton.setText(u'') + self._adjustButton(self.primaryPushButton, False, False, u'') + self._adjustButton(self.alternatePushButton, False, False, u'') return QtGui.QDialog.exec_(self) def reloadShortcutList(self): @@ -227,7 +223,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): def onItemDoubleClicked(self, item, column): """ - A item has been double clicked. ``The primaryPushButton`` will be + A item has been double clicked. The ``primaryPushButton`` will be checked and the item's shortcut will be displayed. """ action = self._currentItemAction(item) @@ -251,18 +247,30 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.alternatePushButton.setEnabled(action is not None) primary_text = u'' alternate_text = u'' + primary_label_text = u'' + alternate_label_text = u'' if action is None: self.primaryPushButton.setChecked(False) self.alternatePushButton.setChecked(False) else: + if len(action.defaultShortcuts) != 0: + primary_label_text = action.defaultShortcuts[0].toString() + if len(action.defaultShortcuts) == 2: + alternate_label_text = action.defaultShortcuts[1].toString() shortcuts = self._actionShortcuts(action) - if len(shortcuts) == 1: - primary_text = shortcuts[0].toString() - elif len(shortcuts) == 2: - primary_text = shortcuts[0].toString() - alternate_text = shortcuts[1].toString() + if shortcuts != action.defaultShortcuts: + self.customRadioButton.setChecked(True) + if len(shortcuts) == 1: + primary_text = shortcuts[0].toString() + elif len(shortcuts) == 2: + primary_text = shortcuts[0].toString() + alternate_text = shortcuts[1].toString() + else: + self.defaultRadioButton.setChecked(True) self.primaryPushButton.setText(primary_text) self.alternatePushButton.setText(alternate_text) + self.primaryLabel.setText(primary_label_text) + self.alternateLabel.setText(alternate_label_text) def onRestoreDefaultsClicked(self, button): """ @@ -277,10 +285,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == QtGui.QMessageBox.No: return - self.primaryPushButton.setChecked(False) - self.primaryPushButton.setText(u'') - self.alternatePushButton.setChecked(False) - self.alternatePushButton.setText(u'') + self._adjustButton(self.primaryPushButton, False, text=u'') + self._adjustButton(self.alternatePushButton, False, text=u'') for category in ActionList.categories: for action in category.actions: self.changedActions[action] = action.defaultShortcuts @@ -318,7 +324,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): def _clearButtonClicked(self, button): """ - Restore the defaults of this action. The given button will be unchecked. + Restore the defaults of this action. The given ``button`` will be + unchecked. """ button.setChecked(False) action = self._currentItemAction() @@ -331,8 +338,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): def _actionShortcuts(self, action): """ This returns the shortcuts for the given ``action``, which also includes - those shortcuts which are not yet assigned to an action (as changes are - applied when closing the dialog). + those shortcuts which are not saved yet but already assigned (as changes + are applied when closing the dialog). """ if self.changedActions.has_key(action): return self.changedActions[action] @@ -340,11 +347,22 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): def _currentItemAction(self, item=None): """ - Returns the action of the current item if no item is given, otherwise - we return the action of the given item. + Returns the action of the given ``item``. If no item is given, we return + the action of the current item of the ``treeWidget``. """ if item is None: item = self.treeWidget.currentItem() if item is None: return return item.data(0, QtCore.Qt.UserRole).toPyObject() + + def _adjustButton(self, button, checked=None, enabled=None, text=None): + """ + Can be called to adjust more properties of the given ``button`` at once. + """ + if checked is not None: + button.setChecked(checked) + if enabled is not None: + button.setEnabled(enabled) + if text is not None: + button.setText(text) From 283171e296ca2aeb1c6d9475d2548ff0ff353c81 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 9 Apr 2011 16:50:44 +0200 Subject: [PATCH 35/76] use weight to sort categories --- openlp/core/ui/mainwindow.py | 9 +++++++ openlp/core/ui/servicemanager.py | 1 + openlp/core/ui/slidecontroller.py | 2 ++ openlp/core/utils/actions.py | 42 ++++++++++++++++++++++++++----- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index ab712a57d..63c5aa777 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -39,6 +39,7 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ShortcutListForm, DisplayTagForm from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ get_application_version +from openlp.core.utils.actions import ActionList log = logging.getLogger(__name__) @@ -161,6 +162,7 @@ class Ui_MainWindow(object): mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.themeManagerDock) # Create the menu items + ActionList.add_category(UiStrings.File, 100) self.FileNewItem = shortcut_action(mainWindow, u'FileNewItem', [QtGui.QKeySequence(u'Ctrl+N')], self.ServiceManagerContents.onNewServiceClicked, @@ -183,14 +185,17 @@ class Ui_MainWindow(object): self.FileExitItem = shortcut_action(mainWindow, u'FileExitItem', [QtGui.QKeySequence(u'Alt+F4')], mainWindow.close, u':/system/system_exit.png', category=UiStrings.File) + ActionList.add_category(UiStrings.Import, 95) self.ImportThemeItem = base_action( mainWindow, u'ImportThemeItem', UiStrings.Import) self.ImportLanguageItem = base_action( mainWindow, u'ImportLanguageItem')#, UiStrings.Import) + ActionList.add_category(UiStrings.Export, 90) self.ExportThemeItem = base_action( mainWindow, u'ExportThemeItem', UiStrings.Export) self.ExportLanguageItem = base_action( mainWindow, u'ExportLanguageItem')#, UiStrings.Export) + ActionList.add_category(UiStrings.View, 85) self.ViewMediaManagerItem = shortcut_action(mainWindow, u'ViewMediaManagerItem', [QtGui.QKeySequence(u'F8')], self.toggleMediaManager, u':/system/system_mediamanager.png', @@ -210,6 +215,7 @@ class Ui_MainWindow(object): self.ViewLivePanel = shortcut_action(mainWindow, u'ViewLivePanel', [QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility, checked=liveVisible, category=UiStrings.View) + ActionList.add_category(UiStrings.ViewMode, 80) self.ModeDefaultItem = checkable_action( mainWindow, u'ModeDefaultItem', category=UiStrings.ViewMode) self.ModeSetupItem = checkable_action( @@ -221,11 +227,13 @@ class Ui_MainWindow(object): self.ModeGroup.addAction(self.ModeSetupItem) self.ModeGroup.addAction(self.ModeLiveItem) self.ModeDefaultItem.setChecked(True) + ActionList.add_category(UiStrings.Tools, 75) self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem', u':/tools/tools_add.png', category=UiStrings.Tools) self.ToolsOpenDataFolder = icon_action(mainWindow, u'ToolsOpenDataFolder', u':/general/general_open.png', category=UiStrings.Tools) + ActionList.add_category(UiStrings.Settings, 70) self.settingsPluginListItem = shortcut_action(mainWindow, u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')], self.onPluginItemClicked, u':/system/settings_plugin_list.png', @@ -253,6 +261,7 @@ class Ui_MainWindow(object): self.SettingsConfigureItem = icon_action(mainWindow, u'SettingsConfigureItem', u':/system/system_settings.png', category=UiStrings.Settings) + ActionList.add_category(UiStrings.Help, 65) self.HelpDocumentationItem = icon_action(mainWindow, u'HelpDocumentationItem', u':/system/system_help_contents.png', category=None)#UiStrings.Help) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index caecaca50..528b642ce 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -167,6 +167,7 @@ class ServiceManager(QtGui.QWidget): 'Move item to the top of the service.'), self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home]) self.serviceManagerList.moveTop.setObjectName(u'moveTop') + ActionList.add_category(UiStrings.Service, 45) ActionList.add_action( self.serviceManagerList.moveTop, UiStrings.Service) self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton( diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 66c26da3b..204dada75 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -367,12 +367,14 @@ class SlideController(QtGui.QWidget): def setPreviewHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') + ActionList.add_category(UiStrings.PreviewToolbar, 55) ActionList.add_action(self.previousItem, UiStrings.PreviewToolbar) ActionList.add_action(self.nextItem, UiStrings.PreviewToolbar) def setLiveHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemLive') self.nextItem.setObjectName(u'nextItemLive') + ActionList.add_category(UiStrings.LiveToolbar, 60) ActionList.add_action(self.previousItem, UiStrings.LiveToolbar) ActionList.add_action(self.nextItem, UiStrings.LiveToolbar) self.previousService = shortcut_action(parent, u'previousService', diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index efac7b1bd..214a42249 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -154,13 +154,10 @@ class CategoryList(object): return False def append(self, name, actions=None): - weight = 0 - if len(self.categories) > 0: - weight = self.categories[-1].weight + 1 if actions: - self.add(name, weight, actions) + self.add(name, actions=actions) else: - self.add(name, weight) + self.add(name) def add(self, name, weight=0, actions=None): category = ActionCategory(name, weight) @@ -171,7 +168,7 @@ class CategoryList(object): else: category.actions.append(action) self.categories.append(category) - self.categories.sort(key=lambda cat: cat.weight) + self.categories.sort(key=lambda cat: cat.weight, reverse=True) def remove(self, name): for category in self.categories: @@ -230,6 +227,17 @@ class ActionList(object): @staticmethod def remove_action(action, category=None): + """ + This removes an action from its category. Empty categories are + automatically removed. + + ``action`` + The QAction object to be removed. + + ``category`` + The name (unicode string) of the category, which contains the + action. Defaults to None. + """ if category is not None: category = unicode(category) if category not in ActionList.categories: @@ -238,3 +246,25 @@ class ActionList(object): # Remove empty categories. if len(ActionList.categories[category].actions) == 0: ActionList.categories.remove(category) + + @staticmethod + def add_category(name, weight): + """ + Add an empty category to the list of categories. This is ony convenient + for categories with a given weight. + + ``name`` + The category's name. + + ``weight`` + The category's weight (int). + """ + if name in ActionList.categories: + # Only change the weight and resort the categories again. + for category in ActionList.categories: + if category.name == name: + category.weight = weight + ActionList.categories.categories.sort( + key=lambda cat: cat.weight, reverse=True) + return + ActionList.categories.add(name, weight) From 9011c85a6beedb1ba623374b34029c7cdc122556 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 9 Apr 2011 18:11:02 +0200 Subject: [PATCH 36/76] removed static methods --- openlp/core/lib/ui.py | 9 ++-- openlp/core/ui/mainwindow.py | 19 ++++---- openlp/core/ui/servicemanager.py | 23 +++++----- openlp/core/ui/shortcutlistform.py | 9 ++-- openlp/core/ui/slidecontroller.py | 18 +++++--- openlp/core/utils/actions.py | 50 +++++++++++++-------- openlp/plugins/alerts/alertsplugin.py | 6 ++- openlp/plugins/bibles/bibleplugin.py | 10 +++-- openlp/plugins/songs/songsplugin.py | 14 +++--- openlp/plugins/songusage/songusageplugin.py | 14 +++--- 10 files changed, 102 insertions(+), 70 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 35ea23497..20aca9c6a 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -259,7 +259,8 @@ def base_action(parent, name, category=None): action = QtGui.QAction(parent) action.setObjectName(name) if category is not None: - ActionList.add_action(action, category) + action_list = ActionList.get_instance() + action_list.add_action(action, category) return action def checkable_action(parent, name, checked=None, category=None): @@ -297,7 +298,8 @@ def shortcut_action(parent, name, shortcuts, function, icon=None, checked=None, action.setChecked(checked) action.setShortcuts(shortcuts) action.setShortcutContext(context) - ActionList.add_action(action, category) + action_list = ActionList.get_instance() + action_list.add_action(action, category) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function) return action @@ -335,7 +337,8 @@ def context_menu_action(base, icon, text, slot, shortcuts=None, category=None, if shortcuts is not None: action.setShortcuts(shortcuts) action.setShortcutContext(context) - ActionList.add_action(action) + action_list = ActionList.get_instance() + action_list.add_action(action) return action def context_menu(base, icon, text): diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 63c5aa777..2038e1972 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -39,7 +39,7 @@ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ShortcutListForm, DisplayTagForm from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ get_application_version -from openlp.core.utils.actions import ActionList +from openlp.core.utils.actions import ActionList, CategoryOrder log = logging.getLogger(__name__) @@ -162,7 +162,8 @@ class Ui_MainWindow(object): mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.themeManagerDock) # Create the menu items - ActionList.add_category(UiStrings.File, 100) + action_list = ActionList.get_instance() + action_list.add_category(UiStrings.File, CategoryOrder.standardMenu) self.FileNewItem = shortcut_action(mainWindow, u'FileNewItem', [QtGui.QKeySequence(u'Ctrl+N')], self.ServiceManagerContents.onNewServiceClicked, @@ -185,17 +186,17 @@ class Ui_MainWindow(object): self.FileExitItem = shortcut_action(mainWindow, u'FileExitItem', [QtGui.QKeySequence(u'Alt+F4')], mainWindow.close, u':/system/system_exit.png', category=UiStrings.File) - ActionList.add_category(UiStrings.Import, 95) + action_list.add_category(UiStrings.Import, CategoryOrder.standardMenu) self.ImportThemeItem = base_action( mainWindow, u'ImportThemeItem', UiStrings.Import) self.ImportLanguageItem = base_action( mainWindow, u'ImportLanguageItem')#, UiStrings.Import) - ActionList.add_category(UiStrings.Export, 90) + action_list.add_category(UiStrings.Export, CategoryOrder.standardMenu) self.ExportThemeItem = base_action( mainWindow, u'ExportThemeItem', UiStrings.Export) self.ExportLanguageItem = base_action( mainWindow, u'ExportLanguageItem')#, UiStrings.Export) - ActionList.add_category(UiStrings.View, 85) + action_list.add_category(UiStrings.View, CategoryOrder.standardMenu) self.ViewMediaManagerItem = shortcut_action(mainWindow, u'ViewMediaManagerItem', [QtGui.QKeySequence(u'F8')], self.toggleMediaManager, u':/system/system_mediamanager.png', @@ -215,7 +216,7 @@ class Ui_MainWindow(object): self.ViewLivePanel = shortcut_action(mainWindow, u'ViewLivePanel', [QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility, checked=liveVisible, category=UiStrings.View) - ActionList.add_category(UiStrings.ViewMode, 80) + action_list.add_category(UiStrings.ViewMode, CategoryOrder.standardMenu) self.ModeDefaultItem = checkable_action( mainWindow, u'ModeDefaultItem', category=UiStrings.ViewMode) self.ModeSetupItem = checkable_action( @@ -227,13 +228,13 @@ class Ui_MainWindow(object): self.ModeGroup.addAction(self.ModeSetupItem) self.ModeGroup.addAction(self.ModeLiveItem) self.ModeDefaultItem.setChecked(True) - ActionList.add_category(UiStrings.Tools, 75) + action_list.add_category(UiStrings.Tools, CategoryOrder.standardMenu) self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem', u':/tools/tools_add.png', category=UiStrings.Tools) self.ToolsOpenDataFolder = icon_action(mainWindow, u'ToolsOpenDataFolder', u':/general/general_open.png', category=UiStrings.Tools) - ActionList.add_category(UiStrings.Settings, 70) + action_list.add_category(UiStrings.Settings, CategoryOrder.standardMenu) self.settingsPluginListItem = shortcut_action(mainWindow, u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')], self.onPluginItemClicked, u':/system/settings_plugin_list.png', @@ -261,7 +262,7 @@ class Ui_MainWindow(object): self.SettingsConfigureItem = icon_action(mainWindow, u'SettingsConfigureItem', u':/system/system_settings.png', category=UiStrings.Settings) - ActionList.add_category(UiStrings.Help, 65) + action_list.add_category(UiStrings.Help, CategoryOrder.standardMenu) self.HelpDocumentationItem = icon_action(mainWindow, u'HelpDocumentationItem', u':/system/system_help_contents.png', category=None)#UiStrings.Help) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 528b642ce..864acc138 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -40,7 +40,7 @@ from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm from openlp.core.ui.printserviceform import PrintServiceForm from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \ split_filename -from openlp.core.utils.actions import ActionList +from openlp.core.utils.actions import ActionList, CategoryOrder class ServiceManagerList(QtGui.QTreeWidget): """ @@ -167,8 +167,9 @@ class ServiceManager(QtGui.QWidget): 'Move item to the top of the service.'), self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home]) self.serviceManagerList.moveTop.setObjectName(u'moveTop') - ActionList.add_category(UiStrings.Service, 45) - ActionList.add_action( + action_list = ActionList.get_instance() + action_list.add_category(UiStrings.Service, CategoryOrder.standardToolbar) + action_list.add_action( self.serviceManagerList.moveTop, UiStrings.Service) self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &up'), @@ -177,7 +178,7 @@ class ServiceManager(QtGui.QWidget): 'Move item up one position in the service.'), self.onServiceUp, shortcuts=[QtCore.Qt.Key_PageUp]) self.serviceManagerList.moveUp.setObjectName(u'moveUp') - ActionList.add_action(self.serviceManagerList.moveUp, UiStrings.Service) + action_list.add_action(self.serviceManagerList.moveUp, UiStrings.Service) self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &down'), u':/services/service_down.png', @@ -185,7 +186,7 @@ class ServiceManager(QtGui.QWidget): 'Move item down one position in the service.'), self.onServiceDown, shortcuts=[QtCore.Qt.Key_PageDown]) self.serviceManagerList.moveDown.setObjectName(u'moveDown') - ActionList.add_action( + action_list.add_action( self.serviceManagerList.moveDown, UiStrings.Service) self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move to &bottom'), @@ -194,7 +195,7 @@ class ServiceManager(QtGui.QWidget): 'Move item to the end of the service.'), self.onServiceEnd, shortcuts=[QtCore.Qt.Key_End]) self.serviceManagerList.moveBottom.setObjectName(u'moveBottom') - ActionList.add_action( + action_list.add_action( self.serviceManagerList.moveBottom, UiStrings.Service) self.serviceManagerList.down = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &down'), @@ -203,7 +204,7 @@ class ServiceManager(QtGui.QWidget): 'Moves the selection down the window.'), self.onMoveSelectionDown, shortcuts=[QtCore.Qt.Key_Down]) self.serviceManagerList.down.setObjectName(u'down') - ActionList.add_action(self.serviceManagerList.down) + action_list.add_action(self.serviceManagerList.down) self.serviceManagerList.down.setVisible(False) self.serviceManagerList.up = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move up'), @@ -212,7 +213,7 @@ class ServiceManager(QtGui.QWidget): 'Moves the selection up the window.'), self.onMoveSelectionUp, shortcuts=[QtCore.Qt.Key_Up]) self.serviceManagerList.up.setObjectName(u'up') - ActionList.add_action(self.serviceManagerList.up) + action_list.add_action(self.serviceManagerList.up) self.serviceManagerList.up.setVisible(False) self.orderToolbar.addSeparator() self.serviceManagerList.delete = self.orderToolbar.addToolbarButton( @@ -229,7 +230,7 @@ class ServiceManager(QtGui.QWidget): 'Expand all the service items.'), self.onExpandAll, shortcuts=[QtCore.Qt.Key_Plus]) self.serviceManagerList.expand.setObjectName(u'expand') - ActionList.add_action(self.serviceManagerList.expand, UiStrings.Service) + action_list.add_action(self.serviceManagerList.expand, UiStrings.Service) self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', '&Collapse all'), u':/services/service_collapse_all.png', @@ -237,7 +238,7 @@ class ServiceManager(QtGui.QWidget): 'Collapse all the service items.'), self.onCollapseAll, shortcuts=[QtCore.Qt.Key_Minus]) self.serviceManagerList.collapse.setObjectName(u'collapse') - ActionList.add_action( + action_list.add_action( self.serviceManagerList.collapse, UiStrings.Service) self.orderToolbar.addSeparator() self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton( @@ -247,7 +248,7 @@ class ServiceManager(QtGui.QWidget): 'Send the selected item to Live.'), self.makeLive, shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]) self.serviceManagerList.makeLive.setObjectName(u'orderToolbar') - ActionList.add_action( + action_list.add_action( self.serviceManagerList.makeLive, UiStrings.Service) self.layout.addWidget(self.orderToolbar) # Connect up our signals and slots diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 336e160b1..ddf84fdd6 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -46,6 +46,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): QtGui.QDialog.__init__(self, parent) self.setupUi(self) self.changedActions = {} + self.action_list = ActionList.get_instance() QtCore.QObject.connect(self.primaryPushButton, QtCore.SIGNAL(u'toggled(bool)'), self.onPrimaryPushButtonClicked) QtCore.QObject.connect(self.alternatePushButton, @@ -96,7 +97,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): # The action we are attempting to change. changing_action = self._currentItemAction() shortcut_valid = True - for category in ActionList.categories: + for category in self.action_list.categories: for action in category.actions: shortcuts = self._actionShortcuts(action) if key_sequence not in shortcuts: @@ -149,7 +150,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): Reload the ``treeWidget`` list to add new and remove old actions. """ self.treeWidget.clear() - for category in ActionList.categories: + for category in self.action_list.categories: # Check if the category is for internal use only. if category.name is None: continue @@ -303,7 +304,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): return self._adjustButton(self.primaryPushButton, False, text=u'') self._adjustButton(self.alternatePushButton, False, text=u'') - for category in ActionList.categories: + for category in self.action_list.categories: for action in category.actions: self.changedActions[action] = action.defaultShortcuts self.refreshShortcutList() @@ -349,7 +350,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ settings = QtCore.QSettings() settings.beginGroup(u'shortcuts') - for category in ActionList.categories: + for category in self.action_list.categories: # Check if the category is for internal use only. if category.name is None: continue diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 204dada75..4f5ed1ea7 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -34,7 +34,7 @@ from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \ ItemCapabilities, translate from openlp.core.lib.ui import UiStrings, shortcut_action from openlp.core.ui import HideMode, MainDisplay -from openlp.core.utils.actions import ActionList +from openlp.core.utils.actions import ActionList, CategoryOrder log = logging.getLogger(__name__) @@ -367,16 +367,20 @@ class SlideController(QtGui.QWidget): def setPreviewHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') - ActionList.add_category(UiStrings.PreviewToolbar, 55) - ActionList.add_action(self.previousItem, UiStrings.PreviewToolbar) - ActionList.add_action(self.nextItem, UiStrings.PreviewToolbar) + action_list = ActionList.get_instance() + action_list.add_category( + UiStrings.PreviewToolbar, CategoryOrder.standardToolbar) + action_list.add_action(self.previousItem, UiStrings.PreviewToolbar) + action_list.add_action(self.nextItem, UiStrings.PreviewToolbar) def setLiveHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemLive') self.nextItem.setObjectName(u'nextItemLive') - ActionList.add_category(UiStrings.LiveToolbar, 60) - ActionList.add_action(self.previousItem, UiStrings.LiveToolbar) - ActionList.add_action(self.nextItem, UiStrings.LiveToolbar) + action_list = ActionList.get_instance() + action_list.add_category( + UiStrings.LiveToolbar, CategoryOrder.standardToolbar) + action_list.add_action(self.previousItem, UiStrings.LiveToolbar) + action_list.add_action(self.nextItem, UiStrings.LiveToolbar) self.previousService = shortcut_action(parent, u'previousService', [QtCore.Qt.Key_Left], self.servicePrevious, UiStrings.LiveToolbar) self.previousService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 214a42249..76b72c55c 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -183,10 +183,18 @@ class ActionList(object): has a weight by which it is sorted when iterating through the list of actions or categories. """ - categories = CategoryList() + instance = None + + def __init__(self): + self.categories = CategoryList() @staticmethod - def add_action(action, category=None, weight=None): + def get_instance(): + if ActionList.instance is None: + ActionList.instance = ActionList() + return ActionList.instance + + def add_action(self, action, category=None, weight=None): """ Add an action to the list of actions. @@ -206,13 +214,13 @@ class ActionList(object): """ if category is not None: category = unicode(category) - if category not in ActionList.categories: - ActionList.categories.append(category) + if category not in self.categories: + self.categories.append(category) action.defaultShortcuts = action.shortcuts() if weight is None: - ActionList.categories[category].actions.append(action) + self.categories[category].actions.append(action) else: - ActionList.categories[category].actions.add(action, weight) + self.categories[category].actions.add(action, weight) if category is None: # Stop here, as this action is not configurable. return @@ -225,8 +233,7 @@ class ActionList(object): [QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) settings.endGroup() - @staticmethod - def remove_action(action, category=None): + def remove_action(self, action, category=None): """ This removes an action from its category. Empty categories are automatically removed. @@ -240,15 +247,14 @@ class ActionList(object): """ if category is not None: category = unicode(category) - if category not in ActionList.categories: + if category not in self.categories: return - ActionList.categories[category].actions.remove(action) + self.categories[category].actions.remove(action) # Remove empty categories. - if len(ActionList.categories[category].actions) == 0: - ActionList.categories.remove(category) + if len(self.categories[category].actions) == 0: + self.categories.remove(category) - @staticmethod - def add_category(name, weight): + def add_category(self, name, weight): """ Add an empty category to the list of categories. This is ony convenient for categories with a given weight. @@ -259,12 +265,20 @@ class ActionList(object): ``weight`` The category's weight (int). """ - if name in ActionList.categories: + if name in self.categories: # Only change the weight and resort the categories again. - for category in ActionList.categories: + for category in self.categories: if category.name == name: category.weight = weight - ActionList.categories.categories.sort( + self.categories.categories.sort( key=lambda cat: cat.weight, reverse=True) return - ActionList.categories.add(name, weight) + self.categories.add(name, weight) + + +class CategoryOrder(object): + """ + An enumeration class for category weights. + """ + standardMenu = 100 + standardToolbar = 90 diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index d564a9754..7d6eac6e2 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -75,7 +75,8 @@ class AlertsPlugin(Plugin): log.info(u'Alerts Initialising') Plugin.initialise(self) self.toolsAlertItem.setVisible(True) - ActionList.add_action(self.toolsAlertItem, UiStrings.Tools) + action_list = ActionList.get_instance() + action_list.add_action(self.toolsAlertItem, UiStrings.Tools) self.liveController.alertTab = self.settings_tab def finalise(self): @@ -86,7 +87,8 @@ class AlertsPlugin(Plugin): self.manager.finalise() Plugin.finalise(self) self.toolsAlertItem.setVisible(False) - ActionList.remove_action(self.toolsAlertItem, u'Tools') + action_list = ActionList.get_instance() + action_list.remove_action(self.toolsAlertItem, u'Tools') def toggleAlertsState(self): self.alertsActive = not self.alertsActive diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 60be388ba..aea732688 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -52,9 +52,10 @@ class BiblePlugin(Plugin): self.manager = BibleManager(self) Plugin.initialise(self) self.importBibleItem.setVisible(True) - ActionList.add_action(self.importBibleItem, UiStrings.Import) + action_list = ActionList.get_instance() + action_list.add_action(self.importBibleItem, UiStrings.Import) # Do not add the action to the list yet. - #ActionList.add_action(self.exportBibleItem, UiStrings.Export) + #action_list.add_action(self.exportBibleItem, UiStrings.Export) # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) @@ -65,9 +66,10 @@ class BiblePlugin(Plugin): log.info(u'Plugin Finalise') self.manager.finalise() Plugin.finalise(self) - ActionList.remove_action(self.importBibleItem, UiStrings.Import) + action_list = ActionList.get_instance() + action_list.remove_action(self.importBibleItem, UiStrings.Import) self.importBibleItem.setVisible(False) - #ActionList.remove_action(self.exportBibleItem, UiStrings.Export) + #action_list.remove_action(self.exportBibleItem, UiStrings.Export) self.exportBibleItem.setVisible(False) def addImportMenuItem(self, import_menu): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index a3230ff7f..af50f3f94 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -66,9 +66,10 @@ class SongsPlugin(Plugin): log.info(u'Songs Initialising') Plugin.initialise(self) self.toolsReindexItem.setVisible(True) - ActionList.add_action(self.SongImportItem, UiStrings.Import) - ActionList.add_action(self.SongExportItem, UiStrings.Export) - ActionList.add_action(self.toolsReindexItem, UiStrings.Tools) + action_list = ActionList.get_instance() + action_list.add_action(self.SongImportItem, UiStrings.Import) + action_list.add_action(self.SongExportItem, UiStrings.Export) + action_list.add_action(self.toolsReindexItem, UiStrings.Tools) self.mediaItem.displayResultsSong( self.manager.get_all_objects(Song, order_by_ref=Song.search_title)) @@ -258,7 +259,8 @@ class SongsPlugin(Plugin): log.info(u'Songs Finalising') self.manager.finalise() self.toolsReindexItem.setVisible(False) - ActionList.remove_action(self.SongImportItem, UiStrings.Import) - ActionList.remove_action(self.SongExportItem, UiStrings.Export) - ActionList.remove_action(self.toolsReindexItem, UiStrings.Tools) + action_list = ActionList.get_instance() + action_list.remove_action(self.SongImportItem, UiStrings.Import) + action_list.remove_action(self.SongExportItem, UiStrings.Export) + action_list.remove_action(self.toolsReindexItem, UiStrings.Tools) Plugin.finalise(self) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index b0a545ad8..5f21451b6 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -110,11 +110,12 @@ class SongUsagePlugin(Plugin): self.settingsSection + u'/active', QtCore.QVariant(False)).toBool() self.SongUsageStatus.setChecked(self.SongUsageActive) - ActionList.add_action(self.SongUsageDelete, + action_list = ActionList.get_instance() + action_list.add_action(self.SongUsageDelete, translate('SongUsagePlugin', 'Song Usage')) - ActionList.add_action(self.SongUsageReport, + action_list.add_action(self.SongUsageReport, translate('SongUsagePlugin', 'Song Usage')) - ActionList.add_action(self.SongUsageStatus, + action_list.add_action(self.SongUsageStatus, translate('SongUsagePlugin', 'Song Usage')) if self.manager is None: self.manager = Manager(u'songusage', init_schema) @@ -131,11 +132,12 @@ class SongUsagePlugin(Plugin): self.manager.finalise() Plugin.finalise(self) self.SongUsageMenu.menuAction().setVisible(False) - ActionList.remove_action(self.SongUsageDelete, + action_list = ActionList.get_instance() + action_list.remove_action(self.SongUsageDelete, translate('SongUsagePlugin', 'Song Usage')) - ActionList.remove_action(self.SongUsageReport, + action_list.remove_action(self.SongUsageReport, translate('SongUsagePlugin', 'Song Usage')) - ActionList.remove_action(self.SongUsageStatus, + action_list.remove_action(self.SongUsageStatus, translate('SongUsagePlugin', 'Song Usage')) #stop any events being processed self.SongUsageActive = False From a54a3eb79255727b3027973eec3b2151244fda41 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 9 Apr 2011 20:14:51 +0200 Subject: [PATCH 37/76] make first column wider; added description label back; removed Qt = Qt.QCore; fixed litte bug which left the shortcut text on the buttons --- openlp/core/ui/shortcutlistdialog.py | 13 +++++++++---- openlp/core/ui/shortcutlistform.py | 15 +++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index a5050ab25..32fe68b95 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -33,11 +33,16 @@ class Ui_ShortcutListDialog(object): shortcutListDialog.setObjectName(u'shortcutListDialog') shortcutListDialog.resize(500, 438) self.shortcutListLayout = QtGui.QVBoxLayout(shortcutListDialog) - self.shortcutListLayout.setObjectName(u'shortcutListLayout') + self.shortcutListLayout.setObjectName(u'shortcutLitLayout') + self.descriptionLabel = QtGui.QLabel(shortcutListDialog) + self.descriptionLabel.setObjectName(u'descriptionLabel') + self.descriptionLabel.setWordWrap(True) + self.shortcutListLayout.addWidget(self.descriptionLabel) self.treeWidget = QtGui.QTreeWidget(shortcutListDialog) self.treeWidget.setObjectName(u'treeWidget') self.treeWidget.setAlternatingRowColors(True) self.treeWidget.setColumnCount(3) + self.treeWidget.setColumnWidth(0, 250) self.shortcutListLayout.addWidget(self.treeWidget) self.detailsLayout = QtGui.QGridLayout() self.detailsLayout.setObjectName(u'detailsLayout') @@ -102,9 +107,9 @@ class Ui_ShortcutListDialog(object): def retranslateUi(self, shortcutListDialog): shortcutListDialog.setWindowTitle( translate('OpenLP.ShortcutListDialog', 'Customize Shortcuts')) - #self.descriptionLabel.setText(translate('OpenLP.ShortcutListDialog', - #'Select an action and click the button below to start capturing ' - #'a new shortcut.')) + self.descriptionLabel.setText(translate('OpenLP.ShortcutListDialog', + 'Select an action and click one of the buttons below to start ' + 'capturing a new primary or alternate shortcut, respectively.')) self.treeWidget.setHeaderLabels([ translate('OpenLP.ShortcutListDialog', 'Action'), translate('OpenLP.ShortcutListDialog', 'Shortcut'), diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index ddf84fdd6..26bfddadd 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -78,20 +78,21 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.close() def keyReleaseEvent(self, event): - Qt = QtCore.Qt if not self.primaryPushButton.isChecked() and \ not self.alternatePushButton.isChecked(): return key = event.key() - if key == Qt.Key_Shift or key == Qt.Key_Control or \ - key == Qt.Key_Meta or key == Qt.Key_Alt: + if key == QtCore.Qt.Key_Shift or key == QtCore.Qt.Key_Control or \ + key == QtCore.Qt.Key_Meta or key == QtCore.Qt.Key_Alt: return key_string = QtGui.QKeySequence(key).toString() - if event.modifiers() & Qt.ControlModifier == Qt.ControlModifier: + if event.modifiers() & QtCore.Qt.ControlModifier == \ + QtCore.Qt.ControlModifier: key_string = u'Ctrl+' + key_string - if event.modifiers() & Qt.AltModifier == Qt.AltModifier: + if event.modifiers() & QtCore.Qt.AltModifier == QtCore.Qt.AltModifier: key_string = u'Alt+' + key_string - if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier: + if event.modifiers() & QtCore.Qt.ShiftModifier == \ + QtCore.Qt.ShiftModifier: key_string = u'Shift+' + key_string key_sequence = QtGui.QKeySequence(key_string) # The action we are attempting to change. @@ -377,6 +378,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): new_shortcuts.append(shortcuts[1]) self.changedActions[action] = new_shortcuts self.refreshShortcutList() + self.onCurrentItemChanged(self.treeWidget.currentItem()) def onClearAlternateButtonClicked(self, toggled): """ @@ -394,6 +396,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): new_shortcuts.append(action.defaultShortcuts[1]) self.changedActions[action] = new_shortcuts self.refreshShortcutList() + self.onCurrentItemChanged(self.treeWidget.currentItem()) def _actionShortcuts(self, action): """ From b7a1554abda5e718744261006240f97210d11f38 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 10 Apr 2011 09:07:02 +0200 Subject: [PATCH 38/76] fixed objectName --- openlp/core/ui/shortcutlistdialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 32fe68b95..288086cba 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -33,7 +33,7 @@ class Ui_ShortcutListDialog(object): shortcutListDialog.setObjectName(u'shortcutListDialog') shortcutListDialog.resize(500, 438) self.shortcutListLayout = QtGui.QVBoxLayout(shortcutListDialog) - self.shortcutListLayout.setObjectName(u'shortcutLitLayout') + self.shortcutListLayout.setObjectName(u'shortcutListLayout') self.descriptionLabel = QtGui.QLabel(shortcutListDialog) self.descriptionLabel.setObjectName(u'descriptionLabel') self.descriptionLabel.setWordWrap(True) From 9dbd54bf8f6396c1121ca13b0dec77f07809862c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 10 Apr 2011 20:44:27 +0200 Subject: [PATCH 39/76] more fixes --- openlp/core/ui/servicemanager.py | 4 ++-- openlp/plugins/songs/lib/mediaitem.py | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index adafe5fd6..5e14ec637 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -691,9 +691,9 @@ class ServiceManager(QtGui.QWidget): Called by the SlideController to request a preview item be made live and allows the next preview to be updated if relevent. """ - id, row = message.split(u':') + uuid, row = message.split(u':') for sitem in self.serviceItems: - if sitem[u'service_item']._uuid == id: + if sitem[u'service_item']._uuid == uuid: item = self.serviceManagerList.topLevelItem(sitem[u'order'] - 1) self.serviceManagerList.setCurrentItem(item) self.makeLive(int(row)) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index f4803d653..e2882ed29 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -283,19 +283,20 @@ class SongMediaItem(MediaManagerItem): self.remoteTriggered = None self.remoteSong = -1 - def onRemoteEdit(self, songid): + def onRemoteEdit(self, message): """ Called by ServiceManager or SlideController by event passing the Song Id in the payload along with an indicator to say which type of display is required. """ - log.debug(u'onRemoteEdit %s' % songid) - fields = songid.split(u':') - valid = self.parent.manager.get_object(Song, fields[1]) + log.debug(u'onRemoteEdit %s' % message) + remote_type, song_id = message.split(u':') + song_id = int(song_id) + valid = self.parent.manager.get_object(Song, song_id) if valid: - self.remoteSong = fields[1] - self.remoteTriggered = fields[0] - self.edit_song_form.loadSong(fields[1], (fields[0] == u'P')) + self.remoteSong = song_id + self.remoteTriggered = remote_type + self.edit_song_form.loadSong(song_id, (remote_type == u'P')) self.edit_song_form.exec_() def onEditClick(self): From 1ce94d1c2080bc608cde241c856305022595c4d3 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sun, 10 Apr 2011 23:10:23 +0100 Subject: [PATCH 40/76] Fix theme image appearing between media images. Try and do same for ppt, but not yet. Broken the blank button... (it'll get worse before it gets better!) --- openlp/core/lib/htmlbuilder.py | 20 +++++++--- openlp/core/ui/maindisplay.py | 8 +++- openlp/core/ui/slidecontroller.py | 63 +++++++++++++++++++++---------- 3 files changed, 64 insertions(+), 27 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index c4361a421..c874c9ff2 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -307,7 +307,7 @@ sup { - + + + From 20fbe4d28d99ad0d291e460a68c32ae1bc94bd36 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 12 Apr 2011 20:32:17 +0100 Subject: [PATCH 47/76] Settings Cleanup part2 --- openlp/core/lib/plugin.py | 23 ++++--------- openlp/core/lib/pluginmanager.py | 2 -- openlp/core/ui/advancedtab.py | 3 +- openlp/core/ui/generaltab.py | 3 +- openlp/core/ui/mediadockmanager.py | 2 +- openlp/core/ui/settingsdialog.py | 11 ++++-- openlp/core/ui/settingsform.py | 47 +++++++++++++++----------- openlp/core/ui/themestab.py | 3 +- openlp/plugins/alerts/alertsplugin.py | 5 +-- openlp/plugins/remotes/remoteplugin.py | 7 ++-- 10 files changed, 54 insertions(+), 52 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 99247c4b9..ef89e6424 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -141,6 +141,7 @@ class Plugin(QtCore.QObject): ``settings_tab_class`` The class name of the plugin's settings tab. """ + log.debug(u'Plugin %s initialised' % name) QtCore.QObject.__init__(self) self.name = name self.textStrings = {} @@ -250,7 +251,8 @@ class Plugin(QtCore.QObject): """ if self.settings_tab_class: return self.settings_tab_class(self.name, - self.getString(StringContent.VisibleName)[u'title'], self.icon_path) + self.getString(StringContent.VisibleName)[u'title'], + self.icon_path) return None def addToMenu(self, menubar): @@ -287,32 +289,19 @@ class Plugin(QtCore.QObject): """ if self.mediaItem: self.mediaItem.initialise() - self.insertToolboxItem() + self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight) + if self.settings_tab: + self.settingsForm.insertTab(self.settings_tab, self.weight) def finalise(self): """ Called by the plugin Manager to cleanup things. """ - self.removeToolboxItem() - - def removeToolboxItem(self): - """ - Called by the plugin to remove toolbar - """ if self.mediaItem: self.mediadock.remove_dock(self.mediaItem) if self.settings_tab: self.settingsForm.removeTab(self.settings_tab) - def insertToolboxItem(self): - """ - Called by plugin to replace toolbar - """ - if self.mediaItem: - self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight) - if self.settings_tab: - self.settingsForm.insertTab(self.settings_tab, self.weight) - def usesTheme(self, theme): """ Called to find out if a plugin is currently using a theme. diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index ef8287ba7..3b73750fe 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -206,8 +206,6 @@ class PluginManager(object): if plugin.isActive(): plugin.initialise() log.info(u'Initialisation Complete for %s ' % plugin.name) - if not plugin.isActive(): - plugin.removeToolboxItem() log.info(u'Initialise Plugins - Finished') def finalise_plugins(self): diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index cf4c5b9d5..6041382b8 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -41,7 +41,8 @@ class AdvancedTab(SettingsTab): """ Initialise the settings tab """ - SettingsTab.__init__(self, u'Advanced') + generalTranslated = translate('AdvancedTab', 'Advanced') + SettingsTab.__init__(self, u'Advanced', generalTranslated) self.default_image = u':/graphics/openlp-splash-screen.png' self.default_color = u'#ffffff' self.icon_path = u':/icon/openlp-logo-16x16.png' diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 279cd8c26..d566244b8 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -45,7 +45,8 @@ class GeneralTab(SettingsTab): # Set to True to allow PostSetup to work on application start up self.overrideChanged = True self.icon_path = u':/icon/openlp-logo-16x16.png' - SettingsTab.__init__(self, u'General') + generalTranslated = translate('GeneralTab', 'General') + SettingsTab.__init__(self, u'General', generalTranslated) def preLoad(self): """ diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index ef4bc62e0..ca4f4d442 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -84,5 +84,5 @@ class MediaDockManager(object): if self.media_dock.widget(dock_index): if self.media_dock.widget(dock_index).settingsSection == \ media_item.plugin.name.lower(): - self.media_dock.widget(dock_index).hide() + self.media_dock.widget(dock_index).setVisible(False) self.media_dock.removeItem(dock_index) diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index 9359ff54c..e66defac3 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -38,15 +38,20 @@ class Ui_SettingsDialog(object): self.settingsLayout = QtGui.QGridLayout(settingsDialog) self.settingsLayout.setObjectName(u'settingsLayout') self.settingListWidget = QtGui.QListWidget(settingsDialog) + self.settingListWidget.setIconSize(QtCore.QSize(32, 32)) self.settingListWidget.setObjectName(u'settingListWidget') self.settingsLayout.addWidget(self.settingListWidget, 0, 0, 1, 1) - self.settingsTabWidget = QtGui.QTabWidget(settingsDialog) - self.settingsTabWidget.setObjectName(u'settingsTabWidget') - self.settingsLayout.addWidget(self.settingsTabWidget, 0, 1, 1, 1) + self.stackedLayout = QtGui.QStackedLayout() + self.stackedLayout.setObjectName(u'stackedLayout') + self.settingsLayout.addLayout(self.stackedLayout, 0, 1, 1, 1) self.buttonBox = create_accept_reject_button_box(settingsDialog, True) self.settingsLayout.addWidget(self.buttonBox, 1, 1, 1, 1) self.retranslateUi(settingsDialog) + self.stackedLayout.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(settingsDialog) + QtCore.QObject.connect(self.settingListWidget, + QtCore.SIGNAL(u'currentRowChanged(int)'), + self.stackedLayout.setCurrentIndex) def retranslateUi(self, settingsDialog): settingsDialog.setWindowTitle(translate('OpenLP.SettingsForm', diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index c145224be..6de2a14d8 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -58,8 +58,8 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): def exec_(self): # load all the settings - for tabIndex in range(0, self.settingsTabWidget.count()): - self.settingsTabWidget.widget(tabIndex).load() + for tabIndex in range(0, self.stackedLayout.count()): + self.stackedLayout.widget(tabIndex).load() return QtGui.QDialog.exec_(self) @@ -69,32 +69,39 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): """ log.debug(u'Inserting %s tab' % tab.tabTitle) # 14 : There are 3 tables currently and locations starts at -10 - self.settingsTabWidget.insertTab( - location + 14, tab, tab.tabTitleVisible) - print tab.tabTitleVisible - item_name = QtGui.QListWidgetItem(tab.tabTitleVisible) - icon = build_icon(tab.icon_path) - pixmap = icon.pixmap(QtCore.QSize(88, 50)) - item_name.setIcon(icon) - self.settingListWidget.insertItem(14 + location, item_name) + match = False + for tabIndex in range(0, self.stackedLayout.count()): + if self.stackedLayout.widget(tabIndex): + if self.stackedLayout.widget(tabIndex).tabTitleVisible == \ + tab.tabTitleVisible: + print tab.tabTitleVisible + self.stackedLayout.widget(tabIndex).setHidden(False) + match = True + break + if not match: + self.stackedLayout.addWidget(tab) + item_name = QtGui.QListWidgetItem(tab.tabTitleVisible) + icon = build_icon(tab.icon_path) + item_name.setIcon(icon) + self.settingListWidget.insertItem(14 + location, item_name) def removeTab(self, tab): """ Remove a tab from the form """ log.debug(u'remove %s tab' % tab.tabTitleVisible) - for tabIndex in range(0, self.settingsTabWidget.count()): - if self.settingsTabWidget.widget(tabIndex): - if self.settingsTabWidget.widget(tabIndex).tabTitleVisible == \ + for tabIndex in range(0, self.stackedLayout.count()): + if self.stackedLayout.widget(tabIndex): + if self.stackedLayout.widget(tabIndex).tabTitleVisible == \ tab.tabTitleVisible: - self.settingsTabWidget.removeTab(tabIndex) + self.settingListWidget.item(tabIndex).setHidden(True) def accept(self): """ Process the form saving the settings """ - for tabIndex in range(0, self.settingsTabWidget.count()): - self.settingsTabWidget.widget(tabIndex).save() + for tabIndex in range(0, self.stackedLayout.count()): + self.stackedLayout.widget(tabIndex).save() # Must go after all settings are save Receiver.send_message(u'config_updated') return QtGui.QDialog.accept(self) @@ -103,13 +110,13 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): """ Process the form saving the settings """ - for tabIndex in range(0, self.settingsTabWidget.count()): - self.settingsTabWidget.widget(tabIndex).cancel() + for tabIndex in range(0, self.stackedLayout.count()): + self.stackedLayout.widget(tabIndex).cancel() return QtGui.QDialog.reject(self) def postSetUp(self): """ Run any post-setup code for the tabs on the form """ - for tabIndex in range(0, self.settingsTabWidget.count()): - self.settingsTabWidget.widget(tabIndex).postSetUp() + for tabIndex in range(0, self.stackedLayout.count()): + self.stackedLayout.widget(tabIndex).postSetUp() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 5d07d0cf7..b5fcce1ec 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -36,7 +36,8 @@ class ThemesTab(SettingsTab): """ def __init__(self, parent): self.parent = parent - SettingsTab.__init__(self, u'Themes') + generalTranslated = translate('ThemeTab', 'Themes') + SettingsTab.__init__(self, u'Themes', generalTranslated) self.icon_path = u':/themes/theme_new.png' def setupUi(self): diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index db0ba3b7e..df7823ed5 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -41,9 +41,10 @@ class AlertsPlugin(Plugin): def __init__(self, plugin_helpers): Plugin.__init__(self, u'Alerts', plugin_helpers, - settingsTabClass=AlertsTab) + settings_tab_class=AlertsTab) self.weight = -3 - self.icon = build_icon(u':/plugins/plugin_alerts.png') + self.icon_path = u':/plugins/plugin_alerts.png' + self.icon = build_icon(self.icon_path) self.alertsmanager = AlertsManager(self) self.manager = Manager(u'alerts', init_schema) self.alertForm = AlertForm(self) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 41346dbab..fea9e5170 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -38,9 +38,9 @@ class RemotesPlugin(Plugin): """ remotes constructor """ - Plugin.__init__(self, u'Remotes', plugin_helpers, - settingsTabClass=RemoteTab) - self.icon = build_icon(u':/plugins/plugin_remote.png') + Plugin.__init__(self, u'Remotes', plugin_helpers) + self.icon_path = u':/plugins/plugin_remote.png' + self.icon = build_icon(self.icon_path) self.weight = -1 self.server = None @@ -50,7 +50,6 @@ class RemotesPlugin(Plugin): """ log.debug(u'initialise') Plugin.initialise(self) - self.insertToolboxItem() self.server = HttpServer(self) def finalise(self): From c6833003851d7e70681a87429cec43e830556c5c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 12 Apr 2011 23:01:27 +0200 Subject: [PATCH 48/76] fixed weight --- openlp/core/utils/actions.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 76b72c55c..0c4eee655 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -154,10 +154,13 @@ class CategoryList(object): return False def append(self, name, actions=None): + weight = 0 + if len(self.categories) > 0: + weight = self.categories[-1].weight + 1 if actions: - self.add(name, actions=actions) + self.add(name, weight, actions) else: - self.add(name) + self.add(name, weight) def add(self, name, weight=0, actions=None): category = ActionCategory(name, weight) @@ -168,7 +171,7 @@ class CategoryList(object): else: category.actions.append(action) self.categories.append(category) - self.categories.sort(key=lambda cat: cat.weight, reverse=True) + self.categories.sort(key=lambda cat: cat.weight) def remove(self, name): for category in self.categories: @@ -270,8 +273,7 @@ class ActionList(object): for category in self.categories: if category.name == name: category.weight = weight - self.categories.categories.sort( - key=lambda cat: cat.weight, reverse=True) + self.categories.categories.sort(key=lambda cat: cat.weight) return self.categories.add(name, weight) @@ -280,5 +282,5 @@ class CategoryOrder(object): """ An enumeration class for category weights. """ - standardMenu = 100 - standardToolbar = 90 + standardMenu = -20 + standardToolbar = -10 From 28dec27ed2847b524d23fff4dbe57ce01a4e79b9 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 12 Apr 2011 23:12:07 +0200 Subject: [PATCH 49/76] fixed bug #758206 Fixes: https://launchpad.net/bugs/758206 --- openlp/core/lib/mediamanageritem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 13277876d..7671064df 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -274,8 +274,8 @@ class MediaManagerItem(QtGui.QWidget): context_menu_action( self.listView, u':/general/general_preview.png', self.plugin.getString(StringContent.Preview)[u'title'], - self.onPreviewClick, [QtCore.Qt.Key_Enter], - context=QtCore.Qt.WidgetShortcut)) + self.onPreviewClick, [QtCore.Qt.Key_Enter, + QtCore.Qt.Key_Return], context=QtCore.Qt.WidgetShortcut)) self.listView.addAction( context_menu_action( self.listView, u':/general/general_live.png', From 6474c99a85cffb7b13692561a335fd35600eebe1 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 13 Apr 2011 05:55:00 +0100 Subject: [PATCH 50/76] Settings Layout Ok ish --- openlp/core/ui/settingsdialog.py | 6 ++++-- openlp/core/ui/settingsform.py | 3 ++- resources/forms/settings.ui | 37 ++++++++++++++++++++++++++------ 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index e66defac3..45a68c321 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -37,8 +37,11 @@ class Ui_SettingsDialog(object): build_icon(u':/system/system_settings.png')) self.settingsLayout = QtGui.QGridLayout(settingsDialog) self.settingsLayout.setObjectName(u'settingsLayout') + self.settingsLayout.setMargin(0) self.settingListWidget = QtGui.QListWidget(settingsDialog) - self.settingListWidget.setIconSize(QtCore.QSize(32, 32)) + self.settingListWidget.setMinimumSize(QtCore.QSize(150, 0)) + self.settingListWidget.setHorizontalScrollBarPolicy( + QtCore.Qt.ScrollBarAlwaysOff) self.settingListWidget.setObjectName(u'settingListWidget') self.settingsLayout.addWidget(self.settingListWidget, 0, 0, 1, 1) self.stackedLayout = QtGui.QStackedLayout() @@ -47,7 +50,6 @@ class Ui_SettingsDialog(object): self.buttonBox = create_accept_reject_button_box(settingsDialog, True) self.settingsLayout.addWidget(self.buttonBox, 1, 1, 1, 1) self.retranslateUi(settingsDialog) - self.stackedLayout.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(settingsDialog) QtCore.QObject.connect(self.settingListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 6de2a14d8..1e71bc985 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -74,7 +74,6 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): if self.stackedLayout.widget(tabIndex): if self.stackedLayout.widget(tabIndex).tabTitleVisible == \ tab.tabTitleVisible: - print tab.tabTitleVisible self.stackedLayout.widget(tabIndex).setHidden(False) match = True break @@ -84,6 +83,8 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): icon = build_icon(tab.icon_path) item_name.setIcon(icon) self.settingListWidget.insertItem(14 + location, item_name) + self.stackedLayout.addWidget(tab) + self.stackedLayout.setCurrentIndex(0) def removeTab(self, tab): """ diff --git a/resources/forms/settings.ui b/resources/forms/settings.ui index 0c378e125..06e55a00d 100644 --- a/resources/forms/settings.ui +++ b/resources/forms/settings.ui @@ -17,26 +17,49 @@ :/icon/openlp.org-icon-32.bmp:/icon/openlp.org-icon-32.bmp - + 10 30 - 681 + 691 441 - - - - + + + 500 + 0 + + + + + + + 0 + 0 + 211 + 409 + + + + + 200 + 0 + + + + Qt::ScrollBarAlwaysOff + + + - + From 5f228a69d101b83d404989b86fb8e8d9e6985ce0 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 13 Apr 2011 06:12:31 +0100 Subject: [PATCH 51/76] Minor fixes and Bible Label corrections --- openlp/core/lib/ui.py | 3 ++- openlp/plugins/bibles/lib/biblestab.py | 3 +-- openlp/plugins/bibles/lib/mediaitem.py | 7 ++----- openlp/plugins/remotes/remoteplugin.py | 3 ++- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 4f6951d13..fa0bc8afa 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -62,6 +62,7 @@ class UiStrings(object): Hours = translate('OpenLP.Ui', 'h', 'The abbreviated unit for hours') Image = translate('OpenLP.Ui', 'Image') Import = translate('OpenLP.Ui', 'Import') + LayoutStyle = translate('OpenLP.Ui', 'Layout style:') LengthTime = unicode(translate('OpenLP.Ui', 'Length %s')) Live = translate('OpenLP.Ui', 'Live') LiveBGError = translate('OpenLP.Ui', 'Live Background Error') @@ -335,4 +336,4 @@ def find_and_set_in_combo_box(combo_box, value_to_find): if index == -1: # Not Found. index = 0 - combo_box.setCurrentIndex(index) \ No newline at end of file + combo_box.setCurrentIndex(index) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index c2e05363e..1d87d20cb 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -118,8 +118,7 @@ class BiblesTab(SettingsTab): self.newChaptersCheckBox.setText( translate('BiblesPlugin.BiblesTab', 'Only show new chapter numbers')) - self.layoutStyleLabel.setText( - translate('BiblesPlugin.BiblesTab', 'Layout style:')) + self.layoutStyleLabel.setText(UiStrings.LayoutStyle) self.displayStyleLabel.setText(UiStrings.DisplayStyle) self.bibleThemeLabel.setText( translate('BiblesPlugin.BiblesTab', 'Bible theme:')) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 73ed0c9bd..89ca69e33 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -279,7 +279,7 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'Clear')) self.advancedClearComboBox.addItem( translate('BiblesPlugin.MediaItem', 'Keep')) - self.quickLayoutLabel.setText(UiStrings.DisplayStyle) + self.quickLayoutLabel.setText(UiStrings.LayoutStyle) self.quickLayoutComboBox.setItemText(LayoutStyle.VersePerSlide, UiStrings.VersePerSlide) self.quickLayoutComboBox.setItemText(LayoutStyle.VersePerLine, @@ -835,9 +835,6 @@ class BibleMediaItem(MediaManagerItem): return u'{su}%s{/su}' % verse_text def onlayoutStyleComboBoxChanged(self): - self.settings.layout_style = self.quickLayoutComboBox.currentIndex() - self.settings.layoutStyleComboBox.setCurrentIndex( - self.settings.layout_style) QtCore.QSettings().setValue( self.settingsSection + u'/verse layout style', - QtCore.QVariant(self.settings.layout_style)) \ No newline at end of file + QtCore.QVariant(self.settings.layout_style)) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index fea9e5170..d3b50e36b 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -38,7 +38,8 @@ class RemotesPlugin(Plugin): """ remotes constructor """ - Plugin.__init__(self, u'Remotes', plugin_helpers) + Plugin.__init__(self, u'Remotes', plugin_helpers, + settings_tab_class=RemoteTab) self.icon_path = u':/plugins/plugin_remote.png' self.icon = build_icon(self.icon_path) self.weight = -1 From d207cf2243f8a2f9a2c354b6b4cdfa775d3532b5 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 13 Apr 2011 11:19:16 +0200 Subject: [PATCH 52/76] clean ups --- openlp.pyw | 2 +- openlp/core/lib/htmlbuilder.py | 5 +- openlp/core/ui/printserviceform.py | 109 ++++++++++++++--------------- 3 files changed, 57 insertions(+), 59 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 57dbcb698..5c3b8ca77 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -116,7 +116,7 @@ class OpenLP(QtGui.QApplication): self.processEvents() # start the main app window self.mainWindow = MainWindow(screens, self.clipboard(), - self.arguments()) + self.arguments()) self.mainWindow.show() if show_splash: # now kill the splashscreen diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index c4361a421..a80fedd06 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -452,7 +452,7 @@ def build_lyrics_css(item, webkitvers): .lyricsshadow { %s } - """ + """ theme = item.themedata lyricstable = u'' lyrics = u'' @@ -460,8 +460,7 @@ def build_lyrics_css(item, webkitvers): outline = u'' shadow = u'' if theme and item.main: - lyricstable = u'left: %spx; top: %spx;' % \ - (item.main.x(), item.main.y()) + lyricstable = u'left: %spx; top: %spx;' % (item.main.x(), item.main.y()) lyrics = build_lyrics_format_css(theme, item.main.width(), item.main.height()) # For performance reasons we want to show as few DIV's as possible, diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 407b8e2b4..25a631ef3 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -29,7 +29,7 @@ import os from PyQt4 import QtCore, QtGui from lxml import html -from openlp.core.lib import translate +from openlp.core.lib import translate, get_text_file_string from openlp.core.lib.ui import UiStrings from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize from openlp.core.utils import AppLocation @@ -155,8 +155,6 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): """ html_data = html.fromstring( u'%s' % unicode(self.titleLineEdit.text())) - style = html.Element(u'style') - style.set(u'type', u'text/css') css_path = os.path.join( AppLocation.get_data_path(), u'servicePrint.css') if not os.path.isfile(css_path): @@ -164,96 +162,97 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): css_file = open(css_path, u'w') css_file.write(DEFAULT_CSS) css_file.close() - css_file = open(css_path, u'r') - style.text = u' '.join(css_file.readlines()) - css_file.close() - html_data.head.append(style) - html_data.append(html.Element(u'body')) - service_title = html.Element(u'span') + custom_css = get_text_file_string(css_path) + style = self._addChildToParent(u'style', custom_css, html_data.head) + style.set(u'type', u'text/css') + self._addChildToParent(u'body', parent=html_data) + service_title = self._addChildToParent( + u'span', unicode(self.titleLineEdit.text()), html_data.body) service_title.set(u'class', u'serviceTitle') - service_title.text = unicode(self.titleLineEdit.text()) - html_data.body.append(service_title) for index, item in enumerate(self.serviceManager.serviceItems): item = item[u'service_item'] - div = html.Element(u'div') + div = self._addChildToParent(u'div', parent=html_data.body) # Add the title of the service item. - item_title = html.Element(u'h2') + item_title = self._addChildToParent(u'h2', parent=div) item_title.set(u'class', u'itemTitle') - icon = html.Element(u'img') + icon = self._addChildToParent(u'img', parent=item_title) icon.set(u'src', item.icon) - item_title.append(icon) - item_title.append(html.fromstring( - u' %s' % item.get_display_title())) - div.append(item_title) + self._fromstring( + u' %s' % item.get_display_title(), item_title) if self.slideTextCheckBox.isChecked(): # Add the text of the service item. if item.is_text(): verse_def = None for slide in item.get_frames(): if not verse_def or verse_def != slide[u'verseTag']: - p = html.Element(u'p') + p = self._addChildToParent(u'p', parent=div) p.set(u'class', u'itemText') - div.append(p) else: - p.append(html.Element(u'br')) - p.append(html.fromstring( - u'%s' % slide[u'html'])) + self._addChildToParent(u'br', parent=p) + self._fromstring(u'%s' % slide[u'html'], p) verse_def = slide[u'verseTag'] # Break the page before the div element. if index != 0 and self.pageBreakAfterText.isChecked(): div.set(u'style', u'page-break-before:always') # Add the image names of the service item. elif item.is_image(): - ol = html.Element(u'ol') + ol = self._addChildToParent(u'ol', parent=div) for slide in range(len(item.get_frames())): - li = html.Element(u'li') - li.text = item.get_frame_title(slide) - ol.append(li) - div.append(ol) + self._addChildToParent(u'li', item.get_frame_title(slide), ol) # add footer if item.foot_text: - p = html.fromstring(item.foot_text) + p = self._fromstring(item.foot_text, div) p.set(u'class', u'itemFooter') - div.append(p) # Add service items' notes. if self.notesCheckBox.isChecked(): if item.notes: - p = html.Element(u'p') - title = html.Element(u'span') + p = self._addChildToParent(u'p', parent=div) + title = self._addChildToParent(u'span', unicode( + translate('OpenLP.ServiceManager', 'Notes:')), p) title.set(u'class', u'itemNotesTitle') - title.text = unicode( - translate('OpenLP.ServiceManager', 'Notes:')) - p.append(title) - text = html.fromstring(u' %s' % - item.notes.replace(u'\n', u'
')) + text = self._fromstring(u' %s' % + item.notes.replace(u'\n', u'
'), p) text.set(u'class', u'itemNotesText') - p.append(text) - div.append(p) # Add play length of media files. if item.is_media() and self.metaDataCheckBox.isChecked(): tme = item.media_length if item.end_time > 0: tme = item.end_time - item.start_time - p = html.fromstring(u'

%s

' % - translate('OpenLP.ServiceManager', 'Playing time:')) - p.append(html.fromstring(u'%s' % - unicode(datetime.timedelta(seconds=tme)))) - div.append(p) - html_data.body.append(div) + title = self._fromstring(u'

%s

' % + translate('OpenLP.ServiceManager', 'Playing time:'), div) + self._fromstring(u'%s' % + unicode(datetime.timedelta(seconds=tme)), title) # Add the custom service notes: - if self.footerTextEdit.toPlainText(): - title = html.Element(u'span') - title.set(u'class', u'customNotesTitle') - title.text = unicode( - translate('OpenLP.ServiceManager', u'Custom Service Notes:')) - div.append(title) - text = html.Element(u'span') - text.set(u'class', u'customNotesText') - text.text = u' %s' % self.footerTextEdit.toPlainText() - div.append(text) + if self.footerTextEdit.toPlainText(): + footer_title = self._addChildToParent(u'span', translate( + 'OpenLP.ServiceManager', u'Custom Service Notes:'), div) + footer_title.set(u'class', u'customNotesTitle') + footer_text = self._addChildToParent(u'span', + u' %s' % self.footerTextEdit.toPlainText(), div) + footer_text.set(u'class', u'customNotesText') self.document.setHtml(html.tostring(html_data)) self.previewWidget.updatePreview() + def _addChildToParent(self, tag, text=None, parent=None): + """ + Creates a html element. If ``text`` is given, the element's text will + set and if a ``parent`` is given, the element is appended. + """ + element = html.Element(tag) + if text is not None: + element.text = text + if parent is not None: + parent.append(element) + return element + + def _fromstring(self, string, parent): + """ + This is used to create a child html element from a string. + """ + element = html.fromstring(string) + parent.append(element) + return element + def paintRequested(self, printer): """ Paint the preview of the *self.document*. From 7d2719288a601256315ca0b607bdf2e8739ee684 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 13 Apr 2011 11:42:18 +0200 Subject: [PATCH 53/76] extended helper methods --- openlp/core/ui/printserviceform.py | 68 ++++++++++++++++++------------ 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 25a631ef3..5de12d78e 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -163,20 +163,19 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): css_file.write(DEFAULT_CSS) css_file.close() custom_css = get_text_file_string(css_path) - style = self._addChildToParent(u'style', custom_css, html_data.head) - style.set(u'type', u'text/css') + self._addChildToParent( + u'style', custom_css, html_data.head, u'type', u'text/css') self._addChildToParent(u'body', parent=html_data) - service_title = self._addChildToParent( - u'span', unicode(self.titleLineEdit.text()), html_data.body) - service_title.set(u'class', u'serviceTitle') + self._addChildToParent(u'span', unicode(self.titleLineEdit.text()), + html_data.body, u'class', u'serviceTitle') for index, item in enumerate(self.serviceManager.serviceItems): item = item[u'service_item'] div = self._addChildToParent(u'div', parent=html_data.body) # Add the title of the service item. - item_title = self._addChildToParent(u'h2', parent=div) - item_title.set(u'class', u'itemTitle') - icon = self._addChildToParent(u'img', parent=item_title) - icon.set(u'src', item.icon) + item_title = self._addChildToParent( + u'h2', parent=div, attribute=u'class', value=u'itemTitle') + self._addChildToParent( + u'img', parent=item_title, attribute=u'src', value=item.icon) self._fromstring( u' %s' % item.get_display_title(), item_title) if self.slideTextCheckBox.isChecked(): @@ -185,8 +184,8 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): verse_def = None for slide in item.get_frames(): if not verse_def or verse_def != slide[u'verseTag']: - p = self._addChildToParent(u'p', parent=div) - p.set(u'class', u'itemText') + p = self._addChildToParent(u'p', parent=div, + attribute=u'class', value=u'itemText') else: self._addChildToParent(u'br', parent=p) self._fromstring(u'%s' % slide[u'html'], p) @@ -201,18 +200,17 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): self._addChildToParent(u'li', item.get_frame_title(slide), ol) # add footer if item.foot_text: - p = self._fromstring(item.foot_text, div) - p.set(u'class', u'itemFooter') + self._fromstring( + item.foot_text, div, u'class', u'itemFooter') # Add service items' notes. if self.notesCheckBox.isChecked(): if item.notes: p = self._addChildToParent(u'p', parent=div) - title = self._addChildToParent(u'span', unicode( - translate('OpenLP.ServiceManager', 'Notes:')), p) - title.set(u'class', u'itemNotesTitle') - text = self._fromstring(u' %s' % - item.notes.replace(u'\n', u'
'), p) - text.set(u'class', u'itemNotesText') + self._addChildToParent(u'span', unicode( + translate('OpenLP.ServiceManager', 'Notes:')), p, + u'class', u'itemNotesTitle') + self._fromstring(u' %s' % item.notes.replace( + u'\n', u'
'), p, u'class', u'itemNotesText') # Add play length of media files. if item.is_media() and self.metaDataCheckBox.isChecked(): tme = item.media_length @@ -224,25 +222,43 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): unicode(datetime.timedelta(seconds=tme)), title) # Add the custom service notes: if self.footerTextEdit.toPlainText(): - footer_title = self._addChildToParent(u'span', translate( - 'OpenLP.ServiceManager', u'Custom Service Notes:'), div) - footer_title.set(u'class', u'customNotesTitle') - footer_text = self._addChildToParent(u'span', - u' %s' % self.footerTextEdit.toPlainText(), div) - footer_text.set(u'class', u'customNotesText') + self._addChildToParent(u'span', translate('OpenLP.ServiceManager', + u'Custom Service Notes:'), div, u'class', u'customNotesTitle') + self._addChildToParent( + u'span', u' %s' % self.footerTextEdit.toPlainText(), div, + u'class', u'customNotesText') self.document.setHtml(html.tostring(html_data)) self.previewWidget.updatePreview() - def _addChildToParent(self, tag, text=None, parent=None): + def _addChildToParent(self, tag, text=None, parent=None, attribute=None, + value=None): """ Creates a html element. If ``text`` is given, the element's text will set and if a ``parent`` is given, the element is appended. + + ``tag`` + The html tag, e. g. ``u'span'``. Defaults to ``None``. + + ``text`` + The text for the tag. Defaults to ``None``. + + ``parent`` + The parent element. Defaults to ``None``. + + ``attribute`` + An optional attribute, for instance ``u'class``. + + ``value`` + The value for the given ``attribute``. It does not have and meaning, + if the attribute is left to its default. """ element = html.Element(tag) if text is not None: element.text = text if parent is not None: parent.append(element) + if attribute is not None: + element.set(attribute, value if value is not None else u'') return element def _fromstring(self, string, parent): From 7d5ee8adf636cb3fc06a4fbd15facd63ec64a9cf Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 13 Apr 2011 11:53:57 +0200 Subject: [PATCH 54/76] spelling --- openlp/core/ui/printserviceform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 5de12d78e..c41084b2f 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -249,7 +249,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): An optional attribute, for instance ``u'class``. ``value`` - The value for the given ``attribute``. It does not have and meaning, + The value for the given ``attribute``. It does not have a meaning, if the attribute is left to its default. """ element = html.Element(tag) From 8451d52f27c0042e67dba88356a5d076f4601b9a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 13 Apr 2011 12:22:26 +0200 Subject: [PATCH 55/76] fixed _fromstring; changed setting name in config --- openlp/core/ui/printserviceform.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index c41084b2f..5348396d7 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -104,7 +104,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): self.slideTextCheckBox.setChecked(settings.value( u'print slide text', QtCore.QVariant(False)).toBool()) self.pageBreakAfterText.setChecked(settings.value( - u'enable page break', QtCore.QVariant(False)).toBool()) + u'add page break', QtCore.QVariant(False)).toBool()) if not self.slideTextCheckBox.isChecked(): self.pageBreakAfterText.setDisabled(True) self.metaDataCheckBox.setChecked(settings.value( @@ -261,11 +261,13 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): element.set(attribute, value if value is not None else u'') return element - def _fromstring(self, string, parent): + def _fromstring(self, string, parent, attribute=None, value=None): """ This is used to create a child html element from a string. """ element = html.fromstring(string) + if attribute is not None: + element.set(attribute, value if value is not None else u'') parent.append(element) return element @@ -371,7 +373,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): settings.beginGroup(u'advanced') settings.setValue(u'print slide text', QtCore.QVariant(self.slideTextCheckBox.isChecked())) - settings.setValue(u'enable page break', + settings.setValue(u'add page break', QtCore.QVariant(self.pageBreakAfterText.isChecked())) settings.setValue(u'print file meta data', QtCore.QVariant(self.metaDataCheckBox.isChecked())) From 2dc2304a2c8b01a62ffc99f67a047f0322b9f1f8 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 13 Apr 2011 15:31:23 +0200 Subject: [PATCH 56/76] fixed advanced bible book initialisation; append a space to completion suggestions --- openlp/plugins/bibles/lib/mediaitem.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index b0d4c8bca..fbafcd725 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -328,6 +328,8 @@ class BibleMediaItem(MediaManagerItem): if bible in bibles: find_and_set_in_combo_box(self.advancedVersionComboBox, bible) self.initialiseAdvancedBible(unicode(bible)) + elif len(bibles): + self.initialiseAdvancedBible(bibles[0]) def reloadBibles(self): log.debug(u'Reloading Bibles') @@ -395,7 +397,7 @@ class BibleMediaItem(MediaManagerItem): bible = unicode(self.quickVersionComboBox.currentText()) if bible: book_data = bibles[bible].get_books() - books = [book.name for book in book_data] + books = [book.name + u' ' for book in book_data] books.sort() add_widget_completer(books, self.quickSearchEdit) From 6082785b3eb2304f434395608545dc2d8ba41bdb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 13 Apr 2011 16:28:31 +0200 Subject: [PATCH 57/76] use map; fixed changing quickBible --- openlp/plugins/bibles/lib/mediaitem.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index fbafcd725..3f1c2b612 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -291,7 +291,11 @@ class BibleMediaItem(MediaManagerItem): log.debug(u'bible manager initialise') self.parent.manager.media = self self.loadBibles() - self.updateAutoCompleter(False) + bible = QtCore.QSettings().value( + self.settingsSection + u'/quick bible', QtCore.QVariant( + self.quickVersionComboBox.currentText())).toString() + find_and_set_in_combo_box(self.quickVersionComboBox, bible) + self.updateAutoCompleter() self.configUpdated() log.debug(u'bible manager initialise complete') @@ -376,20 +380,14 @@ class BibleMediaItem(MediaManagerItem): self.adjustComboBox(1, verse_count, self.advancedFromVerse) self.adjustComboBox(1, verse_count, self.advancedToVerse) - def updateAutoCompleter(self, updateConfig=True): + def updateAutoCompleter(self): """ This updates the bible book completion list for the search field. The completion depends on the bible. It is only updated when we are doing a reference search, otherwise the auto completion list is removed. """ - if updateConfig: - QtCore.QSettings().setValue(self.settingsSection + u'/quick bible', - QtCore.QVariant(self.quickVersionComboBox.currentText())) - else: - book = QtCore.QSettings().value( - self.settingsSection + u'/quick bible', - QtCore.QVariant(u'')).toString() - find_and_set_in_combo_box(self.quickVersionComboBox, book) + QtCore.QSettings().setValue(self.settingsSection + u'/quick bible', + QtCore.QVariant(self.quickVersionComboBox.currentText())) books = [] # We have to do a 'Reference Search'. if self.quickSearchEdit.currentSearchType() == BibleSearch.Reference: @@ -397,7 +395,7 @@ class BibleMediaItem(MediaManagerItem): bible = unicode(self.quickVersionComboBox.currentText()) if bible: book_data = bibles[bible].get_books() - books = [book.name + u' ' for book in book_data] + books = map(lambda x: x.name + u' ', book_data) books.sort() add_widget_completer(books, self.quickSearchEdit) From 01c286e50ef4ad6d30ea9b6f9f54b2da652e688f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 13 Apr 2011 20:01:28 +0200 Subject: [PATCH 58/76] fixed crash --- openlp/core/ui/printserviceform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 5348396d7..01b937d61 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -254,7 +254,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): """ element = html.Element(tag) if text is not None: - element.text = text + element.text = unicode(text) if parent is not None: parent.append(element) if attribute is not None: From a22bb2e0bc4ebbc9f21ddb990d9e4079b5b93f6f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 13 Apr 2011 19:14:38 +0100 Subject: [PATCH 59/76] Active/inactive fixes --- openlp/core/lib/pluginmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 3b73750fe..6854cb53c 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -150,7 +150,7 @@ class PluginManager(object): if plugin.status is not PluginStatus.Disabled: plugin.settings_tab = plugin.getSettingsTab() visible_title = plugin.getString(StringContent.VisibleName) - if plugin.settings_tab: + if plugin.settings_tab and plugin.isActive(): log.debug(u'Inserting settings tab item from %s' % visible_title[u'title']) settingsform.insertTab(plugin.settings_tab, plugin.weight) From 606287bda10665592a1971b64e62474094587f98 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 13 Apr 2011 20:18:25 +0200 Subject: [PATCH 60/76] reverted change --- openlp/plugins/bibles/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 3f1c2b612..118bdfc66 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -395,7 +395,7 @@ class BibleMediaItem(MediaManagerItem): bible = unicode(self.quickVersionComboBox.currentText()) if bible: book_data = bibles[bible].get_books() - books = map(lambda x: x.name + u' ', book_data) + books = [book.name + u' ' for book in book_data] books.sort() add_widget_completer(books, self.quickSearchEdit) From 79ed96648faa71539e85297edfbade42de4d66c4 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 13 Apr 2011 19:40:09 +0100 Subject: [PATCH 61/76] More cleanups --- openlp/core/ui/settingsdialog.py | 12 ++++++------ openlp/core/ui/settingsform.py | 6 ++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index 45a68c321..3f5f12bd2 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -35,20 +35,20 @@ class Ui_SettingsDialog(object): settingsDialog.resize(800, 500) settingsDialog.setWindowIcon( build_icon(u':/system/system_settings.png')) - self.settingsLayout = QtGui.QGridLayout(settingsDialog) - self.settingsLayout.setObjectName(u'settingsLayout') - self.settingsLayout.setMargin(0) + self.dialogLayout = QtGui.QGridLayout(settingsDialog) + self.dialogLayout.setObjectName(u'dialogLayout') + self.dialogLayout.setMargin(0) self.settingListWidget = QtGui.QListWidget(settingsDialog) self.settingListWidget.setMinimumSize(QtCore.QSize(150, 0)) self.settingListWidget.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.settingListWidget.setObjectName(u'settingListWidget') - self.settingsLayout.addWidget(self.settingListWidget, 0, 0, 1, 1) + self.dialogLayout.addWidget(self.settingListWidget, 0, 0, 1, 1) self.stackedLayout = QtGui.QStackedLayout() self.stackedLayout.setObjectName(u'stackedLayout') - self.settingsLayout.addLayout(self.stackedLayout, 0, 1, 1, 1) + self.dialogLayout.addLayout(self.stackedLayout, 0, 1, 1, 1) self.buttonBox = create_accept_reject_button_box(settingsDialog, True) - self.settingsLayout.addWidget(self.buttonBox, 1, 1, 1, 1) + self.dialogLayout.addWidget(self.buttonBox, 1, 1, 1, 1) self.retranslateUi(settingsDialog) QtCore.QMetaObject.connectSlotsByName(settingsDialog) QtCore.QObject.connect(self.settingListWidget, diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 1e71bc985..3415f3ec8 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -60,9 +60,9 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): # load all the settings for tabIndex in range(0, self.stackedLayout.count()): self.stackedLayout.widget(tabIndex).load() + self.settingListWidget.setCurrentRow(0) return QtGui.QDialog.exec_(self) - def insertTab(self, tab, location): """ Add a tab to the form at a specific location @@ -78,13 +78,11 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): match = True break if not match: - self.stackedLayout.addWidget(tab) + pos = self.stackedLayout.addWidget(tab) item_name = QtGui.QListWidgetItem(tab.tabTitleVisible) icon = build_icon(tab.icon_path) item_name.setIcon(icon) self.settingListWidget.insertItem(14 + location, item_name) - self.stackedLayout.addWidget(tab) - self.stackedLayout.setCurrentIndex(0) def removeTab(self, tab): """ From 9e88d0bff4c3a3a761ea974acc5e1a2e9aa2b0da Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 13 Apr 2011 20:53:05 +0200 Subject: [PATCH 62/76] clean ups --- openlp/plugins/bibles/lib/db.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 85ab98de1..ec63dc02f 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -177,10 +177,7 @@ class BibleDB(QtCore.QObject, Manager): Returns the version name of the Bible. """ version_name = self.get_object(BibleMeta, u'Version') - if version_name: - self.name = version_name.value - else: - self.name = None + self.name = version_name.value if version_name else None return self.name def clean_filename(self, old_filename): @@ -256,10 +253,10 @@ class BibleDB(QtCore.QObject, Manager): # Text list has book and chapter as first two elements of the array. for verse_number, verse_text in textlist.iteritems(): verse = Verse.populate( - book_id = book_id, - chapter = chapter, - verse = verse_number, - text = verse_text + book_id=book_id, + chapter=chapter, + verse=verse_number, + text=verse_text ) self.session.add(verse) self.session.commit() @@ -383,15 +380,13 @@ class BibleDB(QtCore.QObject, Manager): log.debug(u'BibleDB.verse_search("%s")', text) verses = self.session.query(Verse) if text.find(u',') > -1: - or_clause = [] - keywords = [u'%%%s%%' % keyword.strip() - for keyword in text.split(u',')] - for keyword in keywords: - or_clause.append(Verse.text.like(keyword)) + keywords = \ + [u'%%%s%%' % keyword.strip() for keyword in text.split(u',')] + or_clause = [Verse.text.like(keyword) for keyword in keywords] verses = verses.filter(or_(*or_clause)) else: - keywords = [u'%%%s%%' % keyword.strip() - for keyword in text.split(u' ')] + keywords = \ + [u'%%%s%%' % keyword.strip() for keyword in text.split(u' ')] for keyword in keywords: verses = verses.filter(Verse.text.like(keyword)) verses = verses.all() From 6454b88a83aea140d4c19bad077768d4b93443e2 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 13 Apr 2011 20:12:47 +0100 Subject: [PATCH 63/76] Fix Tab parentage --- openlp/core/lib/plugin.py | 4 ++-- openlp/core/lib/pluginmanager.py | 2 +- openlp/core/lib/settingstab.py | 4 ++-- openlp/core/ui/advancedtab.py | 4 ++-- openlp/core/ui/generaltab.py | 4 ++-- openlp/core/ui/settingsdialog.py | 1 + openlp/core/ui/settingsform.py | 6 +++--- openlp/core/ui/themestab.py | 14 +++++++------- openlp/plugins/alerts/lib/alertstab.py | 4 ++-- openlp/plugins/bibles/lib/biblestab.py | 4 ++-- openlp/plugins/custom/lib/customtab.py | 4 ++-- openlp/plugins/media/lib/mediatab.py | 4 ++-- .../plugins/presentations/lib/presentationtab.py | 4 ++-- openlp/plugins/presentations/presentationplugin.py | 4 ++-- openlp/plugins/remotes/lib/remotetab.py | 4 ++-- openlp/plugins/songs/lib/songstab.py | 4 ++-- 16 files changed, 36 insertions(+), 35 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index ef89e6424..e4359f6b0 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -244,13 +244,13 @@ class Plugin(QtCore.QObject): """ pass - def getSettingsTab(self): + def getSettingsTab(self, parent): """ Create a tab for the settings window to display the configurable options for this plugin to the user. """ if self.settings_tab_class: - return self.settings_tab_class(self.name, + return self.settings_tab_class(parent, self.name, self.getString(StringContent.VisibleName)[u'title'], self.icon_path) return None diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 6854cb53c..6f1222276 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -148,7 +148,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.settings_tab = plugin.getSettingsTab() + plugin.settings_tab = plugin.getSettingsTab(settingsform) visible_title = plugin.getString(StringContent.VisibleName) if plugin.settings_tab and plugin.isActive(): log.debug(u'Inserting settings tab item from %s' % diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 32d7dc912..e1396d984 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -31,7 +31,7 @@ class SettingsTab(QtGui.QWidget): SettingsTab is a helper widget for plugins to define Tabs for the settings dialog. """ - def __init__(self, title, visible_title=None, icon_path=None): + def __init__(self, parent, title, visible_title=None, icon_path=None): """ Constructor to create the Settings tab item. @@ -41,7 +41,7 @@ class SettingsTab(QtGui.QWidget): ``visible_title`` The title of the tab, which is usually displayed on the tab. """ - QtGui.QWidget.__init__(self) + QtGui.QWidget.__init__(self, parent) self.tabTitle = title self.tabTitleVisible = visible_title self.settingsSection = self.tabTitle.lower() diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 6041382b8..3d9321fe1 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -37,12 +37,12 @@ class AdvancedTab(SettingsTab): The :class:`AdvancedTab` manages the advanced settings tab including the UI and the loading and saving of the displayed settings. """ - def __init__(self): + def __init__(self, parent): """ Initialise the settings tab """ generalTranslated = translate('AdvancedTab', 'Advanced') - SettingsTab.__init__(self, u'Advanced', generalTranslated) + SettingsTab.__init__(self, parent ,u'Advanced', generalTranslated) self.default_image = u':/graphics/openlp-splash-screen.png' self.default_color = u'#ffffff' self.icon_path = u':/icon/openlp-logo-16x16.png' diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index d566244b8..cfde7810c 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -36,7 +36,7 @@ class GeneralTab(SettingsTab): """ GeneralTab is the general settings tab in the settings dialog. """ - def __init__(self, screens): + def __init__(self, parent, screens): """ Initialise the general settings tab """ @@ -46,7 +46,7 @@ class GeneralTab(SettingsTab): self.overrideChanged = True self.icon_path = u':/icon/openlp-logo-16x16.png' generalTranslated = translate('GeneralTab', 'General') - SettingsTab.__init__(self, u'General', generalTranslated) + SettingsTab.__init__(self, parent, u'General', generalTranslated) def preLoad(self): """ diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index 3f5f12bd2..485cb9c5f 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -39,6 +39,7 @@ class Ui_SettingsDialog(object): self.dialogLayout.setObjectName(u'dialogLayout') self.dialogLayout.setMargin(0) self.settingListWidget = QtGui.QListWidget(settingsDialog) + self.settingListWidget.setUniformItemSizes(True) self.settingListWidget.setMinimumSize(QtCore.QSize(150, 0)) self.settingListWidget.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 3415f3ec8..72e1b7fa4 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -47,13 +47,13 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): QtGui.QDialog.__init__(self, parent) self.setupUi(self) # General tab - generalTab = GeneralTab(screens) + generalTab = GeneralTab(self, screens) self.insertTab(generalTab, 1) # Themes tab - themesTab = ThemesTab(mainWindow) + themesTab = ThemesTab(self, mainWindow) self.insertTab(themesTab, 2) # Advanced tab - advancedTab = AdvancedTab() + advancedTab = AdvancedTab(self, ) self.insertTab(advancedTab, 3) def exec_(self): diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index b5fcce1ec..372ee0cc8 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -34,10 +34,10 @@ class ThemesTab(SettingsTab): """ ThemesTab is the theme settings tab in the settings dialog. """ - def __init__(self, parent): - self.parent = parent + def __init__(self, parent, mainwindow): + self.mainwindow = mainwindow generalTranslated = translate('ThemeTab', 'Themes') - SettingsTab.__init__(self, u'Themes', generalTranslated) + SettingsTab.__init__(self, parent, u'Themes', generalTranslated) self.icon_path = u':/themes/theme_new.png' def setupUi(self): @@ -149,7 +149,7 @@ class ThemesTab(SettingsTab): settings.setValue(u'global theme', QtCore.QVariant(self.global_theme)) settings.endGroup() - self.parent.renderManager.set_global_theme( + self.mainwindow.renderManager.set_global_theme( self.global_theme, self.theme_level) Receiver.send_message(u'theme_update_global', self.global_theme) @@ -167,7 +167,7 @@ class ThemesTab(SettingsTab): def onDefaultComboBoxChanged(self, value): self.global_theme = unicode(self.DefaultComboBox.currentText()) - self.parent.renderManager.set_global_theme( + self.mainwindow.renderManager.set_global_theme( self.global_theme, self.theme_level) self.__previewGlobalTheme() @@ -188,7 +188,7 @@ class ThemesTab(SettingsTab): for theme in theme_list: self.DefaultComboBox.addItem(theme) find_and_set_in_combo_box(self.DefaultComboBox, self.global_theme) - self.parent.renderManager.set_global_theme( + self.mainwindow.renderManager.set_global_theme( self.global_theme, self.theme_level) if self.global_theme is not u'': self.__previewGlobalTheme() @@ -197,7 +197,7 @@ class ThemesTab(SettingsTab): """ Utility method to update the global theme preview image. """ - image = self.parent.themeManagerContents.getPreviewImage( + image = self.mainwindow.themeManagerContents.getPreviewImage( self.global_theme) preview = QtGui.QPixmap(unicode(image)) if not preview.isNull(): diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 2e97d27d3..3b6c50a10 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -33,8 +33,8 @@ class AlertsTab(SettingsTab): """ AlertsTab is the alerts settings tab in the settings dialog. """ - def __init__(self, name, visible_title, icon_path): - SettingsTab.__init__(self, name, visible_title, icon_path) + def __init__(self, parent, name, visible_title, icon_path): + SettingsTab.__init__(self, parent, name, visible_title, icon_path) def setupUi(self): self.setObjectName(u'AlertsTab') diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 1d87d20cb..b013c402a 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -40,11 +40,11 @@ class BiblesTab(SettingsTab): """ log.info(u'Bible Tab loaded') - def __init__(self, title, visible_title, icon_path): + def __init__(self, parent, title, visible_title, icon_path): self.paragraph_style = True self.show_new_chapters = False self.display_style = 0 - SettingsTab.__init__(self, title, visible_title, icon_path) + SettingsTab.__init__(self, parent, title, visible_title, icon_path) def setupUi(self): self.setObjectName(u'BiblesTab') diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 006295410..9de294418 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -32,8 +32,8 @@ class CustomTab(SettingsTab): """ CustomTab is the Custom settings tab in the settings dialog. """ - def __init__(self, title, visible_title, icon_path): - SettingsTab.__init__(self, title, visible_title, icon_path) + def __init__(self, parent, title, visible_title, icon_path): + SettingsTab.__init__(self, parent, title, visible_title, icon_path) def setupUi(self): self.setObjectName(u'CustomTab') diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 72085158c..f54aa02fa 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -32,8 +32,8 @@ class MediaTab(SettingsTab): """ MediaTab is the Media settings tab in the settings dialog. """ - def __init__(self, title, visible_title, icon_path): - SettingsTab.__init__(self, title, visible_title, icon_path) + def __init__(self, parent, title, visible_title, icon_path): + SettingsTab.__init__(self, parent, title, visible_title, icon_path) def setupUi(self): self.setObjectName(u'MediaTab') diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index c7a143006..8e3a98031 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -33,12 +33,12 @@ class PresentationTab(SettingsTab): """ PresentationsTab is the Presentations settings tab in the settings dialog. """ - def __init__(self, title, visible_title, controllers, icon_path): + def __init__(self, parent, title, visible_title, controllers, icon_path): """ Constructor """ self.controllers = controllers - SettingsTab.__init__(self, title, visible_title, icon_path) + SettingsTab.__init__(self, parent, title, visible_title, icon_path) def setupUi(self): """ diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 1da9fe511..f217e6023 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -56,12 +56,12 @@ class PresentationPlugin(Plugin): self.icon_path = u':/plugins/plugin_presentations.png' self.icon = build_icon(self.icon_path) - def getSettingsTab(self): + def getSettingsTab(self, parent): """ Create the settings Tab """ visible_name = self.getString(StringContent.VisibleName) - return PresentationTab(self.name, visible_name[u'title'], + return PresentationTab(parent, self.name, visible_name[u'title'], self.controllers, self.icon_path) def initialise(self): diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 97aedc9cd..297437d93 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -32,8 +32,8 @@ class RemoteTab(SettingsTab): """ RemoteTab is the Remotes settings tab in the settings dialog. """ - def __init__(self, title, visible_title, icon_path): - SettingsTab.__init__(self, title, visible_title, icon_path) + def __init__(self, parent, title, visible_title, icon_path): + SettingsTab.__init__(self, parent, title, visible_title, icon_path) def setupUi(self): self.setObjectName(u'RemoteTab') diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 092c6af29..e39c22be7 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -32,8 +32,8 @@ class SongsTab(SettingsTab): """ SongsTab is the Songs settings tab in the settings dialog. """ - def __init__(self, title, visible_title, icon_path): - SettingsTab.__init__(self, title, visible_title, icon_path) + def __init__(self, parent, title, visible_title, icon_path): + SettingsTab.__init__(self, parent, title, visible_title, icon_path) def setupUi(self): self.setObjectName(u'SongsTab') From 5f93ff657ef7f5e84e2ae5b067259db316268ade Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 13 Apr 2011 23:10:41 +0100 Subject: [PATCH 64/76] PPT's are getting there. Going from blank ppt to song broken now --- openlp/core/ui/slidecontroller.py | 50 +++++++++++-------- .../presentations/lib/messagelistener.py | 13 ++--- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 0261b5782..00202d8cc 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -460,7 +460,7 @@ class SlideController(QtGui.QWidget): request = unicode(self.sender().text()) slideno = self.slideList[request] self.__updatePreviewSelection(slideno) - self.onSlideSelected() + self.slideSelected() def receiveSpinDelay(self, value): """ @@ -556,7 +556,7 @@ class SlideController(QtGui.QWidget): # If service item is the same as the current on only change slide if item.__eq__(self.serviceItem): self.__checkUpdateSelectedSlide(slideno) - self.onSlideSelected() + self.slideSelected() return self._processItem(item, slideno) @@ -641,7 +641,7 @@ class SlideController(QtGui.QWidget): self.display.buildHtml(self.serviceItem) if serviceItem.is_media(): self.onMediaStart(serviceItem) - self.onSlideSelected(True) + self.slideSelected(True) self.previewListWidget.setFocus() if old_item: # Close the old item after the new one is opened @@ -699,7 +699,7 @@ class SlideController(QtGui.QWidget): self.updatePreview() else: self.previewListWidget.selectRow(0) - self.onSlideSelected() + self.slideSelected() def onSlideSelectedIndex(self, message): """ @@ -714,7 +714,7 @@ class SlideController(QtGui.QWidget): self.updatePreview() else: self.__checkUpdateSelectedSlide(index) - self.onSlideSelected() + self.slideSelected() def mainDisplaySetBackground(self): """ @@ -755,15 +755,13 @@ class SlideController(QtGui.QWidget): self.themeScreen.setChecked(False) self.desktopScreen.setChecked(False) if checked: - Receiver.send_message(u'maindisplay_hide', HideMode.Blank) QtCore.QSettings().setValue( self.parent.generalSettingsSection + u'/screen blank', QtCore.QVariant(u'blanked')) else: - Receiver.send_message(u'maindisplay_show') QtCore.QSettings().remove( self.parent.generalSettingsSection + u'/screen blank') - self.blankPlugin(checked) + self.blankPlugin() self.updatePreview() def onThemeDisplay(self, checked): @@ -776,15 +774,13 @@ class SlideController(QtGui.QWidget): self.themeScreen.setChecked(checked) self.desktopScreen.setChecked(False) if checked: - Receiver.send_message(u'maindisplay_hide', HideMode.Theme) QtCore.QSettings().setValue( self.parent.generalSettingsSection + u'/screen blank', QtCore.QVariant(u'themed')) else: - Receiver.send_message(u'maindisplay_show') QtCore.QSettings().remove( self.parent.generalSettingsSection + u'/screen blank') - self.blankPlugin(checked) + self.blankPlugin() self.updatePreview() def onHideDisplay(self, checked): @@ -797,28 +793,31 @@ class SlideController(QtGui.QWidget): self.themeScreen.setChecked(False) self.desktopScreen.setChecked(checked) if checked: - Receiver.send_message(u'maindisplay_hide', HideMode.Screen) QtCore.QSettings().setValue( self.parent.generalSettingsSection + u'/screen blank', QtCore.QVariant(u'hidden')) else: - Receiver.send_message(u'maindisplay_show') QtCore.QSettings().remove( self.parent.generalSettingsSection + u'/screen blank') self.hidePlugin(checked) self.updatePreview() - def blankPlugin(self, blank): + def blankPlugin(self): """ - Blank the display screen within a plugin if required. + Blank/Hide the display screen within a plugin if required. """ - log.debug(u'blankPlugin %s ', blank) + hide_mode = self.hideMode() + log.debug(u'blankPlugin %s ', hide_mode) if self.serviceItem is not None: - if blank: + if hide_mode: + if not self.serviceItem.is_command(): + Receiver.send_message(u'maindisplay_hide', hide_mode) Receiver.send_message(u'%s_blank' % self.serviceItem.name.lower(), - [self.serviceItem, self.isLive]) + [self.serviceItem, self.isLive, hide_mode]) else: + if not self.serviceItem.is_command(): + Receiver.send_message(u'maindisplay_show') Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) @@ -830,15 +829,24 @@ class SlideController(QtGui.QWidget): log.debug(u'hidePlugin %s ', hide) if self.serviceItem is not None: if hide: + Receiver.send_message(u'maindisplay_hide', HideMode.Screen) Receiver.send_message(u'%s_hide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) else: + if not self.serviceItem.is_command(): + Receiver.send_message(u'maindisplay_show') Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) def onSlideSelected(self, start=False): + """ + Slide selected in controller + """ + self.slideSelected() + + def slideSelected(self, start=False): """ Generate the preview when you click on a slide. if this is the Live Controller also display on the screen @@ -927,7 +935,7 @@ class SlideController(QtGui.QWidget): Receiver.send_message('servicemanager_next_item') return self.__checkUpdateSelectedSlide(row) - self.onSlideSelected() + self.slideSelected() def onSlideSelectedPreviousNoloop(self): self.onSlideSelectedPrevious(False) @@ -950,7 +958,7 @@ class SlideController(QtGui.QWidget): else: row = 0 self.__checkUpdateSelectedSlide(row) - self.onSlideSelected() + self.slideSelected() def __checkUpdateSelectedSlide(self, row): if row + 1 < self.previewListWidget.rowCount(): @@ -971,7 +979,7 @@ class SlideController(QtGui.QWidget): else: self.previewListWidget.selectRow( self.previewListWidget.rowCount() - 1) - self.onSlideSelected() + self.slideSelected() def onStartLoop(self): """ diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 4f9268b3e..b76fd7d4c 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -70,11 +70,9 @@ class Controller(object): Receiver.send_message(u'maindisplay_hide', HideMode.Screen) self.stop() elif hide_mode == HideMode.Theme: - Receiver.send_message(u'maindisplay_hide', HideMode.Theme) - self.blank() + self.blank(hide_mode) elif hide_mode == HideMode.Blank: - Receiver.send_message(u'maindisplay_hide', HideMode.Blank) - self.blank() + self.blank(hide_mode) else: self.doc.start_presentation() Receiver.send_message(u'maindisplay_hide', HideMode.Screen) @@ -182,7 +180,7 @@ class Controller(object): #self.doc.slidenumber = 0 #self.timer.stop() - def blank(self): + def blank(self, hide_mode): """ Instruct the controller to blank the presentation """ @@ -193,6 +191,8 @@ class Controller(object): return if not self.doc.is_active(): return + if hide_mode == HideMode.Theme: + Receiver.send_message(u'maindisplay_hide', HideMode.Theme) self.doc.blank_screen() def stop(self): @@ -363,8 +363,9 @@ class MessageListener(object): React to the message to blank the display """ is_live = message[1] + hide_mode = message[2] if is_live: - self.live_handler.blank() + self.live_handler.blank(hide_mode) def unblank(self, message): """ From f2f49acd399e0780b3cbd85e2af0fd36148a6e62 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 14 Apr 2011 15:53:02 +0200 Subject: [PATCH 65/76] added ability to change language in a spelledit --- openlp/core/lib/__init__.py | 2 +- openlp/core/lib/spelltextedit.py | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 491f3e652..89eeb6ad4 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -274,8 +274,8 @@ def check_directory_exists(dir): from listwidgetwithdnd import ListWidgetWithDnD from displaytags import DisplayTags -from spelltextedit import SpellTextEdit from eventreceiver import Receiver +from spelltextedit import SpellTextEdit from imagemanager import ImageManager from settingsmanager import SettingsManager from plugin import PluginStatus, StringContent, Plugin diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 95befad09..a99539775 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -36,7 +36,9 @@ except ImportError: # http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check from PyQt4 import QtCore, QtGui + from openlp.core.lib import translate, DisplayTags +from openlp.core.lib.ui import checkable_action log = logging.getLogger(__name__) @@ -80,6 +82,19 @@ class SpellTextEdit(QtGui.QPlainTextEdit): if not cursor.hasSelection(): cursor.select(QtGui.QTextCursor.WordUnderCursor) self.setTextCursor(cursor) + # Add menu with available languages. + if ENCHANT_AVAILABLE: + 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) + lang_menu.addAction(action) + popupMenu.insertSeparator(popupMenu.actions()[0]) + popupMenu.insertMenu(popupMenu.actions()[0], lang_menu) + QtCore.QObject.connect(lang_menu, + QtCore.SIGNAL(u'triggered(QAction*)'), self.setLanguage) # Check if the selected word is misspelled and offer spelling # suggestions if it is. if ENCHANT_AVAILABLE and self.textCursor().hasSelection(): @@ -93,19 +108,30 @@ class SpellTextEdit(QtGui.QPlainTextEdit): spell_menu.addAction(action) # Only add the spelling suggests to the menu if there are # suggestions. - if len(spell_menu.actions()) != 0: - popupMenu.insertSeparator(popupMenu.actions()[0]) + if len(spell_menu.actions()): popupMenu.insertMenu(popupMenu.actions()[0], spell_menu) tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Formatting Tags')) for html in DisplayTags.get_html_tags(): - action = SpellAction( html[u'desc'], tagMenu) + action = SpellAction(html[u'desc'], tagMenu) action.correct.connect(self.htmlTag) tagMenu.addAction(action) popupMenu.insertSeparator(popupMenu.actions()[0]) popupMenu.insertMenu(popupMenu.actions()[0], tagMenu) popupMenu.exec_(event.globalPos()) + def setLanguage(self, action): + """ + Changes the language for this spelltextedit. + + ``action`` + The action. + """ + self.dictionary = enchant.Dict(action.text()) + self.highlighter.spellingDictionary = self.dictionary + self.highlighter.highlightBlock(self.toPlainText()) + self.highlighter.rehighlight() + def correctWord(self, word): """ Replaces the selected text with word. From 27e9edad517fa75d09c9bafa7b42b296bdc3d1ea Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 14 Apr 2011 16:51:05 +0200 Subject: [PATCH 66/76] fixed wrong parentage --- openlp/core/ui/printserviceform.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 01b937d61..0de20d8a9 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -222,6 +222,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): unicode(datetime.timedelta(seconds=tme)), title) # Add the custom service notes: if self.footerTextEdit.toPlainText(): + div = self._addChildToParent(u'div', parent=html_data.body) self._addChildToParent(u'span', translate('OpenLP.ServiceManager', u'Custom Service Notes:'), div, u'class', u'customNotesTitle') self._addChildToParent( From 83e06b6eb1e08e83b0f7b96c44d5e214575b71ef Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 14 Apr 2011 20:05:00 +0200 Subject: [PATCH 67/76] don't allow to change the up/down shortcuts in the slidecontrollers --- openlp/core/lib/ui.py | 3 +-- openlp/core/ui/slidecontroller.py | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 3365b32a0..d54135937 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -87,7 +87,6 @@ class UiStrings(object): OpenService = translate('OpenLP.Ui', 'Open Service') Preview = translate('OpenLP.Ui', 'Preview') PreviewPanel = translate('OpenLP.Ui', 'Preview Panel') - PreviewToolbar = translate('OpenLP.Ui', 'Preview Toolbar') PrintServiceOrder = translate('OpenLP.Ui', 'Print Service Order') ReplaceBG = translate('OpenLP.Ui', 'Replace Background') ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background') @@ -427,4 +426,4 @@ def find_and_set_in_combo_box(combo_box, value_to_find): if index == -1: # Not Found. index = 0 - combo_box.setCurrentIndex(index) \ No newline at end of file + combo_box.setCurrentIndex(index) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 4f5ed1ea7..7a26bea19 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -368,10 +368,8 @@ class SlideController(QtGui.QWidget): self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') action_list = ActionList.get_instance() - action_list.add_category( - UiStrings.PreviewToolbar, CategoryOrder.standardToolbar) - action_list.add_action(self.previousItem, UiStrings.PreviewToolbar) - action_list.add_action(self.nextItem, UiStrings.PreviewToolbar) + action_list.add_action(self.previousItem) + action_list.add_action(self.nextItem) def setLiveHotkeys(self, parent=None): self.previousItem.setObjectName(u'previousItemLive') @@ -379,8 +377,8 @@ class SlideController(QtGui.QWidget): action_list = ActionList.get_instance() action_list.add_category( UiStrings.LiveToolbar, CategoryOrder.standardToolbar) - action_list.add_action(self.previousItem, UiStrings.LiveToolbar) - action_list.add_action(self.nextItem, UiStrings.LiveToolbar) + 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, UiStrings.LiveToolbar) self.previousService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) From 206cd90639eac949f23198347f482c1e3b718b2d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 14 Apr 2011 19:30:53 +0100 Subject: [PATCH 68/76] Finished --- openlp/core/lib/plugin.py | 4 -- openlp/core/lib/pluginmanager.py | 13 ++---- openlp/core/ui/settingsform.py | 55 +++++++++++--------------- openlp/plugins/bibles/lib/mediaitem.py | 3 ++ 4 files changed, 28 insertions(+), 47 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index e4359f6b0..a6cc5df63 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -290,8 +290,6 @@ class Plugin(QtCore.QObject): if self.mediaItem: self.mediaItem.initialise() self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight) - if self.settings_tab: - self.settingsForm.insertTab(self.settings_tab, self.weight) def finalise(self): """ @@ -299,8 +297,6 @@ class Plugin(QtCore.QObject): """ if self.mediaItem: self.mediadock.remove_dock(self.mediaItem) - if self.settings_tab: - self.settingsForm.removeTab(self.settings_tab) def usesTheme(self, theme): """ diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 6f1222276..0fddc75c4 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -137,7 +137,7 @@ class PluginManager(object): if plugin.status is not PluginStatus.Disabled: plugin.mediaItem = plugin.getMediaManagerItem() - def hook_settings_tabs(self, settingsform=None): + def hook_settings_tabs(self, settings_form=None): """ Loop through all the plugins. If a plugin has a valid settings tab item, add it to the settings tab. @@ -148,15 +148,8 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.settings_tab = plugin.getSettingsTab(settingsform) - visible_title = plugin.getString(StringContent.VisibleName) - if plugin.settings_tab and plugin.isActive(): - log.debug(u'Inserting settings tab item from %s' % - visible_title[u'title']) - settingsform.insertTab(plugin.settings_tab, plugin.weight) - else: - log.debug( - u'No tab settings in %s' % visible_title[u'title']) + plugin.settings_tab = plugin.getSettingsTab(settings_form) + settings_form.plugins = self.plugins def hook_import_menu(self, import_menu): """ diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 72e1b7fa4..6d1680b53 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -30,7 +30,7 @@ import logging from PyQt4 import QtGui, QtCore -from openlp.core.lib import Receiver, build_icon +from openlp.core.lib import Receiver, build_icon, PluginStatus from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab from settingsdialog import Ui_SettingsDialog @@ -47,53 +47,42 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): QtGui.QDialog.__init__(self, parent) self.setupUi(self) # General tab - generalTab = GeneralTab(self, screens) - self.insertTab(generalTab, 1) + self.generalTab = GeneralTab(self, screens) # Themes tab - themesTab = ThemesTab(self, mainWindow) - self.insertTab(themesTab, 2) + self.themesTab = ThemesTab(self, mainWindow) # Advanced tab - advancedTab = AdvancedTab(self, ) - self.insertTab(advancedTab, 3) + self.advancedTab = AdvancedTab(self) def exec_(self): # load all the settings - for tabIndex in range(0, self.stackedLayout.count()): - self.stackedLayout.widget(tabIndex).load() + self.settingListWidget.clear() + for tabIndex in range(0, self.stackedLayout.count() + 1): + # take at 0 and the rest shuffell up. + self.stackedLayout.takeAt(0) + self.insertTab(self.generalTab, 0, PluginStatus.Active) + self.insertTab(self.themesTab, 1, PluginStatus.Active) + self.insertTab(self.advancedTab, 2, PluginStatus.Active) + count = 3 + for plugin in self.plugins: + if plugin.settings_tab: + self.insertTab(plugin.settings_tab, count, plugin.status) + count += 1 self.settingListWidget.setCurrentRow(0) return QtGui.QDialog.exec_(self) - def insertTab(self, tab, location): + def insertTab(self, tab, location, is_active): """ Add a tab to the form at a specific location """ log.debug(u'Inserting %s tab' % tab.tabTitle) - # 14 : There are 3 tables currently and locations starts at -10 - match = False - for tabIndex in range(0, self.stackedLayout.count()): - if self.stackedLayout.widget(tabIndex): - if self.stackedLayout.widget(tabIndex).tabTitleVisible == \ - tab.tabTitleVisible: - self.stackedLayout.widget(tabIndex).setHidden(False) - match = True - break - if not match: - pos = self.stackedLayout.addWidget(tab) + pos = self.stackedLayout.addWidget(tab) + if is_active: item_name = QtGui.QListWidgetItem(tab.tabTitleVisible) icon = build_icon(tab.icon_path) item_name.setIcon(icon) - self.settingListWidget.insertItem(14 + location, item_name) - - def removeTab(self, tab): - """ - Remove a tab from the form - """ - log.debug(u'remove %s tab' % tab.tabTitleVisible) - for tabIndex in range(0, self.stackedLayout.count()): - if self.stackedLayout.widget(tabIndex): - if self.stackedLayout.widget(tabIndex).tabTitleVisible == \ - tab.tabTitleVisible: - self.settingListWidget.item(tabIndex).setHidden(True) + self.settingListWidget.insertItem(location, item_name) + else: + self.stackedLayout.takeAt(location) def accept(self): """ diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index b3ffff87c..736d3d82e 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -836,6 +836,9 @@ class BibleMediaItem(MediaManagerItem): return u'{su}%s{/su}' % verse_text def onlayoutStyleComboBoxChanged(self): + self.settings.layout_style = self.quickLayoutComboBox.currentIndex() + self.settings.layoutStyleComboBox.setCurrentIndex( + self.settings.layout_style) QtCore.QSettings().setValue( self.settingsSection + u'/verse layout style', QtCore.QVariant(self.settings.layout_style)) From 4dd70d454ff6c097f0afd002cfcd465c08bfcabe Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 14 Apr 2011 19:55:41 +0100 Subject: [PATCH 69/76] Fix Postsetup --- openlp/core/ui/settingsform.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 6d1680b53..949d907b4 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -106,5 +106,9 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): """ Run any post-setup code for the tabs on the form """ - for tabIndex in range(0, self.stackedLayout.count()): - self.stackedLayout.widget(tabIndex).postSetUp() + self.generalTab.postSetUp() + self.themesTab.postSetUp() + self.advancedTab.postSetUp() + for plugin in self.plugins: + if plugin.settings_tab: + plugin.settings_tab.postSetUp() From 77559e021071bef7bae19337ac2edbc7d58d8813 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 14 Apr 2011 23:32:21 +0200 Subject: [PATCH 70/76] started to implement #746243 Fixes: https://launchpad.net/bugs/746243 --- openlp/core/lib/searchedit.py | 14 ++++++++++++++ openlp/plugins/songs/lib/mediaitem.py | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index d32961ef9..00e0f3ed3 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -110,6 +110,20 @@ class SearchEdit(QtGui.QLineEdit): """ return self._currentSearchType + def setCurrentSearchType(self, identifier): + """ + Set a new current search type. + + ``identifier`` + The search type identifier (int). + """ + menu = self.menuButton.menu() + for action in menu.actions(): + if identifier == action.data().toInt()[0]: + self.menuButton.setDefaultAction(action) + self._currentSearchType = identifier + return True + def setSearchTypes(self, items): """ A list of tuples to be used in the search type menu. The first item in diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index e2882ed29..2ce2478cb 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -156,8 +156,17 @@ class SongMediaItem(MediaManagerItem): (SongSearch.Themes, u':/slides/slide_theme.png', UiStrings.Themes) ]) self.configUpdated() + # FIXME: Saved search type need to be considered when loading the list. + self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value( + u'%s/last search type' % self.settingsSection, + QtCore.QVariant(SongSearch.Entire)).toInt()[0]) def onSearchTextButtonClick(self): + # Save the current search type to the config. so it can be restored. + QtCore.QSettings().setValue(u'%s/last search type' % + self.settingsSection, + QtCore.QVariant(self.searchTextEdit.currentSearchType())) + # Reload the list considering the new search type. search_keywords = unicode(self.searchTextEdit.displayText()) search_results = [] search_type = self.searchTextEdit.currentSearchType() From 4286f6389dda9888a90b61857e34ea7765c43d81 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 14 Apr 2011 22:34:01 +0100 Subject: [PATCH 71/76] Switching from ppt to songs now fine --- openlp/core/lib/htmlbuilder.py | 8 ++++---- openlp/core/ui/slidecontroller.py | 10 ++++++---- openlp/plugins/presentations/lib/messagelistener.py | 5 ----- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 2ba235265..1f2d2498d 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -343,11 +343,11 @@ def build_html(item, screen, alert, islive, background, image=None): webkitvers = webkit_version() # Image generated and poked in if background: - bgimage = u'src="data:image/png;base64,%s"' % background + bgimage_src = u'src="data:image/png;base64,%s"' % background elif item.bg_image_bytes: - bgimage = u'src="data:image/png;base64,%s"' % item.bg_image_bytes + bgimage_src = u'src="data:image/png;base64,%s"' % item.bg_image_bytes else: - bgimage = u'style="display:none;"' + bgimage_src = u'style="display:none;"' if image: image_src = u'src="data:image/png;base64,%s"' % image else: @@ -359,7 +359,7 @@ def build_html(item, screen, alert, islive, background, image=None): build_lyrics_css(item, webkitvers), u'true' if theme and theme.display_slide_transition and islive \ else u'false', - bgimage, image_src, + bgimage_src, image_src, build_lyrics_html(item, webkitvers)) return html diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index b940b1e73..7110ddf02 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -365,7 +365,7 @@ class SlideController(QtGui.QWidget): QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged) def setPreviewHotkeys(self, parent=None): - self.previousItem.setObjectName(u'previousItemPreview') + self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') action_list = ActionList.get_instance() action_list.add_category( @@ -374,7 +374,7 @@ class SlideController(QtGui.QWidget): action_list.add_action(self.nextItem, UiStrings.PreviewToolbar) def setLiveHotkeys(self, parent=None): - self.previousItem.setObjectName(u'previousItemLive') + self.previousItem.setObjectName(u'previousItemLive') self.nextItem.setObjectName(u'nextItemLive') action_list = ActionList.get_instance() action_list.add_category( @@ -575,6 +575,7 @@ class SlideController(QtGui.QWidget): log.debug(u'processManagerItem live = %s' % self.isLive) self.onStopLoop() old_item = self.serviceItem + self.serviceItem = serviceItem if old_item and self.isLive and old_item.is_capable( ItemCapabilities.ProvidesOwnDisplay): self._resetBlank() @@ -582,7 +583,6 @@ class SlideController(QtGui.QWidget): [serviceItem, self.isLive, self.hideMode(), slideno]) self.slideList = {} width = self.parent.controlSplitter.sizes()[self.split] - self.serviceItem = serviceItem self.previewListWidget.clear() self.previewListWidget.setRowCount(0) self.previewListWidget.setColumnWidth(0, width) @@ -642,7 +642,7 @@ class SlideController(QtGui.QWidget): self.__updatePreviewSelection(slideno) self.enableToolBar(serviceItem) # Pass to display for viewing. - # Postpone image build, we need to do this later to avoid theme + # Postpone image build, we need to do this later to avoid the theme # flashing on the screen if not self.serviceItem.is_image(): self.display.buildHtml(self.serviceItem) @@ -1136,6 +1136,8 @@ class SlideController(QtGui.QWidget): self.onThemeDisplay(True) elif hide_mode == HideMode.Screen: self.onHideDisplay(True) + else: + self.hidePlugin(False) def hideMode(self): """ diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index b76fd7d4c..94cd2bfa4 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -173,12 +173,8 @@ class Controller(object): Based on the handler passed at startup triggers slide show to shut down """ log.debug(u'Live = %s, shutdown' % self.is_live) - if self.is_live: - Receiver.send_message(u'maindisplay_show') self.doc.close_presentation() self.doc = None - #self.doc.slidenumber = 0 - #self.timer.stop() def blank(self, hide_mode): """ @@ -345,7 +341,6 @@ class MessageListener(object): """ is_live = message[1] if is_live: - Receiver.send_message(u'maindisplay_show') self.live_handler.shutdown() else: self.preview_handler.shutdown() From 14a2e8e4c2c332984bafe52a2a63ccfd52cfe914 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 15 Apr 2011 14:55:56 +0200 Subject: [PATCH 72/76] finished work on restoring current search methods --- openlp/core/lib/searchedit.py | 1 + openlp/plugins/bibles/lib/mediaitem.py | 21 ++++++++++++++------- openlp/plugins/songs/lib/mediaitem.py | 5 ++--- openlp/plugins/songs/songsplugin.py | 2 -- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 00e0f3ed3..94152ef2f 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -122,6 +122,7 @@ class SearchEdit(QtGui.QLineEdit): if identifier == action.data().toInt()[0]: self.menuButton.setDefaultAction(action) self._currentSearchType = identifier + self.emit(QtCore.SIGNAL(u'searchTypeChanged(int)'), identifier) return True def setSearchTypes(self, items): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 118bdfc66..241854985 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -99,12 +99,6 @@ class BibleMediaItem(MediaManagerItem): self.quickSearchEdit = SearchEdit(self.quickTab) self.quickSearchEdit.setObjectName(u'quickSearchEdit') self.quickSearchLabel.setBuddy(self.quickSearchEdit) - self.quickSearchEdit.setSearchTypes([ - (BibleSearch.Reference, u':/bibles/bibles_search_reference.png', - translate('BiblesPlugin.MediaItem', 'Scripture Reference')), - (BibleSearch.Text, u':/bibles/bibles_search_text.png', - translate('BiblesPlugin.MediaItem', 'Text Search')) - ]) self.quickLayout.addRow(self.quickSearchLabel, self.quickSearchEdit) self.quickLayoutLabel = QtGui.QLabel(self.quickTab) self.quickLayoutLabel.setObjectName(u'quickClearLabel') @@ -295,7 +289,15 @@ class BibleMediaItem(MediaManagerItem): self.settingsSection + u'/quick bible', QtCore.QVariant( self.quickVersionComboBox.currentText())).toString() find_and_set_in_combo_box(self.quickVersionComboBox, bible) - self.updateAutoCompleter() + self.quickSearchEdit.setSearchTypes([ + (BibleSearch.Reference, u':/bibles/bibles_search_reference.png', + translate('BiblesPlugin.MediaItem', 'Scripture Reference')), + (BibleSearch.Text, u':/bibles/bibles_search_text.png', + translate('BiblesPlugin.MediaItem', 'Text Search')) + ]) + self.quickSearchEdit.setCurrentSearchType(QtCore.QSettings().value( + u'%s/last search type' % self.settingsSection, + QtCore.QVariant(BibleSearch.Reference)).toInt()[0]) self.configUpdated() log.debug(u'bible manager initialise complete') @@ -386,6 +388,11 @@ class BibleMediaItem(MediaManagerItem): completion depends on the bible. It is only updated when we are doing a reference search, otherwise the auto completion list is removed. """ + # Save the current search type to the configuration. + QtCore.QSettings().setValue(u'%s/last search type' % + self.settingsSection, + QtCore.QVariant(self.quickSearchEdit.currentSearchType())) + # Save the current bible to the configuration. QtCore.QSettings().setValue(self.settingsSection + u'/quick bible', QtCore.QVariant(self.quickVersionComboBox.currentText())) books = [] diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 2ce2478cb..5890fc76d 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -155,14 +155,13 @@ class SongMediaItem(MediaManagerItem): SongStrings.Authors), (SongSearch.Themes, u':/slides/slide_theme.png', UiStrings.Themes) ]) - self.configUpdated() - # FIXME: Saved search type need to be considered when loading the list. self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value( u'%s/last search type' % self.settingsSection, QtCore.QVariant(SongSearch.Entire)).toInt()[0]) + self.configUpdated() def onSearchTextButtonClick(self): - # Save the current search type to the config. so it can be restored. + # Save the current search type to the configuration. QtCore.QSettings().setValue(u'%s/last search type' % self.settingsSection, QtCore.QVariant(self.searchTextEdit.currentSearchType())) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index af50f3f94..4fc098949 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -70,8 +70,6 @@ class SongsPlugin(Plugin): action_list.add_action(self.SongImportItem, UiStrings.Import) action_list.add_action(self.SongExportItem, UiStrings.Export) action_list.add_action(self.toolsReindexItem, UiStrings.Tools) - self.mediaItem.displayResultsSong( - self.manager.get_all_objects(Song, order_by_ref=Song.search_title)) def addImportMenuItem(self, import_menu): """ From 269c4fa044ef9093793027f0371aed005ab06336 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 15 Apr 2011 18:17:51 +0100 Subject: [PATCH 73/76] Fixups --- openlp/core/lib/plugin.py | 28 ++++++++++++++-------------- openlp/core/ui/advancedtab.py | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index a6cc5df63..2ec1045bb 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -115,7 +115,7 @@ class Plugin(QtCore.QObject): """ log.info(u'loaded') - def __init__(self, name, pluginHelpers=None, mediaItemClass=None, + def __init__(self, name, plugin_helpers=None, media_item_class=None, settings_tab_class=None, version=None): """ This is the constructor for the plugin object. This provides an easy @@ -132,10 +132,10 @@ class Plugin(QtCore.QObject): ``version`` Defaults to *None*. The version of the plugin. - ``pluginHelpers`` + ``plugin_helpers`` Defaults to *None*. A list of helper objects. - ``mediaItemClass`` + ``media_item_class`` The class name of the plugin's media item. ``settings_tab_class`` @@ -153,20 +153,20 @@ class Plugin(QtCore.QObject): self.version = get_application_version()[u'version'] self.settingsSection = self.name.lower() self.icon = None - self.mediaItemClass = mediaItemClass + self.media_item_class = media_item_class self.settings_tab_class = settings_tab_class self.weight = 0 self.status = PluginStatus.Inactive # Set up logging self.log = logging.getLogger(self.name) - self.previewController = pluginHelpers[u'preview'] - self.liveController = pluginHelpers[u'live'] - self.renderManager = pluginHelpers[u'render'] - self.serviceManager = pluginHelpers[u'service'] - self.settingsForm = pluginHelpers[u'settings form'] - self.mediadock = pluginHelpers[u'toolbox'] - self.pluginManager = pluginHelpers[u'pluginmanager'] - self.formparent = pluginHelpers[u'formparent'] + self.previewController = plugin_helpers[u'preview'] + self.liveController = plugin_helpers[u'live'] + self.renderManager = plugin_helpers[u'render'] + self.serviceManager = plugin_helpers[u'service'] + self.settingsForm = plugin_helpers[u'settings form'] + self.mediadock = plugin_helpers[u'toolbox'] + self.pluginManager = plugin_helpers[u'pluginmanager'] + self.formparent = plugin_helpers[u'formparent'] QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), self.processAddServiceEvent) @@ -213,8 +213,8 @@ class Plugin(QtCore.QObject): Construct a MediaManagerItem object with all the buttons and things you need, and return it for integration into openlp.org. """ - if self.mediaItemClass: - return self.mediaItemClass(self, self, self.icon) + if self.media_item_class: + return self.media_item_class(self, self, self.icon) return None def addImportMenuItem(self, importMenu): diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 3d9321fe1..199ebff60 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -45,7 +45,7 @@ class AdvancedTab(SettingsTab): SettingsTab.__init__(self, parent ,u'Advanced', generalTranslated) self.default_image = u':/graphics/openlp-splash-screen.png' self.default_color = u'#ffffff' - self.icon_path = u':/icon/openlp-logo-16x16.png' + self.icon_path = u':/system/system_settings.png' def setupUi(self): """ From 8090adf1bc4167ede05e137f2c68efd763b05936 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 15 Apr 2011 23:43:59 +0200 Subject: [PATCH 74/76] Made UiStrings a Singleton, and updated all usage of it. --- openlp.pyw | 4 +- openlp/core/lib/mediamanageritem.py | 12 +- openlp/core/lib/plugin.py | 18 +- openlp/core/lib/serviceitem.py | 6 +- openlp/core/lib/theme.py | 4 +- openlp/core/lib/ui.py | 176 ++++++++++-------- openlp/core/ui/aboutdialog.py | 6 +- openlp/core/ui/advancedtab.py | 6 +- openlp/core/ui/displaytagdialog.py | 6 +- openlp/core/ui/exceptionform.py | 4 +- openlp/core/ui/generaltab.py | 4 +- openlp/core/ui/mainwindow.py | 86 ++++----- openlp/core/ui/plugindialog.py | 6 +- openlp/core/ui/printservicedialog.py | 4 +- openlp/core/ui/printserviceform.py | 6 +- openlp/core/ui/servicemanager.py | 30 +-- openlp/core/ui/slidecontroller.py | 22 +-- openlp/core/ui/starttimedialog.py | 14 +- openlp/core/ui/starttimeform.py | 8 +- openlp/core/ui/themeform.py | 6 +- openlp/core/ui/thememanager.py | 6 +- openlp/core/ui/themestab.py | 4 +- openlp/core/ui/themewizard.py | 16 +- openlp/core/ui/wizard.py | 4 +- openlp/plugins/alerts/alertsplugin.py | 4 +- openlp/plugins/alerts/lib/alertstab.py | 10 +- openlp/plugins/bibles/bibleplugin.py | 10 +- .../plugins/bibles/forms/bibleimportform.py | 24 +-- openlp/plugins/bibles/lib/biblestab.py | 12 +- openlp/plugins/bibles/lib/mediaitem.py | 20 +- .../plugins/custom/forms/editcustomdialog.py | 6 +- openlp/plugins/custom/lib/mediaitem.py | 6 +- openlp/plugins/images/lib/mediaitem.py | 14 +- openlp/plugins/media/lib/mediaitem.py | 14 +- openlp/plugins/presentations/lib/mediaitem.py | 4 +- .../presentations/lib/presentationtab.py | 4 +- openlp/plugins/songs/forms/editsongdialog.py | 12 +- openlp/plugins/songs/forms/editsongform.py | 6 +- openlp/plugins/songs/forms/songexportform.py | 6 +- openlp/plugins/songs/forms/songimportform.py | 52 +++--- .../songs/forms/songmaintenancedialog.py | 20 +- .../songs/forms/songmaintenanceform.py | 4 +- openlp/plugins/songs/lib/mediaitem.py | 12 +- openlp/plugins/songs/songsplugin.py | 16 +- 44 files changed, 366 insertions(+), 348 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 5c3b8ca77..425d3c874 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -140,7 +140,7 @@ class OpenLP(QtGui.QApplication): self.sharedMemory = QtCore.QSharedMemory('OpenLP') if self.sharedMemory.attach(): status = QtGui.QMessageBox.critical(None, - UiStrings.Error, UiStrings.OpenLPStart, + UiStrings().Error, UiStrings().OpenLPStart, QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) if status == QtGui.QMessageBox.No: @@ -250,4 +250,4 @@ if __name__ == u'__main__': """ Instantiate and run the application. """ - main() + main() \ No newline at end of file diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 7671064df..e7d7bc4ec 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -435,7 +435,7 @@ class MediaManagerItem(QtGui.QWidget): item to the preview slide controller. """ if not self.listView.selectedIndexes() and not self.remoteTriggered: - QtGui.QMessageBox.information(self, UiStrings.NISp, + QtGui.QMessageBox.information(self, UiStrings().NISp, translate('OpenLP.MediaManagerItem', 'You must select one or more items to preview.')) else: @@ -453,7 +453,7 @@ class MediaManagerItem(QtGui.QWidget): item to the live slide controller. """ if not self.listView.selectedIndexes(): - QtGui.QMessageBox.information(self, UiStrings.NISp, + QtGui.QMessageBox.information(self, UiStrings().NISp, translate('OpenLP.MediaManagerItem', 'You must select one or more items to send live.')) else: @@ -468,7 +468,7 @@ class MediaManagerItem(QtGui.QWidget): Add a selected item to the current service """ if not self.listView.selectedIndexes() and not self.remoteTriggered: - QtGui.QMessageBox.information(self, UiStrings.NISp, + QtGui.QMessageBox.information(self, UiStrings().NISp, translate('OpenLP.MediaManagerItem', 'You must select one or more items.')) else: @@ -494,14 +494,14 @@ class MediaManagerItem(QtGui.QWidget): Add a selected item to an existing item in the current service. """ if not self.listView.selectedIndexes() and not self.remoteTriggered: - QtGui.QMessageBox.information(self, UiStrings.NISp, + QtGui.QMessageBox.information(self, UiStrings().NISp, translate('OpenLP.MediaManagerItem', 'You must select one or more items.')) else: log.debug(u'%s Add requested', self.plugin.name) serviceItem = self.parent.serviceManager.getServiceItem() if not serviceItem: - QtGui.QMessageBox.information(self, UiStrings.NISs, + QtGui.QMessageBox.information(self, UiStrings().NISs, translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.')) elif self.plugin.name.lower() == serviceItem.name.lower(): @@ -554,4 +554,4 @@ class MediaManagerItem(QtGui.QWidget): item_id = remoteItem else: item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - return item_id + return item_id \ No newline at end of file diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 2ec1045bb..08be86541 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -330,28 +330,28 @@ class Plugin(QtCore.QObject): """ ## Load Action ## self.__setNameTextString(StringContent.Load, - UiStrings.Load, tooltips[u'load']) + UiStrings().Load, tooltips[u'load']) ## Import Action ## self.__setNameTextString(StringContent.Import, - UiStrings.Import, tooltips[u'import']) + UiStrings().Import, tooltips[u'import']) ## New Action ## self.__setNameTextString(StringContent.New, - UiStrings.Add, tooltips[u'new']) + UiStrings().Add, tooltips[u'new']) ## Edit Action ## self.__setNameTextString(StringContent.Edit, - UiStrings.Edit, tooltips[u'edit']) + UiStrings().Edit, tooltips[u'edit']) ## Delete Action ## self.__setNameTextString(StringContent.Delete, - UiStrings.Delete, tooltips[u'delete']) + UiStrings().Delete, tooltips[u'delete']) ## Preview Action ## self.__setNameTextString(StringContent.Preview, - UiStrings.Preview, tooltips[u'preview']) + UiStrings().Preview, tooltips[u'preview']) ## Send Live Action ## self.__setNameTextString(StringContent.Live, - UiStrings.Live, tooltips[u'live']) + UiStrings().Live, tooltips[u'live']) ## Add to Service Action ## self.__setNameTextString(StringContent.Service, - UiStrings.Service, tooltips[u'service']) + UiStrings().Service, tooltips[u'service']) def __setNameTextString(self, name, title, tooltip): """ @@ -359,4 +359,4 @@ class Plugin(QtCore.QObject): use of the singular name of the plugin object so must only be called after this has been set. """ - self.textStrings[name] = {u'title': title, u'tooltip': tooltip} + self.textStrings[name] = {u'title': title, u'tooltip': tooltip} \ No newline at end of file diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 48a277633..5de25f6aa 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -441,10 +441,10 @@ class ServiceItem(object): start = None end = None if self.start_time != 0: - start = UiStrings.StartTimeCode % \ + start = UiStrings().StartTimeCode % \ unicode(datetime.timedelta(seconds=self.start_time)) if self.media_length != 0: - end = UiStrings.LengthTime % \ + end = UiStrings().LengthTime % \ unicode(datetime.timedelta(seconds=self.media_length)) if not start and not end: return None @@ -453,4 +453,4 @@ class ServiceItem(object): elif not start and end: return end else: - return u'%s : %s' % (start, end) + return u'%s : %s' % (start, end) \ No newline at end of file diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 134df7652..698f0d644 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -192,7 +192,7 @@ class VerticalType(object): Bottom = 2 Names = [u'top', u'middle', u'bottom'] - TranslatedNames = [UiStrings.Top, UiStrings.Middle, UiStrings.Bottom] + TranslatedNames = [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom] BOOLEAN_LIST = [u'bold', u'italics', u'override', u'outline', u'shadow', @@ -637,4 +637,4 @@ class ThemeXML(object): self.font_footer_shadow_size) self.add_display(self.display_horizontal_align, self.display_vertical_align, - self.display_slide_transition) + self.display_slide_transition) \ No newline at end of file diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index bd47ee627..013231b8c 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -39,78 +39,96 @@ class UiStrings(object): """ Provide standard strings for objects to use. """ - # These strings should need a good reason to be retranslated elsewhere. - # Should some/more/less of these have an & attached? - About = translate('OpenLP.Ui', 'About') - Add = translate('OpenLP.Ui', '&Add') - Advanced = translate('OpenLP.Ui', 'Advanced') - AllFiles = translate('OpenLP.Ui', 'All Files') - Bottom = translate('OpenLP.Ui', 'Bottom') - Browse = translate('OpenLP.Ui', 'Browse...') - Cancel = translate('OpenLP.Ui', 'Cancel') - CCLINumberLabel = translate('OpenLP.Ui', 'CCLI number:') - CreateService = translate('OpenLP.Ui', 'Create a new service.') - Continuous = translate('OpenLP.Ui', 'Continuous') - Default = unicode(translate('OpenLP.Ui', 'Default')) - Delete = translate('OpenLP.Ui', '&Delete') - DisplayStyle = translate('OpenLP.Ui', 'Display style:') - Edit = translate('OpenLP.Ui', '&Edit') - EmptyField = translate('OpenLP.Ui', 'Empty Field') - Error = translate('OpenLP.Ui', 'Error') - Export = translate('OpenLP.Ui', 'Export') - File = translate('OpenLP.Ui', 'File') - FontSizePtUnit = translate('OpenLP.Ui', 'pt', - 'Abbreviated font pointsize unit') - Help = translate('OpenLP.Ui', 'Help') - Hours = translate('OpenLP.Ui', 'h', 'The abbreviated unit for hours') - Image = translate('OpenLP.Ui', 'Image') - Import = translate('OpenLP.Ui', 'Import') - LayoutStyle = translate('OpenLP.Ui', 'Layout style:') - LengthTime = unicode(translate('OpenLP.Ui', 'Length %s')) - Live = translate('OpenLP.Ui', 'Live') - LiveBGError = translate('OpenLP.Ui', 'Live Background Error') - LivePanel = translate('OpenLP.Ui', 'Live Panel') - LiveToolbar = translate('OpenLP.Ui', 'Live Toolbar') - Load = translate('OpenLP.Ui', 'Load') - Minutes = translate('OpenLP.Ui', 'm', 'The abbreviated unit for minutes') - Middle = translate('OpenLP.Ui', 'Middle') - New = translate('OpenLP.Ui', 'New') - NewService = translate('OpenLP.Ui', 'New Service') - NewTheme = translate('OpenLP.Ui', 'New Theme') - NFSs = translate('OpenLP.Ui', 'No File Selected', 'Singular') - NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural') - NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular') - NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural') - OLPV1 = translate('OpenLP.Ui', 'openlp.org 1.x') - OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0') - OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you ' - 'wish to continue?') - OpenService = translate('OpenLP.Ui', 'Open Service') - Preview = translate('OpenLP.Ui', 'Preview') - PreviewPanel = translate('OpenLP.Ui', 'Preview Panel') - PrintServiceOrder = translate('OpenLP.Ui', 'Print Service Order') - ReplaceBG = translate('OpenLP.Ui', 'Replace Background') - ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background') - ResetBG = translate('OpenLP.Ui', 'Reset Background') - ResetLiveBG = translate('OpenLP.Ui', 'Reset Live Background') - Seconds = translate('OpenLP.Ui', 's', 'The abbreviated unit for seconds') - SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview') - Search = translate('OpenLP.Ui', 'Search') - SelectDelete = translate('OpenLP.Ui', 'You must select an item to delete.') - SelectEdit = translate('OpenLP.Ui', 'You must select an item to edit.') - Settings = translate('OpenLP.Ui', 'Settings') - SaveService = translate('OpenLP.Ui', 'Save Service') - Service = translate('OpenLP.Ui', 'Service') - StartTimeCode = unicode(translate('OpenLP.Ui', 'Start %s')) - Theme = translate('OpenLP.Ui', 'Theme', 'Singular') - Themes = translate('OpenLP.Ui', 'Themes', 'Plural') - Tools = translate('OpenLP.Ui', 'Tools') - Top = translate('OpenLP.Ui', 'Top') - VersePerSlide = translate('OpenLP.Ui', 'Verse Per Slide') - VersePerLine = translate('OpenLP.Ui', 'Verse Per Line') - Version = translate('OpenLP.Ui', 'Version') - View = translate('OpenLP.Ui', 'View') - ViewMode = translate('OpenLP.Ui', 'View Model') + __instance__ = None + + def __new__(cls): + """ + Override the default object creation method to return a single instance. + """ + if not cls.__instance__: + cls.__instance__ = object.__new__(cls) + return cls.__instance__ + + def __init__(self): + """ + These strings should need a good reason to be retranslated elsewhere. + Should some/more/less of these have an & attached? + """ + self.About = translate('OpenLP.Ui', 'About') + self.Add = translate('OpenLP.Ui', '&Add') + self.Advanced = translate('OpenLP.Ui', 'Advanced') + self.AllFiles = translate('OpenLP.Ui', 'All Files') + self.Bottom = translate('OpenLP.Ui', 'Bottom') + self.Browse = translate('OpenLP.Ui', 'Browse...') + self.Cancel = translate('OpenLP.Ui', 'Cancel') + self.CCLINumberLabel = translate('OpenLP.Ui', 'CCLI number:') + self.CreateService = translate('OpenLP.Ui', 'Create a new service.') + self.Continuous = translate('OpenLP.Ui', 'Continuous') + self.Default = unicode(translate('OpenLP.Ui', 'Default')) + self.Delete = translate('OpenLP.Ui', '&Delete') + self.DisplayStyle = translate('OpenLP.Ui', 'Display style:') + self.Edit = translate('OpenLP.Ui', '&Edit') + self.EmptyField = translate('OpenLP.Ui', 'Empty Field') + self.Error = translate('OpenLP.Ui', 'Error') + self.Export = translate('OpenLP.Ui', 'Export') + self.File = translate('OpenLP.Ui', 'File') + self.FontSizePtUnit = translate('OpenLP.Ui', 'pt', + 'Abbreviated font pointsize unit') + self.Help = translate('OpenLP.Ui', 'Help') + self.Hours = translate('OpenLP.Ui', 'h', + 'The abbreviated unit for hours') + self.Image = translate('OpenLP.Ui', 'Image') + self.Import = translate('OpenLP.Ui', 'Import') + self.LayoutStyle = translate('OpenLP.Ui', 'Layout style:') + self.LengthTime = unicode(translate('OpenLP.Ui', 'Length %s')) + self.Live = translate('OpenLP.Ui', 'Live') + self.LiveBGError = translate('OpenLP.Ui', 'Live Background Error') + self.LivePanel = translate('OpenLP.Ui', 'Live Panel') + self.LiveToolbar = translate('OpenLP.Ui', 'Live Toolbar') + self.Load = translate('OpenLP.Ui', 'Load') + self.Minutes = translate('OpenLP.Ui', 'm', + 'The abbreviated unit for minutes') + self.Middle = translate('OpenLP.Ui', 'Middle') + self.New = translate('OpenLP.Ui', 'New') + self.NewService = translate('OpenLP.Ui', 'New Service') + self.NewTheme = translate('OpenLP.Ui', 'New Theme') + self.NFSs = translate('OpenLP.Ui', 'No File Selected', 'Singular') + self.NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural') + self.NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular') + self.NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural') + self.OLPV1 = translate('OpenLP.Ui', 'openlp.org 1.x') + self.OLPV2 = translate('OpenLP.Ui', 'OpenLP 2.0') + self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. ' + 'Do you wish to continue?') + self.OpenService = translate('OpenLP.Ui', 'Open Service') + self.Preview = translate('OpenLP.Ui', 'Preview') + self.PreviewPanel = translate('OpenLP.Ui', 'Preview Panel') + self.PrintServiceOrder = translate('OpenLP.Ui', 'Print Service Order') + self.ReplaceBG = translate('OpenLP.Ui', 'Replace Background') + self.ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background') + self.ResetBG = translate('OpenLP.Ui', 'Reset Background') + self.ResetLiveBG = translate('OpenLP.Ui', 'Reset Live Background') + self.Seconds = translate('OpenLP.Ui', 's', + 'The abbreviated unit for seconds') + self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview') + self.Search = translate('OpenLP.Ui', 'Search') + self.SelectDelete = translate('OpenLP.Ui', 'You must select an item ' + 'to delete.') + self.SelectEdit = translate('OpenLP.Ui', 'You must select an item to ' + 'edit.') + self.Settings = translate('OpenLP.Ui', 'Settings') + self.SaveService = translate('OpenLP.Ui', 'Save Service') + self.Service = translate('OpenLP.Ui', 'Service') + self.StartTimeCode = unicode(translate('OpenLP.Ui', 'Start %s')) + self.Theme = translate('OpenLP.Ui', 'Theme', 'Singular') + self.Themes = translate('OpenLP.Ui', 'Themes', 'Plural') + self.Tools = translate('OpenLP.Ui', 'Tools') + self.Top = translate('OpenLP.Ui', 'Top') + self.VersePerSlide = translate('OpenLP.Ui', 'Verse Per Slide') + self.VersePerLine = translate('OpenLP.Ui', 'Verse Per Line') + self.Version = translate('OpenLP.Ui', 'Version') + self.View = translate('OpenLP.Ui', 'View') + self.ViewMode = translate('OpenLP.Ui', 'View Model') def add_welcome_page(parent, image): """ @@ -184,11 +202,11 @@ def critical_error_message_box(title=None, message=None, parent=None, Should this message box question the user. """ if question: - return QtGui.QMessageBox.critical(parent, UiStrings.Error, message, + return QtGui.QMessageBox.critical(parent, UiStrings().Error, message, QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) data = {u'message': message} - data[u'title'] = title if title else UiStrings.Error + data[u'title'] = title if title else UiStrings().Error return Receiver.send_message(u'openlp_error_message', data) def media_item_combo_box(parent, name): @@ -218,7 +236,7 @@ def create_delete_push_button(parent, icon=None): delete_button.setObjectName(u'deleteButton') delete_icon = icon if icon else u':/general/general_delete.png' delete_button.setIcon(build_icon(delete_icon)) - delete_button.setText(UiStrings.Delete) + delete_button.setText(UiStrings().Delete) delete_button.setToolTip( translate('OpenLP.Ui', 'Delete the selected item.')) QtCore.QObject.connect(delete_button, @@ -406,9 +424,9 @@ def create_valign_combo(form, parent, layout): verticalLabel.setText(translate('OpenLP.Ui', '&Vertical Align:')) form.verticalComboBox = QtGui.QComboBox(parent) form.verticalComboBox.setObjectName(u'VerticalComboBox') - form.verticalComboBox.addItem(UiStrings.Top) - form.verticalComboBox.addItem(UiStrings.Middle) - form.verticalComboBox.addItem(UiStrings.Bottom) + form.verticalComboBox.addItem(UiStrings().Top) + form.verticalComboBox.addItem(UiStrings().Middle) + form.verticalComboBox.addItem(UiStrings().Bottom) verticalLabel.setBuddy(form.verticalComboBox) layout.addRow(verticalLabel, form.verticalComboBox) @@ -427,4 +445,4 @@ def find_and_set_in_combo_box(combo_box, value_to_find): if index == -1: # Not Found. index = 0 - combo_box.setCurrentIndex(index) + combo_box.setCurrentIndex(index) \ No newline at end of file diff --git a/openlp/core/ui/aboutdialog.py b/openlp/core/ui/aboutdialog.py index 719cb02c2..d4ea463ea 100644 --- a/openlp/core/ui/aboutdialog.py +++ b/openlp/core/ui/aboutdialog.py @@ -87,7 +87,7 @@ class Ui_AboutDialog(object): QtCore.QMetaObject.connectSlotsByName(aboutDialog) def retranslateUi(self, aboutDialog): - aboutDialog.setWindowTitle(u'%s OpenLP' % UiStrings.About) + aboutDialog.setWindowTitle(u'%s OpenLP' % UiStrings().About) self.aboutTextEdit.setPlainText(translate('OpenLP.AboutForm', 'OpenLP - Open Source Lyrics ' 'Projection\n' @@ -105,7 +105,7 @@ class Ui_AboutDialog(object): 'consider contributing by using the button below.' )) self.aboutNotebook.setTabText( - self.aboutNotebook.indexOf(self.aboutTab), UiStrings.About) + self.aboutNotebook.indexOf(self.aboutTab), UiStrings().About) lead = u'Raoul "superfly" Snyman' developers = [u'Tim "TRB143" Bentley', u'Jonathan "gushie" Corwin', u'Michael "cocooncrash" Gorven', @@ -615,4 +615,4 @@ class Ui_AboutDialog(object): self.aboutNotebook.indexOf(self.licenseTab), translate('OpenLP.AboutForm', 'License')) self.contributeButton.setText(translate('OpenLP.AboutForm', - 'Contribute')) + 'Contribute')) \ No newline at end of file diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 199ebff60..94bcb0801 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -127,7 +127,7 @@ class AdvancedTab(SettingsTab): """ Setup the interface translation strings. """ - self.tabTitleVisible = UiStrings.Advanced + self.tabTitleVisible = UiStrings().Advanced self.uiGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'UI Settings')) self.recentLabel.setText( translate('OpenLP.AdvancedTab', @@ -226,10 +226,10 @@ class AdvancedTab(SettingsTab): def onDefaultBrowseButtonPressed(self): file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), - UiStrings.AllFiles) + UiStrings().AllFiles) filename = QtGui.QFileDialog.getOpenFileName(self, translate('OpenLP.AdvancedTab', 'Open File'), '', file_filters) if filename: self.defaultFileEdit.setText(filename) - self.defaultFileEdit.setFocus() + self.defaultFileEdit.setFocus() \ No newline at end of file diff --git a/openlp/core/ui/displaytagdialog.py b/openlp/core/ui/displaytagdialog.py index 848818e88..8e71a60ff 100644 --- a/openlp/core/ui/displaytagdialog.py +++ b/openlp/core/ui/displaytagdialog.py @@ -136,10 +136,10 @@ class Ui_DisplayTagDialog(object): translate('OpenLP.DisplayTagDialog', 'Start tag')) self.endTagLabel.setText( translate('OpenLP.DisplayTagDialog', 'End tag')) - self.deletePushButton.setText(UiStrings.Delete) + self.deletePushButton.setText(UiStrings().Delete) self.defaultPushButton.setText( translate('OpenLP.DisplayTagDialog', 'Default')) - self.newPushButton.setText(UiStrings.New) + self.newPushButton.setText(UiStrings().New) self.tagTableWidget.horizontalHeaderItem(0).setText( translate('OpenLP.DisplayTagDialog', 'Description')) self.tagTableWidget.horizontalHeaderItem(1).setText( @@ -151,4 +151,4 @@ class Ui_DisplayTagDialog(object): self.tagTableWidget.setColumnWidth(0, 120) self.tagTableWidget.setColumnWidth(1, 40) self.tagTableWidget.setColumnWidth(2, 240) - self.tagTableWidget.setColumnWidth(3, 240) + self.tagTableWidget.setColumnWidth(3, 240) \ No newline at end of file diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 0ae9497c9..622d60f79 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -178,11 +178,11 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): self,translate('ImagePlugin.ExceptionDialog', 'Select Attachment'), SettingsManager.get_last_dir(u'exceptions'), - u'%s (*.*) (*)' % UiStrings.AllFiles) + u'%s (*.*) (*)' % UiStrings().AllFiles) log.info(u'New files(s) %s', unicode(files)) if files: self.fileAttachment = unicode(files) def __buttonState(self, state): self.saveReportButton.setEnabled(state) - self.sendReportButton.setEnabled(state) + self.sendReportButton.setEnabled(state) \ No newline at end of file diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index cfde7810c..7dac2fe9d 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -238,7 +238,7 @@ class GeneralTab(SettingsTab): self.timeoutSpinBox.setSuffix(translate('OpenLP.GeneralTab', ' sec')) self.ccliGroupBox.setTitle( translate('OpenLP.GeneralTab', 'CCLI Details')) - self.numberLabel.setText(UiStrings.CCLINumberLabel) + self.numberLabel.setText(UiStrings().CCLINumberLabel) self.usernameLabel.setText( translate('OpenLP.GeneralTab', 'SongSelect username:')) self.passwordLabel.setText( @@ -394,4 +394,4 @@ class GeneralTab(SettingsTab): """ Called when the width, height, x position or y position has changed. """ - self.overrideChanged = True + self.overrideChanged = True \ No newline at end of file diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 2038e1972..d2fbaef9e 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -163,82 +163,82 @@ class Ui_MainWindow(object): self.themeManagerDock) # Create the menu items action_list = ActionList.get_instance() - action_list.add_category(UiStrings.File, CategoryOrder.standardMenu) + action_list.add_category(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=UiStrings.File) + u':/general/general_new.png', category=UiStrings().File) self.FileOpenItem = shortcut_action(mainWindow, u'FileOpenItem', [QtGui.QKeySequence(u'Ctrl+O')], self.ServiceManagerContents.onLoadServiceClicked, - u':/general/general_open.png', category=UiStrings.File) + u':/general/general_open.png', category=UiStrings().File) self.FileSaveItem = shortcut_action(mainWindow, u'FileSaveItem', [QtGui.QKeySequence(u'Ctrl+S')], self.ServiceManagerContents.saveFile, - u':/general/general_save.png', category=UiStrings.File) + u':/general/general_save.png', category=UiStrings().File) self.FileSaveAsItem = shortcut_action(mainWindow, u'FileSaveAsItem', [QtGui.QKeySequence(u'Ctrl+Shift+S')], - self.ServiceManagerContents.saveFileAs, category=UiStrings.File) + self.ServiceManagerContents.saveFileAs, category=UiStrings().File) self.printServiceOrderItem = shortcut_action(mainWindow, u'printServiceItem', [QtGui.QKeySequence(u'Ctrl+P')], self.ServiceManagerContents.printServiceOrder, - category=UiStrings.File) + category=UiStrings().File) self.FileExitItem = shortcut_action(mainWindow, u'FileExitItem', [QtGui.QKeySequence(u'Alt+F4')], mainWindow.close, - u':/system/system_exit.png', category=UiStrings.File) - action_list.add_category(UiStrings.Import, CategoryOrder.standardMenu) + u':/system/system_exit.png', category=UiStrings().File) + action_list.add_category(UiStrings().Import, CategoryOrder.standardMenu) self.ImportThemeItem = base_action( - mainWindow, u'ImportThemeItem', UiStrings.Import) + mainWindow, u'ImportThemeItem', UiStrings().Import) self.ImportLanguageItem = base_action( - mainWindow, u'ImportLanguageItem')#, UiStrings.Import) - action_list.add_category(UiStrings.Export, CategoryOrder.standardMenu) + mainWindow, u'ImportLanguageItem')#, UiStrings().Import) + action_list.add_category(UiStrings().Export, CategoryOrder.standardMenu) self.ExportThemeItem = base_action( - mainWindow, u'ExportThemeItem', UiStrings.Export) + mainWindow, u'ExportThemeItem', UiStrings().Export) self.ExportLanguageItem = base_action( - mainWindow, u'ExportLanguageItem')#, UiStrings.Export) - action_list.add_category(UiStrings.View, CategoryOrder.standardMenu) + mainWindow, u'ExportLanguageItem')#, UiStrings().Export) + action_list.add_category(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(), UiStrings.View) + self.mediaManagerDock.isVisible(), UiStrings().View) self.ViewThemeManagerItem = shortcut_action(mainWindow, u'ViewThemeManagerItem', [QtGui.QKeySequence(u'F10')], self.toggleThemeManager, u':/system/system_thememanager.png', - self.themeManagerDock.isVisible(), UiStrings.View) + self.themeManagerDock.isVisible(), UiStrings().View) self.ViewServiceManagerItem = shortcut_action(mainWindow, u'ViewServiceManagerItem', [QtGui.QKeySequence(u'F9')], self.toggleServiceManager, u':/system/system_servicemanager.png', - self.serviceManagerDock.isVisible(), UiStrings.View) + self.serviceManagerDock.isVisible(), UiStrings().View) self.ViewPreviewPanel = shortcut_action(mainWindow, u'ViewPreviewPanel', [QtGui.QKeySequence(u'F11')], self.setPreviewPanelVisibility, checked=previewVisible, - category=UiStrings.View) + category=UiStrings().View) self.ViewLivePanel = shortcut_action(mainWindow, u'ViewLivePanel', [QtGui.QKeySequence(u'F12')], self.setLivePanelVisibility, - checked=liveVisible, category=UiStrings.View) - action_list.add_category(UiStrings.ViewMode, CategoryOrder.standardMenu) + checked=liveVisible, category=UiStrings().View) + action_list.add_category(UiStrings().ViewMode, CategoryOrder.standardMenu) self.ModeDefaultItem = checkable_action( - mainWindow, u'ModeDefaultItem', category=UiStrings.ViewMode) + mainWindow, u'ModeDefaultItem', category=UiStrings().ViewMode) self.ModeSetupItem = checkable_action( - mainWindow, u'ModeLiveItem', category=UiStrings.ViewMode) + mainWindow, u'ModeLiveItem', category=UiStrings().ViewMode) self.ModeLiveItem = checkable_action( - mainWindow, u'ModeLiveItem', True, UiStrings.ViewMode) + mainWindow, u'ModeLiveItem', True, UiStrings().ViewMode) self.ModeGroup = QtGui.QActionGroup(mainWindow) self.ModeGroup.addAction(self.ModeDefaultItem) self.ModeGroup.addAction(self.ModeSetupItem) self.ModeGroup.addAction(self.ModeLiveItem) self.ModeDefaultItem.setChecked(True) - action_list.add_category(UiStrings.Tools, CategoryOrder.standardMenu) + action_list.add_category(UiStrings().Tools, CategoryOrder.standardMenu) self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem', - u':/tools/tools_add.png', category=UiStrings.Tools) + u':/tools/tools_add.png', category=UiStrings().Tools) self.ToolsOpenDataFolder = icon_action(mainWindow, u'ToolsOpenDataFolder', u':/general/general_open.png', - category=UiStrings.Tools) - action_list.add_category(UiStrings.Settings, CategoryOrder.standardMenu) + category=UiStrings().Tools) + action_list.add_category(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=UiStrings.Settings) + category=UiStrings().Settings) # i18n Language Items self.AutoLanguageItem = checkable_action(mainWindow, u'AutoLanguageItem', LanguageManager.auto_language) @@ -255,25 +255,25 @@ class Ui_MainWindow(object): self.SettingsShortcutsItem = icon_action(mainWindow, u'SettingsShortcutsItem', u':/system/system_configure_shortcuts.png', - category=UiStrings.Settings) + category=UiStrings().Settings) self.DisplayTagItem = icon_action(mainWindow, u'DisplayTagItem', u':/system/tag_editor.png', - category=UiStrings.Settings) + category=UiStrings().Settings) self.SettingsConfigureItem = icon_action(mainWindow, u'SettingsConfigureItem', u':/system/system_settings.png', - category=UiStrings.Settings) - action_list.add_category(UiStrings.Help, CategoryOrder.standardMenu) + category=UiStrings().Settings) + action_list.add_category(UiStrings().Help, CategoryOrder.standardMenu) self.HelpDocumentationItem = icon_action(mainWindow, u'HelpDocumentationItem', u':/system/system_help_contents.png', - category=None)#UiStrings.Help) + category=None)#UiStrings().Help) self.HelpDocumentationItem.setEnabled(False) self.HelpAboutItem = shortcut_action(mainWindow, u'HelpAboutItem', [QtGui.QKeySequence(u'Ctrl+F1')], self.onHelpAboutItemClicked, - u':/system/system_about.png', category=UiStrings.Help) + u':/system/system_about.png', category=UiStrings().Help) self.HelpOnlineHelpItem = base_action( - mainWindow, u'HelpOnlineHelpItem', category=UiStrings.Help) + mainWindow, u'HelpOnlineHelpItem', category=UiStrings().Help) self.helpWebSiteItem = base_action( - mainWindow, u'helpWebSiteItem', category=UiStrings.Help) + mainWindow, u'helpWebSiteItem', category=UiStrings().Help) add_actions(self.FileImportMenu, (self.ImportThemeItem, self.ImportLanguageItem)) add_actions(self.FileExportMenu, @@ -320,7 +320,7 @@ class Ui_MainWindow(object): """ Set up the translation system """ - mainWindow.mainTitle = UiStrings.OLPV2 + mainWindow.mainTitle = UiStrings().OLPV2 mainWindow.setWindowTitle(mainWindow.mainTitle) self.FileMenu.setTitle(translate('OpenLP.MainWindow', '&File')) self.FileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import')) @@ -339,14 +339,14 @@ class Ui_MainWindow(object): self.themeManagerDock.setWindowTitle( translate('OpenLP.MainWindow', 'Theme Manager')) self.FileNewItem.setText(translate('OpenLP.MainWindow', '&New')) - self.FileNewItem.setToolTip(UiStrings.NewService) - self.FileNewItem.setStatusTip(UiStrings.CreateService) + self.FileNewItem.setToolTip(UiStrings().NewService) + self.FileNewItem.setStatusTip(UiStrings().CreateService) self.FileOpenItem.setText(translate('OpenLP.MainWindow', '&Open')) - self.FileOpenItem.setToolTip(UiStrings.OpenService) + self.FileOpenItem.setToolTip(UiStrings().OpenService) self.FileOpenItem.setStatusTip( translate('OpenLP.MainWindow', 'Open an existing service.')) self.FileSaveItem.setText(translate('OpenLP.MainWindow', '&Save')) - self.FileSaveItem.setToolTip(UiStrings.SaveService) + self.FileSaveItem.setToolTip(UiStrings().SaveService) self.FileSaveItem.setStatusTip( translate('OpenLP.MainWindow', 'Save the current service to disk.')) self.FileSaveAsItem.setText( @@ -355,7 +355,7 @@ class Ui_MainWindow(object): translate('OpenLP.MainWindow', 'Save Service As')) self.FileSaveAsItem.setStatusTip(translate('OpenLP.MainWindow', 'Save the current service under a new name.')) - self.printServiceOrderItem.setText(UiStrings.PrintServiceOrder) + self.printServiceOrderItem.setText(UiStrings().PrintServiceOrder) self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', 'Print the current Service Order.')) self.FileExitItem.setText( @@ -1011,4 +1011,4 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.recentFiles.insert(0, QtCore.QString(filename)) while self.recentFiles.count() > maxRecentFiles: # Don't care what API says takeLast works, removeLast doesn't! - self.recentFiles.takeLast() + self.recentFiles.takeLast() \ No newline at end of file diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index 0ead739a5..84fb845c6 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -78,11 +78,11 @@ class Ui_PluginViewDialog(object): translate('OpenLP.PluginForm', 'Plugin List')) self.pluginInfoGroupBox.setTitle( translate('OpenLP.PluginForm', 'Plugin Details')) - self.versionLabel.setText(u'%s:' % UiStrings.Version) - self.aboutLabel.setText(u'%s:' % UiStrings.About) + self.versionLabel.setText(u'%s:' % UiStrings().Version) + self.aboutLabel.setText(u'%s:' % UiStrings().About) self.statusLabel.setText( translate('OpenLP.PluginForm', 'Status:')) self.statusComboBox.setItemText(0, translate('OpenLP.PluginForm', 'Active')) self.statusComboBox.setItemText(1, - translate('OpenLP.PluginForm', 'Inactive')) + translate('OpenLP.PluginForm', 'Inactive')) \ No newline at end of file diff --git a/openlp/core/ui/printservicedialog.py b/openlp/core/ui/printservicedialog.py index 9593e9ec4..889bc4f7d 100644 --- a/openlp/core/ui/printservicedialog.py +++ b/openlp/core/ui/printservicedialog.py @@ -148,7 +148,7 @@ class Ui_PrintServiceDialog(object): QtCore.SIGNAL(u'toggled(bool)'), self.toggleOptions) def retranslateUi(self, printServiceDialog): - printServiceDialog.setWindowTitle(UiStrings.PrintServiceOrder) + printServiceDialog.setWindowTitle(UiStrings().PrintServiceOrder) self.slideTextCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include slide text if available')) self.pageBreakAfterText.setText(translate('OpenLP.PrintServiceForm', @@ -164,4 +164,4 @@ class Ui_PrintServiceDialog(object): self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.OneHundred]) self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.SeventyFive]) self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.Fifty]) - self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.TwentyFive]) + self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.TwentyFive]) \ No newline at end of file diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 0de20d8a9..42b773198 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -354,9 +354,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): Called when html copy check box is selected. """ if value == QtCore.Qt.Checked: - self.copyTextButton.setText(UiStrings.CopyToHtml) + self.copyTextButton.setText(UiStrings().CopyToHtml) else: - self.copyTextButton.setText(UiStrings.CopyToText) + self.copyTextButton.setText(UiStrings().CopyToText) def onSlideTextCheckBoxChanged(self, state): """ @@ -380,4 +380,4 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): QtCore.QVariant(self.metaDataCheckBox.isChecked())) settings.setValue(u'print notes', QtCore.QVariant(self.notesCheckBox.isChecked())) - settings.endGroup() + settings.endGroup() \ No newline at end of file diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ba9ca718a..d682f5b52 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -111,18 +111,18 @@ class ServiceManager(QtGui.QWidget): # Create the top toolbar self.toolbar = OpenLPToolbar(self) self.toolbar.addToolbarButton( - UiStrings.NewService, u':/general/general_new.png', - UiStrings.CreateService, self.onNewServiceClicked) + UiStrings().NewService, u':/general/general_new.png', + UiStrings().CreateService, self.onNewServiceClicked) self.toolbar.addToolbarButton( - UiStrings.OpenService, u':/general/general_open.png', + 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', + UiStrings().SaveService, u':/general/general_save.png', translate('OpenLP.ServiceManager', 'Save this service'), self.saveFile) self.toolbar.addSeparator() - self.themeLabel = QtGui.QLabel(u'%s:' % UiStrings.Theme, self) + 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) @@ -169,9 +169,9 @@ class ServiceManager(QtGui.QWidget): self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home]) self.serviceManagerList.moveTop.setObjectName(u'moveTop') action_list = ActionList.get_instance() - action_list.add_category(UiStrings.Service, CategoryOrder.standardToolbar) + action_list.add_category(UiStrings().Service, CategoryOrder.standardToolbar) action_list.add_action( - self.serviceManagerList.moveTop, UiStrings.Service) + self.serviceManagerList.moveTop, UiStrings().Service) self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &up'), u':/services/service_up.png', @@ -179,7 +179,7 @@ class ServiceManager(QtGui.QWidget): '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, UiStrings.Service) + action_list.add_action(self.serviceManagerList.moveUp, UiStrings().Service) self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &down'), u':/services/service_down.png', @@ -188,7 +188,7 @@ class ServiceManager(QtGui.QWidget): self.onServiceDown, shortcuts=[QtCore.Qt.Key_PageDown]) self.serviceManagerList.moveDown.setObjectName(u'moveDown') action_list.add_action( - self.serviceManagerList.moveDown, UiStrings.Service) + self.serviceManagerList.moveDown, UiStrings().Service) self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move to &bottom'), u':/services/service_bottom.png', @@ -197,7 +197,7 @@ class ServiceManager(QtGui.QWidget): self.onServiceEnd, shortcuts=[QtCore.Qt.Key_End]) self.serviceManagerList.moveBottom.setObjectName(u'moveBottom') action_list.add_action( - self.serviceManagerList.moveBottom, UiStrings.Service) + self.serviceManagerList.moveBottom, UiStrings().Service) self.serviceManagerList.down = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &down'), None, @@ -231,7 +231,7 @@ class ServiceManager(QtGui.QWidget): '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, UiStrings.Service) + action_list.add_action(self.serviceManagerList.expand, UiStrings().Service) self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', '&Collapse all'), u':/services/service_collapse_all.png', @@ -240,7 +240,7 @@ class ServiceManager(QtGui.QWidget): self.onCollapseAll, shortcuts=[QtCore.Qt.Key_Minus]) self.serviceManagerList.collapse.setObjectName(u'collapse') action_list.add_action( - self.serviceManagerList.collapse, UiStrings.Service) + self.serviceManagerList.collapse, UiStrings().Service) self.orderToolbar.addSeparator() self.serviceManagerList.makeLive = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Go Live'), @@ -250,7 +250,7 @@ class ServiceManager(QtGui.QWidget): shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]) self.serviceManagerList.makeLive.setObjectName(u'orderToolbar') action_list.add_action( - self.serviceManagerList.makeLive, UiStrings.Service) + self.serviceManagerList.makeLive, UiStrings().Service) self.layout.addWidget(self.orderToolbar) # Connect up our signals and slots QtCore.QObject.connect(self.themeComboBox, @@ -525,7 +525,7 @@ class ServiceManager(QtGui.QWidget): save the file. """ fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow, - UiStrings.SaveService, + UiStrings().SaveService, SettingsManager.get_last_dir( self.mainwindow.serviceSettingsSection), translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)'))) @@ -1311,4 +1311,4 @@ class ServiceManager(QtGui.QWidget): Print a Service Order Sheet. """ settingDialog = PrintServiceForm(self.mainwindow, self) - settingDialog.exec_() + settingDialog.exec_() \ No newline at end of file diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 2ae39c5e7..5f2c63c23 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -88,11 +88,11 @@ class SlideController(QtGui.QWidget): # Type label for the top of the slide controller self.typeLabel = QtGui.QLabel(self.panel) if self.isLive: - self.typeLabel.setText(UiStrings.Live) + self.typeLabel.setText(UiStrings().Live) self.split = 1 self.typePrefix = u'live' else: - self.typeLabel.setText(UiStrings.Preview) + self.typeLabel.setText(UiStrings().Preview) self.split = 0 self.typePrefix = u'preview' self.typeLabel.setStyleSheet(u'font-weight: bold; font-size: 12pt;') @@ -161,18 +161,18 @@ class SlideController(QtGui.QWidget): 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, UiStrings.LiveToolbar) + u':/slides/slide_blank.png', False, 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, UiStrings.LiveToolbar) + u':/slides/slide_theme.png', False, 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, - UiStrings.LiveToolbar) + UiStrings().LiveToolbar) self.desktopScreen.setText( translate('OpenLP.SlideController', 'Show Desktop')) self.hideMenu.setDefaultAction(self.blankScreen) @@ -194,7 +194,7 @@ class SlideController(QtGui.QWidget): self.delaySpinBox.setMinimum(1) self.delaySpinBox.setMaximum(180) self.toolbar.addToolbarWidget(u'Image SpinBox', self.delaySpinBox) - self.delaySpinBox.setSuffix(UiStrings.Seconds) + self.delaySpinBox.setSuffix(UiStrings().Seconds) self.delaySpinBox.setToolTip(translate('OpenLP.SlideController', 'Delay between slides in seconds')) else: @@ -376,21 +376,21 @@ class SlideController(QtGui.QWidget): self.nextItem.setObjectName(u'nextItemLive') action_list = ActionList.get_instance() action_list.add_category( - UiStrings.LiveToolbar, CategoryOrder.standardToolbar) + 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, UiStrings.LiveToolbar) + [QtCore.Qt.Key_Left], self.servicePrevious, UiStrings().LiveToolbar) self.previousService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.previousService.setText( translate('OpenLP.SlideController', 'Previous Service')) self.nextService = shortcut_action(parent, 'nextService', - [QtCore.Qt.Key_Right], self.serviceNext, UiStrings.LiveToolbar) + [QtCore.Qt.Key_Right], self.serviceNext, UiStrings().LiveToolbar) self.nextService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.nextService.setText( translate('OpenLP.SlideController', 'Next Service')) self.escapeItem = shortcut_action(parent, 'escapeItem', - [QtCore.Qt.Key_Escape], self.liveEscape, UiStrings.LiveToolbar) + [QtCore.Qt.Key_Escape], self.liveEscape, UiStrings().LiveToolbar) self.escapeItem.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) self.escapeItem.setText( translate('OpenLP.SlideController', 'Escape Item')) @@ -1150,4 +1150,4 @@ class SlideController(QtGui.QWidget): elif self.desktopScreen.isChecked(): return HideMode.Screen else: - return None + return None \ No newline at end of file diff --git a/openlp/core/ui/starttimedialog.py b/openlp/core/ui/starttimedialog.py index be34b765e..2d1711231 100644 --- a/openlp/core/ui/starttimedialog.py +++ b/openlp/core/ui/starttimedialog.py @@ -107,15 +107,15 @@ class Ui_StartTimeDialog(object): def retranslateUi(self, StartTimeDialog): self.setWindowTitle(translate('OpenLP.StartTimeForm', 'Item Start and Finish Time')) - self.hourSpinBox.setSuffix(UiStrings.Hours) - self.minuteSpinBox.setSuffix(UiStrings.Minutes) - self.secondSpinBox.setSuffix(UiStrings.Seconds) - self.hourFinishSpinBox.setSuffix(UiStrings.Hours) - self.minuteFinishSpinBox.setSuffix(UiStrings.Minutes) - self.secondFinishSpinBox.setSuffix(UiStrings.Seconds) + self.hourSpinBox.setSuffix(UiStrings().Hours) + self.minuteSpinBox.setSuffix(UiStrings().Minutes) + self.secondSpinBox.setSuffix(UiStrings().Seconds) + self.hourFinishSpinBox.setSuffix(UiStrings().Hours) + self.minuteFinishSpinBox.setSuffix(UiStrings().Minutes) + self.secondFinishSpinBox.setSuffix(UiStrings().Seconds) self.hourLabel.setText(translate('OpenLP.StartTimeForm', 'Hours:')) self.minuteLabel.setText(translate('OpenLP.StartTimeForm', 'Minutes:')) self.secondLabel.setText(translate('OpenLP.StartTimeForm', 'Seconds:')) self.startLabel.setText(translate('OpenLP.StartTimeForm', 'Start')) self.finishLabel.setText(translate('OpenLP.StartTimeForm', 'Finish')) - self.lengthLabel.setText(translate('OpenLP.StartTimeForm', 'Length')) + self.lengthLabel.setText(translate('OpenLP.StartTimeForm', 'Length')) \ No newline at end of file diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index a30dd3b8e..b460bbbd0 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -53,11 +53,11 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): self.hourFinishSpinBox.setValue(hours) self.minuteFinishSpinBox.setValue(minutes) self.secondFinishSpinBox.setValue(seconds) - self.hourFinishLabel.setText(u'%s%s' % (unicode(hour), UiStrings.Hours)) + self.hourFinishLabel.setText(u'%s%s' % (unicode(hour), UiStrings().Hours)) self.minuteFinishLabel.setText(u'%s%s' % - (unicode(minutes), UiStrings.Minutes)) + (unicode(minutes), UiStrings().Minutes)) self.secondFinishLabel.setText(u'%s%s' % - (unicode(seconds), UiStrings.Seconds)) + (unicode(seconds), UiStrings().Seconds)) return QtGui.QDialog.exec_(self) def accept(self): @@ -90,4 +90,4 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): seconds -= 3600 * hours minutes = seconds / 60 seconds -= 60 * minutes - return hours, minutes, seconds + return hours, minutes, seconds \ No newline at end of file diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 3a3b3bb61..ebba45e7c 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -290,7 +290,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): 'Edit Theme - %s')) % self.theme.theme_name) self.next() else: - self.setWindowTitle(UiStrings.NewTheme) + self.setWindowTitle(UiStrings().NewTheme) return QtGui.QWizard.exec_(self) def initializePage(self, id): @@ -473,7 +473,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ images_filter = get_images_filter() images_filter = u'%s;;%s (*.*) (*)' % ( - images_filter, UiStrings.AllFiles) + images_filter, UiStrings().AllFiles) filename = QtGui.QFileDialog.getOpenFileName(self, translate('OpenLP.ThemeForm', 'Select Image'), u'', images_filter) @@ -589,4 +589,4 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): QtGui.QColor(field), self) if new_color.isValid(): field = new_color.name() - return field + return field \ No newline at end of file diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 81da6e021..d2a653a26 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -63,7 +63,7 @@ class ThemeManager(QtGui.QWidget): self.layout.setMargin(0) self.layout.setObjectName(u'layout') self.toolbar = OpenLPToolbar(self) - self.toolbar.addToolbarButton(UiStrings.NewTheme, + self.toolbar.addToolbarButton(UiStrings().NewTheme, u':/themes/theme_new.png', translate('OpenLP.ThemeManager', 'Create a new theme.'), self.onAddTheme) @@ -449,7 +449,7 @@ class ThemeManager(QtGui.QWidget): # No themes have been found so create one if len(files) == 0: theme = ThemeXML() - theme.theme_name = UiStrings.Default + theme.theme_name = UiStrings().Default self._writeTheme(theme, None, None) QtCore.QSettings().setValue( self.settingsSection + u'/global theme', @@ -803,4 +803,4 @@ class ThemeManager(QtGui.QWidget): vAlignCorrection = VerticalType.Bottom newtheme.display_horizontal_align = theme.HorizontalAlign newtheme.display_vertical_align = vAlignCorrection - return newtheme.extract_xml() + return newtheme.extract_xml() \ No newline at end of file diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 372ee0cc8..fccef1244 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -102,7 +102,7 @@ class ThemesTab(SettingsTab): QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) def retranslateUi(self): - self.tabTitleVisible = UiStrings.Themes + self.tabTitleVisible = UiStrings().Themes self.GlobalGroupBox.setTitle( translate('OpenLP.ThemesTab', 'Global Theme')) self.LevelGroupBox.setTitle( @@ -203,4 +203,4 @@ class ThemesTab(SettingsTab): if not preview.isNull(): preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) - self.DefaultListView.setPixmap(preview) + self.DefaultListView.setPixmap(preview) \ No newline at end of file diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 9e464aa7a..759b36101 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -424,7 +424,7 @@ class Ui_ThemeWizard(object): self.backgroundComboBox.setItemText(BackgroundType.Gradient, translate('OpenLP.ThemeWizard', 'Gradient')) self.backgroundComboBox.setItemText( - BackgroundType.Image, UiStrings.Image) + BackgroundType.Image, UiStrings().Image) self.colorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:')) self.gradientStartLabel.setText( translate(u'OpenLP.ThemeWizard', 'Starting color:')) @@ -442,7 +442,7 @@ class Ui_ThemeWizard(object): translate('OpenLP.ThemeWizard', 'Top Left - Bottom Right')) self.gradientComboBox.setItemText(BackgroundGradientType.LeftBottom, translate('OpenLP.ThemeWizard', 'Bottom Left - Top Right')) - self.imageLabel.setText(u'%s:' % UiStrings.Image) + self.imageLabel.setText(u'%s:' % UiStrings().Image) self.mainAreaPage.setTitle( translate('OpenLP.ThemeWizard', 'Main Area Font Details')) self.mainAreaPage.setSubTitle( @@ -451,17 +451,17 @@ class Ui_ThemeWizard(object): self.mainFontLabel.setText(translate('OpenLP.ThemeWizard', 'Font:')) self.mainColorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:')) self.mainSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:')) - self.mainSizeSpinBox.setSuffix(UiStrings.FontSizePtUnit) + self.mainSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit) self.lineSpacingLabel.setText( translate('OpenLP.ThemeWizard', 'Line Spacing:')) - self.lineSpacingSpinBox.setSuffix(UiStrings.FontSizePtUnit) + self.lineSpacingSpinBox.setSuffix(UiStrings().FontSizePtUnit) self.outlineCheckBox.setText( translate('OpenLP.ThemeWizard', '&Outline:')) self.outlineSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:')) - self.outlineSizeSpinBox.setSuffix(UiStrings.FontSizePtUnit) + self.outlineSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit) self.shadowCheckBox.setText(translate('OpenLP.ThemeWizard', '&Shadow:')) self.shadowSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:')) - self.shadowSizeSpinBox.setSuffix(UiStrings.FontSizePtUnit) + self.shadowSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit) self.mainBoldCheckBox.setText(translate('OpenLP.ThemeWizard', 'Bold')) self.mainItalicsCheckBox.setText( translate('OpenLP.ThemeWizard', 'Italic')) @@ -473,7 +473,7 @@ class Ui_ThemeWizard(object): self.footerFontLabel.setText(translate('OpenLP.ThemeWizard', 'Font:')) self.footerColorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:')) self.footerSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:')) - self.footerSizeSpinBox.setSuffix(UiStrings.FontSizePtUnit) + self.footerSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit) self.alignmentPage.setTitle( translate('OpenLP.ThemeWizard', 'Text Formatting Details')) self.alignmentPage.setSubTitle( @@ -537,4 +537,4 @@ class Ui_ThemeWizard(object): labelWidth = max(self.backgroundLabel.minimumSizeHint().width(), self.horizontalLabel.minimumSizeHint().width()) self.spacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) \ No newline at end of file diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index cb3a75294..74ca0715a 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -212,11 +212,11 @@ class OpenLPWizard(QtGui.QWizard): """ if filters: filters += u';;' - filters += u'%s (*)' % UiStrings.AllFiles + filters += u'%s (*)' % UiStrings().AllFiles filename = QtGui.QFileDialog.getOpenFileName(self, title, os.path.dirname(SettingsManager.get_last_dir( self.plugin.settingsSection, 1)), filters) if filename: editbox.setText(filename) SettingsManager.set_last_dir(self.plugin.settingsSection, - filename, 1) + filename, 1) \ No newline at end of file diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index c5714c914..0cfa9c60a 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -77,7 +77,7 @@ class AlertsPlugin(Plugin): Plugin.initialise(self) self.toolsAlertItem.setVisible(True) action_list = ActionList.get_instance() - action_list.add_action(self.toolsAlertItem, UiStrings.Tools) + action_list.add_action(self.toolsAlertItem, UiStrings().Tools) self.liveController.alertTab = self.settings_tab def finalise(self): @@ -118,4 +118,4 @@ class AlertsPlugin(Plugin): ## Name for MediaDockManager, SettingsManager ## self.textStrings[StringContent.VisibleName] = { u'title': translate('AlertsPlugin', 'Alerts', 'container title') - } + } \ No newline at end of file diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 3b6c50a10..2ec2be24b 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -109,12 +109,12 @@ class AlertsTab(SettingsTab): translate('AlertsPlugin.AlertsTab', 'Background color:')) self.FontSizeLabel.setText( translate('AlertsPlugin.AlertsTab', 'Font size:')) - self.FontSizeSpinBox.setSuffix(UiStrings.FontSizePtUnit) + self.FontSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit) self.TimeoutLabel.setText( translate('AlertsPlugin.AlertsTab', 'Alert timeout:')) - self.TimeoutSpinBox.setSuffix(UiStrings.Seconds) - self.PreviewGroupBox.setTitle(UiStrings.Preview) - self.FontPreview.setText(UiStrings.OLPV2) + self.TimeoutSpinBox.setSuffix(UiStrings().Seconds) + self.PreviewGroupBox.setTitle(UiStrings().Preview) + self.FontPreview.setText(UiStrings().OLPV2) def onBackgroundColorButtonClicked(self): new_color = QtGui.QColorDialog.getColor( @@ -191,4 +191,4 @@ class AlertsTab(SettingsTab): font.setPointSize(self.font_size) self.FontPreview.setFont(font) self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' % - (self.bg_color, self.font_color)) + (self.bg_color, self.font_color)) \ No newline at end of file diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index aea732688..5a631bf00 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -53,9 +53,9 @@ class BiblePlugin(Plugin): Plugin.initialise(self) self.importBibleItem.setVisible(True) action_list = ActionList.get_instance() - action_list.add_action(self.importBibleItem, UiStrings.Import) + action_list.add_action(self.importBibleItem, UiStrings().Import) # Do not add the action to the list yet. - #action_list.add_action(self.exportBibleItem, UiStrings.Export) + #action_list.add_action(self.exportBibleItem, UiStrings().Export) # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) @@ -67,9 +67,9 @@ class BiblePlugin(Plugin): self.manager.finalise() Plugin.finalise(self) action_list = ActionList.get_instance() - action_list.remove_action(self.importBibleItem, UiStrings.Import) + action_list.remove_action(self.importBibleItem, UiStrings().Import) self.importBibleItem.setVisible(False) - #action_list.remove_action(self.exportBibleItem, UiStrings.Export) + #action_list.remove_action(self.exportBibleItem, UiStrings().Export) self.exportBibleItem.setVisible(False) def addImportMenuItem(self, import_menu): @@ -146,4 +146,4 @@ class BiblePlugin(Plugin): u'service': translate('BiblesPlugin', 'Add the selected Bible to the service') } - self.setPluginUiTextStrings(tooltips) + self.setPluginUiTextStrings(tooltips) \ No newline at end of file diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 35cd17c4b..439724b66 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -377,7 +377,7 @@ class BibleImportForm(OpenLPWizard): self.formatComboBox.setItemText(BibleFormat.OpenSong, WizardStrings.OS) self.formatComboBox.setItemText(BibleFormat.WebDownload, translate('BiblesPlugin.ImportWizardForm', 'Web Download')) - self.formatComboBox.setItemText(BibleFormat.OpenLP1, UiStrings.OLPV1) + self.formatComboBox.setItemText(BibleFormat.OpenLP1, UiStrings().OLPV1) self.openlp1FileLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) self.osisFileLabel.setText( @@ -451,13 +451,13 @@ class BibleImportForm(OpenLPWizard): elif self.currentPage() == self.selectPage: if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS: if not self.field(u'osis_location').toString(): - critical_error_message_box(UiStrings.NFSs, + critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OSIS) self.osisFileEdit.setFocus() return False elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: if not self.field(u'csv_testamentsfile').toString(): - answer = critical_error_message_box(UiStrings.NFSs, + answer = critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', 'You have not specified a testaments file. Do you ' 'want to proceed with the import?'), question=True) @@ -465,14 +465,14 @@ class BibleImportForm(OpenLPWizard): self.csvTestamentsEdit.setFocus() return False if not self.field(u'csv_booksfile').toString(): - critical_error_message_box(UiStrings.NFSs, + critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file with books of ' 'the Bible to use in the import.')) self.csvBooksEdit.setFocus() return False elif not self.field(u'csv_versefile').toString(): - critical_error_message_box(UiStrings.NFSs, + critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file of Bible ' 'verses to import.')) @@ -481,14 +481,14 @@ class BibleImportForm(OpenLPWizard): elif self.field(u'source_format').toInt()[0] == \ BibleFormat.OpenSong: if not self.field(u'opensong_file').toString(): - critical_error_message_box(UiStrings.NFSs, + critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OS) self.openSongFileEdit.setFocus() return False elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenLP1: if not self.field(u'openlp1_location').toString(): - critical_error_message_box(UiStrings.NFSs, - WizardStrings.YouSpecifyFile % UiStrings.OLPV1) + critical_error_message_box(UiStrings().NFSs, + WizardStrings.YouSpecifyFile % UiStrings().OLPV1) self.openlp1FileEdit.setFocus() return False return True @@ -497,13 +497,13 @@ class BibleImportForm(OpenLPWizard): license_copyright = \ unicode(self.field(u'license_copyright').toString()) if not license_version: - critical_error_message_box(UiStrings.EmptyField, + critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a version name for your Bible.')) self.versionNameEdit.setFocus() return False elif not license_copyright: - critical_error_message_box(UiStrings.EmptyField, + critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.ImportWizardForm', 'You need to set a copyright for your Bible. ' 'Bibles in the Public Domain need to be marked as such.')) @@ -576,7 +576,7 @@ class BibleImportForm(OpenLPWizard): """ Show the file open dialog for the openlp.org 1.x file. """ - self.getFileName(WizardStrings.OpenTypeFile % UiStrings.OLPV1, + self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV1, self.openlp1FileEdit, u'%s (*.bible)' % translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x Bible Files')) @@ -765,4 +765,4 @@ class BibleImportForm(OpenLPWizard): self.progressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.')) del self.manager.db_cache[importer.name] - delete_database(self.plugin.settingsSection, importer.file) + delete_database(self.plugin.settingsSection, importer.file) \ No newline at end of file diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index b013c402a..33c2c1f9f 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -118,16 +118,16 @@ class BiblesTab(SettingsTab): self.newChaptersCheckBox.setText( translate('BiblesPlugin.BiblesTab', 'Only show new chapter numbers')) - self.layoutStyleLabel.setText(UiStrings.LayoutStyle) - self.displayStyleLabel.setText(UiStrings.DisplayStyle) + self.layoutStyleLabel.setText(UiStrings().LayoutStyle) + self.displayStyleLabel.setText(UiStrings().DisplayStyle) self.bibleThemeLabel.setText( translate('BiblesPlugin.BiblesTab', 'Bible theme:')) self.layoutStyleComboBox.setItemText(LayoutStyle.VersePerSlide, - UiStrings.VersePerSlide) + UiStrings().VersePerSlide) self.layoutStyleComboBox.setItemText(LayoutStyle.VersePerLine, - UiStrings.VersePerLine) + UiStrings().VersePerLine) self.layoutStyleComboBox.setItemText(LayoutStyle.Continuous, - UiStrings.Continuous) + UiStrings().Continuous) self.displayStyleComboBox.setItemText(DisplayStyle.NoBrackets, translate('BiblesPlugin.BiblesTab', 'No Brackets')) self.displayStyleComboBox.setItemText(DisplayStyle.Round, @@ -207,4 +207,4 @@ class BiblesTab(SettingsTab): self.bibleThemeComboBox.addItem(u'') for theme in theme_list: self.bibleThemeComboBox.addItem(theme) - find_and_set_in_combo_box(self.bibleThemeComboBox, self.bible_theme) + find_and_set_in_combo_box(self.bibleThemeComboBox, self.bible_theme) \ No newline at end of file diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index bb72b9ff2..e0e06b02f 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -193,7 +193,7 @@ class BibleMediaItem(MediaManagerItem): self.advancedSearchButtonLayout.addWidget(self.advancedSearchButton) self.advancedLayout.addLayout( self.advancedSearchButtonLayout, 7, 0, 1, 3) - self.searchTabWidget.addTab(self.advancedTab, UiStrings.Advanced) + self.searchTabWidget.addTab(self.advancedTab, UiStrings().Advanced) # Add the search tab widget to the page layout. self.pageLayout.addWidget(self.searchTabWidget) # Combo Boxes @@ -242,15 +242,15 @@ class BibleMediaItem(MediaManagerItem): def retranslateUi(self): log.debug(u'retranslateUi') - self.quickVersionLabel.setText(u'%s:' % UiStrings.Version) + self.quickVersionLabel.setText(u'%s:' % UiStrings().Version) self.quickSecondLabel.setText( translate('BiblesPlugin.MediaItem', 'Second:')) self.quickSearchLabel.setText( translate('BiblesPlugin.MediaItem', 'Find:')) - self.quickSearchButton.setText(UiStrings.Search) + self.quickSearchButton.setText(UiStrings().Search) self.quickClearLabel.setText( translate('BiblesPlugin.MediaItem', 'Results:')) - self.advancedVersionLabel.setText(u'%s:' % UiStrings.Version) + self.advancedVersionLabel.setText(u'%s:' % UiStrings().Version) self.advancedSecondLabel.setText( translate('BiblesPlugin.MediaItem', 'Second:')) self.advancedBookLabel.setText( @@ -265,7 +265,7 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'To:')) self.advancedClearLabel.setText( translate('BiblesPlugin.MediaItem', 'Results:')) - self.advancedSearchButton.setText(UiStrings.Search) + self.advancedSearchButton.setText(UiStrings().Search) self.quickClearComboBox.addItem( translate('BiblesPlugin.MediaItem', 'Clear')) self.quickClearComboBox.addItem( @@ -274,13 +274,13 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'Clear')) self.advancedClearComboBox.addItem( translate('BiblesPlugin.MediaItem', 'Keep')) - self.quickLayoutLabel.setText(UiStrings.LayoutStyle) + self.quickLayoutLabel.setText(UiStrings().LayoutStyle) self.quickLayoutComboBox.setItemText(LayoutStyle.VersePerSlide, - UiStrings.VersePerSlide) + UiStrings().VersePerSlide) self.quickLayoutComboBox.setItemText(LayoutStyle.VersePerLine, - UiStrings.VersePerLine) + UiStrings().VersePerLine) self.quickLayoutComboBox.setItemText(LayoutStyle.Continuous, - UiStrings.Continuous) + UiStrings().Continuous) def initialise(self): log.debug(u'bible manager initialise') @@ -849,4 +849,4 @@ class BibleMediaItem(MediaManagerItem): self.settings.layout_style) QtCore.QSettings().setValue( self.settingsSection + u'/verse layout style', - QtCore.QVariant(self.settings.layout_style)) + QtCore.QVariant(self.settings.layout_style)) \ No newline at end of file diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 1ea0413ff..7a6c1f07b 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -107,11 +107,11 @@ class Ui_CustomEditDialog(object): translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides')) self.titleLabel.setText( translate('CustomPlugin.EditCustomForm', '&Title:')) - self.addButton.setText(UiStrings.Add) + self.addButton.setText(UiStrings().Add) self.addButton.setToolTip( translate('CustomPlugin.EditCustomForm', 'Add a new slide at ' 'bottom.')) - self.editButton.setText(UiStrings.Edit) + self.editButton.setText(UiStrings().Edit) self.editButton.setToolTip( translate('CustomPlugin.EditCustomForm', 'Edit the selected ' 'slide.')) @@ -124,4 +124,4 @@ class Ui_CustomEditDialog(object): translate('CustomPlugin.EditCustomForm', 'The&me:')) self.creditLabel.setText( translate('CustomPlugin.EditCustomForm', '&Credits:')) - self.previewButton.setText(UiStrings.SaveAndPreview) + self.previewButton.setText(UiStrings().SaveAndPreview) \ No newline at end of file diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index b045c58a4..b508104c4 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -110,7 +110,7 @@ class CustomMediaItem(MediaManagerItem): """ Edit a custom item """ - if check_item_selected(self.listView, UiStrings.SelectEdit): + if check_item_selected(self.listView, UiStrings().SelectEdit): item = self.listView.currentItem() item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] self.parent.edit_custom_form.loadCustom(item_id, False) @@ -121,7 +121,7 @@ class CustomMediaItem(MediaManagerItem): """ Remove a custom item from the list and database """ - if check_item_selected(self.listView, UiStrings.SelectDelete): + if check_item_selected(self.listView, UiStrings().SelectDelete): row_list = [item.row() for item in self.listView.selectedIndexes()] row_list.sort(reverse=True) id_list = [(item.data(QtCore.Qt.UserRole)).toInt()[0] @@ -160,4 +160,4 @@ class CustomMediaItem(MediaManagerItem): else: raw_footer.append(u'') service_item.raw_footer = raw_footer - return True + return True \ No newline at end of file diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index c29adc3b1..298e701e3 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -55,11 +55,11 @@ class ImageMediaItem(MediaManagerItem): 'Select Image(s)') file_formats = get_images_filter() self.onNewFileMasks = u'%s;;%s (*.*) (*)' % (file_formats, - UiStrings.AllFiles) - self.replaceAction.setText(UiStrings.ReplaceBG) - self.replaceAction.setToolTip(UiStrings.ReplaceLiveBG) - self.resetAction.setText(UiStrings.ResetBG) - self.resetAction.setToolTip(UiStrings.ResetLiveBG) + UiStrings().AllFiles) + self.replaceAction.setText(UiStrings().ReplaceBG) + self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG) + self.resetAction.setText(UiStrings().ResetBG) + self.resetAction.setToolTip(UiStrings().ResetLiveBG) def requiredIcons(self): MediaManagerItem.requiredIcons(self) @@ -198,7 +198,7 @@ class ImageMediaItem(MediaManagerItem): self.parent.liveController.display.directImage(name, filename) self.resetAction.setVisible(True) else: - critical_error_message_box(UiStrings.LiveBGError, + critical_error_message_box(UiStrings().LiveBGError, unicode(translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, ' - 'the image file "%s" no longer exists.')) % filename) + 'the image file "%s" no longer exists.')) % filename) \ No newline at end of file diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 7612ab7c9..559af11e2 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -60,11 +60,11 @@ class MediaMediaItem(MediaManagerItem): self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem', 'Videos (%s);;Audio (%s);;%s (*)')) % ( u' '.join(self.parent.video_extensions_list), - u' '.join(self.parent.audio_extensions_list), UiStrings.AllFiles) - self.replaceAction.setText(UiStrings.ReplaceBG) - self.replaceAction.setToolTip(UiStrings.ReplaceLiveBG) - self.resetAction.setText(UiStrings.ResetBG) - self.resetAction.setToolTip(UiStrings.ResetLiveBG) + u' '.join(self.parent.audio_extensions_list), UiStrings().AllFiles) + self.replaceAction.setText(UiStrings().ReplaceBG) + self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG) + self.resetAction.setText(UiStrings().ResetBG) + self.resetAction.setToolTip(UiStrings().ResetLiveBG) def requiredIcons(self): MediaManagerItem.requiredIcons(self) @@ -111,7 +111,7 @@ class MediaMediaItem(MediaManagerItem): self.parent.liveController.display.video(filename, 0, True) self.resetAction.setVisible(True) else: - critical_error_message_box(UiStrings.LiveBGError, + critical_error_message_box(UiStrings().LiveBGError, unicode(translate('MediaPlugin.MediaItem', 'There was a problem replacing your background, ' 'the media file "%s" no longer exists.')) % filename) @@ -209,4 +209,4 @@ class MediaMediaItem(MediaManagerItem): img = QtGui.QPixmap(u':/media/media_video.png').toImage() item_name.setIcon(build_icon(img)) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) - self.listView.addItem(item_name) + self.listView.addItem(item_name) \ No newline at end of file diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 6009ff906..74ff3fea8 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -203,7 +203,7 @@ class PresentationMediaItem(MediaManagerItem): """ Remove a presentation item from the list """ - if check_item_selected(self.listView, UiStrings.SelectDelete): + if check_item_selected(self.listView, UiStrings().SelectDelete): items = self.listView.selectedIndexes() row_list = [item.row() for item in items] row_list.sort(reverse=True) @@ -296,4 +296,4 @@ class PresentationMediaItem(MediaManagerItem): if self.controllers[controller].enabled(): if filetype in self.controllers[controller].alsosupports: return controller - return None + return None \ No newline at end of file diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 8e3a98031..bba2b469e 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -86,7 +86,7 @@ class PresentationTab(SettingsTab): checkbox.setText( unicode(translate('PresentationPlugin.PresentationTab', '%s (unavailable)')) % controller.name) - self.AdvancedGroupBox.setTitle(UiStrings.Advanced) + self.AdvancedGroupBox.setTitle(UiStrings().Advanced) self.OverrideAppCheckBox.setText( translate('PresentationPlugin.PresentationTab', 'Allow presentation application to be overriden')) @@ -131,4 +131,4 @@ class PresentationTab(SettingsTab): QtCore.QVariant(self.OverrideAppCheckBox.checkState())) changed = True if changed: - Receiver.send_message(u'mediaitem_presentation_rebuild') + Receiver.send_message(u'mediaitem_presentation_rebuild') \ No newline at end of file diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index a9bd132cd..749d5184d 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -260,11 +260,11 @@ class Ui_EditSongDialog(object): translate('SongsPlugin.EditSongForm', '&Lyrics:')) self.verseOrderLabel.setText( translate('SongsPlugin.EditSongForm', '&Verse order:')) - self.verseAddButton.setText(UiStrings.Add) - self.verseEditButton.setText(UiStrings.Edit) + self.verseAddButton.setText(UiStrings().Add) + self.verseEditButton.setText(UiStrings().Edit) self.verseEditAllButton.setText( translate('SongsPlugin.EditSongForm', 'Ed&it All')) - self.verseDeleteButton.setText(UiStrings.Delete) + self.verseDeleteButton.setText(UiStrings().Delete) self.songTabWidget.setTabText( self.songTabWidget.indexOf(self.lyricsTab), translate('SongsPlugin.EditSongForm', 'Title && Lyrics')) @@ -289,13 +289,13 @@ class Ui_EditSongDialog(object): self.songTabWidget.indexOf(self.authorsTab), translate('SongsPlugin.EditSongForm', 'Authors, Topics && Song Book')) - self.themeGroupBox.setTitle(UiStrings.Theme) + self.themeGroupBox.setTitle(UiStrings().Theme) self.themeAddButton.setText( translate('SongsPlugin.EditSongForm', 'New &Theme')) self.rightsGroupBox.setTitle( translate('SongsPlugin.EditSongForm', 'Copyright Information')) self.copyrightInsertButton.setText(SongStrings.CopyrightSymbol) - self.CCLILabel.setText(UiStrings.CCLINumberLabel) + self.CCLILabel.setText(UiStrings().CCLINumberLabel) self.commentsGroupBox.setTitle( translate('SongsPlugin.EditSongForm', 'Comments')) self.songTabWidget.setTabText( @@ -313,4 +313,4 @@ def editSongDialogComboBox(parent, name): comboBox.setEditable(True) comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) comboBox.setObjectName(name) - return comboBox + return comboBox \ No newline at end of file diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 85294d92b..0b9c9316f 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -96,7 +96,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) self.previewButton = QtGui.QPushButton() self.previewButton.setObjectName(u'previewButton') - self.previewButton.setText(UiStrings.SaveAndPreview) + self.previewButton.setText(UiStrings().SaveAndPreview) self.buttonBox.addButton( self.previewButton, QtGui.QDialogButtonBox.ActionRole) QtCore.QObject.connect(self.buttonBox, @@ -355,7 +355,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.__addAuthorToList(author) self.authorsComboBox.setCurrentIndex(0) else: - QtGui.QMessageBox.warning(self, UiStrings.NISs, + QtGui.QMessageBox.warning(self, UiStrings().NISs, translate('SongsPlugin.EditSongForm', 'You have not selected ' 'a valid author. Either select an author from the list, ' 'or type in a new author and click the "Add Author to ' @@ -414,7 +414,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.topicsListView.addItem(topic_item) self.topicsComboBox.setCurrentIndex(0) else: - QtGui.QMessageBox.warning(self, UiStrings.NISs, + QtGui.QMessageBox.warning(self, UiStrings().NISs, translate('SongsPlugin.EditSongForm', 'You have not selected ' 'a valid topic. Either select a topic from the list, or ' 'type in a new topic and click the "Add Topic to Song" ' diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index d71321b98..745ee3f67 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -175,7 +175,7 @@ class SongExportForm(OpenLPWizard): self.availableSongsPage.setSubTitle( translate('SongsPlugin.ExportWizardForm', 'Check the songs you want to export.')) - self.searchLabel.setText(u'%s:' % UiStrings.Search) + self.searchLabel.setText(u'%s:' % UiStrings().Search) self.uncheckButton.setText( translate('SongsPlugin.ExportWizardForm', 'Uncheck All')) self.checkButton.setText( @@ -207,7 +207,7 @@ class SongExportForm(OpenLPWizard): self.availableListWidget) if item.checkState() ] if not items: - critical_error_message_box(UiStrings.NISp, + critical_error_message_box(UiStrings().NISp, translate('SongsPlugin.ExportWizardForm', 'You need to add at least one Song to export.')) return False @@ -360,4 +360,4 @@ class SongExportForm(OpenLPWizard): SettingsManager.get_last_dir(self.plugin.settingsSection, 1), options=QtGui.QFileDialog.ShowDirsOnly)) SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1) - self.directoryLineEdit.setText(path) + self.directoryLineEdit.setText(path) \ No newline at end of file diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 468d2f341..dde8826e0 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -235,8 +235,8 @@ class SongImportForm(OpenLPWizard): self.sourcePage.setTitle(WizardStrings.ImportSelect) self.sourcePage.setSubTitle(WizardStrings.ImportSelectLong) self.formatLabel.setText(WizardStrings.FormatLabel) - self.formatComboBox.setItemText(SongFormat.OpenLP2, UiStrings.OLPV2) - self.formatComboBox.setItemText(SongFormat.OpenLP1, UiStrings.OLPV1) + self.formatComboBox.setItemText(SongFormat.OpenLP2, UiStrings().OLPV2) + self.formatComboBox.setItemText(SongFormat.OpenLP1, UiStrings().OLPV1) self.formatComboBox.setItemText( SongFormat.OpenLyrics, WizardStrings.OL) self.formatComboBox.setItemText(SongFormat.OpenSong, WizardStrings.OS) @@ -261,10 +261,10 @@ class SongImportForm(OpenLPWizard): # self.formatComboBox.setItemText(SongFormat.CSV, WizardStrings.CSV) self.openLP2FilenameLabel.setText( translate('SongsPlugin.ImportWizardForm', 'Filename:')) - self.openLP2BrowseButton.setText(UiStrings.Browse) + self.openLP2BrowseButton.setText(UiStrings().Browse) self.openLP1FilenameLabel.setText( translate('SongsPlugin.ImportWizardForm', 'Filename:')) - self.openLP1BrowseButton.setText(UiStrings.Browse) + self.openLP1BrowseButton.setText(UiStrings().Browse) self.openLP1DisabledLabel.setText(WizardStrings.NoSqlite) self.openLyricsAddButton.setText( translate('SongsPlugin.ImportWizardForm', 'Add Files...')) @@ -305,10 +305,10 @@ class SongImportForm(OpenLPWizard): 'find OpenOffice.org on your computer.')) self.easiSlidesFilenameLabel.setText( translate('SongsPlugin.ImportWizardForm', 'Filename:')) - self.easiSlidesBrowseButton.setText(UiStrings.Browse) + self.easiSlidesBrowseButton.setText(UiStrings().Browse) self.ewFilenameLabel.setText( translate('SongsPlugin.ImportWizardForm', 'Filename:')) - self.ewBrowseButton.setText(UiStrings.Browse) + self.ewBrowseButton.setText(UiStrings().Browse) self.songBeamerAddButton.setText( translate('SongsPlugin.ImportWizardForm', 'Add Files...')) self.songBeamerRemoveButton.setText( @@ -323,7 +323,7 @@ class SongImportForm(OpenLPWizard): translate('SongsPlugin.ImportWizardForm', 'Remove File(s)')) # self.csvFilenameLabel.setText( # translate('SongsPlugin.ImportWizardForm', 'Filename:')) -# self.csvBrowseButton.setText(UiStrings.Browse) +# self.csvBrowseButton.setText(UiStrings().Browse) self.progressPage.setTitle(WizardStrings.Importing) self.progressPage.setSubTitle( translate('SongsPlugin.ImportWizardForm', @@ -346,49 +346,49 @@ class SongImportForm(OpenLPWizard): source_format = self.formatComboBox.currentIndex() if source_format == SongFormat.OpenLP2: if self.openLP2FilenameEdit.text().isEmpty(): - critical_error_message_box(UiStrings.NFSs, - WizardStrings.YouSpecifyFile % UiStrings.OLPV2) + critical_error_message_box(UiStrings().NFSs, + WizardStrings.YouSpecifyFile % UiStrings().OLPV2) self.openLP2BrowseButton.setFocus() return False elif source_format == SongFormat.OpenLP1: if self.openLP1FilenameEdit.text().isEmpty(): - critical_error_message_box(UiStrings.NFSs, - WizardStrings.YouSpecifyFile % UiStrings.OLPV1) + critical_error_message_box(UiStrings().NFSs, + WizardStrings.YouSpecifyFile % UiStrings().OLPV1) self.openLP1BrowseButton.setFocus() return False elif source_format == SongFormat.OpenLyrics: if self.openLyricsFileListWidget.count() == 0: - critical_error_message_box(UiStrings.NFSp, + critical_error_message_box(UiStrings().NFSp, WizardStrings.YouSpecifyFile % WizardStrings.OL) self.openLyricsAddButton.setFocus() return False elif source_format == SongFormat.OpenSong: if self.openSongFileListWidget.count() == 0: - critical_error_message_box(UiStrings.NFSp, + critical_error_message_box(UiStrings().NFSp, WizardStrings.YouSpecifyFile % WizardStrings.OS) self.openSongAddButton.setFocus() return False elif source_format == SongFormat.WordsOfWorship: if self.wordsOfWorshipFileListWidget.count() == 0: - critical_error_message_box(UiStrings.NFSp, + critical_error_message_box(UiStrings().NFSp, WizardStrings.YouSpecifyFile % WizardStrings.WoW) self.wordsOfWorshipAddButton.setFocus() return False elif source_format == SongFormat.CCLI: if self.ccliFileListWidget.count() == 0: - critical_error_message_box(UiStrings.NFSp, + critical_error_message_box(UiStrings().NFSp, WizardStrings.YouSpecifyFile % WizardStrings.CCLI) self.ccliAddButton.setFocus() return False elif source_format == SongFormat.SongsOfFellowship: if self.songsOfFellowshipFileListWidget.count() == 0: - critical_error_message_box(UiStrings.NFSp, + critical_error_message_box(UiStrings().NFSp, WizardStrings.YouSpecifyFile % WizardStrings.SoF) self.songsOfFellowshipAddButton.setFocus() return False elif source_format == SongFormat.Generic: if self.genericFileListWidget.count() == 0: - critical_error_message_box(UiStrings.NFSp, + critical_error_message_box(UiStrings().NFSp, translate('SongsPlugin.ImportWizardForm', 'You need to specify at least one document or ' 'presentation file to import from.')) @@ -396,31 +396,31 @@ class SongImportForm(OpenLPWizard): return False elif source_format == SongFormat.EasiSlides: if self.easiSlidesFilenameEdit.text().isEmpty(): - critical_error_message_box(UiStrings.NFSp, + critical_error_message_box(UiStrings().NFSp, WizardStrings.YouSpecifyFile % WizardStrings.ES) self.easiSlidesBrowseButton.setFocus() return False elif source_format == SongFormat.EasyWorship: if self.ewFilenameEdit.text().isEmpty(): - critical_error_message_box(UiStrings.NFSs, + critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.EW) self.ewBrowseButton.setFocus() return False elif source_format == SongFormat.SongBeamer: if self.songBeamerFileListWidget.count() == 0: - critical_error_message_box(UiStrings.NFSp, + critical_error_message_box(UiStrings().NFSp, WizardStrings.YouSpecifyFile % WizardStrings.SB) self.songBeamerAddButton.setFocus() return False elif source_format == SongFormat.SongShowPlus: if self.songShowPlusFileListWidget.count() == 0: - critical_error_message_box(UiStrings.NFSp, + critical_error_message_box(UiStrings().NFSp, WizardStrings.YouSpecifyFile % WizardStrings.SSP) self.wordsOfWorshipAddButton.setFocus() return False elif source_format == SongFormat.FoilPresenter: if self.foilPresenterFileListWidget.count() == 0: - critical_error_message_box(UiStrings.NFSp, + critical_error_message_box(UiStrings().NFSp, WizardStrings.YouSpecifyFile % WizardStrings.FP) self.foilPresenterAddButton.setFocus() return False @@ -446,7 +446,7 @@ class SongImportForm(OpenLPWizard): """ if filters: filters += u';;' - filters += u'%s (*)' % UiStrings.AllFiles + filters += u'%s (*)' % UiStrings().AllFiles filenames = QtGui.QFileDialog.getOpenFileNames(self, title, SettingsManager.get_last_dir(self.plugin.settingsSection, 1), filters) @@ -476,7 +476,7 @@ class SongImportForm(OpenLPWizard): """ Get OpenLP v2 song database file """ - self.getFileName(WizardStrings.OpenTypeFile % UiStrings.OLPV2, + self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV2, self.openLP2FilenameEdit, u'%s (*.sqlite)' % (translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases')) @@ -486,7 +486,7 @@ class SongImportForm(OpenLPWizard): """ Get OpenLP v1 song database file """ - self.getFileName(WizardStrings.OpenTypeFile % UiStrings.OLPV1, + self.getFileName(WizardStrings.OpenTypeFile % UiStrings().OLPV1, self.openLP1FilenameEdit, u'%s (*.olp)' % translate('SongsPlugin.ImportWizardForm', 'openlp.org v1.x Databases') @@ -836,4 +836,4 @@ class SongImportForm(OpenLPWizard): setattr(self, prefix + u'DisabledLayout', disabledLayout) setattr(self, prefix + u'DisabledLabel', disabledLabel) setattr(self, prefix + u'ImportWidget', importWidget) - return importWidget + return importWidget \ No newline at end of file diff --git a/openlp/plugins/songs/forms/songmaintenancedialog.py b/openlp/plugins/songs/forms/songmaintenancedialog.py index 9d4b7da91..3d65783ac 100644 --- a/openlp/plugins/songs/forms/songmaintenancedialog.py +++ b/openlp/plugins/songs/forms/songmaintenancedialog.py @@ -149,17 +149,17 @@ class Ui_SongMaintenanceDialog(object): self.listItemAuthors.setText(SongStrings.Authors) self.listItemTopics.setText(SongStrings.Topics) self.listItemBooks.setText(SongStrings.SongBooks) - self.authorsAddButton.setText(UiStrings.Add) - self.authorsEditButton.setText(UiStrings.Edit) - self.authorsDeleteButton.setText(UiStrings.Delete) - self.topicsAddButton.setText(UiStrings.Add) - self.topicsEditButton.setText(UiStrings.Edit) - self.topicsDeleteButton.setText(UiStrings.Delete) - self.booksAddButton.setText(UiStrings.Add) - self.booksEditButton.setText(UiStrings.Edit) - self.booksDeleteButton.setText(UiStrings.Delete) + self.authorsAddButton.setText(UiStrings().Add) + self.authorsEditButton.setText(UiStrings().Edit) + self.authorsDeleteButton.setText(UiStrings().Delete) + self.topicsAddButton.setText(UiStrings().Add) + self.topicsEditButton.setText(UiStrings().Edit) + self.topicsDeleteButton.setText(UiStrings().Delete) + self.booksAddButton.setText(UiStrings().Add) + self.booksEditButton.setText(UiStrings().Edit) + self.booksDeleteButton.setText(UiStrings().Delete) typeListWidth = max(self.fontMetrics().width(SongStrings.Authors), self.fontMetrics().width(SongStrings.Topics), self.fontMetrics().width(SongStrings.SongBooks)) self.typeListWidget.setFixedWidth(typeListWidth + - self.typeListWidget.iconSize().width() + 32) + self.typeListWidget.iconSize().width() + 32) \ No newline at end of file diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 0a1effcf3..48e614eeb 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -115,7 +115,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): else: critical_error_message_box(dlg_title, err_text) else: - critical_error_message_box(dlg_title, UiStrings.NISs) + critical_error_message_box(dlg_title, UiStrings().NISs) def resetAuthors(self): """ @@ -503,4 +503,4 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): editButton.setEnabled(False) else: deleteButton.setEnabled(True) - editButton.setEnabled(True) + editButton.setEnabled(True) \ No newline at end of file diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 5890fc76d..8245adfbc 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -137,8 +137,8 @@ class SongMediaItem(MediaManagerItem): QtCore.QVariant(u'True')).toBool() def retranslateUi(self): - self.searchTextLabel.setText(u'%s:' % UiStrings.Search) - self.searchTextButton.setText(UiStrings.Search) + self.searchTextLabel.setText(u'%s:' % UiStrings().Search) + self.searchTextButton.setText(UiStrings().Search) self.maintenanceAction.setText(SongStrings.SongMaintenance) self.maintenanceAction.setToolTip(translate('SongsPlugin.MediaItem', 'Maintain the lists of authors, topics and books')) @@ -153,7 +153,7 @@ class SongMediaItem(MediaManagerItem): translate('SongsPlugin.MediaItem', 'Lyrics')), (SongSearch.Authors, u':/songs/song_search_author.png', SongStrings.Authors), - (SongSearch.Themes, u':/slides/slide_theme.png', UiStrings.Themes) + (SongSearch.Themes, u':/slides/slide_theme.png', UiStrings().Themes) ]) self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value( u'%s/last search type' % self.settingsSection, @@ -312,7 +312,7 @@ class SongMediaItem(MediaManagerItem): Edit a song """ log.debug(u'onEditClick') - if check_item_selected(self.listView, UiStrings.SelectEdit): + if check_item_selected(self.listView, UiStrings().SelectEdit): self.editItem = self.listView.currentItem() item_id = (self.editItem.data(QtCore.Qt.UserRole)).toInt()[0] self.edit_song_form.loadSong(item_id, False) @@ -323,7 +323,7 @@ class SongMediaItem(MediaManagerItem): """ Remove a song from the list and database """ - if check_item_selected(self.listView, UiStrings.SelectDelete): + if check_item_selected(self.listView, UiStrings().SelectDelete): items = self.listView.selectedIndexes() if QtGui.QMessageBox.question(self, translate('SongsPlugin.MediaItem', 'Delete Song(s)?'), @@ -472,4 +472,4 @@ class SongMediaItem(MediaManagerItem): Locale aware collation of song titles """ return locale.strcoll(unicode(song_1.title.lower()), - unicode(song_2.title.lower())) + unicode(song_2.title.lower())) \ No newline at end of file diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 4fc098949..0cace4977 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -67,9 +67,9 @@ class SongsPlugin(Plugin): Plugin.initialise(self) self.toolsReindexItem.setVisible(True) action_list = ActionList.get_instance() - action_list.add_action(self.SongImportItem, UiStrings.Import) - action_list.add_action(self.SongExportItem, UiStrings.Export) - action_list.add_action(self.toolsReindexItem, UiStrings.Tools) + action_list.add_action(self.SongImportItem, UiStrings().Import) + action_list.add_action(self.SongExportItem, UiStrings().Export) + action_list.add_action(self.toolsReindexItem, UiStrings().Tools) def addImportMenuItem(self, import_menu): """ @@ -139,7 +139,7 @@ class SongsPlugin(Plugin): if maxSongs == 0: return progressDialog = QtGui.QProgressDialog( - translate('SongsPlugin', 'Reindexing songs...'), UiStrings.Cancel, + translate('SongsPlugin', 'Reindexing songs...'), UiStrings().Cancel, 0, maxSongs, self.formparent) progressDialog.setWindowModality(QtCore.Qt.WindowModal) songs = self.manager.get_all_objects(Song) @@ -258,7 +258,7 @@ class SongsPlugin(Plugin): self.manager.finalise() self.toolsReindexItem.setVisible(False) action_list = ActionList.get_instance() - action_list.remove_action(self.SongImportItem, UiStrings.Import) - action_list.remove_action(self.SongExportItem, UiStrings.Export) - action_list.remove_action(self.toolsReindexItem, UiStrings.Tools) - Plugin.finalise(self) + action_list.remove_action(self.SongImportItem, UiStrings().Import) + action_list.remove_action(self.SongExportItem, UiStrings().Export) + action_list.remove_action(self.toolsReindexItem, UiStrings().Tools) + Plugin.finalise(self) \ No newline at end of file From 7fdd4bb1c1828e1c1cc70f0c7de2a9ed8bf720f8 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 15 Apr 2011 23:55:11 +0200 Subject: [PATCH 75/76] Line length cleanups. --- openlp/core/lib/ui.py | 5 +++-- openlp/core/ui/servicemanager.py | 11 +++++++---- openlp/core/ui/starttimeform.py | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 013231b8c..a0686416c 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -175,7 +175,8 @@ def create_accept_reject_button_box(parent, okay=False): accept_button = QtGui.QDialogButtonBox.Save if okay: accept_button = QtGui.QDialogButtonBox.Ok - button_box.setStandardButtons(accept_button | QtGui.QDialogButtonBox.Cancel) + button_box.setStandardButtons( + accept_button | QtGui.QDialogButtonBox.Cancel) button_box.setObjectName(u'%sButtonBox' % parent) QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'), parent.accept) @@ -445,4 +446,4 @@ def find_and_set_in_combo_box(combo_box, value_to_find): if index == -1: # Not Found. index = 0 - combo_box.setCurrentIndex(index) \ No newline at end of file + combo_box.setCurrentIndex(index) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index d682f5b52..66cc61989 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -169,7 +169,8 @@ class ServiceManager(QtGui.QWidget): self.onServiceTop, shortcuts=[QtCore.Qt.Key_Home]) self.serviceManagerList.moveTop.setObjectName(u'moveTop') action_list = ActionList.get_instance() - action_list.add_category(UiStrings().Service, CategoryOrder.standardToolbar) + action_list.add_category( + UiStrings().Service, CategoryOrder.standardToolbar) action_list.add_action( self.serviceManagerList.moveTop, UiStrings().Service) self.serviceManagerList.moveUp = self.orderToolbar.addToolbarButton( @@ -179,7 +180,8 @@ class ServiceManager(QtGui.QWidget): '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, UiStrings().Service) + action_list.add_action( + self.serviceManagerList.moveUp, UiStrings().Service) self.serviceManagerList.moveDown = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', 'Move &down'), u':/services/service_down.png', @@ -231,7 +233,8 @@ class ServiceManager(QtGui.QWidget): '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, UiStrings().Service) + action_list.add_action( + self.serviceManagerList.expand, UiStrings().Service) self.serviceManagerList.collapse = self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', '&Collapse all'), u':/services/service_collapse_all.png', @@ -1311,4 +1314,4 @@ class ServiceManager(QtGui.QWidget): Print a Service Order Sheet. """ settingDialog = PrintServiceForm(self.mainwindow, self) - settingDialog.exec_() \ No newline at end of file + settingDialog.exec_() diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index b460bbbd0..956b01a9d 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -53,7 +53,8 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): self.hourFinishSpinBox.setValue(hours) self.minuteFinishSpinBox.setValue(minutes) self.secondFinishSpinBox.setValue(seconds) - self.hourFinishLabel.setText(u'%s%s' % (unicode(hour), UiStrings().Hours)) + self.hourFinishLabel.setText(u'%s%s' % (unicode(hour), + UiStrings().Hours)) self.minuteFinishLabel.setText(u'%s%s' % (unicode(minutes), UiStrings().Minutes)) self.secondFinishLabel.setText(u'%s%s' % @@ -90,4 +91,4 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): seconds -= 3600 * hours minutes = seconds / 60 seconds -= 60 * minutes - return hours, minutes, seconds \ No newline at end of file + return hours, minutes, seconds From b46aa38ce93836662c75efae5e35294dc3c53aa9 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 16 Apr 2011 00:46:24 +0200 Subject: [PATCH 76/76] Add a bit of spacing around the edges of the settings form to make it feel a little less crowded. --- openlp/core/ui/settingsdialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index 485cb9c5f..50bcca4e2 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -37,7 +37,7 @@ class Ui_SettingsDialog(object): build_icon(u':/system/system_settings.png')) self.dialogLayout = QtGui.QGridLayout(settingsDialog) self.dialogLayout.setObjectName(u'dialogLayout') - self.dialogLayout.setMargin(0) + self.dialogLayout.setMargin(8) self.settingListWidget = QtGui.QListWidget(settingsDialog) self.settingListWidget.setUniformItemSizes(True) self.settingListWidget.setMinimumSize(QtCore.QSize(150, 0))