← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bugfixes into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bugfixes into lp:openlp.

Requested reviews:
    openlp.org Core (openlp-core)

Add Keyboard events to ServiceManage
Add Splash Screen to Display Screen
Fix Renderer for footers
-- 
https://code.launchpad.net/~trb143/openlp/bugfixes/+merge/9107
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'cnvdb.py'
--- cnvdb.py	2009-07-19 06:31:08 +0000
+++ cnvdb.py	2009-07-21 18:10:14 +0000
@@ -20,6 +20,7 @@
 """
 import codecs
 import sys
+import chardet
 
 def convert_file(inname, outname):
     """
@@ -31,7 +32,7 @@
     ``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

=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py	2009-07-15 17:33:31 +0000
+++ openlp/core/lib/renderer.py	2009-07-21 20:04:27 +0000
@@ -40,6 +40,7 @@
         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 @@
         # 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 @@
             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,

=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2009-07-19 07:40:31 +0000
+++ openlp/core/ui/maindisplay.py	2009-07-21 18:10:14 +0000
@@ -62,12 +62,22 @@
             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):
         """

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2009-07-11 05:18:34 +0000
+++ openlp/core/ui/servicemanager.py	2009-07-21 20:04:27 +0000
@@ -41,9 +41,38 @@
             if event.key() == QtCore.Qt.Key_Enter:
                 self.parent.makeLive()
                 event.accept()
-            event.ignore()
-        else:
-            event.ignore()
+            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):
     """
@@ -134,6 +163,52 @@
         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 @@
             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 @@
             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 @@
             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 @@
             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 @@
         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 @@
             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):
         """

=== modified file 'openlp/plugins/songs/forms/authorsform.py'
--- openlp/plugins/songs/forms/authorsform.py	2009-07-18 05:43:50 +0000
+++ openlp/plugins/songs/forms/authorsform.py	2009-07-21 18:10:14 +0000
@@ -63,6 +63,7 @@
         else:
             self.AuthorListWidget.setCurrentRow(self.currentRow)
         self._validate_form()
+        self.onAuthorListWidgetItemClicked()
 
     def onDeleteButtonClick(self):
         """
@@ -100,7 +101,7 @@
         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

=== modified file 'openlp/plugins/songs/forms/songbookform.py'
--- openlp/plugins/songs/forms/songbookform.py	2009-07-14 18:38:33 +0000
+++ openlp/plugins/songs/forms/songbookform.py	2009-07-21 18:10:14 +0000
@@ -62,6 +62,7 @@
             self.BookSongListWidget.setCurrentRow(self.BookSongListWidget.count() - 1)
         else:
             self.BookSongListWidget.setCurrentRow(self.currentRow)
+        self.onBooksListViewItemClicked()
 
     def onDeleteButtonClick(self):
         """
@@ -98,7 +99,7 @@
         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

=== modified file 'openlp/plugins/songs/forms/topicsform.py'
--- openlp/plugins/songs/forms/topicsform.py	2009-07-14 18:38:33 +0000
+++ openlp/plugins/songs/forms/topicsform.py	2009-07-21 18:10:14 +0000
@@ -63,6 +63,7 @@
         else:
             self.TopicsListWidget.setCurrentRow(self.currentRow)
         self._validate_form()
+        self.onTopicsListWidgetItemClicked()
 
     def onDeleteButtonClick(self):
         """
@@ -97,7 +98,7 @@
         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

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2009-07-18 05:43:50 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2009-07-21 18:10:14 +0000
@@ -289,7 +289,7 @@
         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:


Follow ups