Merge lp:~maikels/openlp/myfixes into lp:openlp

Proposed by Maikel Stuivenberg
Status: Superseded
Proposed branch: lp:~maikels/openlp/myfixes
Merge into: lp:openlp
Diff against target: None lines
To merge this branch: bzr merge lp:~maikels/openlp/myfixes
Reviewer Review Type Date Requested Status
Raoul Snyman Needs Fixing
Review via email: mp+10802@code.launchpad.net

This proposal has been superseded by a proposal from 2009-08-28.

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Looks good, just a few changes before we'll accept it:

1. Don't break strings up, otherwise we end up with lots of smaller strings to be translated; see below.
2. Use my wording, as below.
3. I haven't seen any usage of QMessageBox passing strings. Please can you update your code to look like mine below.
4. Place your comments immediately under your if statements. If your comment is only one line long, use # comments. """ is generally used for docstrings.
5. There's no need for a "Cancel" option on the confirmation dialog - either they overwrite the theme, or they don't save it at all.

    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)
    if result == QtGui.QMessageBox.Yes:
        # Save the theme, overwriting the existing theme if necessary.
        outfile = open(theme_file, u'w')
        outfile.write(theme_xml)
        outfile.close()
        if image_from is not None and image_from != image_to:
            shutil.copyfile(image_from, image_to)
            self.generateAndSaveImage(self.path, name, theme_xml)
            self.loadThemes()
    else:
        # Don't close the dialog - allow the user to change the name of the theme or to cancel the theme dialog completely.
        return False

review: Needs Fixing
lp:~maikels/openlp/myfixes updated
514. By Maikel Stuivenberg

fixed the theme code

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/ui/amendthemeform.py'
2--- openlp/core/ui/amendthemeform.py 2009-08-26 05:00:19 +0000
3+++ openlp/core/ui/amendthemeform.py 2009-08-27 16:21:00 +0000
4@@ -135,8 +135,8 @@
5 unicode(self.theme.display_horizontalAlign), unicode(self.theme.display_verticalAlign),
6 unicode(self.theme.display_wrapStyle))
7 theme = new_theme.extract_xml()
8- self.thememanager.saveTheme(theme_name, theme, save_from, save_to)
9- return QtGui.QDialog.accept(self)
10+ if self.thememanager.saveTheme(theme_name, theme, save_from, save_to) is not False:
11+ return QtGui.QDialog.accept(self)
12
13 def loadTheme(self, theme):
14 log.debug(u'LoadTheme %s', theme)
15
16=== modified file 'openlp/core/ui/thememanager.py'
17--- openlp/core/ui/thememanager.py 2009-08-26 05:00:19 +0000
18+++ openlp/core/ui/thememanager.py 2009-08-27 16:21:00 +0000
19@@ -329,13 +329,38 @@
20 if os.path.exists(theme_dir) == False:
21 os.mkdir(os.path.join(self.path, name))
22 theme_file = os.path.join(theme_dir, name + u'.xml')
23- outfile = open(theme_file, u'w')
24- outfile.write(theme_xml)
25- outfile.close()
26- if image_from is not None and image_from != image_to:
27- shutil.copyfile(image_from, image_to)
28- self.generateAndSaveImage(self.path, name, theme_xml)
29- self.loadThemes()
30+ log.debug(theme_file)
31+ if os.path.exists(theme_file):
32+ result = QtGui.QMessageBox.information(
33+ self,
34+ translate(u'ThemeManager',u'Theme already exist!'),
35+ translate(u'ThemeManager',u'This theme name already exist.\n') + \
36+ translate(u'ThemeManager',u'do you want to overwrite it?'),
37+ translate(u'ThemeManager',u'Save'),
38+ translate(u'ThemeManager',u'Discard'),
39+ translate(u'ThemeManager',u'Cancel'),
40+ 0,
41+ 2)
42+ else:
43+ result = 0
44+ if result == 0:
45+ outfile = open(theme_file, u'w')
46+ outfile.write(theme_xml)
47+ outfile.close()
48+ if image_from is not None and image_from != image_to:
49+ shutil.copyfile(image_from, image_to)
50+ self.generateAndSaveImage(self.path, name, theme_xml)
51+ self.loadThemes()
52+ """
53+ Case 1, Discard (Only Reload Theme's)
54+ """
55+ if result == 1:
56+ self.loadThemes()
57+ """
58+ Case 2, Cancel (Back to New Theme Screen)
59+ """
60+ if result == 2:
61+ return False
62
63 def generateAndSaveImage(self, dir, name, theme_xml):
64 log.debug(u'generateAndSaveImage %s %s %s', dir, name, theme_xml)