← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/beta1 into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/beta1 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~trb143/openlp/beta1/+merge/54949

Correct Description this time

Forces OpenLP to have a default Theme even if no theme is selected by the FTW.
Makes some hidden "magic" visible.
-- 
https://code.launchpad.net/~trb143/openlp/beta1/+merge/54949
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/beta1 into lp:openlp.
=== modified file 'openlp/core/lib/ui.py'
--- openlp/core/lib/ui.py	2011-03-24 19:04:02 +0000
+++ openlp/core/lib/ui.py	2011-03-26 06:58:27 +0000
@@ -49,6 +49,7 @@
     Cancel = translate('OpenLP.Ui', 'Cancel')
     CCLINumberLabel = translate('OpenLP.Ui', 'CCLI number:')
     CreateService = translate('OpenLP.Ui', 'Create a new service.')
+    Default = unicode(translate('OpenLP.Ui', 'Default'))
     Delete = translate('OpenLP.Ui', '&Delete')
     Edit = translate('OpenLP.Ui', '&Edit')
     EmptyField = translate('OpenLP.Ui', 'Empty Field')

=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2011-03-24 21:20:38 +0000
+++ openlp/core/ui/mainwindow.py	2011-03-26 06:58:27 +0000
@@ -622,9 +622,6 @@
         # Call the initialise method to setup plugins.
         log.info(u'initialise plugins')
         self.pluginManager.initialise_plugins()
-        # Once all components are initialised load the Themes
-        log.info(u'Load Themes')
-        self.themeManagerContents.loadThemes()
         log.info(u'Load data from Settings')
         if QtCore.QSettings().value(u'advanced/save current plugin',
             QtCore.QVariant(False)).toBool():
@@ -633,6 +630,9 @@
             if savedPlugin != -1:
                 self.MediaToolBox.setCurrentIndex(savedPlugin)
         self.settingsForm.postSetUp()
+        # Once all components are initialised load the Themes
+        log.info(u'Load Themes')
+        self.themeManagerContents.loadThemes(True)
         Receiver.send_message(u'cursor_normal')
 
     def setAutoLanguage(self, value):
@@ -679,7 +679,6 @@
     def firstTime(self):
         # Import themes if first time
         Receiver.send_message(u'openlp_process_events')
-        self.themeManagerContents.firstTime()
         for plugin in self.pluginManager.plugins:
             if hasattr(plugin, u'firstTime'):
                 Receiver.send_message(u'openlp_process_events')

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2011-03-24 19:04:02 +0000
+++ openlp/core/ui/thememanager.py	2011-03-26 06:58:27 +0000
@@ -156,10 +156,9 @@
             file = os.path.join(self.path, file).encode(encoding)
             self.unzipTheme(file, self.path)
             delete_file(file)
-        self.loadThemes()
         Receiver.send_message(u'cursor_normal')
 
-    def configUpdated(self, firstTime=False):
+    def configUpdated(self):
         """
         Triggered when Config dialog is updated.
         """
@@ -433,7 +432,7 @@
         self.loadThemes()
         Receiver.send_message(u'cursor_normal')
 
