forked from openlp/openlp
Force there always to be a theme
bzr-revno: 1428
This commit is contained in:
commit
623822749d
@ -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')
|
||||
|
@ -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')
|
||||
|
@ -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):
|
||||
|
@ -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=
|
||||
|
26
resources/openlp.xml
Normal file
26
resources/openlp.xml
Normal file
@ -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>
|
Loading…
Reference in New Issue
Block a user