Force default theme if no theme present

This commit is contained in:
Tim Bentley 2011-03-19 19:45:22 +00:00
parent 3550b77b61
commit 45034c1b8b
3 changed files with 24 additions and 5 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

@ -619,9 +619,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():
@ -630,6 +627,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):

View File

@ -159,7 +159,7 @@ class ThemeManager(QtGui.QWidget):
self.loadThemes() 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 +433,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,6 +443,24 @@ class ThemeManager(QtGui.QWidget):
self.themelist = [] self.themelist = []
self.themeListWidget.clear() self.themeListWidget.clear()
dirList = os.listdir(self.path) dirList = os.listdir(self.path)
if firstTime:
found = False
for name in dirList:
if name.endswith(u'.png'):
theme = os.path.join(self.path, name)
if os.path.exists(theme):
found = True
break
# No themes have been found so create one
if not found:
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()
dirList = os.listdir(self.path)
dirList.sort() dirList.sort()
for name in dirList: for name in dirList:
if name.endswith(u'.png'): if name.endswith(u'.png'):