forked from openlp/openlp
Fix Theme Image copy Bug
Clean up Theme Rename and Copy bugs bzr-revno: 1271 Fixes: https://launchpad.net/bugs/712097
This commit is contained in:
commit
7b30ceb0f3
@ -241,7 +241,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
QtCore.QVariant(self.global_theme))
|
||||
Receiver.send_message(u'theme_update_global',
|
||||
self.global_theme)
|
||||
self.pushThemes()
|
||||
self._pushThemes()
|
||||
|
||||
def onAddTheme(self):
|
||||
"""
|
||||
@ -268,11 +268,12 @@ class ThemeManager(QtGui.QWidget):
|
||||
newThemeName = unicode(self.fileRenameForm.fileNameEdit.text())
|
||||
if self.checkIfThemeExists(newThemeName):
|
||||
oldThemeData = self.getThemeData(oldThemeName)
|
||||
self.deleteTheme(oldThemeName)
|
||||
self.cloneThemeData(oldThemeData, newThemeName)
|
||||
self.deleteTheme(oldThemeName)
|
||||
for plugin in self.mainwindow.pluginManager.plugins:
|
||||
if plugin.usesTheme(oldThemeName):
|
||||
plugin.renameTheme(oldThemeName, newThemeName)
|
||||
self.loadThemes()
|
||||
|
||||
def onCopyTheme(self):
|
||||
"""
|
||||
@ -300,6 +301,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
os.path.split(unicode(themeData.background_filename))[1])
|
||||
saveFrom = themeData.background_filename
|
||||
themeData.theme_name = newThemeName
|
||||
themeData.extend_image_filename(self.path)
|
||||
self.saveTheme(themeData, saveFrom, saveTo)
|
||||
|
||||
def onEditTheme(self):
|
||||
@ -332,6 +334,10 @@ class ThemeManager(QtGui.QWidget):
|
||||
row = self.themeListWidget.row(item)
|
||||
self.themeListWidget.takeItem(row)
|
||||
self.deleteTheme(theme)
|
||||
# As we do not reload the themes, push out the change
|
||||
# Reaload the list as the internal lists and events need
|
||||
# to be triggered
|
||||
self._pushThemes()
|
||||
|
||||
def deleteTheme(self, theme):
|
||||
"""
|
||||
@ -349,10 +355,6 @@ class ThemeManager(QtGui.QWidget):
|
||||
shutil.rmtree(os.path.join(self.path, theme).encode(encoding))
|
||||
except OSError:
|
||||
log.exception(u'Error deleting theme %s', theme)
|
||||
# As we do not reload the themes push out the change
|
||||
# Reaload the list as the internal lists and events need
|
||||
# to be triggered
|
||||
self.pushThemes()
|
||||
|
||||
def onExportTheme(self):
|
||||
"""
|
||||
@ -449,9 +451,9 @@ class ThemeManager(QtGui.QWidget):
|
||||
QtCore.QVariant(textName))
|
||||
self.themeListWidget.addItem(item_name)
|
||||
self.themelist.append(textName)
|
||||
self.pushThemes()
|
||||
self._pushThemes()
|
||||
|
||||
def pushThemes(self):
|
||||
def _pushThemes(self):
|
||||
"""
|
||||
Notify listeners that the theme list has been updated
|
||||
"""
|
||||
@ -571,6 +573,14 @@ class ThemeManager(QtGui.QWidget):
|
||||
Called by thememaintenance Dialog to save the theme
|
||||
and to trigger the reload of the theme list
|
||||
"""
|
||||
self._writeTheme(theme, imageFrom, imageTo)
|
||||
self.loadThemes()
|
||||
|
||||
def _writeTheme(self, theme, imageFrom, imageTo):
|
||||
"""
|
||||
Writes the theme to the disk and handles the background image if
|
||||
necessary
|
||||
"""
|
||||
name = theme.theme_name
|
||||
theme_pretty_xml = theme.extract_formatted_xml()
|
||||
log.debug(u'saveTheme %s %s', name, theme_pretty_xml)
|
||||
@ -598,12 +608,9 @@ class ThemeManager(QtGui.QWidget):
|
||||
except IOError:
|
||||
log.exception(u'Failed to save theme image')
|
||||
self.generateAndSaveImage(self.path, name, theme)
|
||||
self.loadThemes()
|
||||
self.pushThemes()
|
||||
|
||||
def generateAndSaveImage(self, dir, name, theme):
|
||||
log.debug(u'generateAndSaveImage %s %s', dir, name)
|
||||
theme_xml = theme.extract_xml()
|
||||
frame = self.generateImage(theme)
|
||||
samplepathname = os.path.join(self.path, name + u'.png')
|
||||
if os.path.exists(samplepathname):
|
||||
|
@ -102,7 +102,7 @@ class BiblePlugin(Plugin):
|
||||
Called to find out if the bible plugin is currently using a theme.
|
||||
Returns True if the theme is being used, otherwise returns False.
|
||||
"""
|
||||
if self.settings_tab.bible_theme == theme:
|
||||
if unicode(self.settings_tab.bible_theme) == theme:
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -119,6 +119,7 @@ class BiblePlugin(Plugin):
|
||||
The new name the plugin should now use.
|
||||
"""
|
||||
self.settings_tab.bible_theme = newTheme
|
||||
self.settings_tab.save()
|
||||
|
||||
def setPluginTextStrings(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user