Fix song conversions

Fix focus for Song dialog
Preserve state when moving serviceitems
This commit is contained in:
Tim Bentley 2009-07-21 19:10:14 +01:00
parent 2885a08ed2
commit 9da5a3223f
7 changed files with 63 additions and 16 deletions

View File

@ -20,6 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
""" """
import codecs import codecs
import sys import sys
import chardet
def convert_file(inname, outname): def convert_file(inname, outname):
""" """
@ -31,7 +32,7 @@ def convert_file(inname, outname):
``outname`` ``outname``
The output file name. 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') writefile = codecs.open(outname, 'w', encoding='utf-8')
for line in infile: for line in infile:
#replace the quotes with quotes #replace the quotes with quotes

View File

@ -62,12 +62,22 @@ class MainDisplay(QtGui.QWidget):
self.showFullScreen() self.showFullScreen()
else: else:
self.showMinimized() 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() painter = QtGui.QPainter()
self.blankFrame = QtGui.QImage(screen[u'size'].width(), self.blankFrame = QtGui.QImage(screen[u'size'].width(),
screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied) screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied)
painter.begin(self.blankFrame) painter.begin(self.blankFrame)
painter.fillRect(self.blankFrame.rect(), QtCore.Qt.black) painter.fillRect(self.blankFrame.rect(), QtCore.Qt.black)
self.frameView(self.blankFrame)
def frameView(self, frame): def frameView(self, frame):
""" """

View File

@ -41,10 +41,39 @@ class ServiceManagerList(QtGui.QTreeWidget):
if event.key() == QtCore.Qt.Key_Enter: if event.key() == QtCore.Qt.Key_Enter:
self.parent.makeLive() self.parent.makeLive()
event.accept() 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() event.ignore()
else: else:
event.ignore() 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): class ServiceManager(QtGui.QWidget):
""" """
Manages the orders of service. Currently this involves taking Manages the orders of service. Currently this involves taking
@ -159,7 +188,7 @@ class ServiceManager(QtGui.QWidget):
temp = self.serviceItems[item] temp = self.serviceItems[item]
self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(0, temp) self.serviceItems.insert(0, temp)
self.repaintServiceList() self.repaintServiceList(0, count)
self.parent.OosChanged(False, self.serviceName) self.parent.OosChanged(False, self.serviceName)
def onServiceUp(self): def onServiceUp(self):
@ -172,7 +201,7 @@ class ServiceManager(QtGui.QWidget):
temp = self.serviceItems[item] temp = self.serviceItems[item]
self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(item - 1, temp) self.serviceItems.insert(item - 1, temp)
self.repaintServiceList() self.repaintServiceList(item - 1 , count)
self.parent.OosChanged(False, self.serviceName) self.parent.OosChanged(False, self.serviceName)
def onServiceDown(self): def onServiceDown(self):
@ -185,7 +214,7 @@ class ServiceManager(QtGui.QWidget):
temp = self.serviceItems[item] temp = self.serviceItems[item]
self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(item + 1, temp) self.serviceItems.insert(item + 1, temp)
self.repaintServiceList() self.repaintServiceList(item + 1 , count)
self.parent.OosChanged(False, self.serviceName) self.parent.OosChanged(False, self.serviceName)
def onServiceEnd(self): def onServiceEnd(self):
@ -197,7 +226,7 @@ class ServiceManager(QtGui.QWidget):
temp = self.serviceItems[item] temp = self.serviceItems[item]
self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(len(self.serviceItems), temp) self.serviceItems.insert(len(self.serviceItems), temp)
self.repaintServiceList() self.repaintServiceList(len(self.serviceItems) - 1, count)
self.parent.OosChanged(False, self.serviceName) self.parent.OosChanged(False, self.serviceName)
def onNewService(self): def onNewService(self):
@ -216,15 +245,19 @@ class ServiceManager(QtGui.QWidget):
item, count = self.findServiceItem() item, count = self.findServiceItem()
if item is not -1: if item is not -1:
self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.remove(self.serviceItems[item])
self.repaintServiceList() self.repaintServiceList(0, 0)
self.parent.OosChanged(False, self.serviceName) self.parent.OosChanged(False, self.serviceName)
def repaintServiceList(self): def repaintServiceList(self, serviceItem, serviceItemCount):
""" """
Clear the existing service list and prepaint all the items Clear the existing service list and prepaint all the items
Used when moving items as the move takes place in supporting array, Used when moving items as the move takes place in supporting array,
and when regenerating all the items due to theme changes 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 #Correct order of idems in array
count = 1 count = 1
for item in self.serviceItems: for item in self.serviceItems:
@ -232,20 +265,20 @@ class ServiceManager(QtGui.QWidget):
count += 1 count += 1
#Repaint the screen #Repaint the screen
self.ServiceManagerList.clear() self.ServiceManagerList.clear()
for item in self.serviceItems: for itemcount, item in enumerate(self.serviceItems):
serviceitem = item[u'data'] serviceitem = item[u'data']
treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList) treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
treewidgetitem.setText(0,serviceitem.title) treewidgetitem.setText(0,serviceitem.title)
treewidgetitem.setIcon(0,serviceitem.iconic_representation) treewidgetitem.setIcon(0,serviceitem.iconic_representation)
treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order'])) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order']))
treewidgetitem.setExpanded(item[u'expanded']) treewidgetitem.setExpanded(item[u'expanded'])
count = 0 for count , frame in enumerate(serviceitem.frames):
for frame in serviceitem.frames:
treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem) treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem)
text = frame[u'title'] text = frame[u'title']
treewidgetitem1.setText(0,text[:40]) treewidgetitem1.setText(0,text[:40])
treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count)) 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): def onSaveService(self):
""" """

