From e9800d8eccc0acce42337230abe2aaad3d33ccc7 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 17 Oct 2009 19:20:07 +0100 Subject: [PATCH] Fix theme saving --- openlp/core/ui/thememanager.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 9ac09c839..824022d73 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -153,6 +153,7 @@ class ThemeManager(QtGui.QWidget): def onAddTheme(self): self.amendThemeForm.loadTheme(None) + self.saveThemeName = u'' self.amendThemeForm.exec_() def onEditTheme(self): @@ -160,6 +161,7 @@ class ThemeManager(QtGui.QWidget): if item is not None: self.amendThemeForm.loadTheme( unicode(item.data(QtCore.Qt.UserRole).toString())) + self.saveThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) self.amendThemeForm.exec_() def onDeleteTheme(self): @@ -412,15 +414,18 @@ class ThemeManager(QtGui.QWidget): os.mkdir(os.path.join(self.path, name)) theme_file = os.path.join(theme_dir, name + u'.xml') log.debug(theme_file) - result = QtGui.QMessageBox.Yes - if os.path.exists(theme_file): - result = QtGui.QMessageBox.question( - self, - translate(u'ThemeManager', u'Theme Exists'), - translate(u'ThemeManager', u'A theme with this name already exists, would you like to overwrite it?'), - (QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), - QtGui.QMessageBox.No) + print self.saveThemeName , name + if self.saveThemeName != name: + if os.path.exists(theme_file): + result = QtGui.QMessageBox.question( + self, + translate(u'ThemeManager', u'Theme Exists'), + translate(u'ThemeManager', u'A theme with this name already exists, would you like to overwrite it?'), + (QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), + QtGui.QMessageBox.No) + else: + result == QtGui.QMessageBox.Yes if result == QtGui.QMessageBox.Yes: # Save the theme, overwriting the existing theme if necessary. outfile = open(theme_file, u'w')