diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index da046d99c..776b8e349 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -49,6 +49,7 @@ class UiStrings(object): 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') diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b8dfc35f5..e6ace21cd 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -621,9 +621,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # 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(): @@ -632,6 +629,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 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): @@ -678,7 +678,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 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') diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 11d10413c..d033daeb3 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -156,10 +156,9 @@ class ThemeManager(QtGui.QWidget): 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 @@ class ThemeManager(QtGui.QWidget): 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 @@ class ThemeManager(QtGui.QWidget): 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): diff --git a/resources/openlp.desktop b/resources/openlp.desktop index 684119773..07398ede8 100755 --- a/resources/openlp.desktop +++ b/resources/openlp.desktop @@ -3,11 +3,11 @@ Categories=AudioVideo; 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= diff --git a/resources/openlp.xml b/resources/openlp.xml new file mode 100644 index 000000000..215fa2b6e --- /dev/null +++ b/resources/openlp.xml @@ -0,0 +1,26 @@ + + + + + + + OpenLP Service File + + + + + OpenLP Theme File + + +