View File

@ -63,6 +63,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
else: else:
self.AuthorListWidget.setCurrentRow(self.currentRow) self.AuthorListWidget.setCurrentRow(self.currentRow)
self._validate_form() self._validate_form()
self.onAuthorListWidgetItemClicked()
def onDeleteButtonClick(self): def onDeleteButtonClick(self):
""" """
@ -100,7 +101,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
self._validate_form() self._validate_form()
self.DisplayEdit.setFocus() self.DisplayEdit.setFocus()
def onAuthorListWidgetItemClicked(self, index): def onAuthorListWidgetItemClicked(self):
""" """
An Author has been selected display it An Author has been selected display it
If the author is attached to a Song prevent delete If the author is attached to a Song prevent delete

View File

@ -62,6 +62,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
self.BookSongListWidget.setCurrentRow(self.BookSongListWidget.count() - 1) self.BookSongListWidget.setCurrentRow(self.BookSongListWidget.count() - 1)
else: else:
self.BookSongListWidget.setCurrentRow(self.currentRow) self.BookSongListWidget.setCurrentRow(self.currentRow)
self.onBooksListViewItemClicked()
def onDeleteButtonClick(self): def onDeleteButtonClick(self):
""" """
@ -98,7 +99,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
self._validate_form() self._validate_form()
self.NameEdit.setFocus() self.NameEdit.setFocus()
def onBooksListViewItemClicked(self, index): def onBooksListViewItemClicked(self):
""" """
An Book has been selected display it An Book has been selected display it
If the Book is attached to a Song prevent delete If the Book is attached to a Song prevent delete

View File

@ -63,6 +63,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
else: else:
self.TopicsListWidget.setCurrentRow(self.currentRow) self.TopicsListWidget.setCurrentRow(self.currentRow)
self._validate_form() self._validate_form()
self.onTopicsListWidgetItemClicked()
def onDeleteButtonClick(self): def onDeleteButtonClick(self):
""" """
@ -97,7 +98,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
self._validate_form() self._validate_form()
self.TopicNameEdit.setFocus() self.TopicNameEdit.setFocus()
def onTopicsListWidgetItemClicked(self, index): def onTopicsListWidgetItemClicked(self):
""" """
An Topic has been selected display it An Topic has been selected display it
If the Topic is attached to a Song prevent delete If the Topic is attached to a Song prevent delete

View File

@ -289,7 +289,7 @@ class SongMediaItem(MediaManagerItem):
else: else:
verses = song.lyrics.split(u'\n\n') verses = song.lyrics.split(u'\n\n')
for slide in verses: 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 service_item.title = song.title
for author in song.authors: for author in song.authors:
if len(author_list) > 1: if len(author_list) > 1: