diff --git a/openlp.pyw b/openlp.pyw index 67086ae3e..2ac1e064b 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -4,7 +4,7 @@ """ OpenLP - Open Source Lyrics Projection Copyright (c) 2008 Raoul Snyman -Portions copyright (c) 2008 Martin Thompson, Tim Bentley, +Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, 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 @@ -26,17 +26,15 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver logging.basicConfig(level=logging.DEBUG, - format=u'%(asctime)s %(msecs)d %(name)-12s %(levelname)-8s %(message)s', - datefmt=u'%m-%d %H:%M:%S', - filename=u'openlp.log', - filemode=u'w') + format=u'%(asctime)s %(msecs)d %(name)-12s %(levelname)-8s %(message)s', + datefmt=u'%m-%d %H:%M:%S', filename=u'openlp.log', filemode=u'w') from openlp.core.resources import * from openlp.core.ui import MainWindow, SplashScreen class OpenLP(QtGui.QApplication): global log - log=logging.getLogger(u'OpenLP Application') + log = logging.getLogger(u'OpenLP Application') log.info(u'Application Loaded') def run(self): @@ -56,15 +54,16 @@ class OpenLP(QtGui.QApplication): screens.append({u'number': screen, u'size': self.desktop().availableGeometry(screen), u'primary': (self.desktop().primaryScreen() == screen)}) - log.info(u'Screen %d found with resolution %s', screen, self.desktop().availableGeometry(screen)) + log.info(u'Screen %d found with resolution %s', + screen, self.desktop().availableGeometry(screen)) # start the main app window - self.main_window = MainWindow(screens) - self.main_window.show() + self.mainWindow = MainWindow(screens) + self.mainWindow.show() # now kill the splashscreen - self.splash.finish(self.main_window.main_window) + self.splash.finish(self.mainWindow.mainWindow) sys.exit(app.exec_()) -if __name__ == '__main__': +if __name__ == u'__main__': app = OpenLP(sys.argv) app.run() diff --git a/openlp/__init__.py b/openlp/__init__.py index 7a3d0718a..6bcd6d97a 100644 --- a/openlp/__init__.py +++ b/openlp/__init__.py @@ -1,7 +1,7 @@ """ OpenLP - Open Source Lyrics Projection Copyright (c) 2008 Raoul Snyman -Portions copyright (c) 2008 Martin Thompson, Tim Bentley +Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley 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 @@ -15,24 +15,3 @@ 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 types -from PyQt4 import QtCore, QtGui - -__all__ = ['convertStringToBoolean','buildIcon',] - -def convertStringToBoolean(stringvalue): - return stringvalue.strip().lower() in (u'true', u'yes', u'y') - -def buildIcon(icon): - ButtonIcon = None - if type(icon) is QtGui.QIcon: - ButtonIcon = icon - elif type(icon) is types.StringType or type(icon) is types.UnicodeType: - ButtonIcon = QtGui.QIcon() - if icon.startswith(u':/'): - ButtonIcon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal, - QtGui.QIcon.Off) - else: - ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QImage(icon)), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - return ButtonIcon diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index fce0d08c4..e123886b5 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -17,16 +17,8 @@ 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 """ -from PyQt4 import QtCore, QtGui - from settingsmanager import SettingsManager from openlp.core.lib.pluginmanager import PluginManager -__all__ = ['SettingsManager', 'PluginManager', 'translate', - 'fileToXML' ] +__all__ = ['SettingsManager', 'PluginManager' ] -def translate(context, text): - return QtGui.QApplication.translate(context, text, None, QtGui.QApplication.UnicodeUTF8) - -def fileToXML(xmlfile): - return open(xmlfile).read() diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 306c1d5fd..70196b559 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -17,6 +17,46 @@ 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 types +from PyQt4 import QtCore, QtGui + +def translate(context, text): + return QtGui.QApplication.translate(context, text, None, QtGui.QApplication.UnicodeUTF8) + +def file_to_xml(xmlfile): + return open(xmlfile).read() + +def str_to_bool(stringvalue): + return stringvalue.strip().lower() in (u'true', u'yes', u'y') + +def buildIcon(icon): + ButtonIcon = None + if type(icon) is QtGui.QIcon: + ButtonIcon = icon + elif type(icon) is types.StringType or type(icon) is types.UnicodeType: + ButtonIcon = QtGui.QIcon() + if icon.startswith(u':/'): + ButtonIcon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal, + QtGui.QIcon.Off) + else: + ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QImage(icon)), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + return ButtonIcon + +def contextMenuAction(base, icon, text, slot): + """ + Utility method to help build context menus for plugins + """ + action = QtGui.QAction(text, base) + action .setIcon(buildIcon(icon)) + QtCore.QObject.connect(action, QtCore.SIGNAL("triggered()"), slot) + return action + +def contextMenuSeparator(base): + action = QtGui.QAction("", base) + action.setSeparator(True) + return action + from pluginconfig import PluginConfig from plugin import Plugin from settingstab import SettingsTab @@ -35,6 +75,11 @@ from themexmlhandler import ThemeXML from renderer import Renderer from rendermanager import RenderManager -__all__ = ['Renderer','PluginConfig', 'Plugin', 'SettingsTab', 'MediaManagerItem', 'Event', 'EventType' - 'XmlRootClass', 'ServiceItem', 'Receiver', 'OpenLPToolbar', 'SongXMLBuilder', - 'SongXMLParser', 'EventManager', 'ThemeXML', 'RenderManager'] +#__all__ = ['Renderer','PluginConfig', 'Plugin', 'SettingsTab', 'MediaManagerItem', 'Event', 'EventType' +# 'XmlRootClass', 'ServiceItem', 'Receiver', 'OpenLPToolbar', 'SongXMLBuilder', +# 'SongXMLParser', 'EventManager', 'ThemeXML', 'RenderManager'] + +__all__ = [ 'translate', 'file_to_xml', 'str_to_bool', 'contextMenuAction', 'contextMenuSeparator'] + + + diff --git a/openlp/core/lib/event.py b/openlp/core/lib/event.py index 0472edfba..abd43e6d8 100644 --- a/openlp/core/lib/event.py +++ b/openlp/core/lib/event.py @@ -44,6 +44,7 @@ class EventType(object): #PreviewBeforeShow = 13 #PreviewAfterShow = 14 +#Theme Related Events ThemeListChanged = 15 diff --git a/openlp/core/lib/eventmanager.py b/openlp/core/lib/eventmanager.py index 07a6f7024..2a3d0fac2 100644 --- a/openlp/core/lib/eventmanager.py +++ b/openlp/core/lib/eventmanager.py @@ -29,10 +29,10 @@ class EventManager(object): """ global log - log=logging.getLogger(u'EventManager') + log = logging.getLogger(u'EventManager') def __init__(self): - self.endpoints=[] + self.endpoints = [] log.info(u'Initialising') def register(self, plugin): diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 1ddebb3e1..0e3fad84d 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -2,7 +2,7 @@ """ OpenLP - Open Source Lyrics Projection Copyright (c) 2008 Raoul Snyman -Portions copyright (c) 2008 Martin Thompson, Tim Bentley, +Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, 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 @@ -17,15 +17,15 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -from PyQt4.QtCore import * +from PyQt4 import QtCore -class EventReceiver(QObject): +class EventReceiver(QtCore.QObject): """ Class to allow events to be passed from different parts of the system. This is a private class and should not be used directly but via the Receiver class """ def __init__(self): - QObject.__init__(self) + QtCore.QObject.__init__(self) def send_message(self, event, msg=None): self.emit(SIGNAL(event), msg) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 096165f7b..56f59d1d6 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -64,7 +64,7 @@ class MediaManagerItem(QtGui.QWidget): item. """ if self.Toolbar is None: - self.Toolbar=OpenLPToolbar(self) + self.Toolbar = OpenLPToolbar(self) self.PageLayout.addWidget(self.Toolbar) def addToolbarButton(self, title, tooltip, icon, slot=None, objectname=None): @@ -82,7 +82,7 @@ class MediaManagerItem(QtGui.QWidget): self.Toolbar.addSeparator() def contextMenuSeparator(self, base): - action = QtGui.QAction("", base) + action = QtGui.QAction(u'', base) action.setSeparator(True) return action @@ -94,7 +94,7 @@ class MediaManagerItem(QtGui.QWidget): ButtonIcon = icon elif type(icon) is types.StringType: ButtonIcon = QtGui.QIcon() - if icon.startswith(':/'): + if icon.startswith(u':/'): ButtonIcon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) else: @@ -103,6 +103,6 @@ class MediaManagerItem(QtGui.QWidget): action = QtGui.QAction(text, base) action .setIcon(ButtonIcon) - QtCore.QObject.connect(action, QtCore.SIGNAL("triggered()"), slot) + QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot) return action diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 272ee47f3..537cad35d 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -80,7 +80,7 @@ class Plugin(object): if name is not None: self.name = name else: - self.name = 'Plugin' + self.name = u'Plugin' if version is not None: self.version = version self.icon = None @@ -88,12 +88,12 @@ class Plugin(object): self.weight = 0 # Set up logging self.log = logging.getLogger(self.name) - self.preview_controller=plugin_helpers[u'preview'] - self.live_controller=plugin_helpers[u'live'] - self.theme_manager=plugin_helpers[u'theme'] - self.event_manager=plugin_helpers[u'event'] - self.render_manager=plugin_helpers[u'render'] - self.service_manager=plugin_helpers[u'service'] + self.preview_controller = plugin_helpers[u'preview'] + self.live_controller = plugin_helpers[u'live'] + self.theme_manager = plugin_helpers[u'theme'] + self.event_manager = plugin_helpers[u'event'] + self.render_manager = plugin_helpers[u'render'] + self.service_manager = plugin_helpers[u'service'] def check_pre_conditions(self): """ diff --git a/openlp/core/lib/pluginconfig.py b/openlp/core/lib/pluginconfig.py index d371e5328..d8c6ca2d5 100644 --- a/openlp/core/lib/pluginconfig.py +++ b/openlp/core/lib/pluginconfig.py @@ -37,12 +37,12 @@ class PluginConfig(object): Get a configuration value from the configuration registry. """ return ConfigHelper.get_config(self.section, key, default) - + def delete_config(self, key): """ Delete a configuration value from the configuration registry. """ - return ConfigHelper.delete_config(self.section, key) + return ConfigHelper.delete_config(self.section, key) def set_config(self, key, value): """ @@ -64,26 +64,28 @@ class PluginConfig(object): def set_data_path(self, path): return self.set_config(u'data path', os.path.basename(path)) - + def get_files(self, suffix=None): - returnfiles = [] #suffix = self.get_config("suffix name", default_suffixes) try: - files = os.listdir(self.get_data_path()) + files = os.listdir(self.get_data_path()) except: - return returnfiles + return [] if suffix != None: + return_files = [] for f in files: if f.find('.') != -1: nme = f.split('.') bname = nme[0] sfx = nme[1].lower() sfx = sfx.lower() - if suffix.find(sfx) > -1 : # only load files with the correct suffix - returnfiles.append(f) - return returnfiles + # only load files with the correct suffix + if suffix.find(sfx) > -1 : + return_files.append(f) + return return_files else: - return files # no filtering required + # no filtering required + return files def load_list(self, name): """ diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 94a858b2a..f1582e5d4 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -29,7 +29,7 @@ class PluginManager(object): and executes all the hooks, as and when necessary. """ global log - log=logging.getLogger(u'PluginMgr') + log = logging.getLogger(u'PluginMgr') log.info(u'Plugin manager loaded') def __init__(self, dir): @@ -42,25 +42,26 @@ class PluginManager(object): log.debug("Inserting %s into sys.path", dir) sys.path.insert(0, dir) self.basepath = os.path.abspath(dir) - log.debug("Base path %s ", self.basepath) + log.debug(u'Base path %s ', self.basepath) self.plugins = [] # this has to happen after the UI is sorted self.find_plugins(dir) - log.info("Plugin manager done init") + log.info(u'Plugin manager done init') - def find_plugins(self, dir, plugin_helpers, eventmanager): # TODO shouldn't dir come from self.basepath + def find_plugins(self, dir, plugin_helpers, eventmanager): """ Scan the directory dir for objects inheriting from openlp.plugin """ self.plugin_helpers = plugin_helpers - startdepth=len(os.path.abspath(dir).split(os.sep)) - log.debug("find plugins %s at depth %d" %( str(dir), startdepth)) + startdepth = len(os.path.abspath(dir).split(os.sep)) + log.debug(u'find plugins %s at depth %d' %( str(dir), startdepth)) for root, dirs, files in os.walk(dir): for name in files: - if name.endswith(".py") and not name.startswith("__"): + if name.endswith(u'.py') and not name.startswith(u'__'): path = os.path.abspath(os.path.join(root, name)) - thisdepth=len(path.split(os.sep)) - if thisdepth-startdepth > 2: # skip anything lower down + thisdepth = len(path.split(os.sep)) + if thisdepth-startdepth > 2: + # skip anything lower down continue modulename, pyext = os.path.splitext(path) prefix = os.path.commonprefix([self.basepath, path]) @@ -68,11 +69,11 @@ class PluginManager(object): modulename = modulename[len(prefix) + 1:] modulename = modulename.replace(os.path.sep, '.') # import the modules - log.debug("Importing %s from %s. Depth %d" % (modulename, path, thisdepth)) + log.debug(u'Importing %s from %s. Depth %d' % (modulename, path, thisdepth)) try: __import__(modulename, globals(), locals(), []) except ImportError, e: - log.error("Failed to import module %s on path %s for reason %s", modulename, path, e.message) + log.error(u'Failed to import module %s on path %s for reason %s', modulename, path, e.message) self.plugin_classes = Plugin.__subclasses__() self.plugins = [] plugin_objects = [] @@ -80,9 +81,9 @@ class PluginManager(object): try: plugin = p(self.plugin_helpers) log.debug(u'loaded plugin %s with helpers'%str(p)) - log.debug("Plugin="+str(p)) + log.debug(u'Plugin: %s', str(p)) if plugin.check_pre_conditions(): - log.debug("Appending "+str(p)) + log.debug(u'Appending %s ', str(p)) plugin_objects.append(plugin) eventmanager.register(plugin) except TypeError: @@ -100,7 +101,7 @@ class PluginManager(object): for plugin in self.plugins: media_manager_item = plugin.get_media_manager_item() if media_manager_item is not None: - log.debug('Inserting media manager item from %s' % plugin.name) + log.debug(u'Inserting media manager item from %s' % plugin.name) mediatoolbox.addItem(media_manager_item, plugin.icon, media_manager_item.title) def hook_settings_tabs(self, settingsform=None): @@ -111,10 +112,10 @@ class PluginManager(object): for plugin in self.plugins: settings_tab = plugin.get_settings_tab() if settings_tab is not None: - log.debug('Inserting settings tab item from %s' % plugin.name) + log.debug(u'Inserting settings tab item from %s' % plugin.name) settingsform.addTab(settings_tab) else: - log.debug('No settings in %s' % plugin.name) + log.debug(u'No settings in %s' % plugin.name) def hook_import_menu(self, import_menu): """ @@ -132,15 +133,6 @@ class PluginManager(object): for plugin in self.plugins: plugin.add_export_menu_item(export_menu) - def hook_handle_event(self, eventmanager): - for plugin in self.plugins: - handle_event = plugin.handle_event(None) - print plugin, handle_event -# if settings_tab is not None: -# log.debug('Inserting settings tab item from %s' % plugin.name) -# settingsform.addTab(settings_tab) -# else: -# log.debug('No settings in %s' % plugin.name) def initialise_plugins(self): """ Loop through all the plugins and give them an opportunity to add an item diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index a984d322a..236bf136e 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -177,13 +177,11 @@ class Renderer: painter.drawPath(rectPath) elif self._theme.background_type== u'image': # image - r = self._frame.rect() - log.debug(u'Image size details %d %d %d %d ', r.x(), r.y(), r.width(),r.height()) - #log.debug(u' Background Parameter %d ', self._theme.background_color1) - #if self._theme.background_color1 is not None: - # p.fillRect(self._frame.rect(), self._theme.background_borderColor) + #r = self._frame.rect() + #log.debug(u'Image size details %d %d %d %d ', r.x(), r.y(), r.width(),r.height()) if self.bg_image is not None: - painter.drawPixmap(self.background_offsetx,self.background_offsety, self.bg_image) + #painter.drawPixmap(self.background_offsetx,self.background_offsety, self.bg_image) + painter.drawPixmap(0 ,0 , self.bg_image) else: painter.fillRect(self._frame.rect(), QtGui.QColor(u'#000000')) painter.end() @@ -204,24 +202,29 @@ class Renderer: bboxes = [] for line in lines: bboxes.append(self._render_single_line(line, footer)) + #print line, bboxes numlines = len(lines) bottom = self._rect.bottom() - for ratio in (numlines, numlines/2, numlines/3, numlines/4): - good = 1 - startline = 0 - endline = startline + ratio - while (endline <= numlines): - by = 0 - for (x, y) in bboxes[startline:endline]: - by += y - if by > bottom: - good=0 - break - startline += ratio - endline = startline+ratio - if good == 1: + #for ratio in (numlines): #, numlines/2, numlines/3, numlines/4): + ratio = numlines + good = 1 + startline = 0 + endline = startline + ratio + while (endline <= numlines): + by = 0 + for (x, y) in bboxes[startline:endline]: + by += y + #print by + #print by , bottom + if by > bottom: + good=0 break + startline += ratio + endline = startline+ratio +# if good == 1: +# break + #print "---------" retval = [] numlines_per_page = ratio diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 18c49e0f2..d31b4b3a0 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -63,6 +63,7 @@ class RenderManager: self.renderer = Renderer() self.calculate_default(self.screen_list[self.current_display]['size']) self.theme = u'' + self.service_theme = u'' def set_global_theme(self, global_theme, global_style = u'Global'): self.global_theme = global_theme @@ -83,11 +84,13 @@ class RenderManager: else: if theme is not None: self.theme = theme - elif self.global_style == u'Service': + elif self.global_style == u'Song' or self.global_style == u'Service': if self.service_theme == u'': self.theme = self.global_theme else: self.theme = self.service_theme + else: + self.theme = self.global_theme if self.theme is not self.renderer.theme_name: log.debug(u'theme is now %s', self.theme) @@ -117,7 +120,7 @@ class RenderManager: def generate_preview(self, themedata): log.debug(u'generate preview') - self.calculate_default(QtCore.QSize(800, 600)) + self.calculate_default(QtCore.QSize(1024, 768)) self.renderer.set_theme(themedata) self.build_text_rectangle(themedata) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index eb8ce751c..139f19fc7 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -19,10 +19,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA """ import logging import time -from openlp import buildIcon -from PyQt4.QtCore import * -from PyQt4.QtGui import * - +from openlp.core.lib import buildIcon +from PyQt4 import QtCore, QtGui class ServiceItem(): """ @@ -44,6 +42,8 @@ class ServiceItem(): self.items = [] self.iconic_representation = None self.raw_slides = None + self.frame_titles = [] + self.command_files = [] self.frames = [] self.raw_footer = None self.theme = None @@ -62,11 +62,14 @@ class ServiceItem(): else: self.render_manager.set_override_theme(self.theme) log.debug(u'Formatting slides') - if len(self.frames) == 0 : + if len(self.frames) == 0 and len(self.raw_slides) > 0 : for slide in self.raw_slides: formated = self.render_manager.format_slide(slide, False) frame = self.render_manager.generate_slide(formated, self.raw_footer) - self.frames.append({u'formatted': formated, u'image': frame}) + self.frames.append({u'title': formated, u'image': frame}) + else: + if len(self.command_files) > 0: + pass def get_parent_node(self): diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index 31063b28f..74e150369 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -22,7 +22,7 @@ from xml.etree.ElementTree import ElementTree, XML, dump For XML Schema see wiki.openlp.org """ import os, os.path -from openlp import convertStringToBoolean +from openlp.core.lib import str_to_bool from xml.dom.minidom import Document from xml.etree.ElementTree import ElementTree, XML, dump @@ -69,12 +69,14 @@ class ThemeXML(): # Create the minidom document self.theme_xml = Document() - def extend_filename(self, path): + def extend_image_filename(self, path): + """ + Add the path name to the image name so the background can be rendered. + """ if self.background_filename is not None: self.background_filename = os.path.join(path, self.theme_name, self.background_filename) def new_document(self, name): - # Create the base element self.theme = self.theme_xml.createElement(u'theme') self.theme_xml.appendChild(self.theme) self.theme.setAttribute(u'version', u'1.0') @@ -85,89 +87,92 @@ class ThemeXML(): self.theme.appendChild(self.name) def add_background_transparent(self): - # Create the main element + """ + Add a transparent background. + """ background = self.theme_xml.createElement(u'background') background.setAttribute(u'mode', u'transparent') self.theme.appendChild(background) def add_background_solid(self, bkcolor): + """ + Add a Solid background. + """ background = self.theme_xml.createElement(u'background') background.setAttribute(u'mode', u'opaque') background.setAttribute(u'type', u'solid') self.theme.appendChild(background) - color = self.theme_xml.createElement(u'color') - bkc = self.theme_xml.createTextNode(bkcolor) - color.appendChild(bkc) - background.appendChild(color) + self.child_element(background, u'color', bkcolor) def add_background_gradient(self, startcolor, endcolor, direction): + """ + Add a gradient background. + """ background = self.theme_xml.createElement(u'background') background.setAttribute(u'mode', u'opaque') background.setAttribute(u'type', u'gradient') self.theme.appendChild(background) - color = self.theme_xml.createElement(u'startColor') - bkc = self.theme_xml.createTextNode(startcolor) - color.appendChild(bkc) - background.appendChild(color) - - color = self.theme_xml.createElement(u'endColor') - bkc = self.theme_xml.createTextNode(endcolor) - color.appendChild(bkc) - background.appendChild(color) - - color = self.theme_xml.createElement(u'direction') - bkc = self.theme_xml.createTextNode(direction) - color.appendChild(bkc) - background.appendChild(color) + # Create startColor element + self.child_element(background, u'startColor', startcolor) + # Create endColor element + self.child_element(background, u'endColor', endcolor) + # Create direction element + self.child_element(background, u'direction', direction) def add_background_image(self, filename): + """ + Add a image background. + """ background = self.theme_xml.createElement(u'background') background.setAttribute(u'mode', u'opaque') background.setAttribute(u'type', u'image') self.theme.appendChild(background) - color = self.theme_xml.createElement(u'filename') - bkc = self.theme_xml.createCDATASection(filename) - color.appendChild(bkc) - background.appendChild(color) + #Create Filename element + self.child_element(background, u'filename', filename) def add_font(self, name, color, proportion, override, fonttype=u'main', xpos=0, ypos=0 ,width=0, height=0): + """ + Add a Font. + """ background = self.theme_xml.createElement(u'font') background.setAttribute(u'type',fonttype) self.theme.appendChild(background) - element = self.theme_xml.createElement(u'name') - fn = self.theme_xml.createTextNode(name) - element.appendChild(fn) - background.appendChild(element) + #Create Font name element + self.child_element(background, u'name', name) - element = self.theme_xml.createElement(u'color') - fn = self.theme_xml.createTextNode(color) - element.appendChild(fn) - background.appendChild(element) + #Create Font color element + self.child_element(background, u'color', color) - element = self.theme_xml.createElement(u'proportion') - fn = self.theme_xml.createTextNode(proportion) - element.appendChild(fn) - background.appendChild(element) + #Create Proportion name element + self.child_element(background, u'proportion', proportion) + #Create Proportion name element + self.child_element(background, u'proportion', proportion) + + #Create Location element element = self.theme_xml.createElement(u'location') element.setAttribute(u'override',override) if override == u'True': - element.setAttribute(u'x',xpos) - element.setAttribute(u'y',ypos) - element.setAttribute(u'width',width) - element.setAttribute(u'height',height) + element.setAttribute(u'x', xpos) + element.setAttribute(u'y', ypos) + element.setAttribute(u'width', width) + element.setAttribute(u'height', height) background.appendChild(element) def add_display(self, shadow, shadowColor, outline, outlineColor, horizontal, vertical, wrap): + """ + Add a Display options. + """ background = self.theme_xml.createElement(u'display') self.theme.appendChild(background) tagElement = self.theme_xml.createElement(u'shadow') + tagElement.setAttribute(u'color',shadowColor) tagValue = self.theme_xml.createTextNode(shadow) tagElement.appendChild(tagValue) @@ -194,15 +199,15 @@ class ThemeXML(): tagElement.appendChild(tagValue) background.appendChild(tagElement) - def child_element(self, tag, value): - tagElement = self.theme_xml.createElement(tag) - tagValue = self.theme_xml.createTextNode(value) - tagElement.appendChild(ftagValue) - self.background.appendChild(tagElement) + def child_element(self, element, tag, value): + child = self.theme_xml.createElement(tag) + child.appendChild(self.theme_xml.createTextNode(value)) + element.appendChild(child) + return child def dump_xml(self): # Debugging aid to see what we have - print self.theme_xml.toprettyxml(indent=" ") + print self.theme_xml.toprettyxml(indent=u' ') def extract_xml(self): # Print our newly created XML @@ -211,18 +216,19 @@ class ThemeXML(): def parse(self, xml): self.baseParseXml() self.parse_xml(xml) + self.theme_filename_extended = False def baseParseXml(self): self.parse_xml(blankthemexml) def parse_xml(self, xml): theme_xml = ElementTree(element=XML(xml)) - iter=theme_xml.getiterator() + iter = theme_xml.getiterator() master = u'' for element in iter: #print element.tag, element.text if len(element.getchildren()) > 0: - master= element.tag + u'_' + master = element.tag + u'_' if len(element.attrib) > 0: #print "D", element.tag , element.attrib for e in element.attrib.iteritems(): @@ -231,18 +237,18 @@ class ThemeXML(): master += e[1] + u'_' elif master == u'display_' and (element.tag == u'shadow' or element.tag == u'outline'): #print "b", master, element.tag, element.text, e[0], e[1] - et = convertStringToBoolean(element.text) + et = str_to_bool(element.text) setattr(self, master + element.tag , et) - setattr(self, master + element.tag +u'_'+ e[0], e[1]) + setattr(self, master + element.tag + u'_'+ e[0], e[1]) else: field = master + e[0] e1 = e[1] if e[1] == u'True' or e[1] == u'False': - e1 = convertStringToBoolean(e[1]) + e1 = str_to_bool(e[1]) setattr(self, field, e1) else: #print "c", element.tag, element.text - if element.tag is not None : + if element.tag is not None: field = master + element.tag setattr(self, field, element.text) @@ -250,5 +256,5 @@ class ThemeXML(): s = u'' for k in dir(self): if k[0:1] != u'_': - s+= u'%30s : %s\n' %(k,getattr(self,k)) + s += u'%30s : %s\n' %(k,getattr(self,k)) return s diff --git a/openlp/core/lib/xmlrootclass.py b/openlp/core/lib/xmlrootclass.py index 23fbe19ae..95c1dbe1f 100644 --- a/openlp/core/lib/xmlrootclass.py +++ b/openlp/core/lib/xmlrootclass.py @@ -22,13 +22,9 @@ import platform import sys import os from types import StringType, NoneType, UnicodeType -sys.path.append(os.path.abspath("./../..")) +sys.path.append(os.path.abspath(u'./../..')) -ver = platform.python_version() -if ver >= '2.5': - from xml.etree.ElementTree import ElementTree, XML -else: - from elementtree import ElementTree, XML +from xml.etree.ElementTree import ElementTree, XML class XmlRootClass(object): @@ -47,23 +43,27 @@ class XmlRootClass(object): xml (string) -- formatted as xml tags and values rootTag -- main tag of the xml """ - root=ElementTree(element=XML(xml)) - iter=root.getiterator() + root = ElementTree(element=XML(xml)) + iter = root.getiterator() for element in iter: if element.tag != rootTag: - t=element.text + t = element.text #print element.tag, t, type(t) - if type(t) == NoneType: # easy! + if type(t) == NoneType: + # easy! val=t elif type(t) == UnicodeType : val=t - elif type(t) == StringType: # strings need special handling to sort the colours out + elif type(t) == StringType: + # strings need special handling to sort the colours out #print "str", - if t[0] == "$": # might be a hex number + if t[0] == '$': + # might be a hex number #print "hex", try: - val=int(t[1:], 16) - except ValueError: # nope + val = int(t[1:], 16) + except ValueError: + # nope #print "nope", pass else: @@ -74,9 +74,9 @@ class XmlRootClass(object): except ValueError: #print "give up", val=t - if hasattr(self, "post_tag_hook"): + if hasattr(self, u'post_tag_hook'): (element.tag, val) = self.post_tag_hook(element.tag, val) - setattr(self,element.tag, val) + setattr(self, element.tag, val) pass def __str__(self): @@ -88,15 +88,15 @@ class XmlRootClass(object): """ l = [] for k in dir(self): - if not k.startswith("_"): - l.append("%30s : %s" %(k,getattr(self,k))) - return "\n".join(l) + if not k.startswith(u'_'): + l.append(u'%30s : %s' %(k,getattr(self,k))) + return u'\n'.join(l) def _get_as_string(self): """Return one string with all public attributes""" s="" for k in dir(self): - if not k.startswith("_"): - s+= "_%s_" %(getattr(self,k)) + if not k.startswith(u'_'): + s+= u'_%s_' %(getattr(self,k)) return s diff --git a/openlp/core/ui/about.py b/openlp/core/ui/about.py index b92c41468..9135b148c 100644 --- a/openlp/core/ui/about.py +++ b/openlp/core/ui/about.py @@ -19,135 +19,129 @@ Place, Suite 330, Boston, MA 02111-1307 USA """ from PyQt4 import QtCore, QtGui -from PyQt4.QtGui import QDialog -from openlp.core import translate -from openlp.core.resources import * +from openlp.core.lib import translate -class AboutForm(QDialog): +class AboutForm(QtGui.QDialog): def __init__(self, parent=None): - QDialog.__init__(self, parent) + QtGui.QDialog.__init__(self, parent) self.setupUi(self) def setupUi(self, AboutForm): - AboutForm.setObjectName("AboutForm") + AboutForm.setObjectName(u'AboutForm') AboutForm.resize(470, 481) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(":/icon/openlp-logo-16x16.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(u':/icon/openlp-logo-16x16.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) AboutForm.setWindowIcon(icon) AboutFormLayout = QtGui.QVBoxLayout(AboutForm) AboutFormLayout.setSpacing(8) AboutFormLayout.setMargin(8) - AboutFormLayout.setObjectName("AboutDialogLayout") + AboutFormLayout.setObjectName(u'AboutDialogLayout') self.Logo = QtGui.QLabel(AboutForm) self.Logo.setAutoFillBackground(False) - self.Logo.setStyleSheet("background-color: rgb(255, 255, 255);") + self.Logo.setStyleSheet(u'background-color: rgb(255, 255, 255);') self.Logo.setFrameShape(QtGui.QFrame.StyledPanel) self.Logo.setLineWidth(1) - self.Logo.setPixmap(QtGui.QPixmap(":/graphics/openlp-about-logo.png")) + self.Logo.setPixmap(QtGui.QPixmap(u':/graphics/openlp-about-logo.png')) self.Logo.setScaledContents(False) self.Logo.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) - self.Logo.setObjectName("Logo") + self.Logo.setObjectName(u'Logo') AboutFormLayout.addWidget(self.Logo) self.AboutNotebook = QtGui.QTabWidget(AboutForm) - self.AboutNotebook.setObjectName("AboutNotebook") + self.AboutNotebook.setObjectName(u'AboutNotebook') self.LicenseTab = QtGui.QWidget() - self.LicenseTab.setObjectName("LicenseTab") + self.LicenseTab.setObjectName(u'LicenseTab') self.LicenseTabLayout = QtGui.QVBoxLayout(self.LicenseTab) self.LicenseTabLayout.setSpacing(8) self.LicenseTabLayout.setMargin(8) - self.LicenseTabLayout.setObjectName("LicenseTabLayout") + self.LicenseTabLayout.setObjectName(u'LicenseTabLayout') self.CopyrightLabel = QtGui.QLabel(self.LicenseTab) - self.CopyrightLabel.setObjectName("CopyrightLabel") + self.CopyrightLabel.setObjectName(u'CopyrightLabel') self.LicenseTabLayout.addWidget(self.CopyrightLabel) self.AboutAuthors = QtGui.QLabel(self.LicenseTab) self.AboutAuthors.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter) self.AboutAuthors.setWordWrap(True) - self.AboutAuthors.setObjectName("AboutAuthors") + self.AboutAuthors.setObjectName(u'AboutAuthors') self.LicenseTabLayout.addWidget(self.AboutAuthors) self.License1Label = QtGui.QLabel(self.LicenseTab) self.License1Label.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter) self.License1Label.setWordWrap(True) - self.License1Label.setObjectName("License1Label") + self.License1Label.setObjectName(u'License1Label') self.LicenseTabLayout.addWidget(self.License1Label) self.License2Label = QtGui.QLabel(self.LicenseTab) self.License2Label.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter) self.License2Label.setWordWrap(True) - self.License2Label.setObjectName("License2Label") + self.License2Label.setObjectName(u'License2Label') self.LicenseTabLayout.addWidget(self.License2Label) self.License3Label = QtGui.QLabel(self.LicenseTab) self.License3Label.setAlignment(QtCore.Qt.AlignJustify|QtCore.Qt.AlignVCenter) self.License3Label.setWordWrap(True) - self.License3Label.setObjectName("License3Label") + self.License3Label.setObjectName(u'License3Label') self.LicenseTabLayout.addWidget(self.License3Label) - self.AboutNotebook.addTab(self.LicenseTab, "License") + self.AboutNotebook.addTab(self.LicenseTab, u'License') self.CreditsTab = QtGui.QWidget() - self.CreditsTab.setObjectName("CreditsTab") + self.CreditsTab.setObjectName(u'CreditsTab') self.CreditsTabLayout = QtGui.QVBoxLayout(self.CreditsTab) self.CreditsTabLayout.setSpacing(0) # self.CreditsTabLayout.setMargin(8) # - self.CreditsTabLayout.setObjectName("CreditsTabLayout") + self.CreditsTabLayout.setObjectName(u'CreditsTabLayout') self.CreditsTextEdit = QtGui.QTextEdit(self.CreditsTab) self.CreditsTextEdit.setReadOnly(True) - self.CreditsTextEdit.setObjectName("CreditsTextEdit") + self.CreditsTextEdit.setObjectName(u'CreditsTextEdit') self.CreditsTabLayout.addWidget(self.CreditsTextEdit) - self.AboutNotebook.addTab(self.CreditsTab, "Credits") + self.AboutNotebook.addTab(self.CreditsTab, u'Credits') AboutFormLayout.addWidget(self.AboutNotebook) self.ButtonWidget = QtGui.QWidget(AboutForm) - self.ButtonWidget.setObjectName("ButtonWidget") + self.ButtonWidget.setObjectName(u'ButtonWidget') self.ButtonWidgetLayout = QtGui.QHBoxLayout(self.ButtonWidget) self.ButtonWidgetLayout.setSpacing(8) self.ButtonWidgetLayout.setMargin(0) - self.ButtonWidgetLayout.setObjectName("ButtonWidgetLayout") + self.ButtonWidgetLayout.setObjectName(u'ButtonWidgetLayout') spacerItem = QtGui.QSpacerItem(275, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.ButtonWidgetLayout.addItem(spacerItem) self.ContributeButton = QtGui.QPushButton(self.ButtonWidget) - self.ContributeButton.setObjectName("ContributeButton") + self.ContributeButton.setObjectName(u'ContributeButton') self.ButtonWidgetLayout.addWidget(self.ContributeButton) self.CloseButton = QtGui.QPushButton(self.ButtonWidget) - self.CloseButton.setObjectName("CloseButton") + self.CloseButton.setObjectName(u'CloseButton') self.ButtonWidgetLayout.addWidget(self.CloseButton) AboutFormLayout.addWidget(self.ButtonWidget) self.extContributeItem = QtGui.QAction(AboutForm) - self.extContributeItem.setObjectName("extContributeItem") + self.extContributeItem.setObjectName(u'extContributeItem') self.retranslateUi(AboutForm) self.AboutNotebook.setCurrentIndex(0) - QtCore.QObject.connect(self.CloseButton, QtCore.SIGNAL("clicked()"), AboutForm.close) + QtCore.QObject.connect(self.CloseButton, QtCore.SIGNAL(u'clicked()'), AboutForm.close) QtCore.QMetaObject.connectSlotsByName(AboutForm) - QtCore.QObject.connect(self.ContributeButton, QtCore.SIGNAL("clicked()"), self.onContributeButtonClicked) + QtCore.QObject.connect(self.ContributeButton, QtCore.SIGNAL(u'clicked()'), self.onContributeButtonClicked) def retranslateUi(self, AboutForm): - AboutForm.setWindowTitle(translate("AboutDialog", "About openlp.org",)) - self.CopyrightLabel.setText(translate("AboutDialog", "Copyright © 2004-2009 openlp.org Foundation")) - self.AboutAuthors.setText(translate("AboutDialog", "openlp.org is written and maintained by volunteers. If you would like to see more free Christian software being written, please consider contributing by using the button below.")) - self.License1Label.setText(translate("AboutDialog", "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; either version 2 of the License, or (at your option) any later version.")) - self.License2Label.setText(translate("AboutDialog", "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.")) - self.License3Label.setText(translate("AboutDialog", "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.")) - self.AboutNotebook.setTabText(self.AboutNotebook.indexOf(self.LicenseTab), QtGui.QApplication.translate("AboutDialog", "License", None, QtGui.QApplication.UnicodeUTF8)) - self.CreditsTextEdit.setPlainText(translate("AboutDialog", "Project Lead\n" -" Raoul \"superfly\" Snyman\n" -"\n" -"Developers\n" -" Tim \"TRB143\" Bentley\n" -" Jonathan \"gushie\" Corwin\n" -" Scott \"sguerrieri\" Guerrieri\n" -" Raoul \"superfly\" Snyman\n" -" Martin \"mijiti\" Thompson\n" -" Carsten \"catini\" Tingaard")) - self.AboutNotebook.setTabText(self.AboutNotebook.indexOf(self.CreditsTab), translate("AboutDialog", "Credits")) - self.ContributeButton.setText(translate("AboutDialog", "Contribute")) - self.CloseButton.setText(translate("AboutDialog", "Close")) - self.extContributeItem.setText(translate("AboutDialog", "&Contribute")) + AboutForm.setWindowTitle(translate(u'AboutDialog', u'About openlp.org',)) + self.CopyrightLabel.setText(translate(u'AboutDialog', u'Copyright © 2004-2009 openlp.org Foundation')) + self.AboutAuthors.setText(translate(u'AboutDialog', u'openlp.org is written and maintained by volunteers. If you would like to see more free Christian software being written, please consider contributing by using the button below.')) + self.License1Label.setText(translate(u'AboutDialog', u'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; either version 2 of the License, or (at your option) any later version.')) + self.License2Label.setText(translate(u'AboutDialog', u'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.')) + self.License3Label.setText(translate(u'AboutDialog', u'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.')) + self.AboutNotebook.setTabText(self.AboutNotebook.indexOf(self.LicenseTab), translate(u'AboutDialog', u'License')) + self.CreditsTextEdit.setPlainText(translate(u'AboutDialog', + u'Project Lead\n' + u' Raoul \"superfly\" Snyman\n' + u'\n' + u'Developers\n' + u' Tim \"TRB143\" Bentley\n' + u' Jonathan \"gushie\" Corwin\n' + u' Scott \"sguerrieri\" Guerrieri\n' + u' Raoul \"superfly\" Snyman\n' + u' Martin \"mijiti\" Thompson\n' + u' Carsten \"catini\" Tingaard')) + self.AboutNotebook.setTabText(self.AboutNotebook.indexOf(self.CreditsTab), translate(u'AboutDialog', u'Credits')) + self.ContributeButton.setText(translate(u'AboutDialog', u'Contribute')) + self.CloseButton.setText(translate(u'AboutDialog', u'Close')) + self.extContributeItem.setText(translate(u'AboutDialog', u'&Contribute')) def onContributeButtonClicked(self): - ''' This routine will open the default - web-browser to the contribute page - of openlp.org as did the original - button on the About form - ''' import webbrowser url = "http://www.openlp.org/en/documentation/introduction/contributing.html" webbrowser.open_new(url) diff --git a/openlp/core/ui/alertform.py b/openlp/core/ui/alertform.py index 5bf8c9af8..3f0633a19 100644 --- a/openlp/core/ui/alertform.py +++ b/openlp/core/ui/alertform.py @@ -19,17 +19,14 @@ Place, Suite 330, Boston, MA 02111-1307 USA """ import logging from PyQt4 import QtCore, QtGui -from PyQt4.QtGui import QDialog +from openlp.core.lib import translate -from openlp.core import translate -from openlp.core.resources import * - -class AlertForm(QDialog): +class AlertForm(QtGui.QDialog): global log log=logging.getLogger(u'AlertForm') def __init__(self, parent=None): - QDialog.__init__(self, parent) + QtGui.QDialog.__init__(self, parent) self.setupUi(self) log.info(u'Defined') diff --git a/openlp/core/ui/alertstab.py b/openlp/core/ui/alertstab.py index 5fe34d67d..883ebc966 100644 --- a/openlp/core/ui/alertstab.py +++ b/openlp/core/ui/alertstab.py @@ -19,11 +19,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA """ from PyQt4 import QtCore, QtGui -from PyQt4.QtGui import QColor, QFont -from openlp.core import translate -from openlp.core.lib import SettingsTab -from openlp.core.resources import * +from openlp.core.lib import SettingsTab, translate class AlertsTab(SettingsTab): """ @@ -175,7 +172,7 @@ class AlertsTab(SettingsTab): self.timeout = int(self.config.get_config('timeout', 5)) self.font_color = str(self.config.get_config('font color', u'#ffffff')) self.bg_color = str(self.config.get_config('background color', u'#660000')) - self.font_face = str(self.config.get_config('font face', QFont().family())) + self.font_face = str(self.config.get_config('font face', QtGui.QFont().family())) self.TimeoutSpinBox.setValue(self.timeout) self.FontColorButton.setStyleSheet('background-color: %s' % self.font_color) self.BackgroundColorButton.setStyleSheet('background-color: %s' % self.bg_color) @@ -192,7 +189,7 @@ class AlertsTab(SettingsTab): self.config.set_config('timeout', str(self.timeout)) def updateDisplay(self): - font = QFont() + font = QtGui.QFont() font.setFamily(self.FontComboBox.currentFont().family()) font.setBold(True) font.setPointSize(16) diff --git a/openlp/core/ui/amendthemedialog.py b/openlp/core/ui/amendthemedialog.py index 819324eb0..3a352a5d2 100644 --- a/openlp/core/ui/amendthemedialog.py +++ b/openlp/core/ui/amendthemedialog.py @@ -456,7 +456,7 @@ class Ui_AmendThemeDialog(object): self.ThemePreviewLayout.setSpacing(8) self.ThemePreviewLayout.setMargin(8) self.ThemePreviewLayout.setObjectName("ThemePreviewLayout") - spacerItem7 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + spacerItem7 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.ThemePreviewLayout.addItem(spacerItem7) self.ThemePreview = QtGui.QLabel(self.PreviewGroupBox) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) @@ -464,14 +464,14 @@ class Ui_AmendThemeDialog(object): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.ThemePreview.sizePolicy().hasHeightForWidth()) self.ThemePreview.setSizePolicy(sizePolicy) - self.ThemePreview.setMinimumSize(QtCore.QSize(300, 225)) + self.ThemePreview.setMaximumSize(QtCore.QSize(300, 225)) self.ThemePreview.setFrameShape(QtGui.QFrame.WinPanel) self.ThemePreview.setFrameShadow(QtGui.QFrame.Sunken) self.ThemePreview.setLineWidth(1) self.ThemePreview.setScaledContents(True) self.ThemePreview.setObjectName("ThemePreview") self.ThemePreviewLayout.addWidget(self.ThemePreview) - spacerItem8 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + spacerItem8 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.ThemePreviewLayout.addItem(spacerItem8) self.AmendThemeLayout.addWidget(self.PreviewGroupBox) self.ThemeButtonBox = QtGui.QDialogButtonBox(AmendThemeDialog) @@ -517,7 +517,7 @@ class Ui_AmendThemeDialog(object): AmendThemeDialog.setTabOrder(self.HorizontalComboBox, self.VerticalComboBox) def retranslateUi(self, AmendThemeDialog): - AmendThemeDialog.setWindowTitle(QtGui.QApplication.translate("AmendThemeDialog", "Theme Maintance", None, QtGui.QApplication.UnicodeUTF8)) + AmendThemeDialog.setWindowTitle(QtGui.QApplication.translate("AmendThemeDialog", "Theme Maintenance", None, QtGui.QApplication.UnicodeUTF8)) self.ThemeNameLabel.setText(QtGui.QApplication.translate("AmendThemeDialog", "Theme Name:", None, QtGui.QApplication.UnicodeUTF8)) self.BackgroundLabel.setText(QtGui.QApplication.translate("AmendThemeDialog", "Background:", None, QtGui.QApplication.UnicodeUTF8)) self.BackgroundComboBox.setItemText(0, QtGui.QApplication.translate("AmendThemeDialog", "Opaque", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 733e4281a..9f096f197 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -21,9 +21,7 @@ import logging import os, os.path from PyQt4 import QtCore, QtGui -from PyQt4.QtGui import QColor, QFont -from openlp.core.lib import ThemeXML, Renderer -from openlp.core import fileToXML, translate +from openlp.core.lib import ThemeXML, Renderer, file_to_xml, translate from amendthemedialog import Ui_AmendThemeDialog @@ -34,7 +32,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def __init__(self, thememanager, parent=None): QtGui.QDialog.__init__(self, parent) self.thememanager = thememanager - self.theme = ThemeXML() # Needed here as UI setup generates Events + # Needed here as UI setup generates Events + self.path = None + self.theme = ThemeXML() self.setupUi(self) #define signals @@ -113,15 +113,15 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: (path, filename) =os.path.split(str(self.theme.background_filename)) new_theme.add_background_image(filename) - save_to= os.path.join(self.path, theme_name,filename ) + save_to= os.path.join(self.path, theme_name, filename ) save_from = self.theme.background_filename new_theme.add_font(str(self.theme.font_main_name), str(self.theme.font_main_color), - str(self.theme.font_main_proportion), str(self.theme.font_main_override),u'main', + str(self.theme.font_main_proportion), str(self.theme.font_main_override), u'main', str(self.theme.font_main_x), str(self.theme.font_main_y), str(self.theme.font_main_width), str(self.theme.font_main_height)) new_theme.add_font(str(self.theme.font_footer_name), str(self.theme.font_footer_color), - str(self.theme.font_footer_proportion), str(self.theme.font_footer_override),u'footer', + str(self.theme.font_footer_proportion), str(self.theme.font_footer_override), u'footer', str(self.theme.font_footer_x), str(self.theme.font_footer_y), str(self.theme.font_footer_width), str(self.theme.font_footer_height) ) new_theme.add_display(str(self.theme.display_shadow), str(self.theme.display_shadow_color), @@ -134,17 +134,15 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.thememanager.saveTheme(theme_name, theme, save_from, save_to) return QtGui.QDialog.accept(self) - def themePath(self, path): - self.path = path - def loadTheme(self, theme): - log.debug(u'LoadTheme %s ', theme) + log.debug(u'LoadTheme %s', theme) if theme == None: self.theme.parse(self.baseTheme()) else: - xml_file = os.path.join(self.path, theme, theme+u'.xml') - xml = fileToXML(xml_file) + xml_file = os.path.join(self.path, theme, theme + u'.xml') + xml = file_to_xml(xml_file) self.theme.parse(xml) + self.theme.extend_image_filename(self.path) self.allowPreview = False self.paintUi(self.theme) self.allowPreview = True @@ -165,10 +163,10 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onFontMainColorPushButtonClicked(self): self.theme.font_main_color = QtGui.QColorDialog.getColor( - QColor(self.theme.font_main_color), self).name() + QtGui.QColor(self.theme.font_main_color), self).name() self.FontMainColorPushButton.setStyleSheet( - 'background-color: %s' % str(self.theme.font_main_color)) + u'background-color: %s' % str(self.theme.font_main_color)) self.previewTheme(self.theme) def onFontMainSizeSpinBoxChanged(self, value): @@ -218,7 +216,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onFontFooterColorPushButtonClicked(self): self.theme.font_footer_color = QtGui.QColorDialog.getColor( - QColor(self.theme.font_footer_color), self).name() + QtGui.QColor(self.theme.font_footer_color), self).name() self.FontFooterColorPushButton.setStyleSheet( 'background-color: %s' % str(self.theme.font_footer_color)) @@ -307,22 +305,22 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onColor1PushButtonClicked(self): if self.theme.background_type == u'solid': self.theme.background_color = QtGui.QColorDialog.getColor( - QColor(self.theme.background_color), self).name() + QtGui.QColor(self.theme.background_color), self).name() self.Color1PushButton.setStyleSheet( - 'background-color: %s' % str(self.theme.background_color)) + u'background-color: %s' % str(self.theme.background_color)) else: self.theme.background_startColor = QtGui.QColorDialog.getColor( - QColor(self.theme.background_startColor), self).name() + QtGui.QColor(self.theme.background_startColor), self).name() self.Color1PushButton.setStyleSheet( - 'background-color: %s' % str(self.theme.background_startColor)) + u'background-color: %s' % str(self.theme.background_startColor)) self.previewTheme(self.theme) def onColor2PushButtonClicked(self): self.theme.background_endColor = QtGui.QColorDialog.getColor( - QColor(self.theme.background_endColor), self).name() + QtGui.QColor(self.theme.background_endColor), self).name() self.Color2PushButton.setStyleSheet( - 'background-color: %s' % str(self.theme.background_endColor)) + u'background-color: %s' % str(self.theme.background_endColor)) self.previewTheme(self.theme) # @@ -338,9 +336,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onOutlineColorPushButtonClicked(self): self.theme.display_outline_color = QtGui.QColorDialog.getColor( - QColor(self.theme.display_outline_color), self).name() + QtGui.QColor(self.theme.display_outline_color), self).name() self.OutlineColorPushButton.setStyleSheet( - 'background-color: %s' % str(self.theme.display_outline_color)) + u'background-color: %s' % str(self.theme.display_outline_color)) self.previewTheme(self.theme) def onShadowCheckBoxChanged(self, value): @@ -353,9 +351,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onShadowColorPushButtonClicked(self): self.theme.display_shadow_color = QtGui.QColorDialog.getColor( - QColor(self.theme.display_shadow_color), self).name() + QtGui.QColor(self.theme.display_shadow_color), self).name() self.ShadowColorPushButton.setStyleSheet( - 'background-color: %s' % str(self.theme.display_shadow_color)) + u'background-color: %s' % str(self.theme.display_shadow_color)) self.previewTheme(self.theme) def onHorizontalComboBoxSelected(self, currentIndex): @@ -375,8 +373,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): newtheme = ThemeXML() newtheme.new_document(u'New Theme') newtheme.add_background_solid(str(u'#000000')) - newtheme.add_font(str(QFont().family()), str(u'#FFFFFF'), str(30), u'False') - newtheme.add_font(str(QFont().family()), str(u'#FFFFFF'), str(12), u'False', u'footer') + newtheme.add_font(str(QtGui.QFont().family()), str(u'#FFFFFF'), str(30), u'False') + newtheme.add_font(str(QtGui.QFont().family()), str(u'#FFFFFF'), str(12), u'False', u'footer') newtheme.add_display(u'False', str(u'#FFFFFF'), u'False', str(u'#FFFFFF'), str(0), str(0), str(0)) @@ -415,9 +413,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.FontFooterWidthSpinBox.setValue(int(self.theme.font_footer_width)) self.FontFooterHeightSpinBox.setValue(int(self.theme.font_footer_height)) self.FontMainColorPushButton.setStyleSheet( - 'background-color: %s' % str(theme.font_main_color)) + u'background-color: %s' % str(theme.font_main_color)) self.FontFooterColorPushButton.setStyleSheet( - 'background-color: %s' % str(theme.font_footer_color)) + u'background-color: %s' % str(theme.font_footer_color)) if self.theme.font_main_override == False: self.FontMainDefaultCheckBox.setChecked(True) @@ -430,9 +428,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.FontFooterDefaultCheckBox.setChecked(False) self.OutlineColorPushButton.setStyleSheet( - 'background-color: %s' % str(theme.display_outline_color)) + u'background-color: %s' % str(theme.display_outline_color)) self.ShadowColorPushButton.setStyleSheet( - 'background-color: %s' % str(theme.display_shadow_color)) + u'background-color: %s' % str(theme.display_shadow_color)) if self.theme.display_outline: self.OutlineCheckBox.setChecked(True) @@ -454,7 +452,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def stateChanging(self, theme): if theme.background_type == u'solid': self.Color1PushButton.setStyleSheet( - 'background-color: %s' % str(theme.background_color)) + u'background-color: %s' % str(theme.background_color)) self.Color1Label.setText(translate(u'ThemeManager', u'Background Color:')) self.Color1Label.setVisible(True) self.Color1PushButton.setVisible(True) @@ -467,9 +465,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.GradientComboBox.setVisible(False) elif theme.background_type == u'gradient': self.Color1PushButton.setStyleSheet( - 'background-color: %s' % str(theme.background_startColor)) + u'background-color: %s' % str(theme.background_startColor)) self.Color2PushButton.setStyleSheet( - 'background-color: %s' % str(theme.background_endColor)) + u'background-color: %s' % str(theme.background_endColor)) self.Color1Label.setText(translate(u'ThemeManager', u'First Color:')) self.Color2Label.setText(translate(u'ThemeManager', u'Second Color:')) self.Color1Label.setVisible(True) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index f2c574bd5..c04d9ecb9 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -20,9 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import QtCore, QtGui -from openlp.core import translate -from openlp.core.lib import SettingsTab -from openlp.core.resources import * +from openlp.core.lib import SettingsTab, translate class GeneralTab(SettingsTab): """ diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 9f00921c7..0e44b00d2 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import QtCore, QtGui -from openlp.core import translate +from openlp.core.lib import translate class MainDisplay(QtGui.QWidget): diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 3a85922f4..62f855f71 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -21,29 +21,28 @@ import os import logging from time import sleep -from PyQt4 import * from PyQt4 import QtCore, QtGui from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \ SlideController, ServiceManager, ThemeManager, MainDisplay -from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab, EventManager, RenderManager +from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab, EventManager, RenderManager, translate -from openlp.core import PluginManager, translate +from openlp.core import PluginManager class MainWindow(object): global log - log=logging.getLogger(u'MainWindow') + log = logging.getLogger(u'MainWindow') log.info(u'MainWindow loaded') def __init__(self, screens): - self.main_window = QtGui.QMainWindow() - self.main_window.__class__.closeEvent = self.onCloseEvent - self.main_display = MainDisplay(None, screens) - self.screen_list = screens + self.mainWindow = QtGui.QMainWindow() + self.mainWindow.__class__.closeEvent = self.onCloseEvent + self.mainDisplay = MainDisplay(None, screens) + self.screenList = screens self.EventManager = EventManager() - self.alert_form = AlertForm() - self.about_form = AboutForm() - self.settings_form = SettingsForm(self.screen_list, self) + self.alertForm = AlertForm() + self.aboutForm = AboutForm() + self.settingsForm = SettingsForm(self.screenList, self) pluginpath = os.path.split(os.path.abspath(__file__))[0] pluginpath = os.path.abspath(os.path.join(pluginpath, u'..', u'..', u'plugins')) @@ -55,7 +54,7 @@ class MainWindow(object): #warning cyclic dependency #RenderManager needs to call ThemeManager and #ThemeManager needs to call RenderManager - self.RenderManager = RenderManager(self.ThemeManagerContents, self.screen_list) + self.RenderManager = RenderManager(self.ThemeManagerContents, self.screenList) log.info(u'Load Plugins') self.plugin_helpers[u'preview'] = self.PreviewController @@ -75,7 +74,7 @@ class MainWindow(object): # Find and insert settings tabs log.info(u'hook settings') - self.plugin_manager.hook_settings_tabs(self.settings_form) + self.plugin_manager.hook_settings_tabs(self.settingsForm) # Call the hook method to pull in import menus. log.info(u'hook menus') @@ -107,29 +106,29 @@ class MainWindow(object): # Initialise SlideControllers log.info(u'Set Up SlideControllers') - self.LiveController.mainDisplay = self.main_display + self.LiveController.mainDisplay = self.mainDisplay def onCloseEvent(self, event): """ Hook to close the main window and display windows on exit """ - self.main_display.close() + self.mainDisplay.close() event.accept() def setupUi(self): - self.main_window.setObjectName(u'main_window') - self.main_window.resize(1087, 847) + self.mainWindow.setObjectName(u'mainWindow') + self.mainWindow.resize(1087, 847) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.main_window.sizePolicy().hasHeightForWidth()) - self.main_window.setSizePolicy(sizePolicy) + sizePolicy.setHeightForWidth(self.mainWindow.sizePolicy().hasHeightForWidth()) + self.mainWindow.setSizePolicy(sizePolicy) main_icon = QtGui.QIcon() main_icon.addPixmap(QtGui.QPixmap(u':/icon/openlp-logo-16x16.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.main_window.setWindowIcon(main_icon) - self.MainContent = QtGui.QWidget(self.main_window) + self.mainWindow.setWindowIcon(main_icon) + self.MainContent = QtGui.QWidget(self.mainWindow) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -140,14 +139,14 @@ class MainWindow(object): self.MainContentLayout.setSpacing(0) self.MainContentLayout.setMargin(0) self.MainContentLayout.setObjectName(u'MainContentLayout') - self.main_window.setCentralWidget(self.MainContent) + self.mainWindow.setCentralWidget(self.MainContent) self.ControlSplitter = QtGui.QSplitter(self.MainContent) self.ControlSplitter.setOrientation(QtCore.Qt.Horizontal) self.ControlSplitter.setObjectName(u'ControlSplitter') self.MainContentLayout.addWidget(self.ControlSplitter) self.PreviewController = SlideController(self.ControlSplitter, False) self.LiveController = SlideController(self.ControlSplitter, True) - self.MenuBar = QtGui.QMenuBar(self.main_window) + self.MenuBar = QtGui.QMenuBar(self.mainWindow) self.MenuBar.setGeometry(QtCore.QRect(0, 0, 1087, 27)) self.MenuBar.setObjectName(u'MenuBar') self.FileMenu = QtGui.QMenu(self.MenuBar) @@ -169,11 +168,11 @@ class MainWindow(object): self.ToolsMenu.setObjectName(u'ToolsMenu') self.HelpMenu = QtGui.QMenu(self.MenuBar) self.HelpMenu.setObjectName(u'HelpMenu') - self.main_window.setMenuBar(self.MenuBar) - self.StatusBar = QtGui.QStatusBar(self.main_window) + self.mainWindow.setMenuBar(self.MenuBar) + self.StatusBar = QtGui.QStatusBar(self.mainWindow) self.StatusBar.setObjectName(u'StatusBar') - self.main_window.setStatusBar(self.StatusBar) - self.MediaManagerDock = QtGui.QDockWidget(self.main_window) + self.mainWindow.setStatusBar(self.StatusBar) + self.MediaManagerDock = QtGui.QDockWidget(self.mainWindow) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) @@ -202,9 +201,9 @@ class MainWindow(object): self.MediaManagerLayout.addWidget(self.MediaToolBox) self.MediaManagerDock.setWidget(self.MediaManagerContents) - self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock) + self.mainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock) #Sevice Manager Defined - self.ServiceManagerDock = QtGui.QDockWidget(self.main_window) + self.ServiceManagerDock = QtGui.QDockWidget(self.mainWindow) ServiceManagerIcon = QtGui.QIcon() ServiceManagerIcon.addPixmap(QtGui.QPixmap(u':/system/system_servicemanager.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) @@ -213,9 +212,9 @@ class MainWindow(object): self.ServiceManagerDock.setObjectName(u'ServiceManagerDock') self.ServiceManagerContents = ServiceManager(self) self.ServiceManagerDock.setWidget(self.ServiceManagerContents) - self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ServiceManagerDock) + self.mainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ServiceManagerDock) #Theme Manager Defined - self.ThemeManagerDock = QtGui.QDockWidget(self.main_window) + self.ThemeManagerDock = QtGui.QDockWidget(self.mainWindow) ThemeManagerIcon = QtGui.QIcon() ThemeManagerIcon.addPixmap(QtGui.QPixmap(u':/system/system_thememanager.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) @@ -226,96 +225,96 @@ class MainWindow(object): self.ThemeManagerContents = ThemeManager(self) self.ThemeManagerDock.setWidget(self.ThemeManagerContents) - self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ThemeManagerDock) + self.mainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ThemeManagerDock) - self.FileNewItem = QtGui.QAction(self.main_window) + self.FileNewItem = QtGui.QAction(self.mainWindow) self.FileNewItem.setIcon( self.ServiceManagerContents.Toolbar.getIconFromTitle(u'New Service')) self.FileNewItem.setObjectName(u'FileNewItem') - self.FileOpenItem = QtGui.QAction(self.main_window) + self.FileOpenItem = QtGui.QAction(self.mainWindow) self.FileOpenItem.setIcon( self.ServiceManagerContents.Toolbar.getIconFromTitle(u'Open Service')) self.FileOpenItem.setObjectName(u'FileOpenItem') - self.FileSaveItem = QtGui.QAction(self.main_window) + self.FileSaveItem = QtGui.QAction(self.mainWindow) self.FileSaveItem.setIcon( self.ServiceManagerContents.Toolbar.getIconFromTitle(u'Save Service')) self.FileSaveItem.setObjectName(u'FileSaveItem') - self.FileSaveAsItem = QtGui.QAction(self.main_window) + self.FileSaveAsItem = QtGui.QAction(self.mainWindow) self.FileSaveAsItem.setObjectName(u'FileSaveAsItem') - self.FileExitItem = QtGui.QAction(self.main_window) + self.FileExitItem = QtGui.QAction(self.mainWindow) ExitIcon = QtGui.QIcon() ExitIcon.addPixmap(QtGui.QPixmap(u':/system/system_exit.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.FileExitItem.setIcon(ExitIcon) self.FileExitItem.setObjectName(u'FileExitItem') - self.ImportThemeItem = QtGui.QAction(self.main_window) + self.ImportThemeItem = QtGui.QAction(self.mainWindow) self.ImportThemeItem.setObjectName(u'ImportThemeItem') - self.ImportLanguageItem = QtGui.QAction(self.main_window) + self.ImportLanguageItem = QtGui.QAction(self.mainWindow) self.ImportLanguageItem.setObjectName(u'ImportLanguageItem') - self.ExportThemeItem = QtGui.QAction(self.main_window) + self.ExportThemeItem = QtGui.QAction(self.mainWindow) self.ExportThemeItem.setObjectName(u'ExportThemeItem') - self.ExportLanguageItem = QtGui.QAction(self.main_window) + self.ExportLanguageItem = QtGui.QAction(self.mainWindow) self.ExportLanguageItem.setObjectName(u'ExportLanguageItem') - self.actionLook_Feel = QtGui.QAction(self.main_window) + self.actionLook_Feel = QtGui.QAction(self.mainWindow) self.actionLook_Feel.setObjectName(u'actionLook_Feel') - self.OptionsSettingsItem = QtGui.QAction(self.main_window) + self.OptionsSettingsItem = QtGui.QAction(self.mainWindow) SettingsIcon = QtGui.QIcon() SettingsIcon.addPixmap(QtGui.QPixmap(u':/system/system_settings.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.OptionsSettingsItem.setIcon(SettingsIcon) self.OptionsSettingsItem.setObjectName(u'OptionsSettingsItem') - self.ViewMediaManagerItem = QtGui.QAction(self.main_window) + self.ViewMediaManagerItem = QtGui.QAction(self.mainWindow) self.ViewMediaManagerItem.setCheckable(True) self.ViewMediaManagerItem.setChecked(True) self.ViewMediaManagerItem.setIcon(icon) self.ViewMediaManagerItem.setObjectName(u'ViewMediaManagerItem') - self.ViewThemeManagerItem = QtGui.QAction(self.main_window) + self.ViewThemeManagerItem = QtGui.QAction(self.mainWindow) self.ViewThemeManagerItem.setCheckable(True) self.ViewThemeManagerItem.setChecked(True) self.ViewThemeManagerItem.setIcon(ThemeManagerIcon) self.ViewThemeManagerItem.setObjectName(u'ViewThemeManagerItem') - self.ViewServiceManagerItem = QtGui.QAction(self.main_window) + self.ViewServiceManagerItem = QtGui.QAction(self.mainWindow) self.ViewServiceManagerItem.setCheckable(True) self.ViewServiceManagerItem.setChecked(True) self.ViewServiceManagerItem.setIcon(ServiceManagerIcon) self.ViewServiceManagerItem.setObjectName(u'ViewServiceManagerItem') - self.ToolsAlertItem = QtGui.QAction(self.main_window) + self.ToolsAlertItem = QtGui.QAction(self.mainWindow) AlertIcon = QtGui.QIcon() AlertIcon.addPixmap(QtGui.QPixmap(u':/tools/tools_alert.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.ToolsAlertItem.setIcon(AlertIcon) self.ToolsAlertItem.setObjectName(u'ToolsAlertItem') - self.HelpDocumentationItem = QtGui.QAction(self.main_window) + self.HelpDocumentationItem = QtGui.QAction(self.mainWindow) ContentsIcon = QtGui.QIcon() ContentsIcon.addPixmap(QtGui.QPixmap(u':/system/system_help_contents.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.HelpDocumentationItem.setIcon(ContentsIcon) self.HelpDocumentationItem.setObjectName(u'HelpDocumentationItem') - self.HelpAboutItem = QtGui.QAction(self.main_window) + self.HelpAboutItem = QtGui.QAction(self.mainWindow) AboutIcon = QtGui.QIcon() AboutIcon.addPixmap(QtGui.QPixmap(u':/system/system_about.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.HelpAboutItem.setIcon(AboutIcon) self.HelpAboutItem.setObjectName(u'HelpAboutItem') - self.HelpOnlineHelpItem = QtGui.QAction(self.main_window) + self.HelpOnlineHelpItem = QtGui.QAction(self.mainWindow) self.HelpOnlineHelpItem.setObjectName(u'HelpOnlineHelpItem') - self.HelpWebSiteItem = QtGui.QAction(self.main_window) + self.HelpWebSiteItem = QtGui.QAction(self.mainWindow) self.HelpWebSiteItem.setObjectName(u'HelpWebSiteItem') - self.LanguageTranslateItem = QtGui.QAction(self.main_window) + self.LanguageTranslateItem = QtGui.QAction(self.mainWindow) self.LanguageTranslateItem.setObjectName(u'LanguageTranslateItem') - self.LanguageEnglishItem = QtGui.QAction(self.main_window) + self.LanguageEnglishItem = QtGui.QAction(self.mainWindow) self.LanguageEnglishItem.setObjectName(u'LanguageEnglishItem') - self.ToolsAddToolItem = QtGui.QAction(self.main_window) + self.ToolsAddToolItem = QtGui.QAction(self.mainWindow) AddToolIcon = QtGui.QIcon() AddToolIcon.addPixmap(QtGui.QPixmap(u':/tools/tools_add.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.ToolsAddToolItem.setIcon(AddToolIcon) self.ToolsAddToolItem.setObjectName(u'ToolsAddToolItem') - self.action_Preview_Panel = QtGui.QAction(self.main_window) + self.action_Preview_Panel = QtGui.QAction(self.mainWindow) self.action_Preview_Panel.setCheckable(True) self.action_Preview_Panel.setChecked(True) self.action_Preview_Panel.setObjectName(u'action_Preview_Panel') - self.ModeLiveItem = QtGui.QAction(self.main_window) + self.ModeLiveItem = QtGui.QAction(self.mainWindow) self.ModeLiveItem.setObjectName(u'ModeLiveItem') self.FileImportMenu.addAction(self.ImportThemeItem) self.FileImportMenu.addAction(self.ImportLanguageItem) @@ -361,7 +360,7 @@ class MainWindow(object): self.retranslateUi() self.MediaToolBox.setCurrentIndex(0) QtCore.QObject.connect(self.FileExitItem, - QtCore.SIGNAL(u'triggered()'), self.main_window.close) + QtCore.SIGNAL(u'triggered()'), self.mainWindow.close) QtCore.QObject.connect(self.ViewMediaManagerItem, QtCore.SIGNAL(u'triggered(bool)'), self.MediaManagerDock.setVisible) QtCore.QObject.connect(self.ViewServiceManagerItem, @@ -382,103 +381,103 @@ class MainWindow(object): QtCore.SIGNAL(u'triggered()'), self.onToolsAlertItemClicked) QtCore.QObject.connect(self.OptionsSettingsItem, QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked) - QtCore.QMetaObject.connectSlotsByName(self.main_window) + QtCore.QMetaObject.connectSlotsByName(self.mainWindow) def retranslateUi(self): - self.main_window.setWindowTitle(translate(u'main_window', u'openlp.org 2.0')) - self.FileMenu.setTitle(translate(u'main_window', u'&File')) - self.FileImportMenu.setTitle(translate(u'main_window', u'&Import')) - self.FileExportMenu.setTitle(translate(u'main_window', u'&Export')) - self.OptionsMenu.setTitle(translate(u'main_window', u'&Options')) - self.OptionsViewMenu.setTitle(translate(u'main_window', u'&View')) - self.ViewModeMenu.setTitle(translate(u'main_window', u'M&ode')) - self.OptionsLanguageMenu.setTitle(translate(u'main_window', u'&Language')) - self.ToolsMenu.setTitle(translate(u'main_window', u'&Tools')) - self.HelpMenu.setTitle(translate(u'main_window', u'&Help')) - self.MediaManagerDock.setWindowTitle(translate(u'main_window', u'Media Manager')) - self.ServiceManagerDock.setWindowTitle(translate(u'main_window', u'Service Manager')) -# self.ServiceManagerContents.MoveTopButton.setText(translate(u'main_window', u'Move To Top')) -# self.ServiceManagerContents.MoveUpButton.setText(translate(u'main_window', u'Move Up')) -# self.ServiceManagerContents.MoveDownButton.setText(translate(u'main_window', u'Move Down')) -# self.ServiceManagerContents.MoveBottomButton.setText(translate(u'main_window', u'Move To Bottom')) -# self.ServiceManagerContents.NewItem.setText(translate(u'main_window', u'New Service')) -# self.ServiceManagerContents.OpenItem.setText(translate(u'main_window', u'Open Service')) -# self.ServiceManagerContents.SaveItem.setText(translate(u'main_window', u'Save Service')) -# self.ServiceManagerContents.ThemeComboBox.setItemText(0, translate(u'main_window', u'African Sunset')) -# self.ServiceManagerContents.ThemeComboBox.setItemText(1, translate(u'main_window', u'Snowy Mountains')) -# self.ServiceManagerContents.ThemeComboBox.setItemText(2, translate(u'main_window', u'Wilderness')) - self.ThemeManagerDock.setWindowTitle(translate(u'main_window', u'Theme Manager')) -# self.ThemeNewItem.setText(translate(u'main_window', u'New Theme')) -# self.ThemeEditItem.setText(translate(u'main_window', u'Edit Theme')) -# self.ThemeDeleteButton.setText(translate(u'main_window', u'Delete Theme')) -# self.ThemeImportButton.setText(translate(u'main_window', u'Import Theme')) -# self.ThemeExportButton.setText(translate(u'main_window', u'Export Theme')) - self.FileNewItem.setText(translate(u'main_window', u'&New')) - self.FileNewItem.setToolTip(translate(u'main_window', u'New Service')) - self.FileNewItem.setStatusTip(translate(u'main_window', u'Create a new Service')) - self.FileNewItem.setShortcut(translate(u'main_window', u'Ctrl+N')) - self.FileOpenItem.setText(translate(u'main_window', u'&Open')) - self.FileOpenItem.setToolTip(translate(u'main_window', u'Open Service')) - self.FileOpenItem.setStatusTip(translate(u'main_window', u'Open an existing service')) - self.FileOpenItem.setShortcut(translate(u'main_window', u'Ctrl+O')) - self.FileSaveItem.setText(translate(u'main_window', u'&Save')) - self.FileSaveItem.setToolTip(translate(u'main_window', u'Save Service')) - self.FileSaveItem.setStatusTip(translate(u'main_window', u'Save the current service to disk')) - self.FileSaveItem.setShortcut(translate(u'main_window', u'Ctrl+S')) - self.FileSaveAsItem.setText(translate(u'main_window', u'Save &As...')) - self.FileSaveAsItem.setToolTip(translate(u'main_window', u'Save Service As')) - self.FileSaveAsItem.setStatusTip(translate(u'main_window', u'Save the current service under a new name')) - self.FileSaveAsItem.setShortcut(translate(u'main_window', u'F12')) - self.FileExitItem.setText(translate(u'main_window', u'E&xit')) - self.FileExitItem.setStatusTip(translate(u'main_window', u'Quit OpenLP 2.0')) - self.FileExitItem.setShortcut(translate(u'main_window', u'Alt+F4')) - self.ImportThemeItem.setText(translate(u'main_window', u'&Theme')) - self.ImportLanguageItem.setText(translate(u'main_window', u'&Language')) - self.ExportThemeItem.setText(translate(u'main_window', u'&Theme')) - self.ExportLanguageItem.setText(translate(u'main_window', u'&Language')) - self.actionLook_Feel.setText(translate(u'main_window', u'Look && &Feel')) - self.OptionsSettingsItem.setText(translate(u'main_window', u'&Settings')) - self.ViewMediaManagerItem.setText(translate(u'main_window', u'&Media Manager')) - self.ViewMediaManagerItem.setToolTip(translate(u'main_window', u'Toggle Media Manager')) - self.ViewMediaManagerItem.setStatusTip(translate(u'main_window', u'Toggle the visibility of the Media Manager')) - self.ViewMediaManagerItem.setShortcut(translate(u'main_window', u'F8')) - self.ViewThemeManagerItem.setText(translate(u'main_window', u'&Theme Manager')) - self.ViewThemeManagerItem.setToolTip(translate(u'main_window', u'Toggle Theme Manager')) - self.ViewThemeManagerItem.setStatusTip(translate(u'main_window', u'Toggle the visibility of the Theme Manager')) - self.ViewThemeManagerItem.setShortcut(translate(u'main_window', u'F10')) - self.ViewServiceManagerItem.setText(translate(u'main_window', u'&Service Manager')) - self.ViewServiceManagerItem.setToolTip(translate(u'main_window', u'Toggle Service Manager')) - self.ViewServiceManagerItem.setStatusTip(translate(u'main_window', u'Toggle the visibility of the Service Manager')) - self.ViewServiceManagerItem.setShortcut(translate(u'main_window', u'F9')) - self.ToolsAlertItem.setText(translate(u'main_window', u'&Alert')) - self.ToolsAlertItem.setStatusTip(translate(u'main_window', u'Show an alert message')) - self.ToolsAlertItem.setShortcut(translate(u'main_window', u'F7')) - self.HelpDocumentationItem.setText(translate(u'main_window', u'&User Guide')) - self.HelpAboutItem.setText(translate(u'main_window', u'&About')) - self.HelpAboutItem.setStatusTip(translate(u'main_window', u'More information about OpenLP')) - self.HelpAboutItem.setShortcut(translate(u'main_window', u'Ctrl+F1')) - self.HelpOnlineHelpItem.setText(translate(u'main_window', u'&Online Help')) - self.HelpWebSiteItem.setText(translate(u'main_window', u'&Web Site')) - self.LanguageTranslateItem.setText(translate(u'main_window', u'&Translate')) - self.LanguageTranslateItem.setStatusTip(translate(u'main_window', u'Translate the interface to your language')) - self.LanguageEnglishItem.setText(translate(u'main_window', u'English')) - self.LanguageEnglishItem.setStatusTip(translate(u'main_window', u'Set the interface language to English')) - self.ToolsAddToolItem.setText(translate(u'main_window', u'&Add Tool...')) - self.ToolsAddToolItem.setStatusTip(translate(u'main_window', u'Add an application to the list of tools')) - self.action_Preview_Panel.setText(translate(u'main_window', u'&Preview Pane')) - self.ModeLiveItem.setText(translate(u'main_window', u'&Live')) + self.mainWindow.setWindowTitle(translate(u'mainWindow', u'openlp.org 2.0')) + self.FileMenu.setTitle(translate(u'mainWindow', u'&File')) + self.FileImportMenu.setTitle(translate(u'mainWindow', u'&Import')) + self.FileExportMenu.setTitle(translate(u'mainWindow', u'&Export')) + self.OptionsMenu.setTitle(translate(u'mainWindow', u'&Options')) + self.OptionsViewMenu.setTitle(translate(u'mainWindow', u'&View')) + self.ViewModeMenu.setTitle(translate(u'mainWindow', u'M&ode')) + self.OptionsLanguageMenu.setTitle(translate(u'mainWindow', u'&Language')) + self.ToolsMenu.setTitle(translate(u'mainWindow', u'&Tools')) + self.HelpMenu.setTitle(translate(u'mainWindow', u'&Help')) + self.MediaManagerDock.setWindowTitle(translate(u'mainWindow', u'Media Manager')) + self.ServiceManagerDock.setWindowTitle(translate(u'mainWindow', u'Service Manager')) +# self.ServiceManagerContents.MoveTopButton.setText(translate(u'mainWindow', u'Move To Top')) +# self.ServiceManagerContents.MoveUpButton.setText(translate(u'mainWindow', u'Move Up')) +# self.ServiceManagerContents.MoveDownButton.setText(translate(u'mainWindow', u'Move Down')) +# self.ServiceManagerContents.MoveBottomButton.setText(translate(u'mainWindow', u'Move To Bottom')) +# self.ServiceManagerContents.NewItem.setText(translate(u'mainWindow', u'New Service')) +# self.ServiceManagerContents.OpenItem.setText(translate(u'mainWindow', u'Open Service')) +# self.ServiceManagerContents.SaveItem.setText(translate(u'mainWindow', u'Save Service')) +# self.ServiceManagerContents.ThemeComboBox.setItemText(0, translate(u'mainWindow', u'African Sunset')) +# self.ServiceManagerContents.ThemeComboBox.setItemText(1, translate(u'mainWindow', u'Snowy Mountains')) +# self.ServiceManagerContents.ThemeComboBox.setItemText(2, translate(u'mainWindow', u'Wilderness')) + self.ThemeManagerDock.setWindowTitle(translate(u'mainWindow', u'Theme Manager')) +# self.ThemeNewItem.setText(translate(u'mainWindow', u'New Theme')) +# self.ThemeEditItem.setText(translate(u'mainWindow', u'Edit Theme')) +# self.ThemeDeleteButton.setText(translate(u'mainWindow', u'Delete Theme')) +# self.ThemeImportButton.setText(translate(u'mainWindow', u'Import Theme')) +# self.ThemeExportButton.setText(translate(u'mainWindow', u'Export Theme')) + self.FileNewItem.setText(translate(u'mainWindow', u'&New')) + self.FileNewItem.setToolTip(translate(u'mainWindow', u'New Service')) + self.FileNewItem.setStatusTip(translate(u'mainWindow', u'Create a new Service')) + self.FileNewItem.setShortcut(translate(u'mainWindow', u'Ctrl+N')) + self.FileOpenItem.setText(translate(u'mainWindow', u'&Open')) + self.FileOpenItem.setToolTip(translate(u'mainWindow', u'Open Service')) + self.FileOpenItem.setStatusTip(translate(u'mainWindow', u'Open an existing service')) + self.FileOpenItem.setShortcut(translate(u'mainWindow', u'Ctrl+O')) + self.FileSaveItem.setText(translate(u'mainWindow', u'&Save')) + self.FileSaveItem.setToolTip(translate(u'mainWindow', u'Save Service')) + self.FileSaveItem.setStatusTip(translate(u'mainWindow', u'Save the current service to disk')) + self.FileSaveItem.setShortcut(translate(u'mainWindow', u'Ctrl+S')) + self.FileSaveAsItem.setText(translate(u'mainWindow', u'Save &As...')) + self.FileSaveAsItem.setToolTip(translate(u'mainWindow', u'Save Service As')) + self.FileSaveAsItem.setStatusTip(translate(u'mainWindow', u'Save the current service under a new name')) + self.FileSaveAsItem.setShortcut(translate(u'mainWindow', u'F12')) + self.FileExitItem.setText(translate(u'mainWindow', u'E&xit')) + self.FileExitItem.setStatusTip(translate(u'mainWindow', u'Quit OpenLP 2.0')) + self.FileExitItem.setShortcut(translate(u'mainWindow', u'Alt+F4')) + self.ImportThemeItem.setText(translate(u'mainWindow', u'&Theme')) + self.ImportLanguageItem.setText(translate(u'mainWindow', u'&Language')) + self.ExportThemeItem.setText(translate(u'mainWindow', u'&Theme')) + self.ExportLanguageItem.setText(translate(u'mainWindow', u'&Language')) + self.actionLook_Feel.setText(translate(u'mainWindow', u'Look && &Feel')) + self.OptionsSettingsItem.setText(translate(u'mainWindow', u'&Settings')) + self.ViewMediaManagerItem.setText(translate(u'mainWindow', u'&Media Manager')) + self.ViewMediaManagerItem.setToolTip(translate(u'mainWindow', u'Toggle Media Manager')) + self.ViewMediaManagerItem.setStatusTip(translate(u'mainWindow', u'Toggle the visibility of the Media Manager')) + self.ViewMediaManagerItem.setShortcut(translate(u'mainWindow', u'F8')) + self.ViewThemeManagerItem.setText(translate(u'mainWindow', u'&Theme Manager')) + self.ViewThemeManagerItem.setToolTip(translate(u'mainWindow', u'Toggle Theme Manager')) + self.ViewThemeManagerItem.setStatusTip(translate(u'mainWindow', u'Toggle the visibility of the Theme Manager')) + self.ViewThemeManagerItem.setShortcut(translate(u'mainWindow', u'F10')) + self.ViewServiceManagerItem.setText(translate(u'mainWindow', u'&Service Manager')) + self.ViewServiceManagerItem.setToolTip(translate(u'mainWindow', u'Toggle Service Manager')) + self.ViewServiceManagerItem.setStatusTip(translate(u'mainWindow', u'Toggle the visibility of the Service Manager')) + self.ViewServiceManagerItem.setShortcut(translate(u'mainWindow', u'F9')) + self.ToolsAlertItem.setText(translate(u'mainWindow', u'&Alert')) + self.ToolsAlertItem.setStatusTip(translate(u'mainWindow', u'Show an alert message')) + self.ToolsAlertItem.setShortcut(translate(u'mainWindow', u'F7')) + self.HelpDocumentationItem.setText(translate(u'mainWindow', u'&User Guide')) + self.HelpAboutItem.setText(translate(u'mainWindow', u'&About')) + self.HelpAboutItem.setStatusTip(translate(u'mainWindow', u'More information about OpenLP')) + self.HelpAboutItem.setShortcut(translate(u'mainWindow', u'Ctrl+F1')) + self.HelpOnlineHelpItem.setText(translate(u'mainWindow', u'&Online Help')) + self.HelpWebSiteItem.setText(translate(u'mainWindow', u'&Web Site')) + self.LanguageTranslateItem.setText(translate(u'mainWindow', u'&Translate')) + self.LanguageTranslateItem.setStatusTip(translate(u'mainWindow', u'Translate the interface to your language')) + self.LanguageEnglishItem.setText(translate(u'mainWindow', u'English')) + self.LanguageEnglishItem.setStatusTip(translate(u'mainWindow', u'Set the interface language to English')) + self.ToolsAddToolItem.setText(translate(u'mainWindow', u'&Add Tool...')) + self.ToolsAddToolItem.setStatusTip(translate(u'mainWindow', u'Add an application to the list of tools')) + self.action_Preview_Panel.setText(translate(u'mainWindow', u'&Preview Pane')) + self.ModeLiveItem.setText(translate(u'mainWindow', u'&Live')) def show(self): - self.main_window.showMaximized() - self.main_display.setup(0) - self.main_display.show() + self.mainWindow.showMaximized() + self.mainDisplay.setup(0) + self.mainDisplay.show() def onHelpAboutItemClicked(self): - self.about_form.exec_() + self.aboutForm.exec_() def onToolsAlertItemClicked(self): - self.alert_form.exec_() + self.alertForm.exec_() def onOptionsSettingsItemClicked(self): - self.settings_form.exec_() + self.settingsForm.exec_() diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 3f0feaf3b..f34106bb1 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -21,13 +21,7 @@ import os import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import PluginConfig -from openlp.core.lib import OpenLPToolbar -from openlp.core.lib import ServiceItem -from openlp.core.lib import RenderManager -from openlp.core import translate -from openlp import buildIcon -from openlp.core.lib import Event, EventType, EventManager +from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, RenderManager, Event, EventType, EventManager, translate, buildIcon, contextMenuAction, contextMenuSeparator class ServiceManager(QtGui.QWidget): @@ -38,12 +32,12 @@ class ServiceManager(QtGui.QWidget): Also handles the UI tasks of moving things up and down etc. """ global log - log=logging.getLogger(u'ServiceManager') + log = logging.getLogger(u'ServiceManager') def __init__(self, parent): QtGui.QWidget.__init__(self) - self.parent=parent - self.serviceItems=[] + self.parent = parent + self.serviceItems = [] self.Layout = QtGui.QVBoxLayout(self) self.Layout.setSpacing(0) self.Layout.setMargin(0) @@ -57,15 +51,15 @@ class ServiceManager(QtGui.QWidget): self.Toolbar.addToolbarButton(u'Move to bottom', u':/services/service_bottom.png', translate(u'ServiceManager', u'Move to end'), self.onServiceEnd) self.Toolbar.addSeparator() - self.Toolbar.addToolbarButton(u'New Service', u':/services/service_new.png', - translate(u'ServiceManager', u'Create a new Service'), self.onNewService) self.Toolbar.addToolbarButton(u'Delete From Service', u':/services/service_delete.png', translate(u'ServiceManager', u'Delete From Service'), self.onDeleteFromService) + self.Toolbar.addToolbarButton(u'New Service', u':/services/service_new.png', + translate(u'ServiceManager', u'Create a new Service'), self.onNewService) + self.Toolbar.addToolbarButton(u'Open Service', u':/services/service_open.png', + translate(u'ServiceManager', u'Load Existing'), self.onLoadService) self.Toolbar.addSeparator() self.Toolbar.addToolbarButton(u'Save Service', u':/services/service_save.png', translate(u'ServiceManager', u'Save Service'), self.onSaveService) - self.Toolbar.addToolbarButton(u'Load Service', u':/services/service_open.png', - translate(u'ServiceManager', u'Load Existing'), self.onLoadService) self.Toolbar.addSeparator() self.ThemeComboBox = QtGui.QComboBox(self.Toolbar) @@ -87,14 +81,14 @@ class ServiceManager(QtGui.QWidget): self.ServiceManagerList.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) - self.ServiceManagerList.addAction(self.contextMenuAction( + self.ServiceManagerList.addAction(contextMenuAction( self.ServiceManagerList, ':/system/system_preview.png', translate(u'ServiceManager',u'&Preview Verse'), self.makePreview)) - self.ServiceManagerList.addAction(self.contextMenuAction( + self.ServiceManagerList.addAction(contextMenuAction( self.ServiceManagerList, ':/system/system_live.png', translate(u'ServiceManager',u'&Show Live'), self.makeLive)) - self.ServiceManagerList.addAction(self.contextMenuSeparator(self.ServiceManagerList)) - self.ServiceManagerList.addAction(self.contextMenuAction( + self.ServiceManagerList.addAction(contextMenuSeparator(self.ServiceManagerList)) + self.ServiceManagerList.addAction(contextMenuAction( self.ServiceManagerList, ':/services/service_delete', translate(u'ServiceManager',u'&Remove from Service'), self.onDeleteFromService)) @@ -106,20 +100,6 @@ class ServiceManager(QtGui.QWidget): self.config = PluginConfig(u'Main') self.service_theme = self.config.get_config(u'theme service theme', u'') - def contextMenuAction(self, base, icon, text, slot): - """ - Utility method to help build context menus for plugins - """ - action = QtGui.QAction(text, base) - action .setIcon(buildIcon(icon)) - QtCore.QObject.connect(action, QtCore.SIGNAL("triggered()"), slot) - return action - - def contextMenuSeparator(self, base): - action = QtGui.QAction("", base) - action.setSeparator(True) - return action - def onServiceTop(self): pass @@ -160,7 +140,7 @@ class ServiceManager(QtGui.QWidget): count = 0 for frame in item.frames: treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem) - text = frame[u'formatted'][0] + text = frame[u'title'][0] treewidgetitem1.setText(0,text[:30]) treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count)) count = count + 1 @@ -199,7 +179,7 @@ class ServiceManager(QtGui.QWidget): Handle the release of the event and trigger the plugin to add the data """ - link=event.mimeData() + link = event.mimeData() if link.hasText(): plugin = event.mimeData().text() self.EventManager.post_event(Event(EventType.LoadServiceItem, plugin)) @@ -233,7 +213,9 @@ class ServiceManager(QtGui.QWidget): for theme in theme_list: self.ThemeComboBox.addItem(theme) id = self.ThemeComboBox.findText(str(self.service_theme), QtCore.Qt.MatchExactly) + # Not Found if id == -1: - id = 0 # Not Found + id = 0 self.service_theme = u'' self.ThemeComboBox.setCurrentIndex(id) + self.RenderManager.set_service_theme(self.service_theme) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 92431e97b..9e8fdd634 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -22,8 +22,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar -from openlp.core import translate +from openlp.core.lib import OpenLPToolbar, translate class SlideData(QtCore.QAbstractListModel): """ diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index a0a22f6c5..a72feba40 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import QtCore, QtGui -from openlp.core import translate +from openlp.core.lib import translate class SplashScreen(object): def __init__(self, version): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 739e07c35..b50ee7af6 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -23,23 +23,17 @@ import zipfile import shutil from time import sleep -from copy import deepcopy from xml.etree.ElementTree import ElementTree, XML -from PyQt4 import * from PyQt4 import QtCore, QtGui -from PyQt4.QtCore import * -from PyQt4.QtGui import * from openlp.core.ui import AmendThemeForm, ServiceManager -from openlp.core import translate, fileToXML from openlp.core.theme import Theme -from openlp.core.lib import Event, EventType, EventManager, OpenLPToolbar, ThemeXML, Renderer +from openlp.core.lib import Event, EventType, EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, file_to_xml from openlp.core.utils import ConfigHelper -from openlp.core.resources import * import logging -class ThemeData(QAbstractListModel): +class ThemeData(QtCore.QAbstractListModel): """ Tree of items for an order of Theme. Includes methods for reading and writing the contents to an OOS file @@ -49,7 +43,7 @@ class ThemeData(QAbstractListModel): log=logging.getLogger(u'ThemeData') def __init__(self): - QAbstractListModel.__init__(self) + QtCore.QAbstractListModel.__init__(self) self.items = [] self.rowheight = 50 self.maximagewidth = self.rowheight * 16 / 9.0; @@ -62,36 +56,36 @@ class ThemeData(QAbstractListModel): return len(self.items) def insertRow(self, row, filename): - self.beginInsertRows(QModelIndex(), row, row) + self.beginInsertRows(QtCore.QModelIndex(), row, row) log.info(u'insert row %d:%s' % (row, filename)) (prefix, shortfilename) = os.path.split(str(filename)) log.info(u'shortfilename = %s' % shortfilename) theme = shortfilename.split(u'.') # create a preview image if os.path.exists(filename): - preview = QPixmap(str(filename)) + preview = QtGui.QPixmap(str(filename)) width = self.maximagewidth height = self.rowheight - preview = preview.scaled(width, height, Qt.KeepAspectRatio, Qt.SmoothTransformation) + preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) realwidth = preview.width() realheight = preview.height() # and move it to the centre of the preview space - pixmap = QPixmap(width, height) - pixmap.fill(Qt.transparent) - painter = QPainter(pixmap) + pixmap = QtGui.QPixmap(width, height) + pixmap.fill(QtCore.Qt.transparent) + painter = QtGui.QPainter(pixmap) painter.drawPixmap((width - realwidth) / 2, (height - realheight) / 2, preview) else: width = self.maximagewidth height = self.rowheight - pixmap = QPixmap(width, height) - pixmap.fill(Qt.transparent) + pixmap = QtGui.QtGui.QPixmap(width, height) + pixmap.fill(QtCore.Qt.transparent) # finally create the row self.items.insert(row, (filename, pixmap, shortfilename, theme[0])) log.info(u'Items: %s' % self.items) self.endInsertRows() def removeRow(self, row): - self.beginRemoveRows(QModelIndex(), row, row) + self.beginRemoveRows(QtCore.QModelIndex(), row, row) self.items.pop(row) self.endRemoveRows() @@ -102,16 +96,15 @@ class ThemeData(QAbstractListModel): row = index.row() if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row! - return QVariant() - if role == Qt.DisplayRole: + return QtCore.QVariant() + if role == QtCore.Qt.DisplayRole: retval = self.items[row][3] - elif role == Qt.DecorationRole: + elif role == QtCore.Qt.DecorationRole: retval = self.items[row][1] else: - retval = QVariant() - #log.info("Returning"+ str(retval)) - if type(retval) is not type(QVariant): - return QVariant(retval) + retval = QtCore.QVariant() + if type(retval) is not type(QtCore.QVariant): + return QtCore.QVariant(retval) else: return retval @@ -131,15 +124,15 @@ class ThemeData(QAbstractListModel): filelist = [item[3] for item in self.items] return filelist -class ThemeManager(QWidget): +class ThemeManager(QtGui.QWidget): """ Manages the orders of Theme. """ global log - log=logging.getLogger(u'ThemeManager') + log = logging.getLogger(u'ThemeManager') def __init__(self, parent): - QWidget.__init__(self) + QtGui.QWidget.__init__(self) self.parent = parent self.Layout = QtGui.QVBoxLayout(self) self.Layout.setSpacing(0) @@ -174,7 +167,7 @@ class ThemeManager(QWidget): self.themelist = [] self.path = os.path.join(ConfigHelper.get_data_path(), u'themes') self.checkThemesExists(self.path) - self.amendThemeForm.themePath(self.path) + self.amendThemeForm.path = self.path def onAddTheme(self): self.amendThemeForm.loadTheme(None) @@ -224,8 +217,7 @@ class ThemeManager(QWidget): self.themeData.addRow(os.path.join(self.path, name)) self.EventManager.post_event(Event(EventType.ThemeListChanged)) self.ServiceManager.updateThemeList(self.getThemes()) - self.parent.settings_form.ThemesTab.updateThemeList(self.getThemes()) - + self.parent.settingsForm.ThemesTab.updateThemeList(self.getThemes()) def getThemes(self): return self.themeData.getList() @@ -234,19 +226,19 @@ class ThemeManager(QWidget): log.debug(u'getthemedata for theme %s', themename) xml_file = os.path.join(self.path, str(themename), str(themename) + u'.xml') try: - xml = fileToXML(xml_file) + xml = file_to_xml(xml_file) except: newtheme = ThemeXML() newtheme.new_document(u'New Theme') newtheme.add_background_solid(str(u'#000000')) - newtheme.add_font(str(QFont().family()), str(u'#FFFFFF'), str(30), u'False') - newtheme.add_font(str(QFont().family()), str(u'#FFFFFF'), str(12), u'False', u'footer') + newtheme.add_font(str(QtGui.QFont().family()), str(u'#FFFFFF'), str(30), u'False') + newtheme.add_font(str(QtGui.QFont().family()), str(u'#FFFFFF'), str(12), u'False', u'footer') newtheme.add_display(u'False', str(u'#FFFFFF'), u'False', str(u'#FFFFFF'), str(0), str(0), str(0)) xml = newtheme.extract_xml() theme = ThemeXML() theme.parse(xml) - theme.extend_filename(self.path) + theme.extend_image_filename(self.path) return theme def checkThemesExists(self, dir): @@ -353,7 +345,7 @@ class ThemeManager(QWidget): log.debug(u'generateAndSaveImage %s %s %s', dir, name, theme_xml) theme = ThemeXML() theme.parse(theme_xml) - theme.extend_filename(dir) + theme.extend_image_filename(dir) frame = self.generateImage(theme) im = frame.toImage() samplepathname = os.path.join(self.path, name + u'.png') diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 9460750aa..4b61e9f19 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -20,8 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import QtCore, QtGui -from openlp.core import translate -from openlp.core.lib import SettingsTab +from openlp.core.lib import SettingsTab, translate class ThemesTab(SettingsTab): """ diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index d279c6aab..2385af506 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -21,10 +21,8 @@ import logging from PyQt4 import QtCore, QtGui from PyQt4.QtCore import * -from PyQt4.QtGui import * -from openlp.core.lib import Plugin, Event -from openlp.core.lib import EventType +from openlp.core.lib import Plugin, Event, EventType, translate from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem from openlp.plugins.bibles.lib.tables import * @@ -59,7 +57,7 @@ class BiblePlugin(Plugin): self.ImportBibleItem = QtGui.QAction(import_menu) self.ImportBibleItem.setObjectName("ImportBibleItem") import_menu.addAction(self.ImportBibleItem) - self.ImportBibleItem.setText(QtGui.QApplication.translate("main_window", "&Bible", None, QtGui.QApplication.UnicodeUTF8)) + self.ImportBibleItem.setText(translate("BiblePlugin", "&Bible")) # Signals and slots QtCore.QObject.connect(self.ImportBibleItem, QtCore.SIGNAL("triggered()"), self.onBibleNewClick) @@ -67,8 +65,7 @@ class BiblePlugin(Plugin): self.ExportBibleItem = QtGui.QAction(export_menu) self.ExportBibleItem.setObjectName("ExportBibleItem") export_menu.addAction(self.ExportBibleItem) - self.ExportBibleItem.setText( - QtGui.QApplication.translate("main_window", u'&Bible', None, QtGui.QApplication.UnicodeUTF8)) + self.ExportBibleItem.setText(translate("BiblePlugin", u'&Bible')) def initialise(self): pass diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 8c3d96a5d..1f3d1b8a1 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -20,8 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import Qt, QtCore, QtGui -from openlp.core import translate -from openlp import convertStringToBoolean +from openlp.core.lib import translate, str_to_bool from openlp.core.lib import SettingsTab class BiblesTab(SettingsTab): @@ -187,11 +186,11 @@ class BiblesTab(SettingsTab): self.bible_search = True def load(self): - self.paragraph_style = convertStringToBoolean(self.config.get_config(u'paragraph style', u'True')) - self.show_new_chapters = convertStringToBoolean(self.config.get_config(u'display new chapter', u"False")) + self.paragraph_style = str_to_bool(self.config.get_config(u'paragraph style', u'True')) + self.show_new_chapters = str_to_bool(self.config.get_config(u'display new chapter', u"False")) self.display_style = int(self.config.get_config(u'display brackets', u'0')) self.bible_theme = self.config.get_config(u'bible theme', u'0') - self.bible_search = convertStringToBoolean(self.config.get_config(u'search as type', u'True')) + self.bible_search = str_to_bool(self.config.get_config(u'search as type', u'True')) if self.paragraph_style: self.ParagraphRadioButton.setChecked(True) else: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index b20250d47..21e9a5ede 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -21,10 +21,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core import translate -from openlp.core.lib import MediaManagerItem, Receiver -from openlp.core.lib import ServiceItem - +from openlp.core.lib import ServiceItem, MediaManagerItem, Receiver, translate from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import TextListData @@ -57,7 +54,7 @@ class BibleMediaItem(MediaManagerItem): This is the custom media manager item for Bibles. """ global log - log=logging.getLogger(u'BibleMediaItem') + log = logging.getLogger(u'BibleMediaItem') log.info(u'Bible Media Item loaded') def __init__(self, parent, icon, title): @@ -207,7 +204,7 @@ class BibleMediaItem(MediaManagerItem): self.BibleListView.setAlternatingRowColors(True) self.BibleListData = TextListData() self.BibleListView.setModel(self.BibleListData) - self.BibleListView.setSelectionMode(QtGui.QAbstractItemView.MultiSelection) + self.BibleListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) self.BibleListView.setDragEnabled(True) self.PageLayout.addWidget(self.BibleListView) @@ -383,7 +380,7 @@ class BibleMediaItem(MediaManagerItem): verse = str(self.search_results[0][2]) text = self.search_results[0][3] if self.parent.bibles_tab.paragraph_style: #Paragraph - text = text + u'\n' + text = text + u'\n\n' if self.parent.bibles_tab.display_style == 1: loc = self.formatVerse(old_chapter, chapter, verse, u'(', u')') elif self.parent.bibles_tab.display_style == 2: diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index afa7ec87d..d4b6cd754 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -21,10 +21,8 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.resources import * -from openlp.core.lib import Plugin, Event -from openlp.core.lib import EventType from forms import EditCustomForm +from openlp.core.lib import Plugin, Event, EventType from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem, CustomServiceItem diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index d005054f9..22362f3fd 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -8,7 +8,7 @@ # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui -from openlp.core import translate +from openlp.core.lib import translate class Ui_customEditDialog(object): def setupUi(self, customEditDialog): diff --git a/openlp/plugins/custom/lib/customserviceitem.py b/openlp/plugins/custom/lib/customserviceitem.py index dfd41c246..3fd9d6b6d 100644 --- a/openlp/plugins/custom/lib/customserviceitem.py +++ b/openlp/plugins/custom/lib/customserviceitem.py @@ -19,6 +19,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA """ from PyQt4 import QtCore, QtGui import logging + from openlp.core.lib import ServiceItem from openlp.plugins.custom.lib import TextListData @@ -40,12 +41,12 @@ class CustomServiceItem(ServiceItem): it simply tells the slide controller to use it??? It contains 1 or more images - + """ global log log=logging.getLogger(u'CustomServiceItem') log.info(u'CustomServiceItem loaded') - + def __init__(self, controller): """ Init Method @@ -58,7 +59,7 @@ class CustomServiceItem(ServiceItem): # c.uniformItemSizes=True # c.setModel(self.imgs) # c.setGeometry(0,0,200,200) - + def render(self): """ The render method is what the plugin uses to render its meda to the @@ -66,7 +67,7 @@ class CustomServiceItem(ServiceItem): """ # render the "image chooser first" # for f in self.imgs: -# fl , nm = os.path.split(str(f)) +# fl , nm = os.path.split(str(f)) # c = self.slide_controller.rowCount() # self.slide_controller.setRowCount(c+1) # twi = QtGui.QTableWidgetItem(str(f)) @@ -74,7 +75,7 @@ class CustomServiceItem(ServiceItem): # twi = QtGui.QTableWidgetItem(str(nm)) # self.slide_controller.setItem(c , 1, twi) # self.slide_controller.setRowHeight(c, 80) - + # render the preview screen here def get_parent_node(self): @@ -83,7 +84,7 @@ class CustomServiceItem(ServiceItem): Manager. """ pass - + def add(self, data): """ append an image to the list @@ -95,7 +96,7 @@ class CustomServiceItem(ServiceItem): log.info("add Item..."+str(data)) for filename in data.imgs.get_file_list(): self.add(filename) - + def get_oos_text(self): """ @@ -114,4 +115,4 @@ class CustomServiceItem(ServiceItem): files=text.split('\n') for f in files: self.imgs.addRow(f) - + diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 1f7531e3e..77161ae07 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -20,9 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import QtCore, QtGui -from openlp.core import translate -from openlp.core.lib import SettingsTab -from openlp.core.resources import * +from openlp.core.lib import SettingsTab, translate class CustomTab(SettingsTab): """ diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 313c2bff4..b81124994 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -21,11 +21,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core import translate -from openlp.core.lib import MediaManagerItem -from openlp.core.lib import SongXMLParser -from openlp.core.lib import ServiceItem - +from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate from openlp.plugins.custom.lib import TextListData class CustomList(QtGui.QListView): diff --git a/openlp/plugins/custom/lib/textlistdata.py b/openlp/plugins/custom/lib/textlistdata.py index 4900aaef1..6774b230c 100644 --- a/openlp/plugins/custom/lib/textlistdata.py +++ b/openlp/plugins/custom/lib/textlistdata.py @@ -1,55 +1,50 @@ import logging -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PyQt4 import QtCore, QtGui - -class TextListData(QAbstractListModel): +class TextListData(QtCore.QAbstractListModel): """ - An abstract list of strings + An abstract list of strings """ global log log=logging.getLogger(u'TextListData') log.info(u'started') def __init__(self): - QAbstractListModel.__init__(self) + QtCore.QAbstractListModel.__init__(self) self.items=[] # will be a list of (database id , title) tuples def resetStore(self): #reset list so can be reloaded - self.items=[] - + self.items=[] + def rowCount(self, parent): return len(self.items) def insertRow(self, row, id, title): - self.beginInsertRows(QModelIndex(),row,row) - log.debug("insert row %d:%s for id %d"%(row,title, id)) + self.beginInsertRows(QtCore.QModelIndex(),row,row) + log.debug("insert row %d:%s for id %d" % (row,title, id)) self.items.insert(row, (id, title)) self.endInsertRows() def removeRow(self, row): - self.beginRemoveRows(QModelIndex(), row,row) + self.beginRemoveRows(QtCore.QModelIndex(), row,row) self.items.pop(row) self.endRemoveRows() def addRow(self, id, title): self.insertRow(len(self.items), id, title) - + def data(self, index, role): row=index.row() if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row! - return QVariant() - if role==Qt.DisplayRole: - retval= self.items[row][1] -# elif role == Qt.ToolTipRole: #not sure if need as it shows the database row number -# retval= self.items[row][0] + return QtCore.QVariant() + if role == QtCore.Qt.DisplayRole: + retval = self.items[row][1] else: - retval= QVariant() -# log.info("Returning"+ str(retval)) - if type(retval) is not type(QVariant): - return QVariant(retval) + retval = QtCore.QVariant() + if type(retval) is not type(QtCore.QVariant): + return QtCore.QVariant(retval) else: return retval @@ -60,10 +55,7 @@ class TextListData(QAbstractListModel): def getId(self, index): row = index.row() return self.items[row][0] - + def deleteRow(self, index): row = index.row() self.removeRow(row) - -if __name__=="__main__": - sxml=TextListData() diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 4c9e9a058..47365d054 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -21,14 +21,12 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, Event -from openlp.core.lib import EventType - +from openlp.core.lib import Plugin, Event, EventType from openlp.plugins.images.lib import ImageMediaItem, ImageServiceItem class ImagePlugin(Plugin): global log - log=logging.getLogger(u'ImagePlugin') + log = logging.getLogger(u'ImagePlugin') log.info(u'Image Plugin loaded') def __init__(self, plugin_helpers): diff --git a/openlp/plugins/images/lib/imageserviceitem.py b/openlp/plugins/images/lib/imageserviceitem.py index a8e414bbf..a6bb621ea 100644 --- a/openlp/plugins/images/lib/imageserviceitem.py +++ b/openlp/plugins/images/lib/imageserviceitem.py @@ -17,8 +17,8 @@ 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 """ -from PyQt4 import QtCore, QtGui import logging +from PyQt4 import QtCore, QtGui from openlp.core.lib import ServiceItem from listwithpreviews import ListWithPreviews diff --git a/openlp/plugins/images/lib/listwithpreviews.py b/openlp/plugins/images/lib/listwithpreviews.py index 271ea181e..66004b77f 100644 --- a/openlp/plugins/images/lib/listwithpreviews.py +++ b/openlp/plugins/images/lib/listwithpreviews.py @@ -1,51 +1,74 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +""" +OpenLP - Open Source Lyrics Projection +Copyright (c) 2008 Raoul Snyman +Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley + +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 logging -from PyQt4.QtCore import * -from PyQt4.QtGui import * -class ListWithPreviews(QAbstractListModel): +from PyQt4 import QtCore, QtGui + + +class ListWithPreviews(QtCore.QAbstractListModel): """ An abstract list of strings and the preview icon to go with them """ global log - log=logging.getLogger("ListWithPreviews") + log = logging.getLogger("ListWithPreviews") log.info("started") def __init__(self): - QAbstractListModel.__init__(self) - self.items=[] # will be a list of (full filename, QPixmap, shortname) tuples - self.rowheight=50 - self.maximagewidth=self.rowheight*16/9.0; + QtCore.QAbstractListModel.__init__(self) + self.items = [] # will be a list of (full filename, QPixmap, shortname) tuples + self.rowheight = 50 + self.maximagewidth = self.rowheight*16/9.0; def rowCount(self, parent): return len(self.items) def insertRow(self, row, filename): - self.beginInsertRows(QModelIndex(),row,row) - log.info("insert row %d:%s"%(row,filename)) + self.beginInsertRows(QtCore.QModelIndex(),row,row) + log.info("insert row %d:%s"% (row,filename)) # get short filename to display next to image (prefix, shortfilename) = os.path.split(str(filename)) - log.info("shortfilename=%s"%(shortfilename)) + log.info("shortfilename=%s"% (shortfilename)) # create a preview image if os.path.exists(filename): - preview = QPixmap(str(filename)) - w=self.maximagewidth;h=self.rowheight - preview = preview.scaled(w,h, Qt.KeepAspectRatio, Qt.SmoothTransformation) - realw=preview.width(); realh=preview.height() + preview = QtGui.QPixmap(str(filename)) + w = self.maximagewidth; + h = self.rowheight + preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) + realw = preview.width(); + realh = preview.height() # and move it to the centre of the preview space - p=QPixmap(w,h) - p.fill(Qt.transparent) - painter=QPainter(p) + p = QtGui.QPixmap(w,h) + p.fill(QtCore.Qt.transparent) + painter = QtGui.QPainter(p) painter.drawPixmap((w-realw)/2,(h-realh)/2,preview) else: - w=self.maximagewidth;h=self.rowheight - p=QPixmap(w,h) - p.fill(Qt.transparent) + w = self.maximagewidth; + h = self.rowheight + p = QtGui.QPixmap(w,h) + p.fill(QtCore.Qt.transparent) # finally create the row self.items.insert(row, (filename, p, shortfilename)) self.endInsertRows() def removeRow(self, row): - self.beginRemoveRows(QModelIndex(), row,row) + self.beginRemoveRows(QtCore.QModelIndex(), row, row) self.items.pop(row) self.endRemoveRows() @@ -53,20 +76,20 @@ class ListWithPreviews(QAbstractListModel): self.insertRow(len(self.items), filename) def data(self, index, role): - row=index.row() - if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row! - return QVariant() - if role==Qt.DisplayRole: - retval= self.items[row][2] - elif role == Qt.DecorationRole: - retval= self.items[row][1] - elif role == Qt.ToolTipRole: - retval= self.items[row][0] + row = index.row() + if row > len(self.items): + # if the last row is selected and deleted, we then get called with an empty row! + return QtCore.QVariant() + if role == QtCore.Qt.DisplayRole: + retval = self.items[row][2] + elif role == QtCore.Qt.DecorationRole: + retval = self.items[row][1] + elif role == QtCore.Qt.ToolTipRole: + retval = self.items[row][0] else: - retval= QVariant() -# log.info("Returning"+ str(retval)) - if type(retval) is not type(QVariant): - return QVariant(retval) + retval = QtCore.QVariant() + if type(retval) is not type(QtCore.QVariant): + return QtCore.QVariant(retval) else: return retval diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 823cabd0d..54fbcd317 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -22,10 +22,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core import translate -from openlp.core.lib import MediaManagerItem -from openlp.core.lib import ServiceItem - +from openlp.core.lib import MediaManagerItem, ServiceItem, translate from openlp.plugins.images.lib import ListWithPreviews class ImageList(QtGui.QListView): @@ -156,7 +153,7 @@ class ImageMediaItem(MediaManagerItem): for index in indexes: filename = self.ImageListData.getFilename(index) frame = QtGui.QPixmap(str(filename)) - service_item.frames.append({u'formatted': u'Image', u'image': frame}) + service_item.frames.append({u'title': filename , u'image': frame}) def onImagePreviewClick(self): log.debug(u'Image Preview Requested') diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index b21d549b7..032d0f288 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -22,8 +22,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core import translate -from openlp.core.lib import MediaManagerItem +from openlp.core.lib import MediaManagerItem, translate from openlp.plugins.media.lib import MediaTab from openlp.plugins.media.lib import FileListData @@ -33,7 +32,7 @@ class MediaMediaItem(MediaManagerItem): This is the custom media manager item for Media Slides. """ global log - log=logging.getLogger(u'MediaMediaItem') + log = logging.getLogger(u'MediaMediaItem') log.info(u'Media Media Item loaded') def __init__(self, parent, icon, title): diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 1afe340d9..f557fde47 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -20,9 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import QtCore, QtGui -from openlp.core import translate -from openlp import convertStringToBoolean -from openlp.core.lib import SettingsTab +from openlp.core.lib import SettingsTab, str_to_bool, translate class MediaTab(SettingsTab): """ @@ -67,11 +65,12 @@ class MediaTab(SettingsTab): def onVMRCheckBoxChanged(self): use_vmr_mode = self.UseVMRCheckBox.checkState() self.use_vmr_mode = False - if use_vmr_mode == 2: # we have a set value convert to True/False + if use_vmr_mode == 2: + # we have a set value convert to True/False self.use_vmr_mode = True def load(self): - self.use_vmr_mode = convertStringToBoolean(self.config.get_config(u'use mode layout', u'False')) + self.use_vmr_mode = str_to_bool(self.config.get_config(u'use mode layout', u'False')) if self.use_vmr_mode : self.UseVMRCheckBox.setChecked(True) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index b04d4c32b..495dbe89c 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -20,7 +20,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA import os from PyQt4 import QtCore, QtGui -from openlp.core.resources import * from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab from openlp.plugins.media.lib import MediaTab,MediaMediaItem diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 9e4e6e70e..6a97dce8c 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -21,11 +21,7 @@ import logging import os from PyQt4 import QtCore, QtGui - -from openlp.core import translate -from openlp.core.lib import MediaManagerItem -from openlp.core.resources import * - +from openlp.core.lib import MediaManagerItem, translate from openlp.plugins.presentations.lib import FileListData class PresentationMediaItem(MediaManagerItem): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index f52aee184..02c2a1817 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -21,9 +21,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core import translate -from openlp.core.lib import MediaManagerItem -from openlp.core.resources import * +from openlp.core.lib import MediaManagerItem, translate from openlp.plugins.songs.forms import EditSongForm @@ -32,7 +30,7 @@ class SongMediaItem(MediaManagerItem): This is the custom media manager item for Songs. """ global log - log=logging.getLogger("SongMediaItem") + log = logging.getLogger("SongMediaItem") log.info("Song Media Item loaded") def __init__(self, parent, icon, title): diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index eee359fd5..e270b97bc 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -20,9 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import QtCore, QtGui -from openlp.core import translate -from openlp.core.lib import SettingsTab -from openlp.core.resources import * +from openlp.core.lib import SettingsTab, translate class SongsTab(SettingsTab): """ diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 1022b4e2f..6387094b7 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -21,7 +21,6 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.resources import * from openlp.core.lib import Plugin, Event from openlp.core.lib import EventType from openlp.plugins.songs.lib import SongManager, SongsTab, SongMediaItem @@ -31,7 +30,7 @@ from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \ class SongsPlugin(Plugin): global log - log=logging.getLogger(u'SongsPlugin') + log = logging.getLogger(u'SongsPlugin') log.info(u'Song Plugin loaded') def __init__(self, plugin_helpers): @@ -124,7 +123,7 @@ class SongsPlugin(Plugin): """ Handle the event contained in the event object. """ - log.debug(u'Handle event called with event %s'%event.event_type) + log.debug(u'Handle event called with event %s' % event.event_type) if event.event_type == EventType.ThemeListChanged: log.debug(u'New Theme request received') #self.edit_custom_form.loadThemes(self.theme_manager.getThemes())