Fix up song dialog errors

Fix servicemanager key entry
Fix servicemanager state handling

bzr-revno: 496
This commit is contained in:
Tim Bentley 2009-07-22 19:30:35 +01:00
commit b30c7d5558
8 changed files with 153 additions and 58 deletions

View File

@ -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

View File

@ -40,6 +40,7 @@ class Renderer(object):
self._debug = 0
self._right_margin = 64 # the amount of right indent
self._shadow_offset = 5
self._shadow_offset_footer = 3
self._outline_offset = 2
self.theme_name = None
self._theme = None
@ -482,15 +483,17 @@ class Renderer(object):
# dont allow alignment messing with footers
if footer:
align = 0
shadow_offset = self._shadow_offset_footer
else:
align = int(self._theme .display_horizontalAlign)
shadow_offset = self._shadow_offset
for linenum in range(len(lines)):
line = lines[linenum]
#find out how wide line is
w , h = self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=False)
if self._theme.display_shadow:
w += self._shadow_offset
h += self._shadow_offset
w += shadow_offset
h += shadow_offset
if self._theme.display_outline:
# pixels either side
w += 2 * self._outline_offset
@ -515,7 +518,7 @@ class Renderer(object):
if live:
# now draw the text, and any outlines/shadows
if self._theme.display_shadow:
self._get_extent_and_render(line, footer, tlcorner=(x+self._shadow_offset,y+self._shadow_offset),
self._get_extent_and_render(line, footer, tlcorner=(x + shadow_offset, y + shadow_offset),
draw=True, color = self._theme.display_shadow_color)
if self._theme.display_outline:
self._get_extent_and_render(line, footer, (x+self._outline_offset,y), draw=True,

View File

@ -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):
"""

View File

@ -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.onMoveSelectionUp()
event.accept()
elif event.key() == QtCore.Qt.Key_Down:
self.parent.onMoveSelectionDown()
event.accept()
event.ignore()
else:
event.ignore()
class Iter(QtGui.QTreeWidgetItemIterator):
def __init__(self, *args):
QtGui.QTreeWidgetItemIterator.__init__(self, *args)
def next(self):
self.__iadd__(1)
value = self.value()
if value:
return self.value()
else:
return None
class ServiceManager(QtGui.QWidget):
"""
Manages the orders of service. Currently this involves taking
@ -134,6 +163,52 @@ class ServiceManager(QtGui.QWidget):
self.servicePath = self.config.get_data_path()
self.service_theme = self.config.get_config(u'theme service theme', u'')
def onMoveSelectionUp(self):
"""
Moves the selection up the window
Called by the up arrow
"""
it = Iter(self.ServiceManagerList)
item = it.value()
tempItem = None
setLastItem = False
while item is not None:
if item.isSelected() and tempItem is None:
setLastItem = True
item.setSelected(False)
if item.isSelected():
#We are on the first record
if tempItem is not None:
tempItem.setSelected(True)
item.setSelected(False)
else:
tempItem = item
lastItem = item
item = it.next()
#Top Item was selected so set the last one
if setLastItem:
lastItem.setSelected(True)
def onMoveSelectionDown(self):
"""
Moves the selection down the window
Called by the down arrow
"""
it = Iter(self.ServiceManagerList)
item = it.value()
firstItem = item
setSelected = False
while item is not None:
if setSelected:
setSelected = False
item.setSelected(True)
elif item.isSelected():
item.setSelected(False)
setSelected = True
item = it.next()
if setSelected:
firstItem.setSelected(True)
def collapsed(self, item):
"""
Record if an item is collapsed
@ -159,7 +234,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 +247,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 +260,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 +272,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,10 +291,10 @@ 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,
@ -232,20 +307,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):
"""

View File

@ -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,31 +101,32 @@ 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
"""
self.currentRow = self.AuthorListWidget.currentRow()
item = self.AuthorListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.author = self.songmanager.get_author(item_id)
self.DisplayEdit.setText(self.author.display_name)
if self.author.first_name is None:
self.FirstNameEdit.setText(u'')
else:
self.FirstNameEdit.setText(self.author.first_name)
if self.author.last_name is None:
self.LastNameEdit.setText(u'')
else:
self.LastNameEdit.setText(self.author.last_name)
if len(self.author.songs) > 0:
self.MessageLabel.setText(translate(u'AuthorForm', u'Author in use "Delete" is disabled'))
self.DeleteButton.setEnabled(False)
else:
self.MessageLabel.setText(translate(u'AuthorForm', u'Author in not used'))
self.DeleteButton.setEnabled(True)
self._validate_form()
if item is not None:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.author = self.songmanager.get_author(item_id)
self.DisplayEdit.setText(self.author.display_name)
if self.author.first_name is None:
self.FirstNameEdit.setText(u'')
else:
self.FirstNameEdit.setText(self.author.first_name)
if self.author.last_name is None:
self.LastNameEdit.setText(u'')
else:
self.LastNameEdit.setText(self.author.last_name)
if len(self.author.songs) > 0:
self.MessageLabel.setText(translate(u'AuthorForm', u'Author in use "Delete" is disabled'))
self.DeleteButton.setEnabled(False)
else:
self.MessageLabel.setText(translate(u'AuthorForm', u'Author in not used'))
self.DeleteButton.setEnabled(True)
self._validate_form()
self.DisplayEdit.setFocus()
def _validate_form(self):

View File

@ -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,24 +99,25 @@ 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
"""
self.currentRow = self.BookSongListWidget.currentRow()
item = self.BookSongListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.Book = self.songmanager.get_book(item_id)
self.NameEdit.setText(self.Book.name)
self.PublisherEdit.setText(self.Book.publisher)
if len(self.Book.songs) > 0:
self.MessageLabel.setText(translate(u'BookForm', u'Book in use "Delete" is disabled'))
self.DeleteButton.setEnabled(False)
else:
self.MessageLabel.setText(translate(u'BookForm', u'Book in not used'))
self.DeleteButton.setEnabled(True)
self._validate_form()
if item is not None:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.Book = self.songmanager.get_book(item_id)
self.NameEdit.setText(self.Book.name)
self.PublisherEdit.setText(self.Book.publisher)
if len(self.Book.songs) > 0:
self.MessageLabel.setText(translate(u'BookForm', u'Book in use "Delete" is disabled'))
self.DeleteButton.setEnabled(False)
else:
self.MessageLabel.setText(translate(u'BookForm', u'Book in not used'))
self.DeleteButton.setEnabled(True)
self._validate_form()
self.NameEdit.setFocus()
def _validate_form(self):

View File

@ -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,23 +98,24 @@ 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
"""
self.currentRow = self.TopicsListWidget.currentRow()
item = self.TopicsListWidget.currentItem()
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.topic = self.songmanager.get_topic(item_id)
self.TopicNameEdit.setText(self.topic.name)
if len(self.topic.songs) > 0:
self.MessageLabel.setText(translate(u'TopicForm', u'Topic in use "Delete" is disabled'))
self.DeleteButton.setEnabled(False)
else:
self.MessageLabel.setText(translate(u'TopicForm', u'Topic in not used'))
self.DeleteButton.setEnabled(True)
self._validate_form()
if item is not None:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.topic = self.songmanager.get_topic(item_id)
self.TopicNameEdit.setText(self.topic.name)
if len(self.topic.songs) > 0:
self.MessageLabel.setText(translate(u'TopicForm', u'Topic in use "Delete" is disabled'))
self.DeleteButton.setEnabled(False)
else:
self.MessageLabel.setText(translate(u'TopicForm', u'Topic in not used'))
self.DeleteButton.setEnabled(True)
self._validate_form()
self.TopicNameEdit.setFocus()
def _validate_form(self):

View File

@ -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: