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

Proposed by Tim Bentley
Status: Merged
Merged at revision: not available
Proposed branch: lp:~trb143/openlp/bugfixes
Merge into: lp:openlp
Diff against target: None lines
To merge this branch: bzr merge lp:~trb143/openlp/bugfixes
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+9148@code.launchpad.net

This proposal supersedes a proposal from 2009-07-22.

To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote : Posted in a previous version of this proposal

Add Keyboard events to ServiceManage
Add Splash Screen to Display Screen
Fix Renderer for footers

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Sorry if I gave you the wrong impression, but I don't think this will work. CP1252 is a Windows-specific code. We need to find the encoding that matches this.

17 + infile = codecs.open(inname, 'r', encoding='CP1252')

Otherwise everything else looks fine.

review: Needs Fixing
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve
lp:~trb143/openlp/bugfixes updated
496. By Tim Bentley

Fix up song dialog errors
Fix servicemanager key entry
Fix servicemanager state handling

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cnvdb.py'
2--- cnvdb.py 2009-07-19 06:31:08 +0000
3+++ cnvdb.py 2009-07-21 18:10:14 +0000
4@@ -20,6 +20,7 @@
5 """
6 import codecs
7 import sys
8+import chardet
9
10 def convert_file(inname, outname):
11 """
12@@ -31,7 +32,7 @@
13 ``outname``
14 The output file name.
15 """
16- infile = codecs.open(inname, 'r', encoding='iso-8859-1')
17+ infile = codecs.open(inname, 'r', encoding='CP1252')
18 writefile = codecs.open(outname, 'w', encoding='utf-8')
19 for line in infile:
20 #replace the quotes with quotes
21
22=== modified file 'openlp/core/lib/renderer.py'
23--- openlp/core/lib/renderer.py 2009-07-15 17:33:31 +0000
24+++ openlp/core/lib/renderer.py 2009-07-21 20:04:27 +0000
25@@ -40,6 +40,7 @@
26 self._debug = 0
27 self._right_margin = 64 # the amount of right indent
28 self._shadow_offset = 5
29+ self._shadow_offset_footer = 3
30 self._outline_offset = 2
31 self.theme_name = None
32 self._theme = None
33@@ -482,15 +483,17 @@
34 # dont allow alignment messing with footers
35 if footer:
36 align = 0
37+ shadow_offset = self._shadow_offset_footer
38 else:
39 align = int(self._theme .display_horizontalAlign)
40+ shadow_offset = self._shadow_offset
41 for linenum in range(len(lines)):
42 line = lines[linenum]
43 #find out how wide line is
44 w , h = self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=False)
45 if self._theme.display_shadow:
46- w += self._shadow_offset
47- h += self._shadow_offset
48+ w += shadow_offset
49+ h += shadow_offset
50 if self._theme.display_outline:
51 # pixels either side
52 w += 2 * self._outline_offset
53@@ -515,7 +518,7 @@
54 if live:
55 # now draw the text, and any outlines/shadows
56 if self._theme.display_shadow:
57- self._get_extent_and_render(line, footer, tlcorner=(x+self._shadow_offset,y+self._shadow_offset),
58+ self._get_extent_and_render(line, footer, tlcorner=(x + shadow_offset, y + shadow_offset),
59 draw=True, color = self._theme.display_shadow_color)
60 if self._theme.display_outline:
61 self._get_extent_and_render(line, footer, (x+self._outline_offset,y), draw=True,
62
63=== modified file 'openlp/core/ui/maindisplay.py'
64--- openlp/core/ui/maindisplay.py 2009-07-19 07:40:31 +0000
65+++ openlp/core/ui/maindisplay.py 2009-07-21 18:10:14 +0000
66@@ -62,12 +62,22 @@
67 self.showFullScreen()
68 else:
69 self.showMinimized()
70+ #Build a custom splash screen
71+ self.InitialFrame = QtGui.QImage(screen[u'size'].width(),
72+ screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied)
73+ splash_image = QtGui.QImage(u':/graphics/openlp-splash-screen.png')
74+ painter_image = QtGui.QPainter()
75+ painter_image.begin(self.InitialFrame)
76+ painter_image.fillRect(self.InitialFrame.rect(), QtCore.Qt.white)
77+ painter_image.drawImage((screen[u'size'].width() - splash_image.width()) / 2,
78+ (screen[u'size'].height() - splash_image.height()) / 2 , splash_image)
79+ self.frameView(self.InitialFrame)
80+ #Build a Black screen
81 painter = QtGui.QPainter()
82 self.blankFrame = QtGui.QImage(screen[u'size'].width(),
83 screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied)
84 painter.begin(self.blankFrame)
85 painter.fillRect(self.blankFrame.rect(), QtCore.Qt.black)
86- self.frameView(self.blankFrame)
87
88 def frameView(self, frame):
89 """
90
91=== modified file 'openlp/core/ui/servicemanager.py'
92--- openlp/core/ui/servicemanager.py 2009-07-11 05:18:34 +0000
93+++ openlp/core/ui/servicemanager.py 2009-07-21 20:04:27 +0000
94@@ -41,9 +41,38 @@
95 if event.key() == QtCore.Qt.Key_Enter:
96 self.parent.makeLive()
97 event.accept()
98- event.ignore()
99- else:
100- event.ignore()
101+ elif event.key() == QtCore.Qt.Key_Home:
102+ self.parent.onServiceTop()
103+ event.accept()
104+ elif event.key() == QtCore.Qt.Key_End:
105+ self.parent.onServiceEnd()
106+ event.accept()
107+ elif event.key() == QtCore.Qt.Key_PageUp:
108+ self.parent.onServiceUp()
109+ event.accept()
110+ elif event.key() == QtCore.Qt.Key_PageDown:
111+ self.parent.onServiceDown()
112+ event.accept()
113+ elif event.key() == QtCore.Qt.Key_Up:
114+ self.parent.onMoveSelectionUp()
115+ event.accept()
116+ elif event.key() == QtCore.Qt.Key_Down:
117+ self.parent.onMoveSelectionDown()
118+ event.accept()
119+ event.ignore()
120+ else:
121+ event.ignore()
122+
123+class Iter(QtGui.QTreeWidgetItemIterator):
124+ def __init__(self, *args):
125+ QtGui.QTreeWidgetItemIterator.__init__(self, *args)
126+ def next(self):
127+ self.__iadd__(1)
128+ value = self.value()
129+ if value:
130+ return self.value()
131+ else:
132+ return None
133
134 class ServiceManager(QtGui.QWidget):
135 """
136@@ -134,6 +163,52 @@
137 self.servicePath = self.config.get_data_path()
138 self.service_theme = self.config.get_config(u'theme service theme', u'')
139
140+ def onMoveSelectionUp(self):
141+ """
142+ Moves the selection up the window
143+ Called by the up arrow
144+ """
145+ it = Iter(self.ServiceManagerList)
146+ item = it.value()
147+ tempItem = None
148+ setLastItem = False
149+ while item is not None:
150+ if item.isSelected() and tempItem is None:
151+ setLastItem = True
152+ item.setSelected(False)
153+ if item.isSelected():
154+ #We are on the first record
155+ if tempItem is not None:
156+ tempItem.setSelected(True)
157+ item.setSelected(False)
158+ else:
159+ tempItem = item
160+ lastItem = item
161+ item = it.next()
162+ #Top Item was selected so set the last one
163+ if setLastItem:
164+ lastItem.setSelected(True)
165+
166+ def onMoveSelectionDown(self):
167+ """
168+ Moves the selection down the window
169+ Called by the down arrow
170+ """
171+ it = Iter(self.ServiceManagerList)
172+ item = it.value()
173+ firstItem = item
174+ setSelected = False
175+ while item is not None:
176+ if setSelected:
177+ setSelected = False
178+ item.setSelected(True)
179+ elif item.isSelected():
180+ item.setSelected(False)
181+ setSelected = True
182+ item = it.next()
183+ if setSelected:
184+ firstItem.setSelected(True)
185+
186 def collapsed(self, item):
187 """
188 Record if an item is collapsed
189@@ -159,7 +234,7 @@
190 temp = self.serviceItems[item]
191 self.serviceItems.remove(self.serviceItems[item])
192 self.serviceItems.insert(0, temp)
193- self.repaintServiceList()
194+ self.repaintServiceList(0, count)
195 self.parent.OosChanged(False, self.serviceName)
196
197 def onServiceUp(self):
198@@ -172,7 +247,7 @@
199 temp = self.serviceItems[item]
200 self.serviceItems.remove(self.serviceItems[item])
201 self.serviceItems.insert(item - 1, temp)
202- self.repaintServiceList()
203+ self.repaintServiceList(item - 1 , count)
204 self.parent.OosChanged(False, self.serviceName)
205
206 def onServiceDown(self):
207@@ -185,7 +260,7 @@
208 temp = self.serviceItems[item]
209 self.serviceItems.remove(self.serviceItems[item])
210 self.serviceItems.insert(item + 1, temp)
211- self.repaintServiceList()
212+ self.repaintServiceList(item + 1 , count)
213 self.parent.OosChanged(False, self.serviceName)
214
215 def onServiceEnd(self):
216@@ -197,7 +272,7 @@
217 temp = self.serviceItems[item]
218 self.serviceItems.remove(self.serviceItems[item])
219 self.serviceItems.insert(len(self.serviceItems), temp)
220- self.repaintServiceList()
221+ self.repaintServiceList(len(self.serviceItems) - 1, count)
222 self.parent.OosChanged(False, self.serviceName)
223
224 def onNewService(self):
225@@ -216,10 +291,10 @@
226 item, count = self.findServiceItem()
227 if item is not -1:
228 self.serviceItems.remove(self.serviceItems[item])
229- self.repaintServiceList()
230+ self.repaintServiceList(0, 0)
231 self.parent.OosChanged(False, self.serviceName)
232
233- def repaintServiceList(self):
234+ def repaintServiceList(self, serviceItem, serviceItemCount):
235 """
236 Clear the existing service list and prepaint all the items
237 Used when moving items as the move takes place in supporting array,
238@@ -232,20 +307,20 @@
239 count += 1
240 #Repaint the screen
241 self.ServiceManagerList.clear()
242- for item in self.serviceItems:
243+ for itemcount, item in enumerate(self.serviceItems):
244 serviceitem = item[u'data']
245 treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
246 treewidgetitem.setText(0,serviceitem.title)
247 treewidgetitem.setIcon(0,serviceitem.iconic_representation)
248 treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order']))
249 treewidgetitem.setExpanded(item[u'expanded'])
250- count = 0
251- for frame in serviceitem.frames:
252+ for count , frame in enumerate(serviceitem.frames):
253 treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem)
254 text = frame[u'title']
255 treewidgetitem1.setText(0,text[:40])
256 treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count))
257- count = count + 1
258+ if serviceItem == itemcount and serviceItemCount == count:
259+ self.ServiceManagerList.setCurrentItem(treewidgetitem1)
260
261 def onSaveService(self):
262 """
263
264=== modified file 'openlp/plugins/songs/forms/authorsform.py'
265--- openlp/plugins/songs/forms/authorsform.py 2009-07-18 05:43:50 +0000
266+++ openlp/plugins/songs/forms/authorsform.py 2009-07-22 06:14:34 +0000
267@@ -63,6 +63,7 @@
268 else:
269 self.AuthorListWidget.setCurrentRow(self.currentRow)
270 self._validate_form()
271+ self.onAuthorListWidgetItemClicked()
272
273 def onDeleteButtonClick(self):
274 """
275@@ -100,31 +101,32 @@
276 self._validate_form()
277 self.DisplayEdit.setFocus()
278
279- def onAuthorListWidgetItemClicked(self, index):
280+ def onAuthorListWidgetItemClicked(self):
281 """
282 An Author has been selected display it
283 If the author is attached to a Song prevent delete
284 """
285 self.currentRow = self.AuthorListWidget.currentRow()
286 item = self.AuthorListWidget.currentItem()
287- item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
288- self.author = self.songmanager.get_author(item_id)
289- self.DisplayEdit.setText(self.author.display_name)
290- if self.author.first_name is None:
291- self.FirstNameEdit.setText(u'')
292- else:
293- self.FirstNameEdit.setText(self.author.first_name)
294- if self.author.last_name is None:
295- self.LastNameEdit.setText(u'')
296- else:
297- self.LastNameEdit.setText(self.author.last_name)
298- if len(self.author.songs) > 0:
299- self.MessageLabel.setText(translate(u'AuthorForm', u'Author in use "Delete" is disabled'))
300- self.DeleteButton.setEnabled(False)
301- else:
302- self.MessageLabel.setText(translate(u'AuthorForm', u'Author in not used'))
303- self.DeleteButton.setEnabled(True)
304- self._validate_form()
305+ if item is not None:
306+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
307+ self.author = self.songmanager.get_author(item_id)
308+ self.DisplayEdit.setText(self.author.display_name)
309+ if self.author.first_name is None:
310+ self.FirstNameEdit.setText(u'')
311+ else:
312+ self.FirstNameEdit.setText(self.author.first_name)
313+ if self.author.last_name is None:
314+ self.LastNameEdit.setText(u'')
315+ else:
316+ self.LastNameEdit.setText(self.author.last_name)
317+ if len(self.author.songs) > 0:
318+ self.MessageLabel.setText(translate(u'AuthorForm', u'Author in use "Delete" is disabled'))
319+ self.DeleteButton.setEnabled(False)
320+ else:
321+ self.MessageLabel.setText(translate(u'AuthorForm', u'Author in not used'))
322+ self.DeleteButton.setEnabled(True)
323+ self._validate_form()
324 self.DisplayEdit.setFocus()
325
326 def _validate_form(self):
327
328=== modified file 'openlp/plugins/songs/forms/songbookform.py'
329--- openlp/plugins/songs/forms/songbookform.py 2009-07-14 18:38:33 +0000
330+++ openlp/plugins/songs/forms/songbookform.py 2009-07-22 06:14:34 +0000
331@@ -62,6 +62,7 @@
332 self.BookSongListWidget.setCurrentRow(self.BookSongListWidget.count() - 1)
333 else:
334 self.BookSongListWidget.setCurrentRow(self.currentRow)
335+ self.onBooksListViewItemClicked()
336
337 def onDeleteButtonClick(self):
338 """
339@@ -98,24 +99,25 @@
340 self._validate_form()
341 self.NameEdit.setFocus()
342
343- def onBooksListViewItemClicked(self, index):
344+ def onBooksListViewItemClicked(self):
345 """
346 An Book has been selected display it
347 If the Book is attached to a Song prevent delete
348 """
349 self.currentRow = self.BookSongListWidget.currentRow()
350 item = self.BookSongListWidget.currentItem()
351- item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
352- self.Book = self.songmanager.get_book(item_id)
353- self.NameEdit.setText(self.Book.name)
354- self.PublisherEdit.setText(self.Book.publisher)
355- if len(self.Book.songs) > 0:
356- self.MessageLabel.setText(translate(u'BookForm', u'Book in use "Delete" is disabled'))
357- self.DeleteButton.setEnabled(False)
358- else:
359- self.MessageLabel.setText(translate(u'BookForm', u'Book in not used'))
360- self.DeleteButton.setEnabled(True)
361- self._validate_form()
362+ if item is not None:
363+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
364+ self.Book = self.songmanager.get_book(item_id)
365+ self.NameEdit.setText(self.Book.name)
366+ self.PublisherEdit.setText(self.Book.publisher)
367+ if len(self.Book.songs) > 0:
368+ self.MessageLabel.setText(translate(u'BookForm', u'Book in use "Delete" is disabled'))
369+ self.DeleteButton.setEnabled(False)
370+ else:
371+ self.MessageLabel.setText(translate(u'BookForm', u'Book in not used'))
372+ self.DeleteButton.setEnabled(True)
373+ self._validate_form()
374 self.NameEdit.setFocus()
375
376 def _validate_form(self):
377
378=== modified file 'openlp/plugins/songs/forms/topicsform.py'
379--- openlp/plugins/songs/forms/topicsform.py 2009-07-14 18:38:33 +0000
380+++ openlp/plugins/songs/forms/topicsform.py 2009-07-22 06:14:34 +0000
381@@ -63,6 +63,7 @@
382 else:
383 self.TopicsListWidget.setCurrentRow(self.currentRow)
384 self._validate_form()
385+ self.onTopicsListWidgetItemClicked()
386
387 def onDeleteButtonClick(self):
388 """
389@@ -97,23 +98,24 @@
390 self._validate_form()
391 self.TopicNameEdit.setFocus()
392
393- def onTopicsListWidgetItemClicked(self, index):
394+ def onTopicsListWidgetItemClicked(self):
395 """
396 An Topic has been selected display it
397 If the Topic is attached to a Song prevent delete
398 """
399 self.currentRow = self.TopicsListWidget.currentRow()
400 item = self.TopicsListWidget.currentItem()
401- item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
402- self.topic = self.songmanager.get_topic(item_id)
403- self.TopicNameEdit.setText(self.topic.name)
404- if len(self.topic.songs) > 0:
405- self.MessageLabel.setText(translate(u'TopicForm', u'Topic in use "Delete" is disabled'))
406- self.DeleteButton.setEnabled(False)
407- else:
408- self.MessageLabel.setText(translate(u'TopicForm', u'Topic in not used'))
409- self.DeleteButton.setEnabled(True)
410- self._validate_form()
411+ if item is not None:
412+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
413+ self.topic = self.songmanager.get_topic(item_id)
414+ self.TopicNameEdit.setText(self.topic.name)
415+ if len(self.topic.songs) > 0:
416+ self.MessageLabel.setText(translate(u'TopicForm', u'Topic in use "Delete" is disabled'))
417+ self.DeleteButton.setEnabled(False)
418+ else:
419+ self.MessageLabel.setText(translate(u'TopicForm', u'Topic in not used'))
420+ self.DeleteButton.setEnabled(True)
421+ self._validate_form()
422 self.TopicNameEdit.setFocus()
423
424 def _validate_form(self):
425
426=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
427--- openlp/plugins/songs/lib/mediaitem.py 2009-07-18 05:43:50 +0000
428+++ openlp/plugins/songs/lib/mediaitem.py 2009-07-21 18:10:14 +0000
429@@ -289,7 +289,7 @@
430 else:
431 verses = song.lyrics.split(u'\n\n')
432 for slide in verses:
433- service_item.add_from_text(slide[:30], slide)
434+ service_item.add_from_text(slide[:30], unicode(slide))
435 service_item.title = song.title
436 for author in song.authors:
437 if len(author_list) > 1: