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 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raoul Snyman | Approve | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Tim Bentley (trb143) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Raoul Snyman (raoul-snyman) wrote : | # |
Yay! I can see the whole Bible from here!
review:
Approve
lp:~trb143/openlp/bugfixes
updated
- 493. By Tim Bentley
-
Various bug fixes and code improvements.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'openlp/core/lib/renderer.py' |
2 | --- openlp/core/lib/renderer.py 2009-07-10 13:16:15 +0000 |
3 | +++ openlp/core/lib/renderer.py 2009-07-15 17:33:31 +0000 |
4 | @@ -151,10 +151,70 @@ |
5 | lines = verse.split(u'\n') |
6 | for line in lines: |
7 | text.append(line) |
8 | - split_text = self._split_set_of_lines(text, False) |
9 | + #print text |
10 | + split_text = self.pre_render_text(text) |
11 | +# print "-----------------------------" |
12 | +# print split_text |
13 | +# split_text = self._split_set_of_lines(text, False) |
14 | +# print "-----------------------------" |
15 | +# print split_text |
16 | log.debug(u'format_slide - End') |
17 | return split_text |
18 | |
19 | + def pre_render_text(self, text): |
20 | + metrics = QtGui.QFontMetrics(self.mainFont) |
21 | + #take the width work out approx how many characters and add 50% |
22 | + line_width = self._rect.width() - self._right_margin |
23 | + #number of lines on a page - adjust for rounding up. |
24 | + page_length = int(self._rect.height() / metrics.height()) - 1 |
25 | + ave_line_width = line_width / metrics.averageCharWidth() |
26 | + #print ave_line_width |
27 | + ave_line_width = int(ave_line_width + (ave_line_width * 0.5)) |
28 | + #print ave_line_width |
29 | + split_pages = [] |
30 | + page = [] |
31 | + split_lines = [] |
32 | + count = 0 |
33 | + for line in text: |
34 | + #print line , len(line) |
35 | + if len(line) > ave_line_width: |
36 | + while len(line) > 0: |
37 | + pos = line.find(u' ', ave_line_width) |
38 | + #print ave_line_width, pos, line[:pos] |
39 | + split_text = line[:pos] |
40 | + #print metrics.width(split_text, -1), line_width |
41 | + while metrics.width(split_text, -1) > line_width: |
42 | + #Find the next space to the left |
43 | + pos = line[:pos].rfind(u' ') |
44 | + #print ave_line_width, pos, line[:pos] |
45 | + #no more spaces found |
46 | + if pos == -1: |
47 | + split_text = line |
48 | + else: |
49 | + split_text = line[:pos] |
50 | + split_lines.append(split_text) |
51 | + line = line[pos:] |
52 | + #Text fits in a line now |
53 | + if len(line) <= ave_line_width: |
54 | + split_lines.append(line) |
55 | + line = u'' |
56 | +# count += 1 |
57 | +# if count == 50: |
58 | +# a = c |
59 | + #print split_lines |
60 | + #print line |
61 | + else: |
62 | + split_lines.append(line) |
63 | + line = u'' |
64 | + for line in split_lines: |
65 | + page.append(line) |
66 | + if len(page) == page_length: |
67 | + split_pages.append(page) |
68 | + page = [] |
69 | + if len(page) > 0: |
70 | + split_pages.append(page) |
71 | + return split_pages |
72 | + |
73 | def set_text_rectangle(self, rect_main, rect_footer): |
74 | """ |
75 | Sets the rectangle within which text should be rendered. |
76 | @@ -544,7 +604,6 @@ |
77 | painter.setPen(QtGui.QColor(color)) |
78 | x, y = tlcorner |
79 | metrics = QtGui.QFontMetrics(font) |
80 | - # xxx some fudges to make it exactly like wx! Take 'em out later |
81 | w = metrics.width(line) |
82 | h = metrics.height() - 2 |
83 | if draw: |
84 | |
85 | === modified file 'openlp/core/lib/rendermanager.py' |
86 | --- openlp/core/lib/rendermanager.py 2009-07-10 13:16:15 +0000 |
87 | +++ openlp/core/lib/rendermanager.py 2009-07-15 17:33:31 +0000 |
88 | @@ -138,12 +138,12 @@ |
89 | main_rect = None |
90 | footer_rect = None |
91 | if theme.font_main_override == False: |
92 | - main_rect = QtCore.QRect(10,0, self.width-1, self.height-1) |
93 | + main_rect = QtCore.QRect(10,0, self.width - 1, self.footer_start - 20) |
94 | else: |
95 | main_rect = QtCore.QRect(int(theme.font_main_x) , int(theme.font_main_y), |
96 | - int(theme.font_main_width)-1, int(theme.font_main_height)-1) |
97 | + int(theme.font_main_width)-1, int(theme.font_main_height) - 1) |
98 | if theme.font_footer_override == False: |
99 | - footer_rect = QtCore.QRect(10,self.footer_start, self.width-1, self.height-self.footer_start) |
100 | + footer_rect = QtCore.QRect(10,self.footer_start, self.width - 1, self.height-self.footer_start) |
101 | else: |
102 | footer_rect = QtCore.QRect(int(theme.font_footer_x),int(theme.font_footer_y), |
103 | int(theme.font_footer_width)-1, int(theme.font_footer_height)-1) |
104 | |
105 | === modified file 'openlp/core/ui/amendthemeform.py' |
106 | --- openlp/core/ui/amendthemeform.py 2009-07-06 16:34:13 +0000 |
107 | +++ openlp/core/ui/amendthemeform.py 2009-07-14 19:41:44 +0000 |
108 | @@ -71,29 +71,29 @@ |
109 | QtCore.SIGNAL(u'activated(int)'), self.onVerticalComboBoxSelected) |
110 | |
111 | QtCore.QObject.connect(self.FontMainSizeSpinBox, |
112 | - QtCore.SIGNAL(u'valueChanged(int)'), self.onFontMainSizeSpinBoxChanged) |
113 | + QtCore.SIGNAL(u'editingFinished()'), self.onFontMainSizeSpinBoxChanged) |
114 | QtCore.QObject.connect(self.FontFooterSizeSpinBox, |
115 | - QtCore.SIGNAL(u'valueChanged(int)'), self.onFontFooterSizeSpinBoxChanged) |
116 | + QtCore.SIGNAL(u'editingFinished()'), self.onFontFooterSizeSpinBoxChanged) |
117 | QtCore.QObject.connect(self.FontMainDefaultCheckBox, |
118 | QtCore.SIGNAL(u'stateChanged(int)'), self.onFontMainDefaultCheckBoxChanged) |
119 | QtCore.QObject.connect(self.FontMainXSpinBox, |
120 | - QtCore.SIGNAL(u'valueChanged(int)'), self.onFontMainXSpinBoxChanged) |
121 | + QtCore.SIGNAL(u'editingFinished()'), self.onFontMainXSpinBoxChanged) |
122 | QtCore.QObject.connect(self.FontMainYSpinBox, |
123 | - QtCore.SIGNAL(u'valueChanged(int)'), self.onFontMainYSpinBoxChanged) |
124 | + QtCore.SIGNAL(u'editingFinished()'), self.onFontMainYSpinBoxChanged) |
125 | QtCore.QObject.connect(self.FontMainWidthSpinBox, |
126 | - QtCore.SIGNAL(u'valueChanged(int)'), self.onFontMainWidthSpinBoxChanged) |
127 | + QtCore.SIGNAL(u'editingFinished()'), self.onFontMainWidthSpinBoxChanged) |
128 | QtCore.QObject.connect(self.FontMainHeightSpinBox, |
129 | - QtCore.SIGNAL(u'valueChanged(int)'), self.onFontMainHeightSpinBoxChanged) |
130 | + QtCore.SIGNAL(u'editingFinished()'), self.onFontMainHeightSpinBoxChanged) |
131 | QtCore.QObject.connect(self.FontFooterDefaultCheckBox, |
132 | QtCore.SIGNAL(u'stateChanged(int)'), self.onFontFooterDefaultCheckBoxChanged) |
133 | QtCore.QObject.connect(self.FontFooterXSpinBox, |
134 | - QtCore.SIGNAL(u'valueChanged(int)'), self.onFontFooterXSpinBoxChanged) |
135 | + QtCore.SIGNAL(u'editingFinished()'), self.onFontFooterXSpinBoxChanged) |
136 | QtCore.QObject.connect(self.FontFooterYSpinBox, |
137 | - QtCore.SIGNAL(u'valueChanged(int)'), self.onFontFooterYSpinBoxChanged) |
138 | + QtCore.SIGNAL(u'editingFinished()'), self.onFontFooterYSpinBoxChanged) |
139 | QtCore.QObject.connect(self.FontFooterWidthSpinBox, |
140 | - QtCore.SIGNAL(u'valueChanged(int)'), self.onFontFooterWidthSpinBoxChanged) |
141 | + QtCore.SIGNAL(u'editingFinished()'), self.onFontFooterWidthSpinBoxChanged) |
142 | QtCore.QObject.connect(self.FontFooterHeightSpinBox, |
143 | - QtCore.SIGNAL(u'valueChanged(int)'), self.onFontFooterHeightSpinBoxChanged) |
144 | + QtCore.SIGNAL(u'editingFinished()'), self.onFontFooterHeightSpinBoxChanged) |
145 | QtCore.QObject.connect(self.OutlineCheckBox, |
146 | QtCore.SIGNAL(u'stateChanged(int)'), self.onOutlineCheckBoxChanged) |
147 | QtCore.QObject.connect(self.ShadowCheckBox, |
148 | @@ -167,9 +167,10 @@ |
149 | u'background-color: %s' % unicode(self.theme.font_main_color)) |
150 | self.previewTheme(self.theme) |
151 | |
152 | - def onFontMainSizeSpinBoxChanged(self, value): |
153 | - self.theme.font_main_proportion = value |
154 | - self.previewTheme(self.theme) |
155 | + def onFontMainSizeSpinBoxChanged(self): |
156 | + if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value(): |
157 | + self.theme.font_main_proportion = self.FontMainSizeSpinBox.value() |
158 | + self.previewTheme(self.theme) |
159 | |
160 | def onFontMainDefaultCheckBoxChanged(self, value): |
161 | if value == 2: # checked |
162 | @@ -190,21 +191,25 @@ |
163 | self.stateChanging(self.theme) |
164 | self.previewTheme(self.theme) |
165 | |
166 | - def onFontMainXSpinBoxChanged(self, value): |
167 | - self.theme.font_main_x = value |
168 | - self.previewTheme(self.theme) |
169 | - |
170 | - def onFontMainYSpinBoxChanged(self, value): |
171 | - self.theme.font_main_y = value |
172 | - self.previewTheme(self.theme) |
173 | - |
174 | - def onFontMainWidthSpinBoxChanged(self, value): |
175 | - self.theme.font_main_width = value |
176 | - self.previewTheme(self.theme) |
177 | - |
178 | - def onFontMainHeightSpinBoxChanged(self, value): |
179 | - self.theme.font_main_height = value |
180 | - self.previewTheme(self.theme) |
181 | + def onFontMainXSpinBoxChanged(self): |
182 | + if self.theme.font_main_x != self.FontMainXSpinBox.value(): |
183 | + self.theme.font_main_x = self.FontMainXSpinBox.value() |
184 | + self.previewTheme(self.theme) |
185 | + |
186 | + def onFontMainYSpinBoxChanged(self): |
187 | + if self.theme.font_main_y != self.FontMainYSpinBox.value(): |
188 | + self.theme.font_main_y = self.FontMainYSpinBox.value() |
189 | + self.previewTheme(self.theme) |
190 | + |
191 | + def onFontMainWidthSpinBoxChanged(self): |
192 | + if self.theme.font_main_width != self.FontMainWidthSpinBox.value(): |
193 | + self.theme.font_main_width = self.FontMainWidthSpinBox.value() |
194 | + self.previewTheme(self.theme) |
195 | + |
196 | + def onFontMainHeightSpinBoxChanged(self): |
197 | + if self.theme.font_main_height != self.FontMainHeightSpinBox.value(): |
198 | + self.theme.font_main_height = self.FontMainHeightSpinBox.value() |
199 | + self.previewTheme(self.theme) |
200 | # |
201 | #Footer Font Tab |
202 | # |
203 | @@ -220,9 +225,10 @@ |
204 | 'background-color: %s' % unicode(self.theme.font_footer_color)) |
205 | self.previewTheme(self.theme) |
206 | |
207 | - def onFontFooterSizeSpinBoxChanged(self, value): |
208 | - self.theme.font_footer_proportion = value |
209 | - self.previewTheme(self.theme) |
210 | + def onFontFooterSizeSpinBoxChanged(self): |
211 | + if self.theme.font_footer_proportion != self.FontFooterSizeSpinBox.value(): |
212 | + self.theme.font_footer_proportion = self.FontFooterSizeSpinBox.value() |
213 | + self.previewTheme(self.theme) |
214 | |
215 | def onFontFooterDefaultCheckBoxChanged(self, value): |
216 | if value == 2: # checked |
217 | @@ -245,22 +251,25 @@ |
218 | self.stateChanging(self.theme) |
219 | self.previewTheme(self.theme) |
220 | |
221 | - def onFontFooterXSpinBoxChanged(self, value): |
222 | - self.theme.font_footer_x = value |
223 | - self.previewTheme(self.theme) |
224 | - |
225 | - def onFontFooterYSpinBoxChanged(self, value): |
226 | - self.theme.font_footer_y = value |
227 | - self.previewTheme(self.theme) |
228 | - |
229 | - def onFontFooterWidthSpinBoxChanged(self, value): |
230 | - self.theme.font_footer_width = value |
231 | - self.previewTheme(self.theme) |
232 | - |
233 | - def onFontFooterHeightSpinBoxChanged(self, value): |
234 | - self.theme.font_footer_height = value |
235 | - self.previewTheme(self.theme) |
236 | - |
237 | + def onFontFooterXSpinBoxChanged(self): |
238 | + if self.theme.font_footer_x != self.FontFooterXSpinBox.value(): |
239 | + self.theme.font_footer_x = self.FontFooterXSpinBox.value() |
240 | + self.previewTheme(self.theme) |
241 | + |
242 | + def onFontFooterYSpinBoxChanged(self): |
243 | + if self.theme.font_footer_y != self.FontFooterYSpinBox.value(): |
244 | + self.theme.font_footer_y = self.FontFooterYSpinBox.value() |
245 | + self.previewTheme(self.theme) |
246 | + |
247 | + def onFontFooterWidthSpinBoxChanged(self): |
248 | + if self.theme.font_footer_width != self.FontFooterWidthSpinBox.value(): |
249 | + self.theme.font_footer_width = self.FontFooterWidthSpinBox.value() |
250 | + self.previewTheme(self.theme) |
251 | + |
252 | + def onFontFooterHeightSpinBoxChanged(self): |
253 | + if self.theme.font_footer_height != self.FontFooterHeightSpinBox.value(): |
254 | + self.theme.font_footer_height = self.FontFooterHeightSpinBox.value() |
255 | + self.previewTheme(self.theme) |
256 | # |
257 | #Background Tab |
258 | # |
259 | |
260 | === modified file 'openlp/migration/migratesongs.py' |
261 | --- openlp/migration/migratesongs.py 2009-06-24 06:11:04 +0000 |
262 | +++ openlp/migration/migratesongs.py 2009-07-14 18:38:33 +0000 |
263 | @@ -154,6 +154,8 @@ |
264 | author = Author() |
265 | authors_temp = self.session.query(TAuthor).get(a) |
266 | author.display_name = authors_temp.authorname |
267 | + author.first_name = u'' |
268 | + author.last_name = u'' |
269 | song.authors.append(author) |
270 | try: |
271 | self.session.add(song) |
272 | |
273 | === modified file 'openlp/plugins/songs/forms/authorsform.py' |
274 | --- openlp/plugins/songs/forms/authorsform.py 2009-06-14 15:12:40 +0000 |
275 | +++ openlp/plugins/songs/forms/authorsform.py 2009-07-14 18:38:33 +0000 |
276 | @@ -97,6 +97,7 @@ |
277 | self.DeleteButton.setEnabled(False) |
278 | self.author = None |
279 | self._validate_form() |
280 | + self.DisplayEdit.setFocus() |
281 | |
282 | def onAuthorListWidgetItemClicked(self, index): |
283 | """ |
284 | @@ -108,8 +109,14 @@ |
285 | item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] |
286 | self.author = self.songmanager.get_author(item_id) |
287 | self.DisplayEdit.setText(self.author.display_name) |
288 | - self.FirstNameEdit.setText(self.author.first_name) |
289 | - self.LastNameEdit.setText(self.author.last_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 | @@ -117,6 +124,7 @@ |
302 | self.MessageLabel.setText(translate(u'AuthorForm', u'Author in not used')) |
303 | self.DeleteButton.setEnabled(True) |
304 | self._validate_form() |
305 | + self.DisplayEdit.setFocus() |
306 | |
307 | def _validate_form(self): |
308 | # We need at lease a display name |
309 | |
310 | === modified file 'openlp/plugins/songs/forms/songbookform.py' |
311 | --- openlp/plugins/songs/forms/songbookform.py 2009-06-14 15:12:40 +0000 |
312 | +++ openlp/plugins/songs/forms/songbookform.py 2009-07-14 18:38:33 +0000 |
313 | @@ -96,6 +96,7 @@ |
314 | self.AddUpdateButton.setEnabled(True) |
315 | self.Book = None |
316 | self._validate_form() |
317 | + self.NameEdit.setFocus() |
318 | |
319 | def onBooksListViewItemClicked(self, index): |
320 | """ |
321 | @@ -115,6 +116,7 @@ |
322 | self.MessageLabel.setText(translate(u'BookForm', u'Book in not used')) |
323 | self.DeleteButton.setEnabled(True) |
324 | self._validate_form() |
325 | + self.NameEdit.setFocus() |
326 | |
327 | def _validate_form(self): |
328 | # We need at lease a display name |
329 | |
330 | === modified file 'openlp/plugins/songs/forms/topicsform.py' |
331 | --- openlp/plugins/songs/forms/topicsform.py 2009-06-24 06:15:04 +0000 |
332 | +++ openlp/plugins/songs/forms/topicsform.py 2009-07-14 18:38:33 +0000 |
333 | @@ -95,6 +95,7 @@ |
334 | self.DeleteButton.setEnabled(False) |
335 | self.topic = None |
336 | self._validate_form() |
337 | + self.TopicNameEdit.setFocus() |
338 | |
339 | def onTopicsListWidgetItemClicked(self, index): |
340 | """ |
341 | @@ -113,6 +114,7 @@ |
342 | self.MessageLabel.setText(translate(u'TopicForm', u'Topic in not used')) |
343 | self.DeleteButton.setEnabled(True) |
344 | self._validate_form() |
345 | + self.TopicNameEdit.setFocus() |
346 | |
347 | def _validate_form(self): |
348 | # We need at lease a display name |
Fix bugs in ThemeManager where changing a spin box generates too many events.
Start to fix the renderer so Raoul can display the whole bible!
Fix bug in rendermanager where footer was forgotten.