diff --git a/documentation/source/core/lib.rst b/documentation/source/core/lib.rst index 12c7b702c..43ca90b3b 100644 --- a/documentation/source/core/lib.rst +++ b/documentation/source/core/lib.rst @@ -60,18 +60,6 @@ .. autoclass:: openlp.core.lib.settingstab.SettingsTab :members: -:mod:`SongXMLBuilder` ---------------------- - -.. autoclass:: openlp.core.lib.songxmlhandler.SongXMLBuilder - :members: - -:mod:`SongXMLParser` --------------------- - -.. autoclass:: openlp.core.lib.songxmlhandler.SongXMLParser - :members: - :mod:`ThemeXML` --------------- @@ -83,10 +71,3 @@ .. autoclass:: openlp.core.lib.toolbar.OpenLPToolbar :members: - -:mod:`XmlRootClass` -------------------- - -.. autoclass:: openlp.core.lib.xmlrootclass.XmlRootClass - :members: - diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index d6f805c98..4718e289e 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -202,28 +202,17 @@ def check_item_selected(list_widget, message): return False return True - -class ThemeLevel(object): - """ - Provides an enumeration for the level a theme applies to - """ - Global = 1 - Service = 2 - Song = 3 - from eventreceiver import Receiver from settingsmanager import SettingsManager from plugin import PluginStatus, Plugin from pluginmanager import PluginManager from settingstab import SettingsTab -from xmlrootclass import XmlRootClass from serviceitem import ServiceItem from serviceitem import ServiceItemType from serviceitem import ItemCapabilities from toolbar import OpenLPToolbar from dockwidget import OpenLPDockWidget -from songxmlhandler import SongXMLBuilder, SongXMLParser -from themexmlhandler import ThemeXML +from theme import ThemeLevel, ThemeXML from renderer import Renderer from rendermanager import RenderManager from mediamanageritem import MediaManagerItem diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index b000fe918..8acc79541 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -166,17 +166,17 @@ class Manager(object): else: return self.session.query(object_class).get(key) - def get_object_filtered(self, object_class, filter_string): + def get_object_filtered(self, object_class, filter_clause): """ Returns an object matching specified criteria ``object_class`` The type of object to return - ``filter_string`` + ``filter_clause`` The criteria to select the object by """ - return self.session.query(object_class).filter(filter_string).first() + return self.session.query(object_class).filter(filter_clause).first() def get_all_objects(self, object_class, order_by_ref=None): """ @@ -188,21 +188,29 @@ class Manager(object): ``order_by_ref`` Any parameters to order the returned objects by. Defaults to None. """ - if order_by_ref: - return self.session.query(object_class).order_by(order_by_ref).all() - return self.session.query(object_class).all() + query = self.session.query(object_class) + if order_by_ref is not None: + return query.order_by(order_by_ref).all() + return query.all() - def get_all_objects_filtered(self, object_class, filter_string): + def get_all_objects_filtered(self, object_class, filter_clause, + order_by_ref=None): """ Returns a selection of objects from the database ``object_class`` The type of objects to return - ``filter_string`` + ``filter_clause`` The filter governing selection of objects to return + + ``order_by_ref`` + Any parameters to order the returned objects by. Defaults to None. """ - return self.session.query(object_class).filter(filter_string).all() + query = self.session.query(object_class).filter(filter_clause) + if order_by_ref is not None: + return query.order_by(order_by_ref).all() + return query.all() def delete_object(self, object_class, key): """ diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 322ce8cd0..8ebfe88ae 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -443,7 +443,7 @@ class MediaManagerItem(QtGui.QWidget): service_item = self.buildServiceItem() if service_item: service_item.from_plugin = True - self.parent.preview_controller.addServiceItem(service_item) + self.parent.previewController.addServiceItem(service_item) def onLiveClick(self): """ @@ -460,7 +460,7 @@ class MediaManagerItem(QtGui.QWidget): service_item = self.buildServiceItem() if service_item: service_item.from_plugin = True - self.parent.live_controller.addServiceItem(service_item) + self.parent.liveController.addServiceItem(service_item) def onAddClick(self): """ @@ -479,7 +479,7 @@ class MediaManagerItem(QtGui.QWidget): service_item = self.buildServiceItem() if service_item: service_item.from_plugin = False - self.parent.service_manager.addServiceItem(service_item, + self.parent.serviceManager.addServiceItem(service_item, replace=self.remoteTriggered) else: items = self.ListView.selectedIndexes() @@ -487,7 +487,7 @@ class MediaManagerItem(QtGui.QWidget): service_item = self.buildServiceItem(item) if service_item: service_item.from_plugin = False - self.parent.service_manager.addServiceItem(service_item) + self.parent.serviceManager.addServiceItem(service_item) def onAddEditClick(self): """ @@ -500,7 +500,7 @@ class MediaManagerItem(QtGui.QWidget): 'You must select one or more items')) else: log.debug(self.PluginNameShort + u' Add requested') - service_item = self.parent.service_manager.getServiceItem() + service_item = self.parent.serviceManager.getServiceItem() if not service_item: QtGui.QMessageBox.information(self, translate('MediaManagerItem', 'No Service Item Selected'), @@ -508,7 +508,7 @@ class MediaManagerItem(QtGui.QWidget): 'You must select an existing service item to add to.')) elif self.title.lower() == service_item.name.lower(): self.generateSlideData(service_item) - self.parent.service_manager.addServiceItem(service_item, + self.parent.serviceManager.addServiceItem(service_item, replace=True) else: #Turn off the remote edit update message indicator diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index a5d712dfb..18d4bdc9e 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -67,23 +67,23 @@ class Plugin(QtCore.QObject): **Hook Functions** - ``check_pre_conditions()`` + ``checkPreConditions()`` Provides the Plugin with a handle to check if it can be loaded. - ``get_media_manager_item()`` + ``getMediaManagerItem()`` Returns an instance of MediaManagerItem to be used in the Media Manager. - ``add_import_menu_item(import_menu)`` + ``addImportMenuItem(import_menu)`` Add an item to the Import menu. - ``add_export_menu_item(export_menu)`` + ``addExportMenuItem(export_menu)`` Add an item to the Export menu. - ``get_settings_tab()`` + ``getSettingsTab()`` Returns an instance of SettingsTabItem to be used in the Settings dialog. - ``add_to_menu(menubar)`` + ``addToMenu(menubar)`` A method to add a menu item to anywhere in the menu, given the menu bar. ``handle_event(event)`` @@ -124,18 +124,19 @@ class Plugin(QtCore.QObject): self.status = PluginStatus.Inactive # Set up logging self.log = logging.getLogger(self.name) - self.preview_controller = plugin_helpers[u'preview'] - self.live_controller = plugin_helpers[u'live'] - self.render_manager = plugin_helpers[u'render'] - self.service_manager = plugin_helpers[u'service'] - self.settings_form = plugin_helpers[u'settings form'] + 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.maindisplay = plugin_helpers[u'maindisplay'] + self.displayManager = plugin_helpers[u'displaymanager'] + self.pluginManager = plugin_helpers[u'pluginmanager'] QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), - self.process_add_service_event) + self.processAddServiceEvent) - def check_pre_conditions(self): + def checkPreConditions(self): """ Provides the Plugin with a handle to check if it can be loaded. Failing Preconditions does not stop a settings Tab being created @@ -144,7 +145,7 @@ class Plugin(QtCore.QObject): """ return True - def set_status(self): + def setStatus(self): """ Sets the status of the plugin """ @@ -152,7 +153,7 @@ class Plugin(QtCore.QObject): self.settingsSection + u'/status', QtCore.QVariant(PluginStatus.Inactive)).toInt()[0] - def toggle_status(self, new_status): + def toggleStatus(self, new_status): """ Changes the status of the plugin and remembers it """ @@ -160,7 +161,7 @@ class Plugin(QtCore.QObject): QtCore.QSettings().setValue( self.settingsSection + u'/status', QtCore.QVariant(self.status)) - def is_active(self): + def isActive(self): """ Indicates if the plugin is active @@ -168,47 +169,47 @@ class Plugin(QtCore.QObject): """ return self.status == PluginStatus.Active - def get_media_manager_item(self): + def getMediaManagerItem(self): """ Construct a MediaManagerItem object with all the buttons and things you need, and return it for integration into openlp.org. """ pass - def add_import_menu_item(self, import_menu): + def addImportMenuItem(self, importMenu): """ Create a menu item and add it to the "Import" menu. - ``import_menu`` + ``importMenu`` The Import menu. """ pass - def add_export_menu_item(self, export_menu): + def addExportMenuItem(self, exportMenu): """ Create a menu item and add it to the "Export" menu. - ``export_menu`` + ``exportMenu`` The Export menu """ pass - def add_tools_menu_item(self, tools_menu): + def addToolsMenuItem(self, toolsMenu): """ Create a menu item and add it to the "Tools" menu. - ``tools_menu`` + ``toolsMenu`` The Tools menu """ pass - def get_settings_tab(self): + def getSettingsTab(self): """ Create a tab for the settings window. """ pass - def add_to_menu(self, menubar): + def addToMenu(self, menubar): """ Add menu items to the menu, given the menubar. @@ -217,16 +218,16 @@ class Plugin(QtCore.QObject): """ pass - def process_add_service_event(self, replace=False): + def processAddServiceEvent(self, replace=False): """ Generic Drag and drop handler triggered from service_manager. """ - log.debug(u'process_add_service_event event called for plugin %s' % + log.debug(u'processAddServiceEvent event called for plugin %s' % self.name) if replace: - self.media_item.onAddEditClick() + self.mediaItem.onAddEditClick() else: - self.media_item.onAddClick() + self.mediaItem.onAddClick() def about(self): """ @@ -240,33 +241,36 @@ class Plugin(QtCore.QObject): """ Called by the plugin Manager to initialise anything it needs. """ - if self.media_item: - self.media_item.initialise() + if self.mediaItem: + self.mediaItem.initialise() + self.insertToolboxItem() def finalise(self): """ Called by the plugin Manager to cleanup things. """ - pass + self.removeToolboxItem() - def remove_toolbox_item(self): + def removeToolboxItem(self): """ Called by the plugin to remove toolbar """ - self.mediadock.remove_dock(self.name) - self.settings_form.removeTab(self.name) + if self.mediaItem: + self.mediadock.remove_dock(self.name) + if self.settings_tab: + self.settingsForm.removeTab(self.name) - def insert_toolbox_item(self): + def insertToolboxItem(self): """ Called by plugin to replace toolbar """ - if self.media_item: - self.mediadock.insert_dock(self.media_item, self.icon, self.weight) + if self.mediaItem: + self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight) if self.settings_tab: - self.settings_form.insertTab(self.settings_tab, self.weight) + self.settingsForm.insertTab(self.settings_tab, self.weight) - def can_delete_theme(self, theme): + def canDeleteTheme(self, theme): """ Called to ask the plugin if a theme can be deleted """ - return True + return True \ No newline at end of file diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index d9ae40845..20c8bc97b 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -109,9 +109,9 @@ class PluginManager(object): log.exception(u'loaded plugin %s has no helpers', unicode(p)) plugins_list = sorted(plugin_objects, self.order_by_weight) for plugin in plugins_list: - if plugin.check_pre_conditions(): + if plugin.checkPreConditions(): log.debug(u'Plugin %s active', unicode(plugin.name)) - plugin.set_status() + plugin.setStatus() else: plugin.status = PluginStatus.Disabled self.plugins.append(plugin) @@ -138,7 +138,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.media_item = plugin.get_media_manager_item() + plugin.mediaItem = plugin.getMediaManagerItem() def hook_settings_tabs(self, settingsform=None): """ @@ -151,7 +151,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.settings_tab = plugin.get_settings_tab() + plugin.settings_tab = plugin.getSettingsTab() if plugin.settings_tab: log.debug(u'Inserting settings tab item from %s' % plugin.name) @@ -169,7 +169,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.add_import_menu_item(import_menu) + plugin.addImportMenuItem(import_menu) def hook_export_menu(self, export_menu): """ @@ -181,7 +181,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.add_export_menu_item(export_menu) + plugin.addExportMenuItem(export_menu) def hook_tools_menu(self, tools_menu): """ @@ -193,7 +193,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.add_tools_menu_item(tools_menu) + plugin.addToolsMenuItem(tools_menu) def initialise_plugins(self): """ @@ -202,12 +202,12 @@ class PluginManager(object): """ for plugin in self.plugins: log.info(u'initialising plugins %s in a %s state' - % (plugin.name, plugin.is_active())) - if plugin.is_active(): + % (plugin.name, plugin.isActive())) + if plugin.isActive(): plugin.initialise() log.info(u'Initialisation Complete for %s ' % plugin.name) - if not plugin.is_active(): - plugin.remove_toolbox_item() + if not plugin.isActive(): + plugin.removeToolboxItem() def finalise_plugins(self): """ @@ -216,7 +216,6 @@ class PluginManager(object): """ log.info(u'finalising plugins') for plugin in self.plugins: - if plugin.is_active(): + if plugin.isActive(): plugin.finalise() - log.info(u'Finalisation Complete for %s ' % plugin.name) - + log.info(u'Finalisation Complete for %s ' % plugin.name) \ No newline at end of file diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index c7f96528c..04c854afa 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -29,6 +29,7 @@ format it for the output display. import logging from PyQt4 import QtGui, QtCore + from openlp.core.lib import resize_image log = logging.getLogger(__name__) diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 431f74564..b3c46a5eb 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -27,8 +27,7 @@ import logging from PyQt4 import QtCore -from renderer import Renderer -from openlp.core.lib import ThemeLevel +from openlp.core.lib import Renderer, ThemeLevel log = logging.getLogger(__name__) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index c107a1872..a8988aa84 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -35,7 +35,6 @@ import uuid from PyQt4 import QtGui from openlp.core.lib import build_icon, resize_image -from openlp.core.utils import AppLocation log = logging.getLogger(__name__) @@ -74,7 +73,7 @@ class ServiceItem(object): The plugin that this service item belongs to. """ if plugin: - self.render_manager = plugin.render_manager + self.render_manager = plugin.renderManager self.name = plugin.name self.title = u'' self.shortname = u'' @@ -93,7 +92,6 @@ class ServiceItem(object): self.is_valid = True self.cache = {} self.icon = None - self.serviceItemPath = AppLocation.get_section_data_path(u'serviceItems') def add_capability(self, capability): """ @@ -155,12 +153,9 @@ class ServiceItem(object): del self.cache[len(self._display_frames)] log.log(15, u'Formatting took %4s' % (time.time() - before)) elif self.service_item_type == ServiceItemType.Image: - for count, slide in enumerate(self._raw_frames): + for slide in self._raw_frames: slide[u'image'] = resize_image(slide[u'image'], self.render_manager.width, self.render_manager.height) - path = os.path.join(self.serviceItemPath, self._uuid + unicode(count) + u'.png') - slide[u'image'].save(path) - slide[u'display'] = path elif self.service_item_type == ServiceItemType.Command: pass else: @@ -376,8 +371,7 @@ class ServiceItem(object): if self.service_item_type == ServiceItemType.Text: return self.render_individual(row) else: - return {u'main':self._raw_frames[row][u'image'], - u'trans':None, u'display':self._raw_frames[row][u'display']} + return {u'main':self._raw_frames[row][u'image'], u'trans':None} def get_frame_title(self, row=0): """ diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/theme.py similarity index 99% rename from openlp/core/lib/themexmlhandler.py rename to openlp/core/lib/theme.py index a5b4137ce..3f7b613d4 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/theme.py @@ -79,6 +79,14 @@ BLANK_THEME_XML = \ ''' +class ThemeLevel(object): + """ + Provides an enumeration for the level a theme applies to + """ + Global = 1 + Service = 2 + Song = 3 + class ThemeXML(object): """ A class to encapsulate the Theme XML. @@ -313,7 +321,6 @@ class ThemeXML(object): element.appendChild(value) background.appendChild(element) - def child_element(self, element, tag, value): """ Generic child element creator. @@ -351,14 +358,8 @@ class ThemeXML(object): ``xml`` The XML string to parse. """ - self.base_parse_xml() - self.parse_xml(xml) - - def base_parse_xml(self): - """ - Pull in the blank theme XML as a starting point. - """ self.parse_xml(BLANK_THEME_XML) + self.parse_xml(xml) def parse_xml(self, xml): """ @@ -414,4 +415,3 @@ class ThemeXML(object): if key[0:1] != u'_': theme_strings.append(u'%30s: %s' % (key, getattr(self, key))) return u'\n'.join(theme_strings) - diff --git a/openlp/core/lib/xmlrootclass.py b/openlp/core/lib/xmlrootclass.py deleted file mode 100644 index de1339839..000000000 --- a/openlp/core/lib/xmlrootclass.py +++ /dev/null @@ -1,104 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import os -import sys - -from lxml.etree import ElementTree, XML - -sys.path.append(os.path.abspath(os.path.join(u'.', u'..', u'..'))) - -class XmlRootClass(object): - """ - Root class for themes, songs etc - - This class provides interface for parsing xml files into object attributes. - - If you overload this class and provide a function called `post_tag_hook`, - it will be called thusly for each `tag, value` pair:: - - (element.tag, val) = self.post_tag_hook(element.tag, val) - """ - def _set_from_xml(self, xml, root_tag): - """ - Set song properties from given xml content. - - ``xml`` - Formatted xml tags and values. - ``root_tag`` - The root tag of the xml. - """ - root = ElementTree(element=XML(xml)) - xml_iter = root.getiterator() - for element in xml_iter: - if element.tag != root_tag: - text = element.text - if text is None: - val = text - elif isinstance(text, basestring): - # Strings need special handling to sort the colours out - if text[0] == u'$': - # This might be a hex number, let's try to convert it. - try: - val = int(text[1:], 16) - except ValueError: - pass - else: - # Let's just see if it's a integer. - try: - val = int(text) - except ValueError: - # Ok, it seems to be a string. - val = text - if hasattr(self, u'post_tag_hook'): - (element.tag, val) = \ - self.post_tag_hook(element.tag, val) - setattr(self, element.tag, val) - - def __str__(self): - """ - Return string with all public attributes - - The string is formatted with one attribute per line - If the string is split on newline then the length of the - list is equal to the number of attributes - """ - attributes = [] - for attrib in dir(self): - if not attrib.startswith(u'_'): - attributes.append( - u'%30s : %s' % (attrib, getattr(self, attrib))) - return u'\n'.join(attributes) - - def _get_as_string(self): - """ - Return one string with all public attributes - """ - result = u'' - for attrib in dir(self): - if not attrib.startswith(u'_'): - result += u'_%s_' % getattr(self, attrib) - return result - diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 6cddbcb45..82e7ac2cc 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -222,4 +222,3 @@ class Theme(object): if key[0:1] != u'_': theme_strings.append(u'%30s : %s' % (key, getattr(self, key))) return u'\n'.join(theme_strings) - diff --git a/openlp/core/ui/amendthemedialog.py b/openlp/core/ui/amendthemedialog.py index a75f5e686..2bb202964 100644 --- a/openlp/core/ui/amendthemedialog.py +++ b/openlp/core/ui/amendthemedialog.py @@ -178,13 +178,11 @@ class Ui_AmendThemeDialog(object): self.MainFontLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.FontMainSize) self.FontMainSizeSpinBox = QtGui.QSpinBox(self.FontMainGroupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, + defaultSizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth( + defaultSizePolicy.setHeightForWidth( self.FontMainSizeSpinBox.sizePolicy().hasHeightForWidth()) - self.FontMainSizeSpinBox.setSizePolicy(sizePolicy) + self.FontMainSizeSpinBox.setSizePolicy(defaultSizePolicy) self.FontMainSizeSpinBox.setMinimumSize(QtCore.QSize(70, 0)) self.FontMainSizeSpinBox.setProperty(u'value', QtCore.QVariant(16)) self.FontMainSizeSpinBox.setMaximum(999) @@ -230,8 +228,7 @@ class Ui_AmendThemeDialog(object): self.FontMainLineSpacingSpinBox) self.FontMainLinesPageLabel = QtGui.QLabel(self.FontMainGroupBox) self.FontMainLinesPageLabel.setObjectName(u'FontMainLinesPageLabel') - self.MainFontLayout.setWidget(6, QtGui.QFormLayout.LabelRole, - self.FontMainLinesPageLabel) + self.MainFontLayout.addRow(self.FontMainLinesPageLabel) spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.MainLeftLayout.addItem(spacerItem1) @@ -275,13 +272,9 @@ class Ui_AmendThemeDialog(object): self.MainLocationLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.FontMainHeightLabel) self.FontMainXSpinBox = QtGui.QSpinBox(self.MainLocationGroupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, - QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth( + defaultSizePolicy.setHeightForWidth( self.FontMainXSpinBox.sizePolicy().hasHeightForWidth()) - self.FontMainXSpinBox.setSizePolicy(sizePolicy) + self.FontMainXSpinBox.setSizePolicy(defaultSizePolicy) self.FontMainXSpinBox.setMinimumSize(QtCore.QSize(78, 0)) self.FontMainXSpinBox.setProperty(u'value', QtCore.QVariant(0)) self.FontMainXSpinBox.setMaximum(9999) @@ -289,39 +282,27 @@ class Ui_AmendThemeDialog(object): self.MainLocationLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.FontMainXSpinBox) self.FontMainYSpinBox = QtGui.QSpinBox(self.MainLocationGroupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, - QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth( + defaultSizePolicy.setHeightForWidth( self.FontMainYSpinBox.sizePolicy().hasHeightForWidth()) - self.FontMainYSpinBox.setSizePolicy(sizePolicy) + self.FontMainYSpinBox.setSizePolicy(defaultSizePolicy) self.FontMainYSpinBox.setMinimumSize(QtCore.QSize(78, 0)) self.FontMainYSpinBox.setMaximum(9999) self.FontMainYSpinBox.setObjectName(u'FontMainYSpinBox') self.MainLocationLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.FontMainYSpinBox) self.FontMainWidthSpinBox = QtGui.QSpinBox(self.MainLocationGroupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, - QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth( + defaultSizePolicy.setHeightForWidth( self.FontMainWidthSpinBox.sizePolicy().hasHeightForWidth()) - self.FontMainWidthSpinBox.setSizePolicy(sizePolicy) + self.FontMainWidthSpinBox.setSizePolicy(defaultSizePolicy) self.FontMainWidthSpinBox.setMinimumSize(QtCore.QSize(78, 0)) self.FontMainWidthSpinBox.setMaximum(9999) self.FontMainWidthSpinBox.setObjectName(u'FontMainWidthSpinBox') self.MainLocationLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.FontMainWidthSpinBox) self.FontMainHeightSpinBox = QtGui.QSpinBox(self.MainLocationGroupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, - QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth( + defaultSizePolicy.setHeightForWidth( self.FontMainHeightSpinBox.sizePolicy().hasHeightForWidth()) - self.FontMainHeightSpinBox.setSizePolicy(sizePolicy) + self.FontMainHeightSpinBox.setSizePolicy(defaultSizePolicy) self.FontMainHeightSpinBox.setMinimumSize(QtCore.QSize(78, 0)) self.FontMainHeightSpinBox.setMaximum(9999) self.FontMainHeightSpinBox.setObjectName(u'FontMainHeightSpinBox') @@ -378,13 +359,9 @@ class Ui_AmendThemeDialog(object): self.FooterFontLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.FontFooterSizeLabel) self.FontFooterSizeSpinBox = QtGui.QSpinBox(self.FooterFontGroupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, - QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth( + defaultSizePolicy.setHeightForWidth( self.FontFooterSizeSpinBox.sizePolicy().hasHeightForWidth()) - self.FontFooterSizeSpinBox.setSizePolicy(sizePolicy) + self.FontFooterSizeSpinBox.setSizePolicy(defaultSizePolicy) self.FontFooterSizeSpinBox.setMinimumSize(QtCore.QSize(70, 0)) self.FontFooterSizeSpinBox.setProperty(u'value', QtCore.QVariant(10)) self.FontFooterSizeSpinBox.setMaximum(999) @@ -453,13 +430,9 @@ class Ui_AmendThemeDialog(object): self.LocationFooterLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.FontFooterHeightLabel) self.FontFooterXSpinBox = QtGui.QSpinBox(self.LocationFooterGroupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, - QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth( + defaultSizePolicy.setHeightForWidth( self.FontFooterXSpinBox.sizePolicy().hasHeightForWidth()) - self.FontFooterXSpinBox.setSizePolicy(sizePolicy) + self.FontFooterXSpinBox.setSizePolicy(defaultSizePolicy) self.FontFooterXSpinBox.setMinimumSize(QtCore.QSize(78, 0)) self.FontFooterXSpinBox.setProperty(u'value', QtCore.QVariant(0)) self.FontFooterXSpinBox.setMaximum(9999) @@ -467,13 +440,9 @@ class Ui_AmendThemeDialog(object): self.LocationFooterLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.FontFooterXSpinBox) self.FontFooterYSpinBox = QtGui.QSpinBox(self.LocationFooterGroupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, - QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth( - self.FontFooterYSpinBox.sizePolicy().hasHeightForWidth()) - self.FontFooterYSpinBox.setSizePolicy(sizePolicy) + defaultSizePolicy.setHeightForWidth( + self.FontFooterXSpinBox.sizePolicy().hasHeightForWidth()) + self.FontFooterYSpinBox.setSizePolicy(defaultSizePolicy) self.FontFooterYSpinBox.setMinimumSize(QtCore.QSize(78, 0)) self.FontFooterYSpinBox.setProperty(u'value', QtCore.QVariant(0)) self.FontFooterYSpinBox.setMaximum(9999) @@ -901,4 +870,3 @@ class Ui_AmendThemeDialog(object): self.ThemeTabWidget.indexOf(self.OtherOptionsTab), translate('AmendThemeForm', '&Other Options')) self.PreviewGroupBox.setTitle(translate('AmendThemeForm', 'Preview')) - diff --git a/openlp/core/ui/displaytab.py b/openlp/core/ui/displaytab.py index 8a028bbc8..0fb16a9f7 100644 --- a/openlp/core/ui/displaytab.py +++ b/openlp/core/ui/displaytab.py @@ -242,4 +242,3 @@ class DisplayTab(SettingsTab): if self.amend_display_start != self.amend_display: self.amend_display_start = self.amend_display Receiver.send_message(u'config_screen_changed') - diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 4c42bf90c..340753707 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -32,13 +32,16 @@ class GeneralTab(SettingsTab): GeneralTab is the general settings tab in the settings dialog. """ def __init__(self, screens): + """ + Initialise the general settings tab + """ self.screens = screens + self.MonitorNumber = 0 SettingsTab.__init__(self, u'General') def preLoad(self): """ - Set up the display screen and set correct screen - values. + Set up the display screen and set correct screen values. If not set before default to last screen. """ settings = QtCore.QSettings() @@ -47,12 +50,14 @@ class GeneralTab(SettingsTab): QtCore.QVariant(self.screens.display_count - 1)).toInt()[0] self.screens.set_current_display(self.MonitorNumber) self.screens.monitor_number = self.MonitorNumber - self.DisplayOnMonitor = settings.value( + self.screens.display = settings.value( u'display on monitor', QtCore.QVariant(True)).toBool() - self.screens.display = self.DisplayOnMonitor settings.endGroup() def setupUi(self): + """ + Create the user interface for the general settings tab + """ self.setObjectName(u'GeneralTab') self.tabTitleVisible = translate('GeneralTab', 'General') self.GeneralLayout = QtGui.QHBoxLayout(self) @@ -152,31 +157,11 @@ class GeneralTab(SettingsTab): QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.GeneralRightLayout.addItem(self.GeneralRightSpacer) self.GeneralLayout.addWidget(self.GeneralRightWidget) - QtCore.QObject.connect(self.MonitorComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onMonitorComboBoxChanged) - QtCore.QObject.connect(self.DisplayOnMonitorCheck, - QtCore.SIGNAL(u'stateChanged(int)'), - self.onDisplayOnMonitorCheckChanged) - QtCore.QObject.connect(self.WarningCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), self.onWarningCheckBoxChanged) - QtCore.QObject.connect(self.AutoOpenCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), self.onAutoOpenCheckBoxChanged) - QtCore.QObject.connect(self.ShowSplashCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), - self.onShowSplashCheckBoxChanged) - QtCore.QObject.connect(self.SaveCheckServiceCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), - self.onSaveCheckServiceCheckBox) - QtCore.QObject.connect(self.AutoPreviewCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), self.onAutoPreviewCheckBox) - QtCore.QObject.connect(self.NumberEdit, - QtCore.SIGNAL(u'editingFinished()'), self.onNumberEditLostFocus) - QtCore.QObject.connect(self.UsernameEdit, - QtCore.SIGNAL(u'editingFinished()'), self.onUsernameEditLostFocus) - QtCore.QObject.connect(self.PasswordEdit, - QtCore.SIGNAL(u'editingFinished()'), self.onPasswordEditLostFocus) def retranslateUi(self): + """ + Translate the general settings tab to the currently selected language + """ self.MonitorGroupBox.setTitle(translate('GeneralTab', 'Monitors')) self.MonitorLabel.setText( translate('GeneralTab', 'Select monitor for output display:')) @@ -204,37 +189,10 @@ class GeneralTab(SettingsTab): self.PasswordLabel.setText( translate('GeneralTab', 'SongSelect Password:')) - def onMonitorComboBoxChanged(self): - self.MonitorNumber = self.MonitorComboBox.currentIndex() - - def onDisplayOnMonitorCheckChanged(self, value): - self.DisplayOnMonitor = (value == QtCore.Qt.Checked) - - def onAutoOpenCheckBoxChanged(self, value): - self.AutoOpen = (value == QtCore.Qt.Checked) - - def onShowSplashCheckBoxChanged(self, value): - self.ShowSplash = (value == QtCore.Qt.Checked) - - def onWarningCheckBoxChanged(self, value): - self.Warning = (value == QtCore.Qt.Checked) - - def onSaveCheckServiceCheckBox(self, value): - self.PromptSaveService = (value == QtCore.Qt.Checked) - - def onAutoPreviewCheckBox(self, value): - self.AutoPreview = (value == QtCore.Qt.Checked) - - def onNumberEditLostFocus(self): - self.CCLINumber = self.NumberEdit.displayText() - - def onUsernameEditLostFocus(self): - self.Username = self.UsernameEdit.displayText() - - def onPasswordEditLostFocus(self): - self.Password = self.PasswordEdit.displayText() - def load(self): + """ + Load the settings to populate the form + """ settings = QtCore.QSettings() settings.beginGroup(self.settingsSection) for screen in self.screens.screen_list: @@ -244,55 +202,54 @@ class GeneralTab(SettingsTab): screen_name = u'%s (%s)' % (screen_name, translate('GeneralTab', 'primary')) self.MonitorComboBox.addItem(screen_name) - # Get the configs - self.Warning = settings.value( - u'blank warning', QtCore.QVariant(False)).toBool() - self.AutoOpen = settings.value( - u'auto open', QtCore.QVariant(False)).toBool() - self.ShowSplash = settings.value( - u'show splash', QtCore.QVariant(True)).toBool() - self.PromptSaveService = settings.value( - u'save prompt', QtCore.QVariant(False)).toBool() - self.AutoPreview = settings.value( - u'auto preview', QtCore.QVariant(False)).toBool() - self.CCLINumber = unicode(settings.value( - u'ccli number', QtCore.QVariant(u'')).toString()) - self.Username = unicode(settings.value( - u'songselect username', QtCore.QVariant(u'')).toString()) - self.Password = unicode(settings.value( - u'songselect password', QtCore.QVariant(u'')).toString()) - settings.endGroup() - self.SaveCheckServiceCheckBox.setChecked(self.PromptSaveService) - # Set a few things up + self.NumberEdit.setText(unicode(settings.value( + u'ccli number', QtCore.QVariant(u'')).toString())) + self.UsernameEdit.setText(unicode(settings.value( + u'songselect username', QtCore.QVariant(u'')).toString())) + self.PasswordEdit.setText(unicode(settings.value( + u'songselect password', QtCore.QVariant(u'')).toString())) + self.SaveCheckServiceCheckBox.setChecked(settings.value(u'save prompt', + QtCore.QVariant(False)).toBool()) self.MonitorComboBox.setCurrentIndex(self.MonitorNumber) - self.DisplayOnMonitorCheck.setChecked(self.DisplayOnMonitor) - self.WarningCheckBox.setChecked(self.Warning) - self.AutoOpenCheckBox.setChecked(self.AutoOpen) - self.ShowSplashCheckBox.setChecked(self.ShowSplash) - self.AutoPreviewCheckBox.setChecked(self.AutoPreview) - self.NumberEdit.setText(self.CCLINumber) - self.UsernameEdit.setText(self.Username) - self.PasswordEdit.setText(self.Password) + self.DisplayOnMonitorCheck.setChecked(self.screens.display) + self.WarningCheckBox.setChecked(settings.value(u'blank warning', + QtCore.QVariant(False)).toBool()) + self.AutoOpenCheckBox.setChecked(settings.value(u'auto open', + QtCore.QVariant(False)).toBool()) + self.ShowSplashCheckBox.setChecked(settings.value(u'show splash', + QtCore.QVariant(True)).toBool()) + self.AutoPreviewCheckBox.setChecked(settings.value(u'auto preview', + QtCore.QVariant(False)).toBool()) + settings.endGroup() def save(self): + """ + Save the settings from the form + """ + self.MonitorNumber = self.MonitorComboBox.currentIndex() settings = QtCore.QSettings() settings.beginGroup(self.settingsSection) settings.setValue(u'monitor', QtCore.QVariant(self.MonitorNumber)) settings.setValue(u'display on monitor', - QtCore.QVariant(self.DisplayOnMonitor)) - settings.setValue(u'blank warning', QtCore.QVariant(self.Warning)) - settings.setValue(u'auto open', QtCore.QVariant(self.AutoOpen)) - settings.setValue(u'show splash', QtCore.QVariant(self.ShowSplash)) + QtCore.QVariant(self.DisplayOnMonitorCheck.isChecked())) + settings.setValue(u'blank warning', + QtCore.QVariant(self.WarningCheckBox.isChecked())) + settings.setValue(u'auto open', + QtCore.QVariant(self.AutoOpenCheckBox.isChecked())) + settings.setValue(u'show splash', + QtCore.QVariant(self.ShowSplashCheckBox.isChecked())) settings.setValue(u'save prompt', - QtCore.QVariant(self.PromptSaveService)) - settings.setValue(u'auto preview', QtCore.QVariant(self.AutoPreview)) - settings.setValue(u'ccli number', QtCore.QVariant(self.CCLINumber)) + QtCore.QVariant(self.SaveCheckServiceCheckBox.isChecked())) + settings.setValue(u'auto preview', + QtCore.QVariant(self.AutoPreviewCheckBox.isChecked())) + settings.setValue(u'ccli number', + QtCore.QVariant(self.NumberEdit.displayText())) settings.setValue(u'songselect username', - QtCore.QVariant(self.Username)) + QtCore.QVariant(self.UsernameEdit.displayText())) settings.setValue(u'songselect password', - QtCore.QVariant(self.Password)) + QtCore.QVariant(self.PasswordEdit.displayText())) settings.endGroup() - self.screens.display = self.DisplayOnMonitor + self.screens.display = self.DisplayOnMonitorCheck.isChecked() #Monitor Number has changed. if self.screens.monitor_number != self.MonitorNumber: self.screens.monitor_number = self.MonitorNumber diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index ae6d400fe..b770a9e05 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -25,37 +25,37 @@ import logging import os +import time from PyQt4 import QtCore, QtGui, QtWebKit from PyQt4.phonon import Phonon from openlp.core.lib import Receiver, resize_image from openlp.core.ui import HideMode -from openlp.core.utils import AppLocation log = logging.getLogger(__name__) -HTMLIMAGE = """ - - - - """ - #http://www.steveheffernan.com/html5-video-player/demo-video-player.html HTMLVIDEO = u""" - - \" - - + + + +