Merge lp:~tomasgroth/openlp/23bugfixes into lp:openlp

Proposed by Tomas Groth on 2016-01-23
Status: Merged
Approved by: Tomas Groth on 2016-01-24
Approved revision: 2618
Merged at revision: 2610
Proposed branch: lp:~tomasgroth/openlp/23bugfixes
Merge into: lp:openlp
Diff against target: 291 lines (+96/-24)
9 files modified
openlp/core/common/uistrings.py (+2/-2)
openlp/core/lib/renderer.py (+3/-3)
openlp/core/ui/maindisplay.py (+9/-7)
openlp/core/ui/slidecontroller.py (+5/-2)
openlp/plugins/songs/forms/editsongform.py (+2/-0)
openlp/plugins/songs/lib/importers/opensong.py (+1/-0)
tests/functional/openlp_core_lib/test_renderer.py (+16/-10)
tests/functional/openlp_plugins/songs/test_opensongimport.py (+2/-0)
tests/resources/opensongsongs/Amazing Grace2 (+56/-0)
To merge this branch: bzr merge lp:~tomasgroth/openlp/23bugfixes
Reviewer Review Type Date Requested Status
Tomas Groth Approve on 2016-01-24
Tim Bentley 2016-01-23 Approve on 2016-01-23
Review via email: mp+283716@code.launchpad.net

Description of the change

