openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #16355
[Merge] lp:~googol/openlp/theme into lp:openlp
Andreas Preikschat has proposed merging lp:~googol/openlp/theme into lp:openlp.
Requested reviews:
Jonathan Corwin (j-corwin)
Tim Bentley (trb143)
For more details, see:
https://code.launchpad.net/~googol/openlp/theme/+merge/112940
Hello,
fixed wrong image being kept in cache when aborting the themeform
a) Edit a theme
b) change the image
c) go to the last page (but do not save the changes)
d) cancel the wizard
Preview an item with this theme.
Result: Theme uses the wrong image.
--
https://code.launchpad.net/~googol/openlp/theme/+merge/112940
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/themeform.py'
--- openlp/core/ui/themeform.py 2012-06-22 14:14:53 +0000
+++ openlp/core/ui/themeform.py 2012-07-01 18:28:22 +0000
@@ -228,10 +228,8 @@
"""
Detects Page changes and updates as approprate.
"""
- if self.page(pageId) == self.areaPositionPage:
- self.setOption(QtGui.QWizard.HaveCustomButton1, True)
- else:
- self.setOption(QtGui.QWizard.HaveCustomButton1, False)
+ enabled = self.page(pageId) == self.areaPositionPage
+ self.setOption(QtGui.QWizard.HaveCustomButton1, enabled)
if self.page(pageId) == self.previewPage:
self.updateTheme()
frame = self.thememanager.generateImage(self.theme)
@@ -623,8 +621,8 @@
os.path.split(unicode(self.theme.background_filename))[1]
saveTo = os.path.join(self.path, self.theme.theme_name, filename)
saveFrom = self.theme.background_filename
- if not self.edit_mode and \
- not self.thememanager.checkIfThemeExists(self.theme.theme_name):
+ if not self.edit_mode and not \
+ self.thememanager.checkIfThemeExists(self.theme.theme_name):
return
self.thememanager.saveTheme(self.theme, saveFrom, saveTo)
return QtGui.QDialog.accept(self)
=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py 2012-06-22 14:14:53 +0000
+++ openlp/core/ui/thememanager.py 2012-07-01 18:28:22 +0000
@@ -139,14 +139,14 @@
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.configUpdated)
# Variables
- self.theme_list = []
+ self.themeList = []
self.path = AppLocation.get_section_data_path(self.settingsSection)
check_directory_exists(self.path)
- self.thumb_path = os.path.join(self.path, u'thumbnails')
- check_directory_exists(self.thumb_path)
+ self.thumbPath = os.path.join(self.path, u'thumbnails')
+ check_directory_exists(self.thumbPath)
self.themeForm.path = self.path
- self.old_background_image = None
- self.bad_v1_name_chars = re.compile(r'[%+\[\]]')
+ self.oldBackgroundImage = None
+ self.badV1NameChars = re.compile(r'[%+\[\]]')
# Last little bits of setting up
self.configUpdated()
@@ -194,14 +194,10 @@
return
real_theme_name = unicode(item.data(QtCore.Qt.UserRole).toString())
theme_name = unicode(item.text())
- self.deleteAction.setVisible(False)
- self.renameAction.setVisible(False)
- self.globalAction.setVisible(False)
- # If default theme restrict actions
- if real_theme_name == theme_name:
- self.deleteAction.setVisible(True)
- self.renameAction.setVisible(True)
- self.globalAction.setVisible(True)
+ visible = real_theme_name == theme_name
+ self.deleteAction.setVisible(visible)
+ self.renameAction.setVisible(visible)
+ self.globalAction.setVisible(visible)
self.menu.exec_(self.themeListWidget.mapToGlobal(point))
def changeGlobalFromTab(self, theme_name):
@@ -330,10 +326,11 @@
theme = self.getThemeData(
unicode(item.data(QtCore.Qt.UserRole).toString()))
if theme.background_type == u'image':
- self.old_background_image = theme.background_filename
+ self.oldBackgroundImage = theme.background_filename
self.themeForm.theme = theme
self.themeForm.exec_(True)
- self.old_background_image = None
+ self.mainwindow.imageManager.deleteImage(theme.theme_name)
+ self.oldBackgroundImage = None
self.mainwindow.renderer.update_theme(theme.theme_name)
def onDeleteTheme(self):
@@ -361,10 +358,10 @@
``theme``
The theme to delete.
"""
- self.theme_list.remove(theme)
+ self.themeList.remove(theme)
thumb = u'%s.png' % theme
delete_file(os.path.join(self.path, thumb))
- delete_file(os.path.join(self.thumb_path, thumb))
+ delete_file(os.path.join(self.thumbPath, thumb))
try:
encoding = get_filesystem_encoding()
shutil.rmtree(os.path.join(self.path, theme).encode(encoding))
@@ -442,7 +439,7 @@
The plugins will call back in to get the real list if they want it.
"""
log.debug(u'Load themes from dir')
- self.theme_list = []
+ self.themeList = []
self.themeListWidget.clear()
files = SettingsManager.get_files(self.settingsSection, u'.png')
if firstTime:
@@ -473,16 +470,17 @@
'%s (default)')) % text_name
else:
name = text_name
- thumb = os.path.join(self.thumb_path, u'%s.png' % text_name)
+ thumb = os.path.join(self.thumbPath, u'%s.png' % text_name)
item_name = QtGui.QListWidgetItem(name)
if validate_thumb(theme, thumb):
icon = build_icon(thumb)
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.themeList.append(text_name)
self._pushThemes()
def _pushThemes(self):
@@ -495,7 +493,7 @@
"""
Return the list of loaded themes
"""
- return self.theme_list
+ return self.themeList
def getThemeData(self, theme_name):
"""
@@ -509,7 +507,7 @@
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)
@@ -547,8 +545,9 @@
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)
@@ -601,8 +600,8 @@
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'),
@@ -611,13 +610,14 @@
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.
"""
theme_name = xml_tree.find(u'Name').text.strip()
- theme_name = self.bad_v1_name_chars.sub(u'', theme_name)
+ theme_name = self.badV1NameChars.sub(u'', theme_name)
theme_folder = os.path.join(dir, theme_name)
theme_exists = os.path.exists(theme_folder)
if theme_exists and not self.overWriteMessageBox(theme_name):
@@ -632,12 +632,12 @@
if background.text.strip() == u'2':
image_name = xml_tree.find(u'BackgroundParameter1').text.strip()
# image file has same extension and is in subfolder
- imagefile = filter(lambda name: os.path.splitext(name)[1].lower()
+ image_file = filter(lambda name: os.path.splitext(name)[1].lower()
== os.path.splitext(image_name)[1].lower() and name.find(r'/'),
zip.namelist())
- if len(imagefile) >= 1:
+ if len(image_file) >= 1:
out_file = open(os.path.join(themedir, image_name), u'wb')
- out_file.write(zip.read(imagefile[0]))
+ out_file.write(zip.read(image_file[0]))
out_file.close()
else:
log.exception(u'Theme file does not contain image file "%s"' %
@@ -685,9 +685,8 @@
theme_dir = os.path.join(self.path, name)
check_directory_exists(theme_dir)
theme_file = os.path.join(theme_dir, name + u'.xml')
- if self.old_background_image and \
- image_to != self.old_background_image:
- delete_file(self.old_background_image)
+ if self.oldBackgroundImage and image_to != self.oldBackgroundImage:
+ delete_file(self.oldBackgroundImage)
out_file = None
try:
out_file = open(theme_file, u'w')
@@ -714,7 +713,7 @@
if os.path.exists(sample_path_name):
os.unlink(sample_path_name)
frame.save(sample_path_name, u'png')
- thumb = os.path.join(self.thumb_path, u'%s.png' % name)
+ thumb = os.path.join(self.thumbPath, u'%s.png' % name)
create_thumb(sample_path_name, thumb, False)
log.debug(u'Theme image written to %s', sample_path_name)
@@ -722,8 +721,8 @@
"""
Called to update the themes' preview images.
"""
- self.mainwindow.displayProgressBar(len(self.theme_list))
- for theme in self.theme_list:
+ self.mainwindow.displayProgressBar(len(self.themeList))
+ for theme in self.themeList:
self.mainwindow.incrementProgressBar()
self.generateAndSaveImage(
self.path, theme, self.getThemeData(theme))
@@ -819,7 +818,7 @@
"""
theme = Theme(xml_data)
new_theme = ThemeXML()
- new_theme.theme_name = self.bad_v1_name_chars.sub(u'', theme.Name)
+ new_theme.theme_name = self.badV1NameChars.sub(u'', theme.Name)
if theme.BackgroundType == 0:
new_theme.background_type = \
BackgroundType.to_string(BackgroundType.Solid)
Follow ups