fixed the theme code

This commit is contained in:
Maikel Stuivenberg 2009-08-28 20:34:33 +02:00
parent 0c53783acd
commit ec68413cec
1 changed files with 15 additions and 24 deletions

View File

@ -330,36 +330,27 @@ class ThemeManager(QtGui.QWidget):
os.mkdir(os.path.join(self.path, name)) os.mkdir(os.path.join(self.path, name))
theme_file = os.path.join(theme_dir, name + u'.xml') theme_file = os.path.join(theme_dir, name + u'.xml')
log.debug(theme_file) log.debug(theme_file)
if os.path.exists(theme_file):
result = QtGui.QMessageBox.information( result = QtGui.QMessageBox.Yes
self, if os.path.exists(theme_file):
translate(u'ThemeManager',u'Theme already exist!'), result = QtGui.QMessageBox.question(
translate(u'ThemeManager',u'This theme name already exist.\n') + \ self,
translate(u'ThemeManager',u'do you want to overwrite it?'), translate(u'ThemeManager',u'Theme Exists'),
translate(u'ThemeManager',u'Save'), translate(u'ThemeManager',u'A theme with this name already exists, would you like to overwrite it?'),
translate(u'ThemeManager',u'Discard'), (QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
translate(u'ThemeManager',u'Cancel'), QtGui.QMessageBox.No)
0, if result == QtGui.QMessageBox.Yes:
2) # Save the theme, overwriting the existing theme if necessary.
else:
result = 0
if result == 0:
outfile = open(theme_file, u'w') outfile = open(theme_file, u'w')
outfile.write(theme_xml) outfile.write(theme_xml)
outfile.close() outfile.close()
if image_from is not None and image_from != image_to: if image_from is not None and image_from != image_to:
shutil.copyfile(image_from, image_to) shutil.copyfile(image_from, image_to)
self.generateAndSaveImage(self.path, name, theme_xml) self.generateAndSaveImage(self.path, name, theme_xml)
self.loadThemes() self.loadThemes()
""" else:
Case 1, Discard (Only Reload Theme's) # Don't close the dialog - allow the user to change the name of the theme or to cancel the theme dialog completely.
"""
if result == 1:
self.loadThemes()
"""
Case 2, Cancel (Back to New Theme Screen)
"""
if result == 2:
return False return False
def generateAndSaveImage(self, dir, name, theme_xml): def generateAndSaveImage(self, dir, name, theme_xml):