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

This proposal supersedes a proposal from 2009-08-28.

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

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

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-28 18:34:33 +0000
19@@ -329,13 +329,29 @@
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+
32+ result = QtGui.QMessageBox.Yes
33+ if os.path.exists(theme_file):
34+ result = QtGui.QMessageBox.question(
35+ self,
36+ translate(u'ThemeManager',u'Theme Exists'),
37+ translate(u'ThemeManager',u'A theme with this name already exists, would you like to overwrite it?'),
38+ (QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
39+ QtGui.QMessageBox.No)
40+ if result == QtGui.QMessageBox.Yes:
41+ # Save the theme, overwriting the existing theme if necessary.
42+ outfile = open(theme_file, u'w')
43+ outfile.write(theme_xml)
44+ outfile.close()
45+ if image_from is not None and image_from != image_to:
46+ shutil.copyfile(image_from, image_to)
47+
48+ self.generateAndSaveImage(self.path, name, theme_xml)
49+ self.loadThemes()
50+ else:
51+ # Don't close the dialog - allow the user to change the name of the theme or to cancel the theme dialog completely.
52+ return False
53
54 def generateAndSaveImage(self, dir, name, theme_xml):
55 log.debug(u'generateAndSaveImage %s %s %s', dir, name, theme_xml)