-    def loadThemes(self):
+    def loadThemes(self, firstTime=False):
         """
         Loads the theme lists and triggers updates accross the whole system
         using direct calls or core functions and events for the plugins.
@@ -443,31 +442,44 @@
         self.themelist = []
         self.themeListWidget.clear()
         dirList = os.listdir(self.path)
-        dirList.sort()
-        for name in dirList:
-            if name.endswith(u'.png'):
-                # check to see file is in theme root directory
-                theme = os.path.join(self.path, name)
-                if os.path.exists(theme):
-                    textName = os.path.splitext(name)[0]
-                    if textName == self.global_theme:
-                        name = unicode(translate('OpenLP.ThemeManager',
-                            '%s (default)')) % textName
-                    else:
-                        name = textName
-                    thumb = os.path.join(self.thumbPath, u'%s.png' % textName)
-                    item_name = QtGui.QListWidgetItem(name)
-                    if os.path.exists(thumb):
-                        icon = build_icon(thumb)
-                    else:
-                        icon = build_icon(theme)
-                        pixmap = icon.pixmap(QtCore.QSize(88, 50))
-                        pixmap.save(thumb, u'png')
-                    item_name.setIcon(icon)
-                    item_name.setData(QtCore.Qt.UserRole,
-                        QtCore.QVariant(textName))
-                    self.themeListWidget.addItem(item_name)
-                    self.themelist.append(textName)
+        files = SettingsManager.get_files(self.settingsSection, u'.png')
+        if firstTime:
+            self.firstTime()
+            # No themes have been found so create one
+            if len(files) == 0:
+                theme = ThemeXML()
+                theme.theme_name = UiStrings.Default
+                self._writeTheme(theme, None, None)
+                QtCore.QSettings().setValue(
+                    self.settingsSection + u'/global theme',
+                    QtCore.QVariant(theme.theme_name))
+                self.configUpdated()
+                files = SettingsManager.get_files(self.settingsSection, u'.png')
+        files.sort()
+        # now process the file list of png files
+        for name in files:
+            # check to see file is in theme root directory
+            theme = os.path.join(self.path, name)
+            if os.path.exists(theme):
+                textName = os.path.splitext(name)[0]
+                if textName == self.global_theme:
+                    name = unicode(translate('OpenLP.ThemeManager',
+                        '%s (default)')) % textName
+                else:
+                    name = textName
+                thumb = os.path.join(self.thumbPath, u'%s.png' % textName)
+                item_name = QtGui.QListWidgetItem(name)
+                if os.path.exists(thumb):
+                    icon = build_icon(thumb)
+                else:
+                    icon = build_icon(theme)
+                    pixmap = icon.pixmap(QtCore.QSize(88, 50))
+                    pixmap.save(thumb, u'png')
+                item_name.setIcon(icon)
+                item_name.setData(QtCore.Qt.UserRole,
+                    QtCore.QVariant(textName))
+                self.themeListWidget.addItem(item_name)
+                self.themelist.append(textName)
         self._pushThemes()
 
     def _pushThemes(self):

=== modified file 'resources/openlp.desktop'
--- resources/openlp.desktop	2010-09-27 18:34:40 +0000
+++ resources/openlp.desktop	2011-03-26 06:58:27 +0000
@@ -3,11 +3,11 @@
 Comment[de]=
 Comment=
 Encoding=UTF-8
-Exec=openlp
+Exec=openlp %F
 GenericName[de]=Church lyrics projection
 GenericName=Church lyrics projection
 Icon=openlp
-MimeType=
+MimeType=application/x-openlp-service;
 Name[de]=OpenLP
 Name=OpenLP
 Path=

=== added file 'resources/openlp.xml'
--- resources/openlp.xml	1970-01-01 00:00:00 +0000
+++ resources/openlp.xml	2011-03-26 06:58:27 +0000
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+It comes with ABSOLUTELY NO WARRANTY, to the extent permitted by law. You may
+redistribute copies of update-mime-database under the terms of the GNU General
+Public License. For more information about these matters, see the file named
+COPYING.
+-->
+<!--
+Notes:
+- the mime types in this file are valid with the version 0.30 of the
+  shared-mime-info package.
+- the "fdo #xxxxx" are the wish in the freedesktop.org bug database to include
+  the mime type there.
+--> 
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info";>
+  <mime-type type="application/x-openlp-service">
+    <sub-class-of type="application/zip"/>
+    <comment>OpenLP Service File</comment>
+    <glob pattern="*.osz"/>
+  </mime-type> 
+  <mime-type type="application/x-openlp-theme">
+    <sub-class-of type="application/zip"/>
+    <comment>OpenLP Theme File</comment>
+    <glob pattern="*.otz"/>
+  </mime-type> 
+</mime-info>


Follow ups