Head r1428

This commit is contained in:
Jon Tibble 2011-03-26 19:02:14 +00:00
commit 95cb64201b
5 changed files with 72 additions and 34 deletions

View File

@ -49,6 +49,7 @@ class UiStrings(object):
Cancel = translate('OpenLP.Ui', 'Cancel') Cancel = translate('OpenLP.Ui', 'Cancel')
CCLINumberLabel = translate('OpenLP.Ui', 'CCLI number:') CCLINumberLabel = translate('OpenLP.Ui', 'CCLI number:')
CreateService = translate('OpenLP.Ui', 'Create a new service.') CreateService = translate('OpenLP.Ui', 'Create a new service.')
Default = unicode(translate('OpenLP.Ui', 'Default'))
Delete = translate('OpenLP.Ui', '&Delete') Delete = translate('OpenLP.Ui', '&Delete')
Edit = translate('OpenLP.Ui', '&Edit') Edit = translate('OpenLP.Ui', '&Edit')
EmptyField = translate('OpenLP.Ui', 'Empty Field') EmptyField = translate('OpenLP.Ui', 'Empty Field')

View File

@ -621,9 +621,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
# Call the initialise method to setup plugins. # Call the initialise method to setup plugins.
log.info(u'initialise plugins') log.info(u'initialise plugins')
self.pluginManager.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') log.info(u'Load data from Settings')
if QtCore.QSettings().value(u'advanced/save current plugin', if QtCore.QSettings().value(u'advanced/save current plugin',
QtCore.QVariant(False)).toBool(): QtCore.QVariant(False)).toBool():
@ -632,6 +629,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
if savedPlugin != -1: if savedPlugin != -1:
self.MediaToolBox.setCurrentIndex(savedPlugin) self.MediaToolBox.setCurrentIndex(savedPlugin)
self.settingsForm.postSetUp() 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') Receiver.send_message(u'cursor_normal')
def setAutoLanguage(self, value): def setAutoLanguage(self, value):
@ -678,7 +678,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
def firstTime(self): def firstTime(self):
# Import themes if first time # Import themes if first time
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
self.themeManagerContents.firstTime()
for plugin in self.pluginManager.plugins: for plugin in self.pluginManager.plugins:
if hasattr(plugin, u'firstTime'): if hasattr(plugin, u'firstTime'):
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')

View File

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

View File

@ -3,11 +3,11 @@ Categories=AudioVideo;
Comment[de]= Comment[de]=
Comment= Comment=
Encoding=UTF-8 Encoding=UTF-8
Exec=openlp Exec=openlp %F
GenericName[de]=Church lyrics projection GenericName[de]=Church lyrics projection
GenericName=Church lyrics projection GenericName=Church lyrics projection
Icon=openlp Icon=openlp
MimeType= MimeType=application/x-openlp-service;
Name[de]=OpenLP Name[de]=OpenLP
Name=OpenLP Name=OpenLP
Path= Path=

26
resources/openlp.xml Normal file
View 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>