Fix traceback where OpenSong importer crashed if non-numbers were in the CCLI field.
Fix some broken tests that was not being used due to naming.
When setting the verseorder to uppercase, remember the cursor position. Fixes bug 1536411.
Disable OpenGL on linux (too). Fixes bug 1535332.
Disable OpenGL on windows to make webkit player work.
Made workaround for windows display not updating, and disabled OpenGL on Windows, fixes bug 1531319.
Fix playback of linked audio. Fixes bug 1533280.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/common/uistrings.py'
2--- openlp/core/common/uistrings.py 2015-12-31 22:46:06 +0000
3+++ openlp/core/common/uistrings.py 2016-01-23 12:46:09 +0000
4@@ -122,8 +122,8 @@
5 self.Projectors = translate('OpenLP.Ui', 'Projectors', 'Plural')
6 self.ReplaceBG = translate('OpenLP.Ui', 'Replace Background')
7 self.ReplaceLiveBG = translate('OpenLP.Ui', 'Replace live background.')
8- self.ReplaceLiveBGDisabled = translate('OpenLP.Ui', 'Replace live background is not available on this '
9- 'platform in this version of OpenLP.')
10+ self.ReplaceLiveBGDisabled = translate('OpenLP.Ui', 'Replace live background is not available when the WebKit '
11+ 'player is disabled.')
12 self.ResetBG = translate('OpenLP.Ui', 'Reset Background')
13 self.ResetLiveBG = translate('OpenLP.Ui', 'Reset live background.')
14 self.Seconds = translate('OpenLP.Ui', 's', 'The abbreviated unit for seconds')
15
16=== modified file 'openlp/core/lib/renderer.py'
17--- openlp/core/lib/renderer.py 2016-01-09 16:26:14 +0000
18+++ openlp/core/lib/renderer.py 2016-01-23 12:46:09 +0000
19@@ -20,6 +20,7 @@
20 # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21 ###############################################################################
22
23+import re
24
25 from PyQt5 import QtGui, QtCore, QtWebKitWidgets
26
27@@ -441,7 +442,7 @@
28 previous_raw = line + line_end
29 continue
30 # Figure out how many words of the line will fit on screen as the line will not fit as a whole.
31- raw_words = Renderer.words_split(line)
32+ raw_words = words_split(line)
33 html_words = list(map(expand_tags, raw_words))
34 previous_html, previous_raw = \
35 self._binary_chop(formatted, previous_html, previous_raw, html_words, raw_words, ' ', line_end)
36@@ -528,8 +529,7 @@
37 :param line: Line to be split
38 """
39 # this parse we are to be wordy
40- line = line.replace('\n', ' ')
41- return line.split(' ')
42+ return re.split('\s+', line)
43
44
45 def get_start_tags(raw_text):
46
47=== modified file 'openlp/core/ui/maindisplay.py'
48--- openlp/core/ui/maindisplay.py 2016-01-08 21:43:43 +0000
49+++ openlp/core/ui/maindisplay.py 2016-01-23 12:46:09 +0000
50@@ -86,12 +86,6 @@
51 super(Display, self).__init__()
52 self.controller = parent
53 self.screen = {}
54- # FIXME: On Mac OS X (tested on 10.7) the display screen is corrupt with
55- # OpenGL. Only white blank screen is shown on the 2nd monitor all the
56- # time. We need to investigate more how to use OpenGL properly on Mac OS
57- # X.
58- if not is_macosx() and not is_win():
59- self.setViewport(QtOpenGL.QGLWidget())
60
61 def setup(self):
62 """
63@@ -559,6 +553,13 @@
64 if window_id == main_window_id:
65 self.main_window.raise_()
66
67+ def shake_web_view(self):
68+ """
69+ Resizes the web_view a bit to force an update. Workaround for bug #1531319, should not be needed with PyQt 5.6.
70+ """
71+ self.web_view.setGeometry(0, 0, self.width(), self.height() - 1)
72+ self.web_view.setGeometry(0, 0, self.width(), self.height())
73+
74
75 class AudioPlayer(OpenLPMixin, QtCore.QObject):
76 """
77@@ -576,6 +577,7 @@
78 self.player = QtMultimedia.QMediaPlayer()
79 self.playlist = QtMultimedia.QMediaPlaylist(self.player)
80 self.volume_slider = None
81+ self.player.setPlaylist(self.playlist)
82 self.player.positionChanged.connect(self._on_position_changed)
83
84 def __del__(self):
85@@ -643,7 +645,7 @@
86 if not isinstance(file_names, list):
87 file_names = [file_names]
88 for file_name in file_names:
89- self.playlist.addMedia(QtCore.QUrl(file_name))
90+ self.playlist.addMedia(QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(file_name)))
91
92 def next(self):
93 """
94
95=== modified file 'openlp/core/ui/slidecontroller.py'
96--- openlp/core/ui/slidecontroller.py 2016-01-13 21:00:46 +0000
97+++ openlp/core/ui/slidecontroller.py 2016-01-23 12:46:09 +0000
98@@ -31,7 +31,7 @@
99 from PyQt5 import QtCore, QtGui, QtWidgets
100
101 from openlp.core.common import Registry, RegistryProperties, Settings, SlideLimits, UiStrings, translate, \
102- RegistryMixin, OpenLPMixin
103+ RegistryMixin, OpenLPMixin, is_win
104 from openlp.core.lib import OpenLPToolbar, ItemCapabilities, ServiceItem, ImageSource, ServiceItemAction, \
105 ScreenList, build_icon, build_html
106 from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
107@@ -1101,6 +1101,9 @@
108 self.display.image(to_display)
109 # reset the store used to display first image
110 self.service_item.bg_image_bytes = None
111+ # Workaround for bug #1531319, should not be needed with PyQt 5.6.
112+ if self.is_live and is_win():
113+ self.display.shake_web_view()
114 self.selected_row = row
115 self.update_preview()
116 self.preview_widget.change_slide(row)
117@@ -1421,7 +1424,7 @@
118
119 :param time: the time remaining
120 """
121- seconds = self.display.audio_player.media_object.remainingTime() // 1000
122+ seconds = (self.display.audio_player.player.duration() - self.display.audio_player.player.position()) // 1000
123 minutes = seconds // 60
124 seconds %= 60
125 self.audio_time_label.setText(' %02d:%02d ' % (minutes, seconds))
126
127=== modified file 'openlp/plugins/songs/forms/editsongform.py'
128--- openlp/plugins/songs/forms/editsongform.py 2016-01-15 20:37:53 +0000
129+++ openlp/plugins/songs/forms/editsongform.py 2016-01-23 12:46:09 +0000
130@@ -843,7 +843,9 @@
131 :param text: The text of the verse order edit (ignored).
132 """
133 # First make sure that all letters entered in the verse order field are uppercase
134+ pos = self.verse_order_edit.cursorPosition()
135 self.verse_order_edit.setText(text.upper())
136+ self.verse_order_edit.setCursorPosition(pos)
137 # Extract all verses which were used in the order.
138 verses_in_order = self._extract_verse_order(self.verse_order_edit.text())
139 # Find the verses which were not used in the order.
140
141=== modified file 'openlp/plugins/songs/lib/importers/opensong.py'
142--- openlp/plugins/songs/lib/importers/opensong.py 2015-12-31 22:46:06 +0000
143+++ openlp/plugins/songs/lib/importers/opensong.py 2016-01-23 12:46:09 +0000
144@@ -157,6 +157,7 @@
145 if isinstance(fn_or_string, str):
146 if attr in ['ccli']:
147 if ustring:
148+ ustring = ''.join(re.findall('\d+', ustring))
149 setattr(self, fn_or_string, int(ustring))
150 else:
151 setattr(self, fn_or_string, None)
152
153=== modified file 'tests/functional/openlp_core_lib/test_renderer.py'
154--- tests/functional/openlp_core_lib/test_renderer.py 2015-12-31 22:46:06 +0000
155+++ tests/functional/openlp_core_lib/test_renderer.py 2016-01-23 12:46:09 +0000
156@@ -27,9 +27,10 @@
157 from PyQt5 import QtCore
158
159 from openlp.core.common import Registry
160-from openlp.core.lib import Renderer, ScreenList, ServiceItem
161+from openlp.core.lib import Renderer, ScreenList, ServiceItem, FormattingTags
162+from openlp.core.lib.renderer import words_split, get_start_tags
163
164-from tests.functional import MagicMock
165+from tests.functional import MagicMock, patch
166
167 SCREEN = {
168 'primary': False,
169@@ -71,34 +72,39 @@
170 self.assertEqual(renderer.screen_ratio, 0.75, 'The base renderer should be a live controller')
171 self.assertEqual(renderer.footer_start, 691, 'The base renderer should be a live controller')
172
173- def _get_start_tags_test(self):
174+ @patch('openlp.core.lib.renderer.FormattingTags.get_html_tags')
175+ def get_start_tags_test(self, mocked_get_html_tags):
176 """
177- Test the _get_start_tags() method
178+ Test the get_start_tags() method
179 """
180 # GIVEN: A new renderer instance. Broken raw_text (missing closing tags).
181- renderer = Renderer()
182 given_raw_text = '{st}{r}Text text text'
183 expected_tuple = ('{st}{r}Text text text{/r}{/st}', '{st}{r}',
184 '<strong><span style="-webkit-text-fill-color:red">')
185+ mocked_get_html_tags.return_value = [{'temporary': False, 'end tag': '{/r}', 'desc': 'Red',
186+ 'start html': '<span style="-webkit-text-fill-color:red">',
187+ 'end html': '</span>', 'start tag': '{r}', 'protected': True},
188+ {'temporary': False, 'end tag': '{/st}', 'desc': 'Bold',
189+ 'start html': '<strong>', 'end html': '</strong>', 'start tag': '{st}',
190+ 'protected': True}]
191
192 # WHEN: The renderer converts the start tags
193- result = renderer._get_start_tags(given_raw_text)
194+ result = get_start_tags(given_raw_text)
195
196 # THEN: Check if the correct tuple is returned.
197 self.assertEqual(result, expected_tuple), 'A tuple should be returned containing the text with correct ' \
198 'tags, the opening tags, and the opening html tags.'
199
200- def _word_split_test(self):
201+ def word_split_test(self):
202 """
203- Test the _word_split() method
204+ Test the word_split() method
205 """
206 # GIVEN: A line of text
207- renderer = Renderer()
208 given_line = 'beginning asdf \n end asdf'
209 expected_words = ['beginning', 'asdf', 'end', 'asdf']
210
211 # WHEN: Split the line based on word split rules
212- result_words = renderer._words_split(given_line)
213+ result_words = words_split(given_line)
214
215 # THEN: The word lists should be the same.
216 self.assertListEqual(result_words, expected_words)
217
218=== modified file 'tests/functional/openlp_plugins/songs/test_opensongimport.py'
219--- tests/functional/openlp_plugins/songs/test_opensongimport.py 2015-12-31 22:46:06 +0000
220+++ tests/functional/openlp_plugins/songs/test_opensongimport.py 2016-01-23 12:46:09 +0000
221@@ -52,6 +52,8 @@
222 self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json')))
223 self.file_import([os.path.join(TEST_PATH, 'One, Two, Three, Four, Five')],
224 self.load_external_result_data(os.path.join(TEST_PATH, 'One, Two, Three, Four, Five.json')))
225+ self.file_import([os.path.join(TEST_PATH, 'Amazing Grace2')],
226+ self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
227
228
229 class TestOpenSongImport(TestCase):
230
231=== added file 'tests/resources/opensongsongs/Amazing Grace2'
232--- tests/resources/opensongsongs/Amazing Grace2 1970-01-01 00:00:00 +0000
233+++ tests/resources/opensongsongs/Amazing Grace2 2016-01-23 12:46:09 +0000
234@@ -0,0 +1,56 @@
235+<?xml version="1.0" encoding="UTF-8"?>
236+<song>
237+ <title>Amazing Grace (Demonstration)</title>
238+ <author>John Newton, Edwin Excell &amp; John P. Rees</author>
239+ <copyright>Public Domain </copyright>
240+ <presentation>V1 V2 V3 V4 V5</presentation>
241+ <capo print="false"></capo>
242+ <tempo></tempo>
243+ <ccli>CC: 22025 number</ccli>
244+ <theme>God: Assurance/Grace/Salvation</theme>
245+ <alttheme>Worship: Praise</alttheme>
246+ <user1> </user1>
247+ <user2> </user2>
248+ <user3> </user3>
249+ <lyrics>[V]
250+;Test the chords format
251+;Chords beging with .
252+;Verses begin with their verse number
253+;Link words with _
254+;Comments begin with ;
255+. D D7 G D
256+1A______ma________zing grace! How sweet the sound!
257+2'Twas grace that taught my heart to fear,
258+3The Lord has pro____mised good to me,
259+4Thro' ma________ny dan____gers, toils and snares
260+5When we've been there ten thou__sand years,
261+
262+. Bm E A A7
263+1That saved a wretch like me!
264+2And grace my fears re___lieved.
265+3His Word my hope se___cures.
266+4I have al___rea____dy come.
267+5Bright shi___ning as the sun,
268+
269+. D D7 G D
270+1I once was lost, but now am found;
271+2How pre___cious did that grace ap____pear,
272+3He will my shield and por___tion be
273+4'Tis grace that brought me safe thus far,
274+5We've no less days to sing God's praise,
275+
276+. Bm A G D
277+1Was blind, but now I see.
278+2The hour I first be_lieved.
279+3As long as life en_dures.
280+4And grace will lead me home.
281+5Than when we first be_gun.
282+
283+</lyrics>
284+ <hymn_number>Demonstration Songs 0</hymn_number>
285+ <key></key>
286+ <aka></aka>
287+ <key_line></key_line>
288+ <time_sig></time_sig>
289+ <style index="default_style"></style>
290+</song>
291\ No newline at end of file