Allow existing themes to be edited (well at least viewed)

This commit is contained in:
Tim Bentley 2009-04-11 16:16:02 +01:00
parent 61dbab1899
commit 6b4a5ff5d9
2 changed files with 19 additions and 4 deletions

View File

@ -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 Place, Suite 330, Boston, MA 02111-1307 USA
""" """
import logging import logging
import os, os.path
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import QColor, QFont from PyQt4.QtGui import QColor, QFont
from openlp.core.lib import ThemeXML from openlp.core.lib import ThemeXML
from openlp.core import fileToXML
from openlp.core import Renderer from openlp.core import Renderer
from openlp.core import translate from openlp.core import translate
@ -60,12 +62,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def accept(self): def accept(self):
return QtGui.QDialog.accept(self) return QtGui.QDialog.accept(self)
def themePath(self, path):
self.path = path
def loadTheme(self, theme): def loadTheme(self, theme):
self.theme = ThemeXML()
if theme == None: if theme == None:
self.theme = ThemeXML()
self.theme.parse(self.baseTheme()) self.theme.parse(self.baseTheme())
else: 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.paintUi(self.theme)
self.generateImage(self.theme) self.generateImage(self.theme)

View File

@ -128,7 +128,11 @@ class ThemeData(QAbstractItemModel):
for i in self.items: for i in self.items:
yield i 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))) log.info(u'Get Item:%d -> %s' %(row, str(self.items)))
return self.items[row] return self.items[row]
@ -177,6 +181,7 @@ class ThemeManager(QWidget):
self.themelist= [] self.themelist= []
self.path = os.path.join(ConfigHelper.get_data_path(), u'themes') self.path = os.path.join(ConfigHelper.get_data_path(), u'themes')
self.checkThemesExists(self.path) self.checkThemesExists(self.path)
self.amendThemeForm.themePath(self.path)
def setEventManager(self, eventManager): def setEventManager(self, eventManager):
self.eventManager = eventManager self.eventManager = eventManager
@ -186,7 +191,10 @@ class ThemeManager(QWidget):
self.amendThemeForm.exec_() self.amendThemeForm.exec_()
def onEditTheme(self): 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_() self.amendThemeForm.exec_()
def onDeleteTheme(self): def onDeleteTheme(self):