diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 4403ac8ec..9af8debb8 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -29,8 +29,7 @@ The :mod:`lib` module contains most of the components and libraries that make OpenLP work. """ import logging -import os.path -import types +import os from PyQt4 import QtCore, QtGui, Qt @@ -63,6 +62,7 @@ class ServiceItemAction(object): PreviousLastSlide = 2 Next = 3 + def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, translate=QtCore.QCoreApplication.translate): @@ -84,6 +84,7 @@ def translate(context, text, comment=None, """ return translate(context, text, comment, encoding, n) + def get_text_file_string(text_file): """ Open a file and return its content as unicode string. If the supplied file @@ -112,6 +113,7 @@ def get_text_file_string(text_file): file_handle.close() return content_string + def str_to_bool(stringvalue): """ Convert a string version of a boolean into a real boolean. @@ -123,6 +125,7 @@ def str_to_bool(stringvalue): return stringvalue return unicode(stringvalue).strip().lower() in (u'true', u'yes', u'y') + def build_icon(icon): """ Build a QIcon instance from an existing QIcon, a resource location, or a @@ -149,6 +152,7 @@ def build_icon(icon): QtGui.QIcon.Normal, QtGui.QIcon.Off) return button_icon + def image_to_byte(image): """ Resize an image to fit on the current screen for the web and returns @@ -167,6 +171,7 @@ def image_to_byte(image): # convert to base64 encoding so does not get missed! return byte_array.toBase64() + def create_thumb(image_path, thumb_path, return_icon=True, size=None): """ Create a thumbnail from the given image path and depending on @@ -202,6 +207,7 @@ def create_thumb(image_path, thumb_path, return_icon=True, size=None): # Fallback for files with animation support. return build_icon(unicode(image_path)) + def validate_thumb(file_path, thumb_path): """ Validates whether an file's thumb still exists and if is up to date. @@ -220,6 +226,7 @@ def validate_thumb(file_path, thumb_path): thumb_date = os.stat(thumb_path).st_mtime return image_date <= thumb_date + def resize_image(image_path, width, height, background=u'#000000'): """ Resize an image to fit on the current screen. @@ -267,6 +274,7 @@ def resize_image(image_path, width, height, background=u'#000000'): painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) return new_image + def check_item_selected(list_widget, message): """ Check if a list item is selected so an action may be performed on it @@ -283,6 +291,7 @@ def check_item_selected(list_widget, message): return False return True + def clean_tags(text): """ Remove Tags from text for display @@ -295,6 +304,7 @@ def clean_tags(text): text = text.replace(tag[u'end tag'], u'') return text + def expand_tags(text): """ Expand tags HTML for display @@ -304,6 +314,7 @@ def expand_tags(text): text = text.replace(tag[u'end tag'], tag[u'end html']) return text + def check_directory_exists(dir): """ Check a theme directory exists and if not create it @@ -318,6 +329,7 @@ def check_directory_exists(dir): except IOError: pass + def create_separated_list(stringlist): """ Returns a string that represents a join of a list of strings with a @@ -346,6 +358,7 @@ def create_separated_list(stringlist): return unicode(translate('OpenLP.core.lib', '%1, %2', u'Locale list separator: start').arg(stringlist[0], merged)) + from eventreceiver import Receiver from listwidgetwithdnd import ListWidgetWithDnD from formattingtags import FormattingTags diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index 67fa45f74..9e9787914 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -27,7 +27,7 @@ """ Extend QListWidget to handle drag and drop functionality """ -import os.path +import os from PyQt4 import QtCore, QtGui diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 49d4d3e4c..0fff153a3 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -582,7 +582,7 @@ class MediaManagerItem(QtGui.QWidget): Common method for generating a service item """ serviceItem = ServiceItem(self.plugin) - serviceItem.add_icon(self.plugin.icon_path) + serviceItem.add_icon(self.plugin.iconPath) if self.generateSlideData(serviceItem, item, xmlVersion, remote): return serviceItem else: diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index f704bd9cd..a27e496cf 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -155,9 +155,9 @@ class Plugin(QtCore.QObject): self.version = get_application_version()[u'version'] self.settingsSection = self.name self.icon = None - self.media_item_class = media_item_class - self.settings_tab_class = settings_tab_class - self.settings_tab = None + self.mediaItemClass = media_item_class + self.settingsTabClass = settings_tab_class + self.settingsTab = None self.mediaItem = None self.weight = 0 self.status = PluginStatus.Inactive @@ -166,9 +166,9 @@ class Plugin(QtCore.QObject): self.renderer = plugin_helpers[u'renderer'] self.serviceManager = plugin_helpers[u'service'] self.settingsForm = plugin_helpers[u'settings form'] - self.mediadock = plugin_helpers[u'toolbox'] + self.mediaDock = plugin_helpers[u'toolbox'] self.pluginManager = plugin_helpers[u'pluginmanager'] - self.formparent = plugin_helpers[u'formparent'] + self.formParent = plugin_helpers[u'formparent'] self.mediaController = plugin_helpers[u'mediacontroller'] QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), @@ -219,8 +219,8 @@ class Plugin(QtCore.QObject): Construct a MediaManagerItem object with all the buttons and things you need, and return it for integration into OpenLP. """ - if self.media_item_class: - self.mediaItem = self.media_item_class(self.mediadock.media_dock, + if self.mediaItemClass: + self.mediaItem = self.mediaItemClass(self.mediaDock.media_dock, self, self.icon) def addImportMenuItem(self, importMenu): @@ -255,10 +255,10 @@ class Plugin(QtCore.QObject): Create a tab for the settings window to display the configurable options for this plugin to the user. """ - if self.settings_tab_class: - self.settings_tab = self.settings_tab_class(parent, self.name, + if self.settingsTabClass: + self.settingsTab = self.settingsTabClass(parent, self.name, self.getString(StringContent.VisibleName)[u'title'], - self.icon_path) + self.iconPath) def addToMenu(self, menubar): """ @@ -294,14 +294,14 @@ class Plugin(QtCore.QObject): """ if self.mediaItem: self.mediaItem.initialise() - self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight) + self.mediaDock.insert_dock(self.mediaItem, self.icon, self.weight) def finalise(self): """ Called by the plugin Manager to cleanup things. """ if self.mediaItem: - self.mediadock.remove_dock(self.mediaItem) + self.mediaDock.remove_dock(self.mediaItem) def appStartup(self): """ diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 8da5967a1..39f69dda6 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -236,18 +236,18 @@ class Renderer(object): # the first two slides (and neglect the last for now). if len(slides) == 3: html_text = expand_tags(u'\n'.join(slides[:2])) - # We check both slides to determine if the virtual break is - # needed (there is only one virtual break). + # We check both slides to determine if the optional break is + # needed (there is only one optional break). else: html_text = expand_tags(u'\n'.join(slides)) html_text = html_text.replace(u'\n', u'
') if self._text_fits_on_slide(html_text): - # The first two virtual slides fit (as a whole) on one + # The first two optional slides fit (as a whole) on one # slide. Replace the first occurrence of [---]. text = text.replace(u'\n[---]', u'', 1) else: - # The first virtual slide fits, which means we have to - # render the first virtual slide. + # The first optional slide fits, which means we have to + # render the first optional slide. text_contains_break = u'[---]' in text if text_contains_break: try: @@ -364,7 +364,7 @@ class Renderer(object): self.web.setVisible(False) self.web.resize(self.page_width, self.page_height) self.web_frame = self.web.page().mainFrame() - # Adjust width and height to account for shadow. outline done in css + # Adjust width and height to account for shadow. outline done in css. html = u""" @@ -39,7 +40,7 @@ "go_live": "${go_live}", "add_to_service": "${add_to_service}", "no_results": "${no_results}", - "back": "${back}" + "home": "${home}" } @@ -58,71 +59,79 @@
-
- ${back} +
+ ${home}

${service_manager}

${refresh} -
-
-
- ${blank} - ${show} -
-
- ${prev} - ${next} +
+
-
-
- ${back} +
+ ${home}

${slide_controller}

${refresh} -
-
- -
-
- ${back} + ${home}

${alerts}

+
+ +
@@ -133,9 +142,17 @@