Merge lp:~raoul-snyman/openlp/mac-niggles into lp:openlp

Proposed by Raoul Snyman on 2016-12-15
Status: Merged
Merged at revision: 2711
Proposed branch: lp:~raoul-snyman/openlp/mac-niggles
Merge into: lp:openlp
Diff against target: 272 lines (+95/-22)
6 files modified
openlp/core/__init__.py (+17/-5)
openlp/core/common/settings.py (+3/-3)
openlp/core/ui/mainwindow.py (+8/-11)
openlp/core/ui/themewizard.py (+1/-1)
tests/functional/openlp_core_ui/test_shortcutlistdialog.py (+60/-0)
tests/functional/test_init.py (+6/-2)
To merge this branch: bzr merge lp:~raoul-snyman/openlp/mac-niggles
Reviewer Review Type Date Requested Status
Tim Bentley 2016-12-15 Approve on 2016-12-16
Review via email: mp+313403@code.launchpad.net

Description of the change

Fix segfault on click on a spinner on macOS
Fix spurious traceback on some platforms or configurations of media players
Make the tab style affect only the media library tabs, not everything else too
Hide the splash screen when the backup dialog shows and when the exception form shows

Add this to your merge proposal:
--------------------------------
lp:~raoul-snyman/openlp/mac-niggles (revision 2713)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1873/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1784/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1723/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1462/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/1052/
[SUCCESS] https://ci.openlp.io/job/Branch-05a-Code_Analysis/1120/
[SUCCESS] https://ci.openlp.io/job/Branch-05b-Test_Coverage/988/
[SUCCESS] https://ci.openlp.io/job/Branch-05c-Code_Analysis2/139/

