diff --git a/openlp-get-strings.py b/openlp-get-strings.py old mode 100644 new mode 100755 index e53924b02..02aa16772 --- a/openlp-get-strings.py +++ b/openlp-get-strings.py @@ -42,7 +42,7 @@ ts_message = u""" """ -find_trUtf8 = re.compile(r"trUtf8\(u'([\.:;\\&\w]+)'\)", re.UNICODE) +find_trUtf8 = re.compile(r"trUtf8\(u?(['\"])([^\1]+)\1\)", re.UNICODE) strings = {} def parse_file(filename): @@ -56,9 +56,9 @@ def parse_file(filename): class_name = line[6:line.find(u'(')] continue for match in find_trUtf8.finditer(line): - key = u'%s-%s' % (class_name, match.group(1)) + key = u'%s-%s' % (class_name, match.group(2)) if not key in strings: - strings[key] = [class_name, filename, line_number, match.group(1)] + strings[key] = [class_name, filename, line_number, match.group(2)] file.close() def write_file(filename): diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index e3618c7a1..1f3fcd4b8 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -27,6 +27,7 @@ The :mod:`lib` module contains most of the components and libraries that make OpenLP work. """ import logging +import os.path import types from PyQt4 import QtCore, QtGui @@ -49,26 +50,28 @@ def translate(context, text): return QtGui.QApplication.translate( context, text, None, QtGui.QApplication.UnicodeUTF8) -def file_to_xml(xmlfile): +def get_text_file_string(text_file): """ - Open a file and return the contents of the file. + Open a file and return the contents of the file. If the supplied file name + is not a file then the function returns False. If there is an error + loading the file then the function will return None. - ``xmlfile`` + ``textfile`` The name of the file. """ - file = None - xml = None + if not os.path.isfile(text_file): + return False + file_handle = None + content_string = None try: - file = open(xmlfile, u'r') - xml = file.read() + file_handle = open(text_file, u'r') + content_string = file_handle.read() except IOError: - #This may not be an error as this is also used to check - #that a file exist - log.error(u'Failed to open XML file %s' % xmlfile) + log.error(u'Failed to open text file %s' % text_file) finally: - if file: - file.close() - return xml + if file_handle: + file_handle.close() + return content_string def str_to_bool(stringvalue): """ @@ -152,5 +155,5 @@ from rendermanager import RenderManager from mediamanageritem import MediaManagerItem from baselistwithdnd import BaseListWithDnD -__all__ = [ 'translate', 'file_to_xml', 'str_to_bool', - 'contextMenuAction', 'contextMenuSeparator','ServiceItem'] +__all__ = [ 'translate', 'get_text_file_string', 'str_to_bool', + 'contextMenuAction', 'contextMenuSeparator', 'ServiceItem'] diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 07f405bb2..23051cb77 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -168,35 +168,45 @@ class Renderer(object): line_width = self._rect.width() - self._right_margin #number of lines on a page - adjust for rounding up. page_length = int(self._rect.height() / metrics.height() - 2 ) - 1 + #Average number of characters in line ave_line_width = line_width / metrics.averageCharWidth() - ave_line_width = int(ave_line_width + (ave_line_width * 1)) + #Maximum size of a character + max_char_width = metrics.maxWidth() + #Min size of a character + min_char_width = metrics.width(u'i') + char_per_line = line_width / min_char_width log.debug(u'Page Length area height %s , metrics %s , lines %s' % (int(self._rect.height()), metrics.height(), page_length )) split_pages = [] page = [] split_lines = [] + count = 0 for line in text: #Must be a blank line so keep it. if len(line) == 0: line = u' ' while len(line) > 0: - if len(line) > ave_line_width: - pos = line.find(u' ', ave_line_width) - split_text = line[:pos] - else: - pos = len(line) - split_text = line - while metrics.width(split_text, -1) > line_width: - #Find the next space to the left - pos = line[:pos].rfind(u' ') - #no more spaces found - if pos == 0: - split_text = line + pos = char_per_line + split_text = line[:pos] + #line needs splitting + if metrics.width(split_text, -1) > line_width: + #We have no spaces + if split_text.find(u' ') == -1: + #Move back 1 char at a time till it fits while metrics.width(split_text, -1) > line_width: split_text = split_text[:-1] - pos = len(split_text) + pos = len(split_text) else: - split_text = line[:pos] + #We have spaces so split at previous one + while metrics.width(split_text, -1) > line_width: + pos = split_text.rfind(u' ') + #no more spaces and we are still too long + if pos == -1: + while metrics.width(split_text, -1) > line_width: + split_text = split_text[:-1] + pos = len(split_text) + else: + split_text = line[:pos] split_lines.append(split_text) line = line[pos:].lstrip() #if we have more text add up to 10 spaces on the front. @@ -450,32 +460,32 @@ class Renderer(object): draw=True, color = self._theme.display_shadow_color) if self._theme.display_outline: self._get_extent_and_render(line, footer, - (x+self._outline_offset, y), draw=True, + (x + self._outline_offset, y), draw=True, color = self._theme.display_outline_color) self._get_extent_and_render(line, footer, - (x, y+self._outline_offset), draw=True, + (x, y + self._outline_offset), draw=True, color = self._theme.display_outline_color) self._get_extent_and_render(line, footer, - (x, y-self._outline_offset), draw=True, + (x, y - self._outline_offset), draw=True, color = self._theme.display_outline_color) self._get_extent_and_render(line, footer, - (x-self._outline_offset, y), draw=True, + (x - self._outline_offset, y), draw=True, color = self._theme.display_outline_color) if self._outline_offset > 1: self._get_extent_and_render(line, footer, - (x+self._outline_offset, y+self._outline_offset), + (x + self._outline_offset, y + self._outline_offset), draw=True, color = self._theme.display_outline_color) self._get_extent_and_render(line, footer, - (x-self._outline_offset, y+self._outline_offset), + (x - self._outline_offset, y + self._outline_offset), draw=True, color = self._theme.display_outline_color) self._get_extent_and_render(line, footer, - (x+self._outline_offset, y-self._outline_offset), + (x + self._outline_offset, y - self._outline_offset), draw=True, color = self._theme.display_outline_color) self._get_extent_and_render(line, footer, - (x-self._outline_offset, y-self._outline_offset), + (x - self._outline_offset, y - self._outline_offset), draw=True, color = self._theme.display_outline_color) self._get_extent_and_render(line, footer,tlcorner=(x, y), diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index d35495dbc..034abff49 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -193,17 +193,17 @@ class RenderManager(object): self.renderer.set_theme(themedata) self.build_text_rectangle(themedata) self.renderer.set_frame_dest(self.width, self.height, True) - verse = [] - verse.append(u'Amazing Grace!') - verse.append(u'How sweet the sound') - verse.append(u'To save a wretch like me;') - verse.append(u'I once was lost but now am found,') - verse.append(u'Was blind, but now I see.') + verse = u'Amazing Grace!\n'\ + 'How sweet the sound\n'\ + 'To save a wretch like me;\n'\ + 'I once was lost but now am found,\n'\ + 'Was blind, but now I see.' footer = [] footer.append(u'Amazing Grace (John Newton)' ) footer.append(u'Public Domain') footer.append(u'CCLI xxx') - return self.renderer.generate_frame_from_lines(verse, footer) + formatted = self.renderer.format_slide(verse, False) + return self.renderer.generate_frame_from_lines(formatted[0], footer) def format_slide(self, words): """ diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index e9de1f832..27e16e95f 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -29,7 +29,7 @@ import uuid from PyQt4 import QtGui -from openlp.core.lib import buildIcon +from openlp.core.lib import buildIcon, Receiver class ServiceItemType(object): """ @@ -49,31 +49,28 @@ class ServiceItem(object): log = logging.getLogger(u'ServiceItem') log.info(u'Service Item created') - def __init__(self, hostplugin=None): + def __init__(self, plugin=None): """ Set up the service item. - ``hostplugin`` + ``plugin`` The plugin that this service item belongs to. """ - self.plugin = hostplugin - if hostplugin: - self.RenderManager = self.plugin.render_manager - self.shortname = hostplugin.name - self.name = self.plugin.name + if plugin: + self.RenderManager = plugin.render_manager + self.name = plugin.name self.title = u'' self.audit = u'' self.items = [] self.iconic_representation = None - self.raw_slides = None - self.frames = [] self.raw_footer = None self.theme = None self.service_item_path = None self.service_item_type = None - self.editEnabled = False - self.service_frames = [] - self.uuid = unicode(uuid.uuid1()) + self.edit_enabled = False + self._raw_frames = [] + self._display_frames = [] + self._uuid = unicode(uuid.uuid1()) def addIcon(self, icon): """ @@ -92,32 +89,27 @@ class ServiceItem(object): The render method is what generates the frames for the screen. """ log.debug(u'Render called') - self.frames = [] + self._display_frames = [] if self.service_item_type == ServiceItemType.Text: log.debug(u'Formatting slides') if self.theme is None: self.RenderManager.set_override_theme(None) else: self.RenderManager.set_override_theme(self.theme) - for slide in self.service_frames: + for slide in self._raw_frames: before = time.time() formated = self.RenderManager.format_slide(slide[u'raw_slide']) for format in formated: - frame = None lines = u'' for line in format: lines += line + u'\n' title = lines.split(u'\n')[0] - self.frames.append({u'title': title, u'text': lines, - u'image': frame}) - log.info(u'Formatting took %4s' % (time.time() - before)) - elif self.service_item_type == ServiceItemType.Command: - self.frames = self.service_frames + self._display_frames.append({u'title': title, u'text': lines}) + log.log(15, u'Formatting took %4s' % (time.time() - before)) elif self.service_item_type == ServiceItemType.Image: - for slide in self.service_frames: + for slide in self._raw_frames: slide[u'image'] = \ self.RenderManager.resize_image(slide[u'image']) - self.frames = self.service_frames else: log.error(u'Invalid value renderer :%s' % self.service_item_type) @@ -132,19 +124,19 @@ class ServiceItem(object): self.RenderManager.set_override_theme(None) else: self.RenderManager.set_override_theme(self.theme) - format = self.frames[row][u'text'].split(u'\n') + format = self._display_frames[row][u'text'].split(u'\n') frame = self.RenderManager.generate_slide(format, self.raw_footer) return frame - def add_from_image(self, path, frame_title, image): + def add_from_image(self, path, title, image): """ Add an image slide to the service item. ``path`` The directory in which the image file is located. - ``frame_title`` + ``title`` A title for the slide in the service item. ``image`` @@ -152,10 +144,10 @@ class ServiceItem(object): """ self.service_item_type = ServiceItemType.Image self.service_item_path = path - self.service_frames.append( - {u'title': frame_title, u'text': None, u'image': image}) + self._raw_frames.append( + {u'title': title, u'image': image}) - def add_from_text(self, frame_title, raw_slide): + def add_from_text(self, title, raw_slide): """ Add a text slide to the service item. @@ -166,24 +158,27 @@ class ServiceItem(object): The raw text of the slide. """ self.service_item_type = ServiceItemType.Text - frame_title = frame_title.split(u'\n')[0] - self.service_frames.append( - {u'title': frame_title, u'raw_slide': raw_slide}) + title = title.split(u'\n')[0] + self._raw_frames.append( + {u'title': title, u'raw_slide': raw_slide}) - def add_from_command(self, path, frame_title, image): + def add_from_command(self, path, file_name, image): """ Add a slide from a command. - ``frame_title`` + ``path`` The title of the slide in the service item. - ``command`` + ``file_name`` + The title of the slide in the service item. + + ``image`` The command of/for the slide. """ self.service_item_type = ServiceItemType.Command self.service_item_path = path - self.service_frames.append( - {u'title': frame_title, u'command': None, u'text':None, u'image': image}) + self._raw_frames.append( + {u'title': file_name, u'image': image}) def get_service_repr(self): """ @@ -192,7 +187,7 @@ class ServiceItem(object): """ service_header = { u'name': self.name.lower(), - u'plugin': self.shortname, + u'plugin': self.name, u'theme':self.theme, u'title':self.title, u'icon':self.icon, @@ -202,13 +197,13 @@ class ServiceItem(object): } service_data = [] if self.service_item_type == ServiceItemType.Text: - for slide in self.service_frames: + for slide in self._raw_frames: service_data.append(slide) elif self.service_item_type == ServiceItemType.Image: - for slide in self.service_frames: + for slide in self._raw_frames: service_data.append(slide[u'title']) elif self.service_item_type == ServiceItemType.Command: - for slide in self.service_frames: + for slide in self._raw_frames: service_data.append({u'title':slide[u'title'], u'image':slide[u'image']}) return {u'header': service_header, u'data': service_data} @@ -234,7 +229,7 @@ class ServiceItem(object): self.audit = header[u'audit'] if self.service_item_type == ServiceItemType.Text: for slide in serviceitem[u'serviceitem'][u'data']: - self.service_frames.append(slide) + self._raw_frames.append(slide) elif self.service_item_type == ServiceItemType.Image: for text_image in serviceitem[u'serviceitem'][u'data']: filename = os.path.join(path, text_image) @@ -247,11 +242,11 @@ class ServiceItem(object): def merge(self, other): """ - Updates the uuid with the value from the original one - The uuid is unique for a give service item but this allows one to + Updates the _uuid with the value from the original one + The _uuid is unique for a give service item but this allows one to replace an original version. """ - self.uuid = other.uuid + self._uuid = other._uuid def __eq__(self, other): """ @@ -259,25 +254,51 @@ class ServiceItem(object): """ if not other: return False - return self.uuid == other.uuid + return self._uuid == other._uuid def __ne__(self, other): """ Confirms the service items are not for the same instance """ - return self.uuid != other.uuid + return self._uuid != other._uuid - def isSong(self): + def is_song(self): return self.name == u'Songs' - def isMedia(self): + def is_media(self): return self.name.lower() == u'media' - def isCommand(self): + def is_command(self): return self.service_item_type == ServiceItemType.Command - def isImage(self): + def is_image(self): return self.service_item_type == ServiceItemType.Image - def isText(self): + def is_text(self): return self.service_item_type == ServiceItemType.Text + + def get_frames(self): + if self.service_item_type == ServiceItemType.Text: + return self._display_frames + else: + return self._raw_frames + + def get_rendered_frame(self, row): + """ + Returns the correct frame for a given list and + renders it if required. + """ + if self.service_item_type == ServiceItemType.Text: + return self.render_individual(row) + else: + return self._raw_frames[row][u'image'] + + def get_frame_title(self, row=0): + """ + Returns the title of the raw frame + """ + return self._raw_frames[row][u'title'] + + def request_audit(self): + if self.audit: + Receiver.send_message(u'songusage_live', self.audit) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 4e5b9cd9d..187d5f6e2 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -184,12 +184,12 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def loadTheme(self, theme): log.debug(u'LoadTheme %s', theme) - self.theme = self.thememanager.getThemeData(theme) + self.theme = theme # Stop the initial screen setup generating 1 preview per field! self.allowPreview = False self.paintUi(self.theme) self.allowPreview = True - self.previewTheme(self.theme) + self.previewTheme() def onImageToolButtonClicked(self): filename = QtGui.QFileDialog.getOpenFileName( @@ -197,13 +197,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): if filename: self.ImageLineEdit.setText(filename) self.theme.background_filename = filename - self.previewTheme(self.theme) + self.previewTheme() # #Main Font Tab # def onFontMainComboBoxSelected(self): self.theme.font_main_name = self.FontMainComboBox.currentFont().family() - self.previewTheme(self.theme) + self.previewTheme() def onFontMainWeightComboBoxSelected(self, value): if value == 0: @@ -218,7 +218,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: self.theme.font_main_weight = u'Bold' self.theme.font_main_italics = True - self.previewTheme(self.theme) + self.previewTheme() def onFontMainColorPushButtonClicked(self): self.theme.font_main_color = QtGui.QColorDialog.getColor( @@ -226,12 +226,12 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.FontMainColorPushButton.setStyleSheet( u'background-color: %s' % unicode(self.theme.font_main_color)) - self.previewTheme(self.theme) + self.previewTheme() def onFontMainSizeSpinBoxChanged(self): if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value(): self.theme.font_main_proportion = self.FontMainSizeSpinBox.value() - self.previewTheme(self.theme) + self.previewTheme() def onFontMainDefaultCheckBoxChanged(self, value): if value == 2: # checked @@ -252,41 +252,41 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.FontMainLineSpacingSpinBox.setValue( self.theme.font_main_indentation) self.stateChanging(self.theme) - self.previewTheme(self.theme) + self.previewTheme() def onFontMainXSpinBoxChanged(self): if self.theme.font_main_x != self.FontMainXSpinBox.value(): self.theme.font_main_x = self.FontMainXSpinBox.value() - self.previewTheme(self.theme) + self.previewTheme() def onFontMainYSpinBoxChanged(self): if self.theme.font_main_y != self.FontMainYSpinBox.value(): self.theme.font_main_y = self.FontMainYSpinBox.value() - self.previewTheme(self.theme) + self.previewTheme() def onFontMainWidthSpinBoxChanged(self): if self.theme.font_main_width != self.FontMainWidthSpinBox.value(): self.theme.font_main_width = self.FontMainWidthSpinBox.value() - self.previewTheme(self.theme) + self.previewTheme() def onFontMainLineSpacingSpinBoxChanged(self): if self.theme.font_main_indentation != \ self.FontMainLineSpacingSpinBox.value(): self.theme.font_main_indentation = \ self.FontMainLineSpacingSpinBox.value() - self.previewTheme(self.theme) + self.previewTheme() def onFontMainHeightSpinBoxChanged(self): if self.theme.font_main_height != self.FontMainHeightSpinBox.value(): self.theme.font_main_height = self.FontMainHeightSpinBox.value() - self.previewTheme(self.theme) + self.previewTheme() # #Footer Font Tab # def onFontFooterComboBoxSelected(self): self.theme.font_footer_name = \ self.FontFooterComboBox.currentFont().family() - self.previewTheme(self.theme) + self.previewTheme() def onFontFooterWeightComboBoxSelected(self, value): if value == 0: @@ -301,22 +301,21 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: self.theme.font_footer_weight = u'Bold' self.theme.font_footer_italics = True - self.previewTheme(self.theme) + self.previewTheme() def onFontFooterColorPushButtonClicked(self): self.theme.font_footer_color = QtGui.QColorDialog.getColor( QtGui.QColor(self.theme.font_footer_color), self).name() - self.FontFooterColorPushButton.setStyleSheet( 'background-color: %s' % unicode(self.theme.font_footer_color)) - self.previewTheme(self.theme) + self.previewTheme() def onFontFooterSizeSpinBoxChanged(self): if self.theme.font_footer_proportion != \ self.FontFooterSizeSpinBox.value(): self.theme.font_footer_proportion = \ self.FontFooterSizeSpinBox.value() - self.previewTheme(self.theme) + self.previewTheme() def onFontFooterDefaultCheckBoxChanged(self, value): if value == 2: # checked @@ -336,29 +335,29 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.FontFooterHeightSpinBox.setValue( self.theme.font_footer_height) self.stateChanging(self.theme) - self.previewTheme(self.theme) + self.previewTheme() def onFontFooterXSpinBoxChanged(self): if self.theme.font_footer_x != self.FontFooterXSpinBox.value(): self.theme.font_footer_x = self.FontFooterXSpinBox.value() - self.previewTheme(self.theme) + self.previewTheme() def onFontFooterYSpinBoxChanged(self): if self.theme.font_footer_y != self.FontFooterYSpinBox.value(): self.theme.font_footer_y = self.FontFooterYSpinBox.value() - self.previewTheme(self.theme) + self.previewTheme() def onFontFooterWidthSpinBoxChanged(self): if self.theme.font_footer_width != self.FontFooterWidthSpinBox.value(): self.theme.font_footer_width = self.FontFooterWidthSpinBox.value() - self.previewTheme(self.theme) + self.previewTheme() def onFontFooterHeightSpinBoxChanged(self): if self.theme.font_footer_height != \ self.FontFooterHeightSpinBox.value(): self.theme.font_footer_height = \ self.FontFooterHeightSpinBox.value() - self.previewTheme(self.theme) + self.previewTheme() # #Background Tab # @@ -372,7 +371,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: self.theme.background_mode = u'transparent' self.stateChanging(self.theme) - self.previewTheme(self.theme) + self.previewTheme() def onBackgroundTypeComboBoxSelected(self, currentIndex): self.setBackground(currentIndex, self.GradientComboBox.currentIndex()) @@ -397,7 +396,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: self.theme.background_type = u'image' self.stateChanging(self.theme) - self.previewTheme(self.theme) + self.previewTheme() def onColor1PushButtonClicked(self): if self.theme.background_type == u'solid': @@ -412,14 +411,14 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): u'background-color: %s' % \ unicode(self.theme.background_startColor)) - self.previewTheme(self.theme) + self.previewTheme() def onColor2PushButtonClicked(self): self.theme.background_endColor = QtGui.QColorDialog.getColor( QtGui.QColor(self.theme.background_endColor), self).name() self.Color2PushButton.setStyleSheet( u'background-color: %s' % unicode(self.theme.background_endColor)) - self.previewTheme(self.theme) + self.previewTheme() # #Other Tab # @@ -429,14 +428,14 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: self.theme.display_outline = False self.stateChanging(self.theme) - self.previewTheme(self.theme) + self.previewTheme() def onOutlineColorPushButtonClicked(self): self.theme.display_outline_color = QtGui.QColorDialog.getColor( QtGui.QColor(self.theme.display_outline_color), self).name() self.OutlineColorPushButton.setStyleSheet( u'background-color: %s' % unicode(self.theme.display_outline_color)) - self.previewTheme(self.theme) + self.previewTheme() def onShadowCheckBoxChanged(self, value): if value == 2: # checked @@ -444,24 +443,24 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: self.theme.display_shadow = False self.stateChanging(self.theme) - self.previewTheme(self.theme) + self.previewTheme() def onShadowColorPushButtonClicked(self): self.theme.display_shadow_color = QtGui.QColorDialog.getColor( QtGui.QColor(self.theme.display_shadow_color), self).name() self.ShadowColorPushButton.setStyleSheet( u'background-color: %s' % unicode(self.theme.display_shadow_color)) - self.previewTheme(self.theme) + self.previewTheme() def onHorizontalComboBoxSelected(self, currentIndex): self.theme.display_horizontalAlign = currentIndex self.stateChanging(self.theme) - self.previewTheme(self.theme) + self.previewTheme() def onVerticalComboBoxSelected(self, currentIndex): self.theme.display_verticalAlign = currentIndex self.stateChanging(self.theme) - self.previewTheme(self.theme) + self.previewTheme() # #Local Methods # @@ -654,18 +653,10 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: self.ShadowColorPushButton.setEnabled(False) - def previewTheme(self, theme): + def previewTheme(self): if self.allowPreview: #calculate main number of rows - main_weight = 50 - if self.theme.font_main_weight == u'Bold': - main_weight = 75 - mainFont = QtGui.QFont(self.theme.font_main_name, - self.theme.font_main_proportion, # size - main_weight, # weight - self.theme.font_main_italics)# italic - mainFont.setPixelSize(self.theme.font_main_proportion) - metrics = QtGui.QFontMetrics(mainFont) + metrics = self._getThemeMetrics() page_length = \ (self.FontMainHeightSpinBox.value() / metrics.height() - 2) - 1 log.debug(u'Page Length area height %s, metrics %s, lines %s' % @@ -673,6 +664,22 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): page_length)) page_length_text = unicode(self.trUtf8(u'Slide Height is %s rows')) self.FontMainLinesPageLabel.setText(page_length_text % page_length) - frame = self.thememanager.generateImage(theme) + #a=c + frame = self.thememanager.generateImage(self.theme) self.ThemePreview.setPixmap(QtGui.QPixmap.fromImage(frame)) + def _getThemeMetrics(self): + main_weight = 50 + if self.theme.font_main_weight == u'Bold': + main_weight = 75 + mainFont = QtGui.QFont(self.theme.font_main_name, + self.theme.font_main_proportion, # size + main_weight, # weight + self.theme.font_main_italics)# italic + mainFont.setPixelSize(self.theme.font_main_proportion) + metrics = QtGui.QFontMetrics(mainFont) + #Validate that the screen width is big enough to display the text + if self.theme.font_main_width < metrics.maxWidth() * 2 + 64: + self.theme.font_main_width = metrics.maxWidth() * 2 + 64 + self.FontMainWidthSpinBox.setValue(self.theme.font_main_width) + return metrics diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index fd2b08af3..a387deaef 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -24,7 +24,6 @@ import logging import os -import time from PyQt4 import QtCore, QtGui from PyQt4.phonon import Phonon @@ -275,6 +274,7 @@ class MainDisplay(DisplayWidget): self.mediaLoaded = True self.display.hide() self.video.setFullScreen(True) + self.video.setVisible(True) self.mediaObject.play() if self.primary: self.setVisible(True) @@ -286,7 +286,6 @@ class MainDisplay(DisplayWidget): def onMediaStop(self): log.debug(u'Media stopped by user') self.mediaObject.stop() - self.display.show() def onMediaFinish(self): log.debug(u'Reached end of media playlist') diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 3ba2ebbb5..8a927fc68 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -23,7 +23,6 @@ ############################################################################### import os -import string import logging import cPickle import zipfile @@ -48,7 +47,7 @@ class ServiceManagerList(QtGui.QTreeWidget): # else: # pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] # serviceItem = self.parent.serviceItems[pos - 1] -# if serviceItem[u'data'].editEnabled: +# if serviceItem[u'data'].edit_enabled: # self.parent.editAction.setVisible(True) # else: # self.parent.editAction.setVisible(False) @@ -388,14 +387,14 @@ class ServiceManager(QtGui.QWidget): #Repaint the screen self.ServiceManagerList.clear() for itemcount, item in enumerate(self.serviceItems): - serviceitem = item[u'data'] + serviceitem = item[u'service_item'] treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList) treewidgetitem.setText(0,serviceitem.title) treewidgetitem.setIcon(0,serviceitem.iconic_representation) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order'])) treewidgetitem.setExpanded(item[u'expanded']) - for count, frame in enumerate(serviceitem.frames): + for count, frame in enumerate(serviceitem.get_frames()): treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem) text = frame[u'title'] treewidgetitem1.setText(0,text[:40]) @@ -431,12 +430,12 @@ class ServiceManager(QtGui.QWidget): zip = zipfile.ZipFile(unicode(filename), 'w') for item in self.serviceItems: service.append( - {u'serviceitem':item[u'data'].get_service_repr()}) - if item[u'data'].service_item_type == ServiceItemType.Image or \ - item[u'data'].service_item_type == ServiceItemType.Command: - for frame in item[u'data'].frames: + {u'serviceitem':item[u'service_item'].get_service_repr()}) + if item[u'service_item'].service_item_type == ServiceItemType.Image or \ + item[u'service_item'].service_item_type == ServiceItemType.Command: + for frame in item[u'service_item'].frames: path_from = unicode(os.path.join( - item[u'data'].service_item_path, frame[u'title'])) + item[u'service_item'].service_item_path, frame[u'title'])) zip.write(path_from) file = open(servicefile, u'wb') cPickle.dump(service, file) @@ -460,7 +459,7 @@ class ServiceManager(QtGui.QWidget): def onQuickSaveService(self): self.onSaveService(True) - def onLoadService(self, lastService = False): + def onLoadService(self, lastService=False): """ Load an existing service from disk and rebuild the serviceitems. All files retrieved from the zip file are placed in a temporary directory @@ -481,11 +480,8 @@ class ServiceManager(QtGui.QWidget): try: zip = zipfile.ZipFile(unicode(filename)) for file in zip.namelist(): - if os.name == u'nt': - winfile = string.replace(file, '/', os.path.sep) - names = winfile.split(os.path.sep) - else: - names = file.split(os.path.sep) + osfile = unicode(QtCore.QDir.toNativeSeparators(file)) + names = osfile.split(os.path.sep) file_to = os.path.join(self.servicePath, names[len(names) - 1]) f = open(file_to, u'wb') @@ -501,7 +497,7 @@ class ServiceManager(QtGui.QWidget): for item in items: serviceitem = ServiceItem() serviceitem.RenderManager = self.parent.RenderManager - serviceitem.set_from_service(item, self.servicePath ) + serviceitem.set_from_service(item, self.servicePath) self.addServiceItem(serviceitem) try: if os.path.isfile(p_file): @@ -545,7 +541,7 @@ class ServiceManager(QtGui.QWidget): tempServiceItems = self.serviceItems self.onNewService() for item in tempServiceItems: - self.addServiceItem(item[u'data']) + self.addServiceItem(item[u'service_item']) def addServiceItem(self, item): """ @@ -558,19 +554,19 @@ class ServiceManager(QtGui.QWidget): sitem, count = self.findServiceItem() item.render() if self.remoteEditTriggered: - item.merge(self.serviceItems[sitem][u'data']) - self.serviceItems[sitem][u'data'] = item + item.merge(self.serviceItems[sitem][u'service_item']) + self.serviceItems[sitem][u'service_item'] = item self.remoteEditTriggered = False self.repaintServiceList(sitem + 1, 0) self.parent.LiveController.replaceServiceManagerItem(item) else: if sitem == -1: - self.serviceItems.append({u'data': item, + self.serviceItems.append({u'service_item': item, u'order': len(self.serviceItems) + 1, u'expanded':True}) self.repaintServiceList(len(self.serviceItems) + 1, 0) else: - self.serviceItems.insert(sitem + 1, {u'data': item, + self.serviceItems.insert(sitem + 1, {u'service_item': item, u'order': len(self.serviceItems)+1, u'expanded':True}) self.repaintServiceList(sitem + 1, 0) @@ -582,7 +578,7 @@ class ServiceManager(QtGui.QWidget): """ item, count = self.findServiceItem() self.parent.PreviewController.addServiceManagerItem( - self.serviceItems[item][u'data'], count) + self.serviceItems[item][u'service_item'], count) def makeLive(self): """ @@ -590,17 +586,18 @@ class ServiceManager(QtGui.QWidget): """ item, count = self.findServiceItem() self.parent.LiveController.addServiceManagerItem( - self.serviceItems[item][u'data'], count) + self.serviceItems[item][u'service_item'], count) def remoteEdit(self): """ Posts a remote edit message to a plugin to allow item to be edited. """ item, count = self.findServiceItem() - if self.serviceItems[item][u'data'].editEnabled: + if self.serviceItems[item][u'service_item'].edit_enabled: self.remoteEditTriggered = True - Receiver.send_message(u'%s_edit' % self.serviceItems[item][u'data'].name, u'L:%s' % - self.serviceItems[item][u'data'].editId ) + Receiver.send_message(u'%s_edit' % + self.serviceItems[item][u'service_item'].name, u'L:%s' % + self.serviceItems[item][u'service_item'].editId ) def onRemoteEditClear(self): self.remoteEditTriggered = False @@ -698,5 +695,5 @@ class ServiceManager(QtGui.QWidget): def onThemeChangeAction(self): theme = unicode(self.sender().text()) item, count = self.findServiceItem() - self.serviceItems[item][u'data'].theme = theme + self.serviceItems[item][u'service_item'].theme = theme self.regenerateServiceItems() diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index a21edd994..9edf906b3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -28,8 +28,7 @@ import os from PyQt4 import QtCore, QtGui from PyQt4.phonon import Phonon -from openlp.core.lib import OpenLPToolbar, Receiver, ServiceItemType, \ - str_to_bool, PluginConfig +from openlp.core.lib import OpenLPToolbar, Receiver, str_to_bool, PluginConfig class SlideList(QtGui.QTableWidget): """ @@ -86,9 +85,9 @@ class SlideController(QtGui.QWidget): u'Edit Song', ] self.timer_id = 0 - self.commandItem = None self.songEdit = False - self.row = 0 + self.selectedRow = 0 + self.serviceItem = None self.Panel = QtGui.QWidget(parent.ControlSplitter) # Layout for holding panel self.PanelLayout = QtGui.QVBoxLayout(self.Panel) @@ -296,15 +295,12 @@ class SlideController(QtGui.QWidget): Handle changes of width from the splitter between the live and preview controller. Event only issues when changes have finished """ - if not self.commandItem: - return width = self.parent.ControlSplitter.sizes()[self.split] height = width * self.parent.RenderManager.screen_ratio self.PreviewListWidget.setColumnWidth(0, width) - for framenumber, frame in enumerate(self.commandItem.frames): - if frame[u'text']: - return - self.PreviewListWidget.setRowHeight(framenumber, height) + if self.serviceItem and not self.serviceItem.is_text(): + for framenumber, frame in enumerate(self.serviceItem.get_frames()): + self.PreviewListWidget.setRowHeight(framenumber, height) def trackSplitter(self, tab, pos): """ @@ -348,9 +344,9 @@ class SlideController(QtGui.QWidget): self.Songbar.setVisible(False) self.Mediabar.setVisible(False) self.Toolbar.makeWidgetsInvisible(self.image_list) - if item.isText(): + if item.is_text(): self.Toolbar.makeWidgetsInvisible(self.image_list) - if item.isSong() and \ + if item.is_song() and \ str_to_bool(self.songsconfig.get_config(u'display songbar', True)): for action in self.Songbar.actions: self.Songbar.actions[action].setVisible(False) @@ -365,11 +361,11 @@ class SlideController(QtGui.QWidget): #More than 20 verses hard luck pass self.Songbar.setVisible(True) - elif item.isImage(): + elif item.is_image(): #Not sensible to allow loops with 1 frame - if len(item.frames) > 1: + if len(item.get_frames()) > 1: self.Toolbar.makeWidgetsVisible(self.image_list) - elif item.isMedia(): + elif item.is_media(): self.Toolbar.setVisible(False) self.Mediabar.setVisible(True) self.volumeSlider.setAudioOutput(self.parent.mainDisplay.audio) @@ -381,68 +377,53 @@ class SlideController(QtGui.QWidget): self.Toolbar.setVisible(True) self.Mediabar.setVisible(False) self.Toolbar.makeWidgetsInvisible(self.song_edit_list) - if item.editEnabled and item.fromPlugin: + if item.edit_enabled and item.fromPlugin: self.Toolbar.makeWidgetsVisible(self.song_edit_list) - elif item.isMedia(): + elif item.is_media(): self.Toolbar.setVisible(False) self.Mediabar.setVisible(True) self.volumeSlider.setAudioOutput(self.audio) def addServiceItem(self, item): """ - Method to install the service item into the controller and - request the correct the toolbar of the plugin + Method to install the service item into the controller Called by plugins """ log.debug(u'addServiceItem') - #If old item was a command tell it to stop - if self.commandItem and self.commandItem.isCommand(): - self.onMediaStop() - self.commandItem = item before = time.time() item.render() log.log(15, u'Rendering took %4s' % (time.time() - before)) - self.enableToolBar(item) - if item.isCommand(): - if self.isLive: - Receiver.send_message(u'%s_start' % item.name.lower(), \ - [item.shortname, item.service_item_path, - item.service_frames[0][u'title'], self.isLive]) - else: - if item.isMedia(): - self.onMediaStart(item) slideno = 0 if self.songEdit: - slideno = self.row + slideno = self.selectedRow self.songEdit = False - self.displayServiceManagerItems(item, slideno) + self.addServiceManagerItem(item, slideno) def replaceServiceManagerItem(self, item): """ Replacement item following a remote edit """ - if item.__eq__(self.commandItem): + if item.__eq__(self.serviceItem): self.addServiceManagerItem(item, self.PreviewListWidget.currentRow()) def addServiceManagerItem(self, item, slideno): """ Method to install the service item into the controller and - request the correct the toolbar of the plugin + request the correct toolbar for the plugin. Called by ServiceManager """ log.debug(u'addServiceManagerItem') #If old item was a command tell it to stop - if self.commandItem and self.commandItem.isCommand(): + if self.serviceItem and self.serviceItem.is_command(): self.onMediaStop() - self.commandItem = item self.enableToolBar(item) - if item.isCommand(): + if item.is_command(): if self.isLive: Receiver.send_message(u'%s_start' % item.name.lower(), \ - [item.shortname, item.service_item_path, - item.service_frames[0][u'title'], slideno, self.isLive]) + [item.title, item.service_item_path, + item.get_frame_title(), slideno, self.isLive]) else: - if item.isMedia(): + if item.is_media(): self.onMediaStart(item) self.displayServiceManagerItems(item, slideno) @@ -456,17 +437,17 @@ class SlideController(QtGui.QWidget): #Set pointing cursor when we have somthing to point at self.PreviewListWidget.setCursor(QtCore.Qt.PointingHandCursor) before = time.time() - self.serviceitem = serviceitem + self.serviceItem = serviceitem self.PreviewListWidget.clear() self.PreviewListWidget.setRowCount(0) self.PreviewListWidget.setColumnWidth(0, width) - for framenumber, frame in enumerate(self.serviceitem.frames): + for framenumber, frame in enumerate(self.serviceItem.get_frames()): self.PreviewListWidget.setRowCount( self.PreviewListWidget.rowCount() + 1) item = QtGui.QTableWidgetItem() slide_height = 0 #It is a Image - if frame[u'text'] is None: + if not self.serviceItem.is_text(): label = QtGui.QLabel() label.setMargin(4) pixmap = self.parent.RenderManager.resize_image(frame[u'image']) @@ -479,7 +460,7 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.setItem(framenumber, 0, item) if slide_height != 0: self.PreviewListWidget.setRowHeight(framenumber, slide_height) - if self.serviceitem.frames[0][u'text']: + if self.serviceItem.is_text(): self.PreviewListWidget.resizeRowsToContents() self.PreviewListWidget.setColumnWidth( 0, self.PreviewListWidget.viewport().size().width()) @@ -490,8 +471,8 @@ class SlideController(QtGui.QWidget): self.onSlideSelected() self.PreviewListWidget.setFocus() log.log(15, u'Display Rendering took %4s' % (time.time() - before)) - if self.serviceitem.audit and self.isLive: - Receiver.send_message(u'songusage_live', self.serviceitem.audit) + if self.isLive: + self.serviceItem.request_audit() log.debug(u'displayServiceManagerItems End') #Screen event methods @@ -499,8 +480,8 @@ class SlideController(QtGui.QWidget): """ Go to the first slide. """ - if self.commandItem and self.commandItem.isCommand(): - Receiver.send_message(u'%s_first'% self.commandItem.name.lower()) + if self.serviceItem.is_command(): + Receiver.send_message(u'%s_first'% self.serviceItem.name.lower()) self.updatePreview() else: self.PreviewListWidget.selectRow(0) @@ -513,11 +494,11 @@ class SlideController(QtGui.QWidget): """ Blank the screen. """ - if self.commandItem and self.commandItem.isCommand(): + if self.serviceItem and self.serviceItem.is_command(): if blanked: - Receiver.send_message(u'%s_blank'% self.commandItem.name.lower()) + Receiver.send_message(u'%s_blank'% self.serviceItem.name.lower()) else: - Receiver.send_message(u'%s_unblank'% self.commandItem.name.lower()) + Receiver.send_message(u'%s_unblank'% self.serviceItem.name.lower()) else: self.parent.mainDisplay.blankDisplay(blanked) @@ -527,22 +508,20 @@ class SlideController(QtGui.QWidget): if this is the Live Controller also display on the screen """ row = self.PreviewListWidget.currentRow() - self.row = 0 + self.selectedRow = 0 if row > -1 and row < self.PreviewListWidget.rowCount(): - if self.commandItem.isCommand(): - Receiver.send_message(u'%s_slide'% self.commandItem.name.lower(), [row]) + if self.serviceItem.is_command(): + Receiver.send_message(u'%s_slide'% self.serviceItem.name.lower(), [row]) if self.isLive: self.updatePreview() else: - frame = self.serviceitem.frames[row][u'image'] before = time.time() - if frame is None: - frame = self.serviceitem.render_individual(row) + frame = self.serviceItem.get_rendered_frame(row) self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame)) log.log(15, u'Slide Rendering took %4s' % (time.time() - before)) if self.isLive: self.parent.mainDisplay.frameView(frame) - self.row = row + self.selectedRow = row def onSlideChange(self, row): """ @@ -574,8 +553,8 @@ class SlideController(QtGui.QWidget): """ Go to the next slide. """ - if self.commandItem and self.commandItem.isCommand(): - Receiver.send_message(u'%s_next'% self.commandItem.name.lower()) + if self.serviceItem.is_command(): + Receiver.send_message(u'%s_next'% self.serviceItem.name.lower()) self.updatePreview() else: row = self.PreviewListWidget.currentRow() + 1 @@ -588,9 +567,9 @@ class SlideController(QtGui.QWidget): """ Go to the previous slide. """ - if self.commandItem and self.commandItem.isCommand(): + if self.serviceItem.is_command(): Receiver.send_message( - u'%s_previous'% self.commandItem.name.lower()) + u'%s_previous'% self.serviceItem.name.lower()) self.updatePreview() else: row = self.PreviewListWidget.currentRow() - 1 @@ -603,8 +582,8 @@ class SlideController(QtGui.QWidget): """ Go to the last slide. """ - if self.commandItem and self.commandItem.isCommand(): - Receiver.send_message(u'%s_last'% self.commandItem.name.lower()) + if self.serviceItem.is_command(): + Receiver.send_message(u'%s_last'% self.serviceItem.name.lower()) self.updatePreview() else: self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount() - 1) @@ -633,8 +612,8 @@ class SlideController(QtGui.QWidget): def onEditSong(self): self.songEdit = True - Receiver.send_message(u'%s_edit' % self.commandItem.name, u'P:%s' % - self.commandItem.editId ) + Receiver.send_message(u'%s_edit' % self.serviceItem.name, u'P:%s' % + self.serviceItem.editId ) def onGoLive(self): """ @@ -643,24 +622,24 @@ class SlideController(QtGui.QWidget): row = self.PreviewListWidget.currentRow() if row > -1 and row < self.PreviewListWidget.rowCount(): self.parent.LiveController.addServiceManagerItem( - self.commandItem, row) + self.serviceItem, row) def onMediaStart(self, item): self.mediaObject.stop() self.mediaObject.clearQueue() - file = os.path.join(item.service_item_path, item.service_frames[0][u'title']) + file = os.path.join(item.service_item_path, item.get_frame_title()) self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) self.onMediaPlay() def onMediaPause(self): if self.isLive: - Receiver.send_message(u'%s_pause'% self.commandItem.name.lower()) + Receiver.send_message(u'%s_pause'% self.serviceItem.name.lower()) else: self.mediaObject.pause() def onMediaPlay(self): if self.isLive: - Receiver.send_message(u'%s_play'% self.commandItem.name.lower(), self.isLive) + Receiver.send_message(u'%s_play'% self.serviceItem.name.lower(), self.isLive) else: self.SlidePreview.hide() self.video.show() @@ -668,7 +647,7 @@ class SlideController(QtGui.QWidget): def onMediaStop(self): if self.isLive: - Receiver.send_message(u'%s_stop'% self.commandItem.name.lower()) + Receiver.send_message(u'%s_stop'% self.serviceItem.name.lower()) else: self.mediaObject.stop() self.video.hide() diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index c165075eb..6a207fb9c 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.ui import AmendThemeForm from openlp.core.theme import Theme from openlp.core.lib import PluginConfig, OpenLPToolbar, ThemeXML, \ - str_to_bool, file_to_xml, buildIcon, Receiver, contextMenuAction, \ + str_to_bool, get_text_file_string, buildIcon, Receiver, contextMenuAction, \ contextMenuSeparator from openlp.core.utils import ConfigHelper @@ -150,15 +150,17 @@ class ThemeManager(QtGui.QWidget): self.pushThemes() def onAddTheme(self): - self.amendThemeForm.loadTheme(None) + theme = self.createThemeFromXml(self.baseTheme(), self.path) + self.amendThemeForm.loadTheme(theme) self.saveThemeName = u'' self.amendThemeForm.exec_() def onEditTheme(self): item = self.ThemeListWidget.currentItem() if item: - self.amendThemeForm.loadTheme( + theme = self.getThemeData( unicode(item.data(QtCore.Qt.UserRole).toString())) + self.amendThemeForm.loadTheme(theme) self.saveThemeName = unicode( item.data(QtCore.Qt.UserRole).toString()) self.amendThemeForm.exec_() @@ -274,7 +276,7 @@ class ThemeManager(QtGui.QWidget): log.debug(u'getthemedata for theme %s', themename) xml_file = os.path.join(self.path, unicode(themename), unicode(themename) + u'.xml') - xml = file_to_xml(xml_file) + xml = get_text_file_string(xml_file) if not xml: xml = self.baseTheme() return self.createThemeFromXml(xml, self.path) @@ -501,6 +503,8 @@ class ThemeManager(QtGui.QWidget): theme.display_wrapStyle = theme.display_wrapStyle.strip() theme.font_footer_color = theme.font_footer_color.strip() theme.font_footer_height = int(theme.font_footer_height.strip()) + theme.font_footer_indentation = \ + int(theme.font_footer_indentation.strip()) theme.font_footer_italics = str_to_bool(theme.font_footer_italics) theme.font_footer_name = theme.font_footer_name.strip() #theme.font_footer_override diff --git a/openlp/core/utils/registry.py b/openlp/core/utils/registry.py index 8fa0bb6a8..e56d939ef 100644 --- a/openlp/core/utils/registry.py +++ b/openlp/core/utils/registry.py @@ -101,10 +101,10 @@ class Registry(object): return False def _load(self): + if not os.path.isfile(self.file_name): + return False file_handle = None try: - if not os.path.isfile(self.file_name): - return False file_handle = open(self.file_name, u'r') self.config.readfp(file_handle) return True diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 8b86ab290..dbd7db643 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -145,7 +145,7 @@ class CustomMediaItem(MediaManagerItem): customSlide = self.parent.custommanager.get_custom(item_id) title = customSlide.title credit = customSlide.credits - service_item.editEnabled = True + service_item.edit_enabled = True service_item.editId = item_id theme = customSlide.theme_name if len(theme) is not 0 : @@ -159,4 +159,4 @@ class CustomMediaItem(MediaManagerItem): for slide in raw_slides: service_item.add_from_text(slide[:30], slide) service_item.raw_footer = raw_footer - return True + return True \ No newline at end of file diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index cb4bfd320..f0b4785ae 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -136,18 +136,18 @@ class PresentationMediaItem(MediaManagerItem): return False service_item.title = unicode(self.DisplayTypeComboBox.currentText()) service_item.shortname = unicode(self.DisplayTypeComboBox.currentText()) - cont = self.controllers[service_item.shortname] + controller = self.controllers[service_item.shortname] for item in items: bitem = self.ListView.item(item.row()) filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) (path, name) = os.path.split(filename) - cont.store_filename(filename) - if cont.get_slide_preview_file(1) is None: - cont.load_presentation(filename) + controller.store_filename(filename) + if controller.get_slide_preview_file(1) is None: + controller.load_presentation(filename) i = 1 - img = cont.get_slide_preview_file(i) + img = controller.get_slide_preview_file(i) while img: service_item.add_from_command(path, name, img) i = i + 1 - img = cont.get_slide_preview_file(i) + img = controller.get_slide_preview_file(i) return True diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index f69faed8b..000f752af 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -287,7 +287,7 @@ class SongMediaItem(MediaManagerItem): item_id = self.remoteSong song = self.parent.songmanager.get_song(item_id) service_item.theme = song.theme_name - service_item.editEnabled = True + service_item.edit_enabled = True service_item.editId = item_id service_item.verse_order = song.verse_order if song.lyrics.startswith(u'