From 6b4a5ff5d94a0decd03b384d836cf061e8b6c5a5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 11 Apr 2009 16:16:02 +0100 Subject: [PATCH] Allow existing themes to be edited (well at least viewed) --- openlp/core/ui/amendthemeform.py | 11 +++++++++-- openlp/core/ui/thememanager.py | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 570df2d02..2d6c988c4 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -18,10 +18,12 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ import logging +import os, os.path from PyQt4 import QtCore, QtGui from PyQt4.QtGui import QColor, QFont from openlp.core.lib import ThemeXML +from openlp.core import fileToXML from openlp.core import Renderer from openlp.core import translate @@ -60,12 +62,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def accept(self): return QtGui.QDialog.accept(self) + def themePath(self, path): + self.path = path + def loadTheme(self, theme): + self.theme = ThemeXML() if theme == None: - self.theme = ThemeXML() self.theme.parse(self.baseTheme()) else: - pass + xml_file = os.path.join(self.path, theme, theme+u'.xml') + xml = fileToXML(xml_file) + self.theme.parse(xml) self.paintUi(self.theme) self.generateImage(self.theme) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index b3a655b61..3726c23a7 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -128,7 +128,11 @@ class ThemeData(QAbstractItemModel): for i in self.items: yield i - def item(self, row): + def getValue(self, index): + row = index.row() + return self.items[row] + + def getItem(self, row): log.info(u'Get Item:%d -> %s' %(row, str(self.items))) return self.items[row] @@ -177,6 +181,7 @@ class ThemeManager(QWidget): self.themelist= [] self.path = os.path.join(ConfigHelper.get_data_path(), u'themes') self.checkThemesExists(self.path) + self.amendThemeForm.themePath(self.path) def setEventManager(self, eventManager): self.eventManager = eventManager @@ -186,7 +191,10 @@ class ThemeManager(QWidget): self.amendThemeForm.exec_() def onEditTheme(self): - self.amendThemeForm.loadTheme(theme) + items = self.ThemeListView.selectedIndexes() + for item in items: + data = self.Theme_data.getValue(item) + self.amendThemeForm.loadTheme(data[3]) self.amendThemeForm.exec_() def onDeleteTheme(self):