To post a comment you must log in.
Tim Bentley (trb143) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/__init__.py'
2--- openlp/core/__init__.py 2016-11-21 20:21:31 +0000
3+++ openlp/core/__init__.py 2016-12-15 22:20:16 +0000
4@@ -129,21 +129,21 @@
5 application_stylesheet += WIN_REPAIR_STYLESHEET
6 if application_stylesheet:
7 self.setStyleSheet(application_stylesheet)
8- show_splash = Settings().value('core/show splash')
9- if show_splash:
10+ can_show_splash = Settings().value('core/show splash')
11+ if can_show_splash:
12 self.splash = SplashScreen()
13 self.splash.show()
14 # make sure Qt really display the splash screen
15 self.processEvents()
16 # Check if OpenLP has been upgrade and if a backup of data should be created
17- self.backup_on_upgrade(has_run_wizard)
18+ self.backup_on_upgrade(has_run_wizard, can_show_splash)
19 # start the main app window
20 self.main_window = MainWindow()
21 Registry().execute('bootstrap_initialise')
22 Registry().execute('bootstrap_post_set_up')
23 Registry().initialise = False
24 self.main_window.show()
25- if show_splash:
26+ if can_show_splash:
27 # now kill the splashscreen
28 self.splash.finish(self.main_window)
29 log.debug('Splashscreen closed')
30@@ -224,13 +224,20 @@
31 self.exception_form = ExceptionForm()
32 self.exception_form.exception_text_edit.setPlainText(''.join(format_exception(exc_type, value, traceback)))
33 self.set_normal_cursor()
34+ is_splash_visible = False
35+ if hasattr(self, 'splash') and self.splash.isVisible():
36+ is_splash_visible = True
37+ self.splash.hide()
38 self.exception_form.exec()
39+ if is_splash_visible:
40+ self.splash.show()
41
42- def backup_on_upgrade(self, has_run_wizard):
43+ def backup_on_upgrade(self, has_run_wizard, can_show_splash):
44 """
45 Check if OpenLP has been upgraded, and ask if a backup of data should be made
46
47 :param has_run_wizard: OpenLP has been run before
48+ :param can_show_splash: Should OpenLP show the splash screen
49 """
50 data_version = Settings().value('core/application version')
51 openlp_version = get_application_version()['version']
52@@ -239,6 +246,8 @@
53 Settings().setValue('core/application version', openlp_version)
54 # If data_version is different from the current version ask if we should backup the data folder
55 elif data_version != openlp_version:
56+ if self.splash.isVisible():
57+ self.splash.hide()
58 if QtWidgets.QMessageBox.question(None, translate('OpenLP', 'Backup'),
59 translate('OpenLP', 'OpenLP has been upgraded, do you want to create\n'
60 'a backup of the old data folder?'),
61@@ -261,6 +270,8 @@
62
63 # Update the version in the settings
64 Settings().setValue('core/application version', openlp_version)
65+ if can_show_splash:
66+ self.splash.show()
67
68 def process_events(self):
69 """
70@@ -375,6 +386,7 @@
71 application.setOrganizationName('OpenLP')
72 application.setOrganizationDomain('openlp.org')
73 application.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
74+ application.setAttribute(QtCore.Qt.AA_DontCreateNativeWidgetSiblings, True)
75 if args and args.portable:
76 application.setApplicationName('OpenLPPortable')
77 Settings.setDefaultFormat(Settings.IniFormat)
78
79=== modified file 'openlp/core/common/settings.py'
80--- openlp/core/common/settings.py 2016-10-23 19:24:53 +0000
81+++ openlp/core/common/settings.py 2016-12-15 22:20:16 +0000
82@@ -216,8 +216,8 @@
83 ('advanced/default color', 'core/logo background color', []), # Default image renamed + moved to general > 2.4.
84 ('advanced/default image', 'core/logo file', []), # Default image renamed + moved to general after 2.4.
85 ('shortcuts/escapeItem', 'shortcuts/desktopScreenEnable', []), # Escape item was removed in 2.6.
86- ('shortcuts/offlineHelpItem', 'shortcuts/HelpItem', []), # Online and Offline help were combined in 2.6.
87- ('shortcuts/onlineHelpItem', 'shortcuts/HelpItem', []) # Online and Offline help were combined in 2.6.
88+ ('shortcuts/offlineHelpItem', 'shortcuts/userManualItem', []), # Online and Offline help were combined in 2.6.
89+ ('shortcuts/onlineHelpItem', 'shortcuts/userManualItem', []) # Online and Offline help were combined in 2.6.
90 ]
91
92 @staticmethod
93@@ -276,7 +276,7 @@
94 'shortcuts/fileSaveItem': [QtGui.QKeySequence(QtGui.QKeySequence.Save)],
95 'shortcuts/fileOpenItem': [QtGui.QKeySequence(QtGui.QKeySequence.Open)],
96 'shortcuts/goLive': [],
97- 'shortcuts/HelpItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents)],
98+ 'shortcuts/userManualItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents)],
99 'shortcuts/importThemeItem': [],
100 'shortcuts/importBibleItem': [],
101 'shortcuts/listViewBiblesDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete)],
102
103=== modified file 'openlp/core/ui/mainwindow.py'
104--- openlp/core/ui/mainwindow.py 2016-12-13 06:41:59 +0000
105+++ openlp/core/ui/mainwindow.py 2016-12-15 22:20:16 +0000
106@@ -52,7 +52,7 @@
107 log = logging.getLogger(__name__)
108
109 MEDIA_MANAGER_STYLE = """
110-::tab {
111+::tab#media_tool_box {
112 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
113 stop: 0 palette(button), stop: 1.0 palette(mid));
114 border: 0;
115@@ -61,10 +61,8 @@
116 margin-bottom: 0;
117 text-align: left;
118 }
119-::tab:selected {
120- border: 1px solid palette(highlight);
121- font-weight: bold;
122-}
123+/* This is here to make the tabs on KDE with the Breeze theme work */
124+::tab:selected {}
125 """
126
127 PROGRESSBAR_STYLE = """
128@@ -310,10 +308,9 @@
129 elif is_macosx():
130 self.local_help_file = os.path.join(AppLocation.get_directory(AppLocation.AppDir),
131 '..', 'Resources', 'OpenLP.help')
132- self.on_help_item = create_action(main_window, 'HelpItem',
133- icon=':/system/system_help_contents.png',
134- can_shortcuts=True,
135- category=UiStrings().Help, triggers=self.on_help_clicked)
136+ self.user_manual_item = create_action(main_window, 'userManualItem', icon=':/system/system_help_contents.png',
137+ can_shortcuts=True, category=UiStrings().Help,
138+ triggers=self.on_help_clicked)
139 self.web_site_item = create_action(main_window, 'webSiteItem', can_shortcuts=True, category=UiStrings().Help)
140 # Shortcuts not connected to buttons or menu entries.
141 self.search_shortcut_action = create_action(main_window,
142@@ -352,7 +349,7 @@
143 add_actions(self.tools_menu, (self.tools_open_data_folder, None))
144 add_actions(self.tools_menu, (self.tools_first_time_wizard, None))
145 add_actions(self.tools_menu, [self.update_theme_images])
146- add_actions(self.help_menu, (self.on_help_item, None, self.web_site_item, self.about_item))
147+ add_actions(self.help_menu, (self.user_manual_item, None, self.web_site_item, self.about_item))
148 add_actions(self.menu_bar, (self.file_menu.menuAction(), self.view_menu.menuAction(),
149 self.tools_menu.menuAction(), self.settings_menu.menuAction(), self.help_menu.menuAction()))
150 add_actions(self, [self.search_shortcut_action])
151@@ -448,7 +445,7 @@
152 'from here.'))
153 self.about_item.setText(translate('OpenLP.MainWindow', '&About'))
154 self.about_item.setStatusTip(translate('OpenLP.MainWindow', 'More information about OpenLP.'))
155- self.on_help_item.setText(translate('OpenLP.MainWindow', '&User Manual'))
156+ self.user_manual_item.setText(translate('OpenLP.MainWindow', '&User Manual'))
157 self.search_shortcut_action.setText(UiStrings().Search)
158 self.search_shortcut_action.setToolTip(
159 translate('OpenLP.MainWindow', 'Jump to the search box of the current active plugin.'))
160
161=== modified file 'openlp/core/ui/themewizard.py'
162--- openlp/core/ui/themewizard.py 2016-10-27 17:45:50 +0000
163+++ openlp/core/ui/themewizard.py 2016-12-15 22:20:16 +0000
164@@ -44,9 +44,9 @@
165 theme_wizard.setModal(True)
166 theme_wizard.setOptions(QtWidgets.QWizard.IndependentPages |
167 QtWidgets.QWizard.NoBackButtonOnStartPage | QtWidgets.QWizard.HaveCustomButton1)
168+ theme_wizard.setFixedWidth(640)
169 if is_macosx():
170 theme_wizard.setPixmap(QtWidgets.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png'))
171- theme_wizard.resize(646, 400)
172 else:
173 theme_wizard.setWizardStyle(QtWidgets.QWizard.ModernStyle)
174 self.spacer = QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
175
176=== added file 'tests/functional/openlp_core_ui/test_shortcutlistdialog.py'
177--- tests/functional/openlp_core_ui/test_shortcutlistdialog.py 1970-01-01 00:00:00 +0000
178+++ tests/functional/openlp_core_ui/test_shortcutlistdialog.py 2016-12-15 22:20:16 +0000
179@@ -0,0 +1,60 @@
180+# -*- coding: utf-8 -*-
181+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
182+
183+###############################################################################
184+# OpenLP - Open Source Lyrics Projection #
185+# --------------------------------------------------------------------------- #
186+# Copyright (c) 2008-2016 OpenLP Developers #
187+# --------------------------------------------------------------------------- #
188+# This program is free software; you can redistribute it and/or modify it #
189+# under the terms of the GNU General Public License as published by the Free #
190+# Software Foundation; version 2 of the License. #
191+# #
192+# This program is distributed in the hope that it will be useful, but WITHOUT #
193+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
194+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
195+# more details. #
196+# #
197+# You should have received a copy of the GNU General Public License along #
198+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
199+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
200+###############################################################################
201+"""
202+Package to test the openlp.core.ui.shortcutlistdialog package.
203+"""
204+from PyQt5 import QtCore, QtGui, QtWidgets
205+
206+from openlp.core.ui.shortcutlistdialog import CaptureShortcutButton, ShortcutTreeWidget
207+
208+from tests.interfaces import MagicMock, patch
209+
210+
211+def test_key_press_event():
212+ """
213+ Test the keyPressEvent method
214+ """
215+ # GIVEN: A checked button and a mocked event
216+ button = CaptureShortcutButton()
217+ button.setChecked(True)
218+ mocked_event = MagicMock()
219+ mocked_event.key.return_value = QtCore.Qt.Key_Space
220+
221+ # WHEN: keyPressEvent is called with an event that should be ignored
222+ button.keyPressEvent(mocked_event)
223+
224+ # THEN: The ignore() method on the event should have been called
225+ mocked_event.ignore.assert_called_once_with()
226+
227+
228+def test_keyboard_search():
229+ """
230+ Test the keyboardSearch method of the ShortcutTreeWidget
231+ """
232+ # GIVEN: A ShortcutTreeWidget
233+ widget = ShortcutTreeWidget()
234+
235+ # WHEN: keyboardSearch() is called
236+ widget.keyboardSearch('')
237+
238+ # THEN: Nothing happens
239+ assert True
240
241=== modified file 'tests/functional/test_init.py'
242--- tests/functional/test_init.py 2016-05-31 21:40:13 +0000
243+++ tests/functional/test_init.py 2016-12-15 22:20:16 +0000
244@@ -102,7 +102,7 @@
245 mocked_question.return_value = QtWidgets.QMessageBox.No
246
247 # WHEN: We check if a backup should be created
248- self.openlp.backup_on_upgrade(old_install)
249+ self.openlp.backup_on_upgrade(old_install, False)
250
251 # THEN: It should not ask if we want to create a backup
252 self.assertEqual(Settings().value('core/application version'), '2.2.0', 'Version should be the same!')
253@@ -120,14 +120,18 @@
254 'build': 'bzr000'
255 }
256 Settings().setValue('core/application version', '2.0.5')
257+ self.openlp.splash = MagicMock()
258+ self.openlp.splash.isVisible.return_value = True
259 with patch('openlp.core.get_application_version') as mocked_get_application_version,\
260 patch('openlp.core.QtWidgets.QMessageBox.question') as mocked_question:
261 mocked_get_application_version.return_value = MOCKED_VERSION
262 mocked_question.return_value = QtWidgets.QMessageBox.No
263
264 # WHEN: We check if a backup should be created
265- self.openlp.backup_on_upgrade(old_install)
266+ self.openlp.backup_on_upgrade(old_install, True)
267
268 # THEN: It should ask if we want to create a backup
269 self.assertEqual(Settings().value('core/application version'), '2.2.0', 'Version should be upgraded!')
270 self.assertEqual(mocked_question.call_count, 1, 'A question should have been asked!')
271+ self.openlp.splash.hide.assert_called_once_with()
272+ self.openlp.splash.show.assert_called_once_with()