Merge lp:~raoul-snyman/openlp/bug-1314469 into lp:openlp
- bug-1314469
- Merge into trunk
Proposed by
Raoul Snyman
Status: | Superseded |
---|---|
Proposed branch: | lp:~raoul-snyman/openlp/bug-1314469 |
Merge into: | lp:openlp |
Diff against target: |
407 lines (+117/-47) 14 files modified
openlp/core/ui/maindisplay.py (+24/-7) tests/functional/openlp_core_ui/test_maindisplay.py (+54/-19) tests/functional/openlp_core_ui/test_mainwindow.py (+3/-2) tests/functional/openlp_core_ui/test_themeform.py (+1/-1) tests/interfaces/openlp_core_common/test_historycombobox.py (+8/-1) tests/interfaces/openlp_core_lib/test_pluginmanager.py (+10/-10) tests/interfaces/openlp_core_lib/test_searchedit.py (+5/-0) tests/interfaces/openlp_core_ui/__init__.py (+6/-3) tests/interfaces/openlp_core_ui/test_projectormanager.py (+1/-1) tests/interfaces/openlp_core_ui/test_thememanager.py (+1/-1) tests/interfaces/openlp_plugins/bibles/test_lib_manager.py (+1/-0) tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py (+1/-0) tests/interfaces/openlp_plugins/custom/forms/test_customform.py (+1/-1) tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py (+1/-1) |
To merge this branch: | bzr merge lp:~raoul-snyman/openlp/bug-1314469 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenLP Core | Pending | ||
Review via email:
|
This proposal has been superseded by a proposal from 2015-01-11.
Commit message
Description of the change
[bug 1314469] Fix the border seen in the main display on KDE by not overwriting that bit of the stylesheet
To post a comment you must log in.
- 2459. By Raoul Snyman
-
HEAD
- 2460. By Raoul Snyman
-
Fix an erroneous import (probably PyCharm)
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'openlp/core/ui/maindisplay.py' |
2 | --- openlp/core/ui/maindisplay.py 2014-12-31 10:58:13 +0000 |
3 | +++ openlp/core/ui/maindisplay.py 2015-01-11 15:22:39 +0000 |
4 | @@ -38,20 +38,37 @@ |
5 | |
6 | import cgi |
7 | import logging |
8 | -import sys |
9 | |
10 | from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL |
11 | from PyQt4.phonon import Phonon |
12 | |
13 | from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, Settings, translate, is_macosx |
14 | -from openlp.core.lib import ServiceItem, ImageSource, build_html, expand_tags, image_to_byte |
15 | +from openlp.core.lib import ServiceItem, ImageSource, ScreenList, build_html, expand_tags, image_to_byte |
16 | from openlp.core.lib.theme import BackgroundType |
17 | - |
18 | -from openlp.core.lib import ScreenList |
19 | from openlp.core.ui import HideMode, AlertLocation |
20 | |
21 | log = logging.getLogger(__name__) |
22 | |
23 | +OPAQUE_STYLESHEET = """ |
24 | +QWidget { |
25 | + border: 0px; |
26 | + margin: 0px; |
27 | + padding: 0px; |
28 | +} |
29 | +QGraphicsView {} |
30 | +""" |
31 | +TRANSPARENT_STYLESHEET = """ |
32 | +QWidget { |
33 | + border: 0px; |
34 | + margin: 0px; |
35 | + padding: 0px; |
36 | +} |
37 | +QGraphicsView { |
38 | + background: transparent; |
39 | + border: 0px; |
40 | +} |
41 | +""" |
42 | + |
43 | |
44 | class Display(QtGui.QGraphicsView): |
45 | """ |
46 | @@ -135,7 +152,7 @@ |
47 | self.audio_player = None |
48 | self.first_time = True |
49 | self.web_loaded = True |
50 | - self.setStyleSheet('border: 0px; margin: 0px; padding: 0px;') |
51 | + self.setStyleSheet(OPAQUE_STYLESHEET) |
52 | window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint |
53 | if Settings().value('advanced/x11 bypass wm'): |
54 | window_flags |= QtCore.Qt.X11BypassWindowManagerHint |
55 | @@ -175,10 +192,10 @@ |
56 | """ |
57 | if enabled: |
58 | self.setAutoFillBackground(False) |
59 | - self.setStyleSheet("QGraphicsView {background: transparent; border: 0px;}") |
60 | + self.setStyleSheet(TRANSPARENT_STYLESHEET) |
61 | else: |
62 | self.setAttribute(QtCore.Qt.WA_NoSystemBackground, False) |
63 | - self.setStyleSheet("QGraphicsView {}") |
64 | + self.setStyleSheet(OPAQUE_STYLESHEET) |
65 | self.setAttribute(QtCore.Qt.WA_TranslucentBackground, enabled) |
66 | self.repaint() |
67 | |
68 | |
69 | === modified file 'tests/functional/openlp_core_ui/test_maindisplay.py' |
70 | --- tests/functional/openlp_core_ui/test_maindisplay.py 2014-12-31 10:58:13 +0000 |
71 | +++ tests/functional/openlp_core_ui/test_maindisplay.py 2015-01-11 15:22:39 +0000 |
72 | @@ -36,8 +36,10 @@ |
73 | from openlp.core.common import Registry |
74 | from openlp.core.lib import ScreenList |
75 | from openlp.core.ui import MainDisplay |
76 | +from openlp.core.ui.maindisplay import TRANSPARENT_STYLESHEET, OPAQUE_STYLESHEET |
77 | |
78 | -from tests.interfaces import MagicMock, patch |
79 | +from tests.helpers.testmixin import TestMixin |
80 | +from tests.interfaces import MagicMock |
81 | |
82 | SCREEN = { |
83 | 'primary': False, |
84 | @@ -46,7 +48,7 @@ |
85 | } |
86 | |
87 | |
88 | -class TestMainDisplay(TestCase): |
89 | +class TestMainDisplay(TestCase, TestMixin): |
90 | |
91 | def setUp(self): |
92 | """ |
93 | @@ -59,6 +61,9 @@ |
94 | self.desktop.screenGeometry.return_value = SCREEN['size'] |
95 | self.screens = ScreenList.create(self.desktop) |
96 | Registry.create() |
97 | + self.registry = Registry() |
98 | + self.setup_application() |
99 | + Registry().register('application', self.app) |
100 | |
101 | def tearDown(self): |
102 | """ |
103 | @@ -80,30 +85,60 @@ |
104 | # THEN: The controller should not be a live controller. |
105 | self.assertEqual(main_display.is_live, True, 'The main display should be a live controller') |
106 | |
107 | - def set_transparency_test(self): |
108 | - """ |
109 | - Test creating an instance of the MainDisplay class |
110 | - """ |
111 | - # GIVEN: get an instance of MainDisplay |
112 | + def set_transparency_enabled_test(self): |
113 | + """ |
114 | + Test setting the display to be transparent |
115 | + """ |
116 | + # GIVEN: An instance of MainDisplay |
117 | display = MagicMock() |
118 | main_display = MainDisplay(display) |
119 | |
120 | - # WHEN: We enable transparency |
121 | + # WHEN: Transparency is enabled |
122 | main_display.set_transparency(True) |
123 | |
124 | - # THEN: There should be a Stylesheet |
125 | - self.assertEqual('QGraphicsView {background: transparent; border: 0px;}', main_display.styleSheet(), |
126 | - 'MainDisplay instance should be transparent') |
127 | + # THEN: The transparent stylesheet should be used |
128 | + self.assertEqual(TRANSPARENT_STYLESHEET, main_display.styleSheet(), |
129 | + 'The MainDisplay should use the transparent stylesheet') |
130 | self.assertFalse(main_display.autoFillBackground(), |
131 | - 'MainDisplay instance should be without background auto fill') |
132 | + 'The MainDisplay should not have autoFillBackground set') |
133 | self.assertTrue(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground), |
134 | - 'MainDisplay hasnt translucent background') |
135 | - |
136 | - # WHEN: We disable transparency |
137 | + 'The MainDisplay should have a translucent background') |
138 | + |
139 | + def set_transparency_disabled_test(self): |
140 | + """ |
141 | + Test setting the display to be opaque |
142 | + """ |
143 | + # GIVEN: An instance of MainDisplay |
144 | + display = MagicMock() |
145 | + main_display = MainDisplay(display) |
146 | + |
147 | + # WHEN: Transparency is disabled |
148 | main_display.set_transparency(False) |
149 | |
150 | - # THEN: The Stylesheet should be empty |
151 | - self.assertEqual('QGraphicsView {}', main_display.styleSheet(), |
152 | - 'MainDisplay instance should not be transparent') |
153 | + # THEN: The opaque stylesheet should be used |
154 | + self.assertEqual(OPAQUE_STYLESHEET, main_display.styleSheet(), |
155 | + 'The MainDisplay should use the opaque stylesheet') |
156 | self.assertFalse(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground), |
157 | - 'MainDisplay hasnt translucent background') |
158 | + 'The MainDisplay should not have a translucent background') |
159 | + |
160 | + def css_changed_test(self): |
161 | + """ |
162 | + Test that when the CSS changes, the plugins are looped over and given an opportunity to update the CSS |
163 | + """ |
164 | + # GIVEN: A mocked list of plugins, a mocked display and a MainDisplay |
165 | + mocked_songs_plugin = MagicMock() |
166 | + mocked_bibles_plugin = MagicMock() |
167 | + mocked_plugin_manager = MagicMock() |
168 | + mocked_plugin_manager.plugins = [mocked_songs_plugin, mocked_bibles_plugin] |
169 | + Registry().register('plugin_manager', mocked_plugin_manager) |
170 | + display = MagicMock() |
171 | + main_display = MainDisplay(display) |
172 | + # This is set up dynamically, so we need to mock it out for now |
173 | + main_display.frame = MagicMock() |
174 | + |
175 | + # WHEN: The css_changed() method is triggered |
176 | + main_display.css_changed() |
177 | + |
178 | + # THEN: The plugins should have each been given an opportunity to add their bit to the CSS |
179 | + mocked_songs_plugin.refresh_css.assert_called_with(main_display.frame) |
180 | + mocked_bibles_plugin.refresh_css.assert_called_with(main_display.frame) |
181 | |
182 | === modified file 'tests/functional/openlp_core_ui/test_mainwindow.py' |
183 | --- tests/functional/openlp_core_ui/test_mainwindow.py 2014-12-31 10:58:13 +0000 |
184 | +++ tests/functional/openlp_core_ui/test_mainwindow.py 2015-01-11 15:22:39 +0000 |
185 | @@ -36,9 +36,10 @@ |
186 | from openlp.core.ui.mainwindow import MainWindow |
187 | from openlp.core.lib.ui import UiStrings |
188 | from openlp.core.common.registry import Registry |
189 | + |
190 | +from tests.functional import MagicMock, patch |
191 | +from tests.helpers.testmixin import TestMixin |
192 | from tests.utils.constants import TEST_RESOURCES_PATH |
193 | -from tests.helpers.testmixin import TestMixin |
194 | -from tests.functional import MagicMock, patch |
195 | |
196 | |
197 | class TestMainWindow(TestCase, TestMixin): |
198 | |
199 | === modified file 'tests/functional/openlp_core_ui/test_themeform.py' |
200 | --- tests/functional/openlp_core_ui/test_themeform.py 2015-01-09 19:51:39 +0000 |
201 | +++ tests/functional/openlp_core_ui/test_themeform.py 2015-01-11 15:22:39 +0000 |
202 | @@ -34,7 +34,7 @@ |
203 | |
204 | from openlp.core.ui import ThemeForm |
205 | |
206 | -from tests.interfaces import MagicMock, patch |
207 | +from tests.functional import MagicMock, patch |
208 | |
209 | |
210 | class TestThemeManager(TestCase): |
211 | |
212 | === modified file 'tests/interfaces/openlp_core_common/test_historycombobox.py' |
213 | --- tests/interfaces/openlp_core_common/test_historycombobox.py 2014-12-31 10:58:13 +0000 |
214 | +++ tests/interfaces/openlp_core_common/test_historycombobox.py 2015-01-11 15:22:39 +0000 |
215 | @@ -42,6 +42,9 @@ |
216 | |
217 | class TestHistoryComboBox(TestCase, TestMixin): |
218 | def setUp(self): |
219 | + """ |
220 | + Some pre-test setup required. |
221 | + """ |
222 | Registry.create() |
223 | self.setup_application() |
224 | self.main_window = QtGui.QMainWindow() |
225 | @@ -49,9 +52,13 @@ |
226 | self.combo = HistoryComboBox(self.main_window) |
227 | |
228 | def tearDown(self): |
229 | + """ |
230 | + Delete all the C++ objects at the end so that we don't have a segfault |
231 | + """ |
232 | del self.combo |
233 | + del self.main_window |
234 | |
235 | - def getItems_test(self): |
236 | + def get_items_test(self): |
237 | """ |
238 | Test the getItems() method |
239 | """ |
240 | |
241 | === modified file 'tests/interfaces/openlp_core_lib/test_pluginmanager.py' |
242 | --- tests/interfaces/openlp_core_lib/test_pluginmanager.py 2014-12-31 10:58:13 +0000 |
243 | +++ tests/interfaces/openlp_core_lib/test_pluginmanager.py 2015-01-11 15:22:39 +0000 |
244 | @@ -63,9 +63,9 @@ |
245 | Registry().register('main_window', self.main_window) |
246 | |
247 | def tearDown(self): |
248 | - del self.main_window |
249 | Settings().remove('advanced/data path') |
250 | self.destroy_settings() |
251 | + del self.main_window |
252 | # On windows we need to manually garbage collect to close sqlalchemy files |
253 | # to avoid errors when temporary files are deleted. |
254 | gc.collect() |
255 | @@ -86,12 +86,12 @@ |
256 | |
257 | # THEN: We should find the "Songs", "Bibles", etc in the plugins list |
258 | plugin_names = [plugin.name for plugin in plugin_manager.plugins] |
259 | - assert 'songs' in plugin_names, 'There should be a "songs" plugin.' |
260 | - assert 'bibles' in plugin_names, 'There should be a "bibles" plugin.' |
261 | - assert 'presentations' in plugin_names, 'There should be a "presentations" plugin.' |
262 | - assert 'images' in plugin_names, 'There should be a "images" plugin.' |
263 | - assert 'media' in plugin_names, 'There should be a "media" plugin.' |
264 | - assert 'custom' in plugin_names, 'There should be a "custom" plugin.' |
265 | - assert 'songusage' in plugin_names, 'There should be a "songusage" plugin.' |
266 | - assert 'alerts' in plugin_names, 'There should be a "alerts" plugin.' |
267 | - assert 'remotes' in plugin_names, 'There should be a "remotes" plugin.' |
268 | + self.assertIn('songs', plugin_names, 'There should be a "songs" plugin') |
269 | + self.assertIn('bibles', plugin_names, 'There should be a "bibles" plugin') |
270 | + self.assertIn('presentations', plugin_names, 'There should be a "presentations" plugin') |
271 | + self.assertIn('images', plugin_names, 'There should be a "images" plugin') |
272 | + self.assertIn('media', plugin_names, 'There should be a "media" plugin') |
273 | + self.assertIn('custom', plugin_names, 'There should be a "custom" plugin') |
274 | + self.assertIn('songusage', plugin_names, 'There should be a "songusage" plugin') |
275 | + self.assertIn('alerts', plugin_names, 'There should be a "alerts" plugin') |
276 | + self.assertIn('remotes', plugin_names, 'There should be a "remotes" plugin') |
277 | |
278 | === modified file 'tests/interfaces/openlp_core_lib/test_searchedit.py' |
279 | --- tests/interfaces/openlp_core_lib/test_searchedit.py 2014-12-31 10:58:13 +0000 |
280 | +++ tests/interfaces/openlp_core_lib/test_searchedit.py 2015-01-11 15:22:39 +0000 |
281 | @@ -35,10 +35,14 @@ |
282 | |
283 | from openlp.core.common import Registry |
284 | from openlp.core.lib.searchedit import SearchEdit |
285 | + |
286 | from tests.helpers.testmixin import TestMixin |
287 | |
288 | |
289 | class SearchTypes(object): |
290 | + """ |
291 | + Types of search |
292 | + """ |
293 | First = 0 |
294 | Second = 1 |
295 | |
296 | @@ -69,6 +73,7 @@ |
297 | """ |
298 | Delete all the C++ objects at the end so that we don't have a segfault |
299 | """ |
300 | + del self.search_edit |
301 | del self.main_window |
302 | |
303 | def set_search_types_test(self): |
304 | |
305 | === modified file 'tests/interfaces/openlp_core_ui/__init__.py' |
306 | --- tests/interfaces/openlp_core_ui/__init__.py 2014-12-31 10:58:13 +0000 |
307 | +++ tests/interfaces/openlp_core_ui/__init__.py 2015-01-11 15:22:39 +0000 |
308 | @@ -31,14 +31,17 @@ |
309 | """ |
310 | |
311 | import os |
312 | + |
313 | +from openlp.core.common import is_win |
314 | + |
315 | from tests.interfaces import patch |
316 | - |
317 | -from openlp.core.common import is_win |
318 | - |
319 | from .test_projectormanager import tmpfile |
320 | |
321 | |
322 | def setUp(): |
323 | + """ |
324 | + Set up this module of tests |
325 | + """ |
326 | if not is_win(): |
327 | # Wine creates a sharing violation during tests. Ignore. |
328 | try: |
329 | |
330 | === modified file 'tests/interfaces/openlp_core_ui/test_projectormanager.py' |
331 | --- tests/interfaces/openlp_core_ui/test_projectormanager.py 2014-12-31 10:58:13 +0000 |
332 | +++ tests/interfaces/openlp_core_ui/test_projectormanager.py 2015-01-11 15:22:39 +0000 |
333 | @@ -70,8 +70,8 @@ |
334 | Delete all the C++ objects at the end so that we don't have a segfault. |
335 | """ |
336 | self.projectordb.session.close() |
337 | + self.destroy_settings() |
338 | del self.projector_manager |
339 | - self.destroy_settings() |
340 | |
341 | def bootstrap_initialise_test(self): |
342 | """ |
343 | |
344 | === modified file 'tests/interfaces/openlp_core_ui/test_thememanager.py' |
345 | --- tests/interfaces/openlp_core_ui/test_thememanager.py 2014-12-31 10:58:13 +0000 |
346 | +++ tests/interfaces/openlp_core_ui/test_thememanager.py 2015-01-11 15:22:39 +0000 |
347 | @@ -54,8 +54,8 @@ |
348 | """ |
349 | Delete all the C++ objects at the end so that we don't have a segfault |
350 | """ |
351 | - |
352 | self.destroy_settings() |
353 | + del self.theme_manager |
354 | |
355 | def initialise_test(self): |
356 | """ |
357 | |
358 | === modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_manager.py' |
359 | --- tests/interfaces/openlp_plugins/bibles/test_lib_manager.py 2014-12-31 10:58:13 +0000 |
360 | +++ tests/interfaces/openlp_plugins/bibles/test_lib_manager.py 2015-01-11 15:22:39 +0000 |
361 | @@ -73,6 +73,7 @@ |
362 | """ |
363 | Delete all the C++ objects at the end so that we don't have a segfault |
364 | """ |
365 | + del self.manager |
366 | self.destroy_settings() |
367 | |
368 | def get_books_test(self): |
369 | |
370 | === modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py' |
371 | --- tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2014-12-31 10:58:13 +0000 |
372 | +++ tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2015-01-11 15:22:39 +0000 |
373 | @@ -73,6 +73,7 @@ |
374 | """ |
375 | Delete all the C++ objects at the end so that we don't have a segfault |
376 | """ |
377 | + del self.manager |
378 | self.destroy_settings() |
379 | |
380 | def parse_reference_one_test(self): |
381 | |
382 | === modified file 'tests/interfaces/openlp_plugins/custom/forms/test_customform.py' |
383 | --- tests/interfaces/openlp_plugins/custom/forms/test_customform.py 2014-12-31 10:58:13 +0000 |
384 | +++ tests/interfaces/openlp_plugins/custom/forms/test_customform.py 2015-01-11 15:22:39 +0000 |
385 | @@ -34,7 +34,7 @@ |
386 | from PyQt4 import QtGui, QtTest, QtCore |
387 | |
388 | from openlp.core.common import Registry |
389 | -# Import needed due to import problems. |
390 | +# TODO: FIXME: Import needed due to horrible bad imports |
391 | from openlp.plugins.custom.lib.mediaitem import CustomMediaItem |
392 | from openlp.plugins.custom.forms.editcustomform import EditCustomForm |
393 | from tests.interfaces import MagicMock, patch |
394 | |
395 | === modified file 'tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py' |
396 | --- tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py 2014-12-31 10:58:13 +0000 |
397 | +++ tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py 2015-01-11 15:22:39 +0000 |
398 | @@ -76,8 +76,8 @@ |
399 | """ |
400 | Delete all the C++ objects at the end so that we don't have a segfault |
401 | """ |
402 | + del self.form |
403 | self.vlc_patcher.stop() |
404 | - del self.form |
405 | del self.main_window |
406 | |
407 | def basic_test(self): |