← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~j-corwin/openlp/bug-1094198b into lp:openlp

 

Jonathan Corwin has proposed merging lp:~j-corwin/openlp/bug-1094198b into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~j-corwin/openlp/bug-1094198b/+merge/141678

2.1 version.

Fix import of settings.

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

- Support the import of the 'players' section

- Change the setting group validation to skip those it doesn't know. Just test for an expected setting earlier instead. Also fix the error message.
-- 
https://code.launchpad.net/~j-corwin/openlp/bug-1094198b/+merge/141678
Your team OpenLP Core is requested to review the proposed merge of lp:~j-corwin/openlp/bug-1094198b into lp:openlp.
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2012-12-29 20:56:56 +0000
+++ openlp/core/ui/mainwindow.py	2013-01-02 22:38:21 +0000
@@ -468,6 +468,7 @@
         self.serviceManagerSettingsSection = u'servicemanager'
         self.songsSettingsSection = u'songs'
         self.themesSettingsSection = u'themes'
+        self.playersSettingsSection = u'players'
         self.displayTagsSection = u'displayTags'
         self.headerSection = u'SettingsImport'
         self.serviceNotSaved = False
@@ -824,6 +825,7 @@
         setting_sections.extend([self.shortcutsSettingsSection])
         setting_sections.extend([self.serviceManagerSettingsSection])
         setting_sections.extend([self.themesSettingsSection])
+        setting_sections.extend([self.playersSettingsSection])
         setting_sections.extend([self.displayTagsSection])
         setting_sections.extend([self.headerSection])
         setting_sections.extend([u'crashreport'])
@@ -832,6 +834,15 @@
             setting_sections.extend([plugin.name])
         settings = Settings()
         import_settings = Settings(import_file_name, Settings.IniFormat)
+        # Lets do a basic sanity check. If it contains this string we can
+        # assume it was created by OpenLP and so we'll load what we can
+        # from it, and just silently ignore anything we don't recognise
+        if import_settings.value(u'SettingsImport/type', u'') != u'OpenLP_settings_export':
+            QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Import settings'),
+                translate('OpenLP.MainWindow', 'The file you have selected does not appear to be a valid OpenLP '
+                    'settings file.\n\nProcessing has terminated and no changes have been made.'),
+                QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
+            return
         import_keys = import_settings.allKeys()
         for section_key in import_keys:
             # We need to handle the really bad files.
@@ -841,17 +852,12 @@
                 section = u'unknown'
                 key = u''
             # Switch General back to lowercase.
-            if section == u'General':
+            if section == u'General' or section == u'%General':
                 section = u'general'
                 section_key = section + "/" + key
             # Make sure it's a valid section for us.
             if not section in setting_sections:
-                QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Import settings'),
-                    translate('OpenLP.MainWindow', 'The file you selected does appear to be a valid OpenLP '
-                        'settings file.\n\nSection [%s] is not valid \n\n'
-                        'Processing has terminated and no changed have been made.').replace('%s', section),
-                    QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
-                return
+                continue
         # We have a good file, import it.
         for section_key in import_keys:
             value = import_settings.value(section_key, None)


Follow ups