Merge lp:~j-corwin/openlp/bug-1094198 into lp:openlp/2.0

Proposed by Jonathan Corwin
Status: Merged
Approved by: Tim Bentley
Approved revision: 2124
Merged at revision: 2125
Proposed branch: lp:~j-corwin/openlp/bug-1094198
Merge into: lp:openlp/2.0
Diff against target: 51 lines (+18/-12)
1 file modified
openlp/core/ui/mainwindow.py (+18/-12)
To merge this branch: bzr merge lp:~j-corwin/openlp/bug-1094198
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tim Bentley Approve
Review via email: mp+141469@code.launchpad.net

Description of the change

** 2.0 **

Attempt to successfully import the settings we can now export.

* QSettings exports the 'general' group as '%General' but appears in some circumstances (Linux?) to struggle to import this again. Try and compensate.

* If you run 2.1, even if just the once, it'll create a [players] settings group. If you later go back to 2.0 it'll load this group (even if it doesn't use it) and so it'll be exported. However the import considers the group invalid so fails. I've therefore changed the import to be more forgiving and just ignore unknown groups. A basic sanity test is done earlier instead. (Using the same string to avoid translation problems)

Tim please can you see if this solves your problem? Ta.

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

16 + 'The file you selected does appear to be a valid OpenLP '
17 + 'settings file.\n\n'

Is this really necessary? Surely if it gets to the stage of parsing sections, then it is a valid OpenLP settings file? Or are you confused and need to rewrite that IF statement?

Revision history for this message
Tim Bentley (trb143) wrote :

This is a 2.0 change and a text change would break the translations. Or does this break them any way?

Revision history for this message
Jonathan Corwin (j-corwin) wrote :

Well a check was already in there so I figured someone did it for a reason. All I've done is move it and check something different. I didn't want to change the (incorrect) text since then we'd need to update the translation strings.

I don't know how lenient QSettings() is when loading a random text file, but I guess someone could try and open another apps settings file by mistake, so this just does a basic test to check for this.

Revision history for this message
Tim Bentley (trb143) wrote :

Approved.
Can you roll a fix (may be with text changes for 2.1)

review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Ah, OK. I can live with that for now.

We must look into how Transifex recommends doing multiple versions of an app... of course we could always have another project for the 2.0 branch if all else fails.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/ui/mainwindow.py'
2--- openlp/core/ui/mainwindow.py 2012-11-11 21:16:14 +0000
3+++ openlp/core/ui/mainwindow.py 2012-12-29 23:04:23 +0000
4@@ -982,6 +982,22 @@
5 settings = Settings()
6 import_settings = Settings(import_file_name,
7 Settings.IniFormat)
8+ # Lets do a basic sanity check. If it contains this string we can
9+ # assume it was created by OpenLP and so we'll load what we can
10+ # from it, and just silently ignore anything we don't recognise
11+ if import_settings.value(u'SettingsImport/type').toString() \
12+ != u'OpenLP_settings_export':
13+ QtGui.QMessageBox.critical(self,
14+ translate('OpenLP.MainWindow', 'Import settings'),
15+ translate('OpenLP.MainWindow',
16+ 'The file you selected does appear to be a valid OpenLP '
17+ 'settings file.\n\n'
18+ 'Section [%s] is not valid \n\n'
19+ 'Processing has terminated and no changed have been made.'
20+ ).replace('%s', u'SettingsImport'),
21+ QtGui.QMessageBox.StandardButtons(
22+ QtGui.QMessageBox.Ok))
23+ return
24 import_keys = import_settings.allKeys()
25 for section_key in import_keys:
26 # We need to handle the really bad files.
27@@ -991,22 +1007,12 @@
28 section = u'unknown'
29 key = u''
30 # Switch General back to lowercase.
31- if section == u'General':
32+ if section == u'General' or section == u'%General':
33 section = u'general'
34 section_key = section + "/" + key
35 # Make sure it's a valid section for us.
36 if not section in setting_sections:
37- QtGui.QMessageBox.critical(self,
38- translate('OpenLP.MainWindow', 'Import settings'),
39- translate('OpenLP.MainWindow',
40- 'The file you selected does appear to be a valid OpenLP '
41- 'settings file.\n\n'
42- 'Section [%s] is not valid \n\n'
43- 'Processing has terminated and no changed have been made.'
44- ).replace('%s', section),
45- QtGui.QMessageBox.StandardButtons(
46- QtGui.QMessageBox.Ok))
47- return
48+ continue
49 # We have a good file, import it.
50 for section_key in import_keys:
51 value = import_settings.value(section_key)

Subscribers

People subscribed via source and target branches