Clean up initial theme setup

This commit is contained in:
Tim Bentley 2011-03-20 07:37:44 +00:00
parent 45034c1b8b
commit d26c8fce86
2 changed files with 29 additions and 36 deletions

View File

@ -676,7 +676,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')

View File

@ -156,7 +156,6 @@ 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):
@ -443,16 +442,11 @@ class ThemeManager(QtGui.QWidget):
self.themelist = []
self.themeListWidget.clear()
dirList = os.listdir(self.path)
files = SettingsManager.get_files(self.settingsSection, u'.png')
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
self.firstTime()
# No themes have been found so create one
if not found:
if len(files) == 0:
theme = ThemeXML()
theme.theme_name = UiStrings.Default
self._writeTheme(theme, None, None)
@ -460,32 +454,32 @@ class ThemeManager(QtGui.QWidget):
self.settingsSection + u'/global theme',
QtCore.QVariant(theme.theme_name))
self.configUpdated()
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')
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):