forked from openlp/openlp
commit
7a896ee336
@ -29,8 +29,5 @@ def translate(context, text):
|
|||||||
return QtGui.QApplication.translate(context, text, None, QtGui.QApplication.UnicodeUTF8)
|
return QtGui.QApplication.translate(context, text, None, QtGui.QApplication.UnicodeUTF8)
|
||||||
|
|
||||||
def fileToXML(xmlfile):
|
def fileToXML(xmlfile):
|
||||||
file=open(xmlfile)
|
return open(xmlfile).read()
|
||||||
xml =''.join(file.readlines()) # read the file and change list to a string
|
|
||||||
file.close()
|
|
||||||
return xml
|
|
||||||
|
|
||||||
|
@ -31,9 +31,8 @@ from serviceitem import ServiceItem
|
|||||||
from toolbar import OpenLPToolbar
|
from toolbar import OpenLPToolbar
|
||||||
from songxmlhandler import SongXMLBuilder
|
from songxmlhandler import SongXMLBuilder
|
||||||
from songxmlhandler import SongXMLParser
|
from songxmlhandler import SongXMLParser
|
||||||
from themexmlhandler import ThemeXMLBuilder
|
from themexmlhandler import ThemeXML
|
||||||
from themexmlhandler import ThemeXMLParser
|
|
||||||
|
|
||||||
__all__ = ['PluginConfig', 'Plugin', 'SettingsTab', 'MediaManagerItem', 'Event', 'EventType'
|
__all__ = ['PluginConfig', 'Plugin', 'SettingsTab', 'MediaManagerItem', 'Event', 'EventType'
|
||||||
'XmlRootClass', 'ServiceItem', 'Receiver', 'OpenLPToolbar', 'SongXMLBuilder',
|
'XmlRootClass', 'ServiceItem', 'Receiver', 'OpenLPToolbar', 'SongXMLBuilder',
|
||||||
'SongXMLParser', 'EventManager', 'ThemeXMLBuilder', 'ThemeXMLParser']
|
'SongXMLParser', 'EventManager', 'ThemeXML']
|
||||||
|
@ -24,7 +24,7 @@ For XML Schema see wiki.openlp.org
|
|||||||
from xml.dom.minidom import Document
|
from xml.dom.minidom import Document
|
||||||
from xml.etree.ElementTree import ElementTree, XML, dump
|
from xml.etree.ElementTree import ElementTree, XML, dump
|
||||||
|
|
||||||
class ThemeXMLBuilder():
|
class ThemeXML():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Create the minidom document
|
# Create the minidom document
|
||||||
self.theme_xml = Document()
|
self.theme_xml = Document()
|
||||||
@ -154,8 +154,7 @@ class ThemeXMLBuilder():
|
|||||||
# Print our newly created XML
|
# Print our newly created XML
|
||||||
return self.theme_xml.toxml()
|
return self.theme_xml.toxml()
|
||||||
|
|
||||||
class ThemeXMLParser():
|
def parse(self, xml):
|
||||||
def __init__(self, xml):
|
|
||||||
theme_xml = ElementTree(element=XML(xml))
|
theme_xml = ElementTree(element=XML(xml))
|
||||||
iter=theme_xml.getiterator()
|
iter=theme_xml.getiterator()
|
||||||
master = u''
|
master = u''
|
||||||
|
@ -37,8 +37,7 @@ from openlp.core.lib import Event
|
|||||||
from openlp.core.lib import EventType
|
from openlp.core.lib import EventType
|
||||||
from openlp.core.lib import EventManager
|
from openlp.core.lib import EventManager
|
||||||
from openlp.core.lib import OpenLPToolbar
|
from openlp.core.lib import OpenLPToolbar
|
||||||
from openlp.core.lib import ThemeXMLBuilder
|
from openlp.core.lib import ThemeXML
|
||||||
from openlp.core.lib import ThemeXMLParser
|
|
||||||
from openlp.core.utils import ConfigHelper
|
from openlp.core.utils import ConfigHelper
|
||||||
|
|
||||||
|
|
||||||
@ -52,6 +51,7 @@ class ThemeData(QAbstractItemModel):
|
|||||||
"""
|
"""
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger(u'ThemeData')
|
log=logging.getLogger(u'ThemeData')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QAbstractItemModel.__init__(self)
|
QAbstractItemModel.__init__(self)
|
||||||
self.items=[]
|
self.items=[]
|
||||||
@ -132,9 +132,13 @@ class ThemeData(QAbstractItemModel):
|
|||||||
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]
|
||||||
|
|
||||||
|
def getList(self):
|
||||||
|
filelist = [item[3] for item in self.items];
|
||||||
|
return filelist
|
||||||
|
|
||||||
class ThemeManager(QWidget):
|
class ThemeManager(QWidget):
|
||||||
"""
|
"""
|
||||||
Manages the orders of Theme. C
|
Manages the orders of Theme.
|
||||||
"""
|
"""
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger(u'ThemeManager')
|
log=logging.getLogger(u'ThemeManager')
|
||||||
@ -178,6 +182,7 @@ class ThemeManager(QWidget):
|
|||||||
self.eventManager = eventManager
|
self.eventManager = eventManager
|
||||||
|
|
||||||
def onAddTheme(self):
|
def onAddTheme(self):
|
||||||
|
self.amendThemeForm.loadTheme(None)
|
||||||
self.amendThemeForm.exec_()
|
self.amendThemeForm.exec_()
|
||||||
|
|
||||||
def onEditTheme(self):
|
def onEditTheme(self):
|
||||||
@ -213,7 +218,7 @@ class ThemeManager(QWidget):
|
|||||||
self.eventManager.post_event(Event(EventType.ThemeListChanged))
|
self.eventManager.post_event(Event(EventType.ThemeListChanged))
|
||||||
|
|
||||||
def getThemes(self):
|
def getThemes(self):
|
||||||
return self.themelist
|
return self.Theme_data.getList()
|
||||||
|
|
||||||
def checkThemesExists(self, dir):
|
def checkThemesExists(self, dir):
|
||||||
log.debug(u'check themes')
|
log.debug(u'check themes')
|
||||||
@ -232,7 +237,7 @@ class ThemeManager(QWidget):
|
|||||||
fullpath = os.path.join(dir, file)
|
fullpath = os.path.join(dir, file)
|
||||||
names = file.split(u'/')
|
names = file.split(u'/')
|
||||||
xml_data = zip.read(file)
|
xml_data = zip.read(file)
|
||||||
if file.endswith(u'.xml'):
|
if os.path.splitext (file) [1].lower () in [u'.xml']:
|
||||||
if self.checkVersion1(xml_data):
|
if self.checkVersion1(xml_data):
|
||||||
filexml = self.migrateVersion122(filename, fullpath, xml_data)
|
filexml = self.migrateVersion122(filename, fullpath, xml_data)
|
||||||
outfile = open(fullpath, 'w')
|
outfile = open(fullpath, 'w')
|
||||||
@ -240,7 +245,7 @@ class ThemeManager(QWidget):
|
|||||||
outfile.close()
|
outfile.close()
|
||||||
self.generateImage(dir,names[0], filexml)
|
self.generateImage(dir,names[0], filexml)
|
||||||
else:
|
else:
|
||||||
if file.endswith(u'.bmp'):
|
if os.path.splitext (file) [1].lower () in [u'.bmp']:
|
||||||
if fullpath is not os.path.join(dir, file):
|
if fullpath is not os.path.join(dir, file):
|
||||||
outfile = open(fullpath, 'w')
|
outfile = open(fullpath, 'w')
|
||||||
outfile.write(zip.read(file))
|
outfile.write(zip.read(file))
|
||||||
@ -259,7 +264,7 @@ class ThemeManager(QWidget):
|
|||||||
log.debug(u'migrateVersion122 %s %s', filename , fullpath)
|
log.debug(u'migrateVersion122 %s %s', filename , fullpath)
|
||||||
t=Theme(xml_data)
|
t=Theme(xml_data)
|
||||||
|
|
||||||
newtheme = ThemeXMLBuilder()
|
newtheme = ThemeXML()
|
||||||
newtheme.new_document(t.Name)
|
newtheme.new_document(t.Name)
|
||||||
if t.BackgroundType == 0:
|
if t.BackgroundType == 0:
|
||||||
newtheme.add_background_solid(str(t.BackgroundParameter1.name()))
|
newtheme.add_background_solid(str(t.BackgroundParameter1.name()))
|
||||||
@ -285,7 +290,8 @@ class ThemeManager(QWidget):
|
|||||||
|
|
||||||
def generateImage(self, dir, name, theme_xml):
|
def generateImage(self, dir, name, theme_xml):
|
||||||
log.debug(u'generateImage %s %s ', dir, theme_xml)
|
log.debug(u'generateImage %s %s ', dir, theme_xml)
|
||||||
theme = ThemeXMLParser(theme_xml)
|
theme = ThemeXML()
|
||||||
|
theme.parse(theme_xml)
|
||||||
#print theme
|
#print theme
|
||||||
size=QtCore.QSize(800,600)
|
size=QtCore.QSize(800,600)
|
||||||
frame=TstFrame(size)
|
frame=TstFrame(size)
|
||||||
|
@ -23,15 +23,17 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
from openlp.core.resources import *
|
from openlp.core.resources import *
|
||||||
from openlp.core.lib import Plugin, Event
|
from openlp.core.lib import Plugin, Event
|
||||||
|
from openlp.core.lib import EventType
|
||||||
from forms import EditCustomForm
|
from forms import EditCustomForm
|
||||||
from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem, CustomServiceItem
|
from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem, CustomServiceItem
|
||||||
|
|
||||||
|
|
||||||
class CustomPlugin(Plugin):
|
class CustomPlugin(Plugin):
|
||||||
|
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger(u'CustomPlugin')
|
log=logging.getLogger(u'CustomPlugin')
|
||||||
log.info(u'Custom Plugin loaded')
|
log.info(u'Custom Plugin loaded')
|
||||||
|
|
||||||
def __init__(self, plugin_helpers):
|
def __init__(self, plugin_helpers):
|
||||||
# Call the parent constructor
|
# Call the parent constructor
|
||||||
Plugin.__init__(self, u'Custom', u'1.9.0', plugin_helpers)
|
Plugin.__init__(self, u'Custom', u'1.9.0', plugin_helpers)
|
||||||
@ -49,9 +51,12 @@ class CustomPlugin(Plugin):
|
|||||||
# Create the CustomManagerItem object
|
# Create the CustomManagerItem object
|
||||||
self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')
|
self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')
|
||||||
return self.media_item
|
return self.media_item
|
||||||
|
|
||||||
def handle_event(self, event):
|
def handle_event(self, event):
|
||||||
"""
|
"""
|
||||||
Handle the event contained in the event object.
|
Handle the event contained in the event object.
|
||||||
"""
|
"""
|
||||||
log.debug(u'Handle event called with event %s' %event.get_type())
|
log.debug(u'Handle event called with event %s' %event.event_type)
|
||||||
|
if event.event_type == EventType.ThemeListChanged:
|
||||||
|
log.debug(u'New Theme request received')
|
||||||
|
self.edit_custom_form.loadThemes(self.theme_manager.getThemes())
|
||||||
|
@ -32,7 +32,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
Constructor
|
Constructor
|
||||||
"""
|
"""
|
||||||
QtGui.QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
#self.parent = parent
|
#self.parent = parent
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
# Connecting signals and slots
|
# Connecting signals and slots
|
||||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.rejected)
|
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), self.rejected)
|
||||||
@ -43,18 +43,18 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
QtCore.QObject.connect(self.DeleteButton, QtCore.SIGNAL("pressed()"), self.onDeleteButtonPressed)
|
QtCore.QObject.connect(self.DeleteButton, QtCore.SIGNAL("pressed()"), self.onDeleteButtonPressed)
|
||||||
QtCore.QObject.connect(self.ClearButton, QtCore.SIGNAL("pressed()"), self.onClearButtonPressed)
|
QtCore.QObject.connect(self.ClearButton, QtCore.SIGNAL("pressed()"), self.onClearButtonPressed)
|
||||||
QtCore.QObject.connect(self.UpButton, QtCore.SIGNAL("pressed()"), self.onUpButtonPressed)
|
QtCore.QObject.connect(self.UpButton, QtCore.SIGNAL("pressed()"), self.onUpButtonPressed)
|
||||||
QtCore.QObject.connect(self.DownButton, QtCore.SIGNAL("pressed()"), self.onDownButtonPressed)
|
QtCore.QObject.connect(self.DownButton, QtCore.SIGNAL("pressed()"), self.onDownButtonPressed)
|
||||||
QtCore.QObject.connect(self.TitleEdit, QtCore.SIGNAL("lostFocus()"), self.validate)
|
QtCore.QObject.connect(self.TitleEdit, QtCore.SIGNAL("lostFocus()"), self.validate)
|
||||||
|
|
||||||
QtCore.QObject.connect(self.VerseListView,
|
QtCore.QObject.connect(self.VerseListView,
|
||||||
QtCore.SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.onVerseListViewSelected)
|
QtCore.SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.onVerseListViewSelected)
|
||||||
QtCore.QObject.connect(self.VerseListView,
|
QtCore.QObject.connect(self.VerseListView,
|
||||||
QtCore.SIGNAL("itemClicked(QListWidgetItem*)"), self.onVerseListViewPressed)
|
QtCore.SIGNAL("itemClicked(QListWidgetItem*)"), self.onVerseListViewPressed)
|
||||||
# Create other objects and forms
|
# Create other objects and forms
|
||||||
self.custommanager = custommanager
|
self.custommanager = custommanager
|
||||||
self.initialise()
|
self.initialise()
|
||||||
self.VerseListView.setAlternatingRowColors(True)
|
self.VerseListView.setAlternatingRowColors(True)
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
self.valid = True
|
self.valid = True
|
||||||
self.DeleteButton.setEnabled(False)
|
self.DeleteButton.setEnabled(False)
|
||||||
@ -64,10 +64,15 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
self.CreditEdit.setText('')
|
self.CreditEdit.setText('')
|
||||||
self.VerseTextEdit.clear()
|
self.VerseTextEdit.clear()
|
||||||
self.VerseListView.clear()
|
self.VerseListView.clear()
|
||||||
#make sure we have a new item
|
#make sure we have a new item
|
||||||
self.customSlide = CustomSlide()
|
self.customSlide = CustomSlide()
|
||||||
self.ThemecomboBox.addItem(u'')
|
self.ThemecomboBox.addItem(u'')
|
||||||
#self.theme_manager.getThemes()
|
|
||||||
|
def loadThemes(self, themelist):
|
||||||
|
self.ThemecomboBox.clear()
|
||||||
|
self.ThemecomboBox.addItem(u'')
|
||||||
|
for themename in themelist:
|
||||||
|
self.ThemecomboBox.addItem(themename)
|
||||||
|
|
||||||
def loadCustom(self, id):
|
def loadCustom(self, id):
|
||||||
self.customSlide = CustomSlide()
|
self.customSlide = CustomSlide()
|
||||||
@ -76,12 +81,19 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
self.customSlide = self.custommanager.get_custom(id)
|
self.customSlide = self.custommanager.get_custom(id)
|
||||||
self.TitleEdit.setText(self.customSlide.title)
|
self.TitleEdit.setText(self.customSlide.title)
|
||||||
self.CreditEdit.setText(self.customSlide.title)
|
self.CreditEdit.setText(self.customSlide.title)
|
||||||
|
|
||||||
songXML=SongXMLParser(self.customSlide.text)
|
songXML=SongXMLParser(self.customSlide.text)
|
||||||
verseList = songXML.get_verses()
|
verseList = songXML.get_verses()
|
||||||
for verse in verseList:
|
for verse in verseList:
|
||||||
self.VerseListView.addItem(verse[1])
|
self.VerseListView.addItem(verse[1])
|
||||||
|
theme = str(self.customSlide.theme_name)
|
||||||
|
id = self.ThemecomboBox.findText(theme, QtCore.Qt.MatchExactly)
|
||||||
|
if id == -1:
|
||||||
|
id = 0 # Not Found
|
||||||
|
self.ThemecomboBox.setCurrentIndex(id)
|
||||||
self.validate()
|
self.validate()
|
||||||
|
else:
|
||||||
|
self.ThemecomboBox.setCurrentIndex(0)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
self.validate()
|
self.validate()
|
||||||
@ -96,6 +108,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
self.customSlide.title = unicode(self.TitleEdit.displayText())
|
self.customSlide.title = unicode(self.TitleEdit.displayText())
|
||||||
self.customSlide.text = unicode(sxml.extract_xml())
|
self.customSlide.text = unicode(sxml.extract_xml())
|
||||||
self.customSlide.credits = unicode(self.CreditEdit.displayText())
|
self.customSlide.credits = unicode(self.CreditEdit.displayText())
|
||||||
|
self.customSlide.theme_name = unicode(self.ThemecomboBox.currentText())
|
||||||
self.custommanager.save_slide(self.customSlide)
|
self.custommanager.save_slide(self.customSlide)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
@ -114,7 +127,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
if selectedRow != self.VerseListView.count() - 1: # zero base arrays
|
if selectedRow != self.VerseListView.count() - 1: # zero base arrays
|
||||||
qw = self.VerseListView.takeItem(selectedRow)
|
qw = self.VerseListView.takeItem(selectedRow)
|
||||||
self.VerseListView.insertItem(selectedRow + 1, qw)
|
self.VerseListView.insertItem(selectedRow + 1, qw)
|
||||||
self.VerseListView.setCurrentRow(selectedRow + 1)
|
self.VerseListView.setCurrentRow(selectedRow + 1)
|
||||||
|
|
||||||
def onClearButtonPressed(self):
|
def onClearButtonPressed(self):
|
||||||
self.VerseTextEdit.clear()
|
self.VerseTextEdit.clear()
|
||||||
@ -122,7 +135,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
|||||||
def onVerseListViewPressed(self, item):
|
def onVerseListViewPressed(self, item):
|
||||||
self.DeleteButton.setEnabled(True)
|
self.DeleteButton.setEnabled(True)
|
||||||
self.EditButton.setEnabled(True)
|
self.EditButton.setEnabled(True)
|
||||||
|
|
||||||
def onVerseListViewSelected(self, item):
|
def onVerseListViewSelected(self, item):
|
||||||
self.VerseTextEdit.setPlainText(item.text())
|
self.VerseTextEdit.setPlainText(item.text())
|
||||||
self.DeleteButton.setEnabled(False)
|
self.DeleteButton.setEnabled(False)
|
||||||
|
Loading…
Reference in New Issue
Block a user