forked from openlp/openlp
Fix song conversions
Fix focus for Song dialog Preserve state when moving serviceitems
This commit is contained in:
parent
2885a08ed2
commit
9da5a3223f
3
cnvdb.py
3
cnvdb.py
@ -20,6 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
import codecs
|
||||
import sys
|
||||
import chardet
|
||||
|
||||
def convert_file(inname, outname):
|
||||
"""
|
||||
@ -31,7 +32,7 @@ def convert_file(inname, outname):
|
||||
``outname``
|
||||
The output file name.
|
||||
"""
|
||||
infile = codecs.open(inname, 'r', encoding='iso-8859-1')
|
||||
infile = codecs.open(inname, 'r', encoding='CP1252')
|
||||
writefile = codecs.open(outname, 'w', encoding='utf-8')
|
||||
for line in infile:
|
||||
#replace the quotes with quotes
|
||||
|
@ -62,12 +62,22 @@ class MainDisplay(QtGui.QWidget):
|
||||
self.showFullScreen()
|
||||
else:
|
||||
self.showMinimized()
|
||||
#Build a custom splash screen
|
||||
self.InitialFrame = QtGui.QImage(screen[u'size'].width(),
|
||||
screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied)
|
||||
splash_image = QtGui.QImage(u':/graphics/openlp-splash-screen.png')
|
||||
painter_image = QtGui.QPainter()
|
||||
painter_image.begin(self.InitialFrame)
|
||||
painter_image.fillRect(self.InitialFrame.rect(), QtCore.Qt.white)
|
||||
painter_image.drawImage((screen[u'size'].width() - splash_image.width()) / 2,
|
||||
(screen[u'size'].height() - splash_image.height()) / 2 , splash_image)
|
||||
self.frameView(self.InitialFrame)
|
||||
#Build a Black screen
|
||||
painter = QtGui.QPainter()
|
||||
self.blankFrame = QtGui.QImage(screen[u'size'].width(),
|
||||
screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied)
|
||||
painter.begin(self.blankFrame)
|
||||
painter.fillRect(self.blankFrame.rect(), QtCore.Qt.black)
|
||||
self.frameView(self.blankFrame)
|
||||
|
||||
def frameView(self, frame):
|
||||
"""
|
||||
|
@ -41,10 +41,39 @@ class ServiceManagerList(QtGui.QTreeWidget):
|
||||
if event.key() == QtCore.Qt.Key_Enter:
|
||||
self.parent.makeLive()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_Home:
|
||||
self.parent.onServiceTop()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_End:
|
||||
self.parent.onServiceEnd()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_PageUp:
|
||||
self.parent.onServiceUp()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_PageDown:
|
||||
self.parent.onServiceDown()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_Up:
|
||||
self.parent.onServiceUp()
|
||||
event.accept()
|
||||
elif event.key() == QtCore.Qt.Key_Down:
|
||||
self.parent.onServiceDown()
|
||||
event.accept()
|
||||
event.ignore()
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
class Iter(QtGui.QTreeWidgetItemIterator):
|
||||
def __init__(self, *args):
|
||||
QTreeWidgetItemIterator.__init__(self, *args)
|
||||
def next(self):
|
||||
self.__iadd__(1)
|
||||
value = self.value()
|
||||
if value:
|
||||
return self.value()
|
||||
else:
|
||||
raise StopIteration
|
||||
|
||||
class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
Manages the orders of service. Currently this involves taking
|
||||
@ -159,7 +188,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(0, temp)
|
||||
self.repaintServiceList()
|
||||
self.repaintServiceList(0, count)
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def onServiceUp(self):
|
||||
@ -172,7 +201,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(item - 1, temp)
|
||||
self.repaintServiceList()
|
||||
self.repaintServiceList(item - 1 , count)
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def onServiceDown(self):
|
||||
@ -185,7 +214,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(item + 1, temp)
|
||||
self.repaintServiceList()
|
||||
self.repaintServiceList(item + 1 , count)
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def onServiceEnd(self):
|
||||
@ -197,7 +226,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(len(self.serviceItems), temp)
|
||||
self.repaintServiceList()
|
||||
self.repaintServiceList(len(self.serviceItems) - 1, count)
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def onNewService(self):
|
||||
@ -216,15 +245,19 @@ class ServiceManager(QtGui.QWidget):
|
||||
item, count = self.findServiceItem()
|
||||
if item is not -1:
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.repaintServiceList()
|
||||
self.repaintServiceList(0, 0)
|
||||
self.parent.OosChanged(False, self.serviceName)
|
||||
|
||||
def repaintServiceList(self):
|
||||
def repaintServiceList(self, serviceItem, serviceItemCount):
|
||||
"""
|
||||
Clear the existing service list and prepaint all the items
|
||||
Used when moving items as the move takes place in supporting array,
|
||||
and when regenerating all the items due to theme changes
|
||||
"""
|
||||
aa = Iter(self.ServiceManagerList)
|
||||
print aa
|
||||
for a in aa:
|
||||
print a
|
||||
#Correct order of idems in array
|
||||
count = 1
|
||||
for item in self.serviceItems:
|
||||
@ -232,20 +265,20 @@ class ServiceManager(QtGui.QWidget):
|
||||
count += 1
|
||||
#Repaint the screen
|
||||
self.ServiceManagerList.clear()
|
||||
for item in self.serviceItems:
|
||||
for itemcount, item in enumerate(self.serviceItems):
|
||||
serviceitem = item[u'data']
|
||||
treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
|
||||
treewidgetitem.setText(0,serviceitem.title)
|
||||
treewidgetitem.setIcon(0,serviceitem.iconic_representation)
|
||||
treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order']))
|
||||
treewidgetitem.setExpanded(item[u'expanded'])
|
||||
count = 0
|
||||
for frame in serviceitem.frames:
|
||||
for count , frame in enumerate(serviceitem.frames):
|
||||
treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem)
|
||||
text = frame[u'title']
|
||||
treewidgetitem1.setText(0,text[:40])
|
||||
treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count))
|
||||
count = count + 1
|
||||
if serviceItem == itemcount and serviceItemCount == count:
|
||||
self.ServiceManagerList.setCurrentItem(treewidgetitem1)
|
||||
|
||||
def onSaveService(self):
|
||||
"""
|
||||
|
@ -63,6 +63,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
||||
else:
|
||||
self.AuthorListWidget.setCurrentRow(self.currentRow)
|
||||
self._validate_form()
|
||||
self.onAuthorListWidgetItemClicked()
|
||||
|
||||
def onDeleteButtonClick(self):
|
||||
"""
|
||||
@ -100,7 +101,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
||||
self._validate_form()
|
||||
self.DisplayEdit.setFocus()
|
||||
|
||||
def onAuthorListWidgetItemClicked(self, index):
|
||||
def onAuthorListWidgetItemClicked(self):
|
||||
"""
|
||||
An Author has been selected display it
|
||||
If the author is attached to a Song prevent delete
|
||||
|
@ -62,6 +62,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
|
||||
self.BookSongListWidget.setCurrentRow(self.BookSongListWidget.count() - 1)
|
||||
else:
|
||||
self.BookSongListWidget.setCurrentRow(self.currentRow)
|
||||
self.onBooksListViewItemClicked()
|
||||
|
||||
def onDeleteButtonClick(self):
|
||||
"""
|
||||
@ -98,7 +99,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
|
||||
self._validate_form()
|
||||
self.NameEdit.setFocus()
|
||||
|
||||
def onBooksListViewItemClicked(self, index):
|
||||
def onBooksListViewItemClicked(self):
|
||||
"""
|
||||
An Book has been selected display it
|
||||
If the Book is attached to a Song prevent delete
|
||||
|
@ -63,6 +63,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
||||
else:
|
||||
self.TopicsListWidget.setCurrentRow(self.currentRow)
|
||||
self._validate_form()
|
||||
self.onTopicsListWidgetItemClicked()
|
||||
|
||||
def onDeleteButtonClick(self):
|
||||
"""
|
||||
@ -97,7 +98,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
||||
self._validate_form()
|
||||
self.TopicNameEdit.setFocus()
|
||||
|
||||
def onTopicsListWidgetItemClicked(self, index):
|
||||
def onTopicsListWidgetItemClicked(self):
|
||||
"""
|
||||
An Topic has been selected display it
|
||||
If the Topic is attached to a Song prevent delete
|
||||
|
@ -289,7 +289,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
else:
|
||||
verses = song.lyrics.split(u'\n\n')
|
||||
for slide in verses:
|
||||
service_item.add_from_text(slide[:30], slide)
|
||||
service_item.add_from_text(slide[:30], unicode(slide))
|
||||
service_item.title = song.title
|
||||
for author in song.authors:
|
||||
if len(author_list) > 1:
|
||||
|
Loading…
Reference in New Issue
Block a user