forked from openlp/openlp
fixed the theme code
This commit is contained in:
parent
0c53783acd
commit
ec68413cec
@ -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
|
||||||
|
if os.path.exists(theme_file):
|
||||||
|
result = QtGui.QMessageBox.question(
|
||||||
self,
|
self,
|
||||||
translate(u'ThemeManager',u'Theme already exist!'),
|
translate(u'ThemeManager',u'Theme Exists'),
|
||||||
translate(u'ThemeManager',u'This theme name already exist.\n') + \
|
translate(u'ThemeManager',u'A theme with this name already exists, would you like to overwrite it?'),
|
||||||
translate(u'ThemeManager',u'do you want to overwrite it?'),
|
(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
|
||||||
translate(u'ThemeManager',u'Save'),
|
QtGui.QMessageBox.No)
|
||||||
translate(u'ThemeManager',u'Discard'),
|
if result == QtGui.QMessageBox.Yes:
|
||||||
translate(u'ThemeManager',u'Cancel'),
|
# Save the theme, overwriting the existing theme if necessary.
|
||||||
0,
|
|
||||||
2)
|
|
||||||
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):
|
||||||
|
Loading…
Reference in New Issue
Block a user