forked from openlp/openlp
Add update to ServiceManager of Themes from ThemeManager
This commit is contained in:
parent
a3e2bce831
commit
4696564c09
@ -87,6 +87,7 @@ class MainWindow(object):
|
|||||||
log.info(u'Load Themes')
|
log.info(u'Load Themes')
|
||||||
self.ThemeManagerContents.setEventManager(self.EventManager)
|
self.ThemeManagerContents.setEventManager(self.EventManager)
|
||||||
self.ThemeManagerContents.setRenderManager(self.RenderManager)
|
self.ThemeManagerContents.setRenderManager(self.RenderManager)
|
||||||
|
self.ThemeManagerContents.setServiceManager(self.ServiceManagerContents)
|
||||||
self.ThemeManagerContents.loadThemes()
|
self.ThemeManagerContents.loadThemes()
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
|
@ -61,7 +61,7 @@ class ServiceData(QAbstractItemModel):
|
|||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
def addRow(self, item):
|
def addRow(self, item):
|
||||||
self.insertRow(len(self.items), item)
|
self.insertRow(len(self.items), item)
|
||||||
|
|
||||||
def index(self, row, col, parent = QModelIndex()):
|
def index(self, row, col, parent = QModelIndex()):
|
||||||
return self.createIndex(row,col)
|
return self.createIndex(row,col)
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class ServiceData(QAbstractItemModel):
|
|||||||
return QVariant(retval)
|
return QVariant(retval)
|
||||||
else:
|
else:
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for i in self.items:
|
for i in self.items:
|
||||||
yield i
|
yield i
|
||||||
@ -99,7 +99,7 @@ class ServiceData(QAbstractItemModel):
|
|||||||
log.info("Get Item:%d -> %s" %(row, str(self.items)))
|
log.info("Get Item:%d -> %s" %(row, str(self.items)))
|
||||||
return self.items[row]
|
return self.items[row]
|
||||||
|
|
||||||
|
|
||||||
class ServiceManager(QWidget):
|
class ServiceManager(QWidget):
|
||||||
|
|
||||||
"""Manages the orders of service. Currently this involves taking
|
"""Manages the orders of service. Currently this involves taking
|
||||||
@ -109,7 +109,7 @@ class ServiceManager(QWidget):
|
|||||||
Also handles the UI tasks of moving things up and down etc.
|
Also handles the UI tasks of moving things up and down etc.
|
||||||
"""
|
"""
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger(u'ServiceManager')
|
log=logging.getLogger(u'ServiceManager')
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
QWidget.__init__(self)
|
QWidget.__init__(self)
|
||||||
@ -128,9 +128,6 @@ class ServiceManager(QWidget):
|
|||||||
self.Toolbar.addSeparator()
|
self.Toolbar.addSeparator()
|
||||||
self.ThemeComboBox = QtGui.QComboBox(self.Toolbar)
|
self.ThemeComboBox = QtGui.QComboBox(self.Toolbar)
|
||||||
self.ThemeComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
self.ThemeComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
||||||
self.ThemeComboBox.addItem(QtCore.QString())
|
|
||||||
self.ThemeComboBox.addItem(QtCore.QString())
|
|
||||||
self.ThemeComboBox.addItem(QtCore.QString())
|
|
||||||
self.ThemeWidget = QtGui.QWidgetAction(self.Toolbar)
|
self.ThemeWidget = QtGui.QWidgetAction(self.Toolbar)
|
||||||
self.ThemeWidget.setDefaultWidget(self.ThemeComboBox)
|
self.ThemeWidget.setDefaultWidget(self.ThemeComboBox)
|
||||||
self.Toolbar.addAction(self.ThemeWidget)
|
self.Toolbar.addAction(self.ThemeWidget)
|
||||||
@ -141,7 +138,7 @@ class ServiceManager(QWidget):
|
|||||||
self.service_data=ServiceData()
|
self.service_data=ServiceData()
|
||||||
self.TreeView.setModel(self.service_data)
|
self.TreeView.setModel(self.service_data)
|
||||||
self.Layout.addWidget(self.TreeView)
|
self.Layout.addWidget(self.TreeView)
|
||||||
|
|
||||||
def addServiceItem(self, item):
|
def addServiceItem(self, item):
|
||||||
"""Adds service item"""
|
"""Adds service item"""
|
||||||
log.info("addServiceItem")
|
log.info("addServiceItem")
|
||||||
@ -165,7 +162,7 @@ class ServiceManager(QWidget):
|
|||||||
self.service_data.addRow(item)
|
self.service_data.addRow(item)
|
||||||
else:
|
else:
|
||||||
self.service_data.insertRow(row+1, item)
|
self.service_data.insertRow(row+1, item)
|
||||||
|
|
||||||
def removeServiceItem(self):
|
def removeServiceItem(self):
|
||||||
"""Remove currently selected item"""
|
"""Remove currently selected item"""
|
||||||
pass
|
pass
|
||||||
@ -189,3 +186,8 @@ class ServiceManager(QWidget):
|
|||||||
oosfile.write(self.oos_as_text)
|
oosfile.write(self.oos_as_text)
|
||||||
oosfile.write("# END OOS\n")
|
oosfile.write("# END OOS\n")
|
||||||
oosfile.close()
|
oosfile.close()
|
||||||
|
|
||||||
|
def updateThemeList(self, theme_list):
|
||||||
|
self.ThemeComboBox.clear()
|
||||||
|
for theme in theme_list:
|
||||||
|
self.ThemeComboBox.addItem(theme)
|
||||||
|
@ -31,6 +31,7 @@ from PyQt4.QtCore import *
|
|||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
|
|
||||||
from openlp.core.ui import AmendThemeForm
|
from openlp.core.ui import AmendThemeForm
|
||||||
|
from openlp.core.ui import ServiceManager
|
||||||
from openlp.core import translate
|
from openlp.core import translate
|
||||||
from openlp.core.theme import Theme
|
from openlp.core.theme import Theme
|
||||||
from openlp.core.lib import Event
|
from openlp.core.lib import Event
|
||||||
@ -41,7 +42,6 @@ from openlp.core.lib import ThemeXML
|
|||||||
from openlp.core.lib import Renderer
|
from openlp.core.lib import Renderer
|
||||||
from openlp.core.utils import ConfigHelper
|
from openlp.core.utils import ConfigHelper
|
||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
class ThemeData(QAbstractItemModel):
|
class ThemeData(QAbstractItemModel):
|
||||||
@ -190,6 +190,9 @@ class ThemeManager(QWidget):
|
|||||||
def setRenderManager(self, renderManager):
|
def setRenderManager(self, renderManager):
|
||||||
self.renderManager = renderManager
|
self.renderManager = renderManager
|
||||||
|
|
||||||
|
def setServiceManager(self, serviceManager):
|
||||||
|
self.serviceManager = serviceManager
|
||||||
|
|
||||||
def onAddTheme(self):
|
def onAddTheme(self):
|
||||||
self.amendThemeForm.loadTheme(None)
|
self.amendThemeForm.loadTheme(None)
|
||||||
self.amendThemeForm.exec_()
|
self.amendThemeForm.exec_()
|
||||||
@ -240,6 +243,7 @@ class ThemeManager(QWidget):
|
|||||||
self.Theme_data.addRow(os.path.join(self.path, name))
|
self.Theme_data.addRow(os.path.join(self.path, name))
|
||||||
|
|
||||||
self.eventManager.post_event(Event(EventType.ThemeListChanged))
|
self.eventManager.post_event(Event(EventType.ThemeListChanged))
|
||||||
|
self.serviceManager.updateThemeList(self.getThemes())
|
||||||
|
|
||||||
def getThemes(self):
|
def getThemes(self):
|
||||||
return self.Theme_data.getList()
|
return self.Theme_data.getList()
|
||||||
@ -323,6 +327,7 @@ class ThemeManager(QWidget):
|
|||||||
return newtheme.extract_xml()
|
return newtheme.extract_xml()
|
||||||
|
|
||||||
def saveTheme(self, name, theme_xml) :
|
def saveTheme(self, name, theme_xml) :
|
||||||
|
log.debug(u'saveTheme %s %s', name, theme_xml)
|
||||||
self.generateAndSaveImage(self.path, name, theme_xml)
|
self.generateAndSaveImage(self.path, name, theme_xml)
|
||||||
theme_dir = os.path.join(self.path, name)
|
theme_dir = os.path.join(self.path, name)
|
||||||
if os.path.exists(theme_dir) == False:
|
if os.path.exists(theme_dir) == False:
|
||||||
|
Loading…
Reference in New Issue
Block a user