From 2095a6d0d0957bd2148a60aefa662c542c3ff9b5 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 17 Jun 2012 18:25:56 +0200 Subject: [PATCH 01/12] fixed wrong image being kept in cache when aborting the themeform --- openlp/core/lib/renderer.py | 1 + openlp/core/ui/themeform.py | 1 + openlp/core/ui/thememanager.py | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index e35c78559..a7f830944 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -134,6 +134,7 @@ class Renderer(object): else: theme_data, main_rect, footer_rect = \ self._theme_dimensions[theme_name] + self.image_manager.deleteImage(theme_data.theme_name) # if No file do not update cache if theme_data.background_filename: self.image_manager.addImage(theme_data.theme_name, diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 60e073b13..5d3526adb 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -54,6 +54,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): The QWidget-derived parent of the wizard. """ QtGui.QWizard.__init__(self, parent) + #FIXME: remove self.thememanager and use self.parent() instead. self.thememanager = parent self.setupUi(self) self.registerFields() diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 7ca56ce08..72c354dff 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -138,13 +138,17 @@ class ThemeManager(QtGui.QWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated) # Variables + #FIXME: convert to camelCase. self.theme_list = [] self.path = AppLocation.get_section_data_path(self.settingsSection) check_directory_exists(self.path) + #FIXME: convert to camelCase. self.thumb_path = os.path.join(self.path, u'thumbnails') check_directory_exists(self.thumb_path) self.themeForm.path = self.path + #FIXME: convert to camelCase. self.old_background_image = None + #FIXME: convert to camelCase. self.bad_v1_name_chars = re.compile(r'[%+\[\]]') # Last little bits of setting up self.configUpdated() From 39916e423210c836f65b20da39b2b020f45eac6e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 23 Jun 2012 19:21:27 +0200 Subject: [PATCH 02/12] fixed code, fixed long lines --- openlp/core/lib/renderer.py | 1 - openlp/core/ui/thememanager.py | 23 ++++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index a7f830944..e35c78559 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -134,7 +134,6 @@ class Renderer(object): else: theme_data, main_rect, footer_rect = \ self._theme_dimensions[theme_name] - self.image_manager.deleteImage(theme_data.theme_name) # if No file do not update cache if theme_data.background_filename: self.image_manager.addImage(theme_data.theme_name, diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 72c354dff..2db482aa3 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -197,6 +197,11 @@ class ThemeManager(QtGui.QWidget): return real_theme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) theme_name = unicode(item.text()) + # FIXME: Shorten code. +# visible = real_theme_name == theme_name: +# self.deleteAction.setVisible(visible) +# self.renameAction.setVisible(visible) +# self.globalAction.setVisible(visible) self.deleteAction.setVisible(False) self.renameAction.setVisible(False) self.globalAction.setVisible(False) @@ -336,6 +341,7 @@ class ThemeManager(QtGui.QWidget): self.old_background_image = theme.background_filename self.themeForm.theme = theme self.themeForm.exec_(True) + self.mainwindow.imageManager.deleteImage(theme.theme_name) self.old_background_image = None self.mainwindow.renderer.update_theme(theme.theme_name) @@ -483,7 +489,8 @@ class ThemeManager(QtGui.QWidget): else: icon = create_thumb(theme, thumb) item_name.setIcon(icon) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(text_name)) + item_name.setData( + QtCore.Qt.UserRole, QtCore.QVariant(text_name)) self.themeListWidget.addItem(item_name) self.theme_list.append(text_name) self._pushThemes() @@ -512,7 +519,7 @@ class ThemeManager(QtGui.QWidget): unicode(theme_name) + u'.xml') xml = get_text_file_string(xml_file) if not xml: - log.debug("No theme data - using default theme") + log.debug(u'No theme data - using default theme') return ThemeXML() else: return self._createThemeFromXml(xml, self.path) @@ -550,8 +557,9 @@ class ThemeManager(QtGui.QWidget): xml_tree = ElementTree(element=XML(zip.read(xml_file[0]))).getroot() v1_background = xml_tree.find(u'BackgroundType') if v1_background is not None: - theme_name, file_xml, out_file, abort_import = self.unzipVersion122(dir, zip, - xml_file[0], xml_tree, v1_background, out_file) + theme_name, file_xml, out_file, abort_import = \ + self.unzipVersion122( + dir, zip, xml_file[0], xml_tree, v1_background, out_file) else: theme_name = xml_tree.find(u'name').text.strip() theme_folder = os.path.join(dir, theme_name) @@ -604,8 +612,8 @@ class ThemeManager(QtGui.QWidget): if file_xml: theme = self._createThemeFromXml(file_xml, self.path) self.generateAndSaveImage(dir, theme_name, theme) - # Only show the error message, when IOError was not raised (in this - # case the error message has already been shown). + # Only show the error message, when IOError was not raised (in + # this case the error message has already been shown). elif zip is not None: critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), @@ -614,7 +622,8 @@ class ThemeManager(QtGui.QWidget): log.exception(u'Theme file does not contain XML data %s' % file_name) - def unzipVersion122(self, dir, zip, xml_file, xml_tree, background, out_file): + def unzipVersion122(self, dir, zip, xml_file, xml_tree, background, + out_file): """ Unzip openlp.org 1.2x theme file and upgrade the theme xml. When calling this method, please keep in mind, that some parameters are redundant. From 2518a340ae4e8d8fd357a95d0ca2b978f096e139 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Mon, 25 Jun 2012 23:14:53 +0100 Subject: [PATCH 03/12] Well only creating the QWebView just the once fixes it. But I'm sure we used to do that and there was a good reason why we started recreating it for each render... --- openlp/core/lib/renderer.py | 8 +++++--- openlp/core/lib/serviceitem.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 9ccaf4cab..b781c0882 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -82,6 +82,7 @@ class Renderer(object): self._calculate_default() QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.set_global_theme) + self.web = None def update_display(self): """ @@ -397,6 +398,10 @@ class Renderer(object): The footer text block. """ log.debug(u'_set_text_rectangle %s , %s' % (rect_main, rect_footer)) + if not self.web: + self.web = QtWebKit.QWebView() + self.web.setVisible(False) + self.web_frame = self.web.page().mainFrame() self._rect = rect_main self._rect_footer = rect_footer self.page_width = self._rect.width() @@ -404,10 +409,7 @@ class Renderer(object): if theme_data.font_main_shadow: self.page_width -= int(theme_data.font_main_shadow_size) self.page_height -= int(theme_data.font_main_shadow_size) - self.web = QtWebKit.QWebView() - 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. html = u"""