diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 5de5e69de..ad06f3629 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -129,21 +129,21 @@ class OpenLP(OpenLPMixin, QtWidgets.QApplication): application_stylesheet += WIN_REPAIR_STYLESHEET if application_stylesheet: self.setStyleSheet(application_stylesheet) - show_splash = Settings().value('core/show splash') - if show_splash: + can_show_splash = Settings().value('core/show splash') + if can_show_splash: self.splash = SplashScreen() self.splash.show() # make sure Qt really display the splash screen self.processEvents() # Check if OpenLP has been upgrade and if a backup of data should be created - self.backup_on_upgrade(has_run_wizard) + self.backup_on_upgrade(has_run_wizard, can_show_splash) # start the main app window self.main_window = MainWindow() Registry().execute('bootstrap_initialise') Registry().execute('bootstrap_post_set_up') Registry().initialise = False self.main_window.show() - if show_splash: + if can_show_splash: # now kill the splashscreen self.splash.finish(self.main_window) log.debug('Splashscreen closed') @@ -224,13 +224,20 @@ class OpenLP(OpenLPMixin, QtWidgets.QApplication): self.exception_form = ExceptionForm() self.exception_form.exception_text_edit.setPlainText(''.join(format_exception(exc_type, value, traceback))) self.set_normal_cursor() + is_splash_visible = False + if hasattr(self, 'splash') and self.splash.isVisible(): + is_splash_visible = True + self.splash.hide() self.exception_form.exec() + if is_splash_visible: + self.splash.show() - def backup_on_upgrade(self, has_run_wizard): + def backup_on_upgrade(self, has_run_wizard, can_show_splash): """ Check if OpenLP has been upgraded, and ask if a backup of data should be made :param has_run_wizard: OpenLP has been run before + :param can_show_splash: Should OpenLP show the splash screen """ data_version = Settings().value('core/application version') openlp_version = get_application_version()['version'] @@ -239,6 +246,8 @@ class OpenLP(OpenLPMixin, QtWidgets.QApplication): Settings().setValue('core/application version', openlp_version) # If data_version is different from the current version ask if we should backup the data folder elif data_version != openlp_version: + if self.splash.isVisible(): + self.splash.hide() if QtWidgets.QMessageBox.question(None, translate('OpenLP', 'Backup'), translate('OpenLP', 'OpenLP has been upgraded, do you want to create\n' 'a backup of the old data folder?'), @@ -261,6 +270,8 @@ class OpenLP(OpenLPMixin, QtWidgets.QApplication): # Update the version in the settings Settings().setValue('core/application version', openlp_version) + if can_show_splash: + self.splash.show() def process_events(self): """ @@ -375,6 +386,7 @@ def main(args=None): application.setOrganizationName('OpenLP') application.setOrganizationDomain('openlp.org') application.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) + application.setAttribute(QtCore.Qt.AA_DontCreateNativeWidgetSiblings, True) if args and args.portable: application.setApplicationName('OpenLPPortable') Settings.setDefaultFormat(Settings.IniFormat) diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index 8f70fafff..132e9652a 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -216,8 +216,8 @@ class Settings(QtCore.QSettings): ('advanced/default color', 'core/logo background color', []), # Default image renamed + moved to general > 2.4. ('advanced/default image', 'core/logo file', []), # Default image renamed + moved to general after 2.4. ('shortcuts/escapeItem', 'shortcuts/desktopScreenEnable', []), # Escape item was removed in 2.6. - ('shortcuts/offlineHelpItem', 'shortcuts/HelpItem', []), # Online and Offline help were combined in 2.6. - ('shortcuts/onlineHelpItem', 'shortcuts/HelpItem', []) # Online and Offline help were combined in 2.6. + ('shortcuts/offlineHelpItem', 'shortcuts/userManualItem', []), # Online and Offline help were combined in 2.6. + ('shortcuts/onlineHelpItem', 'shortcuts/userManualItem', []) # Online and Offline help were combined in 2.6. ] @staticmethod @@ -276,7 +276,7 @@ class Settings(QtCore.QSettings): 'shortcuts/fileSaveItem': [QtGui.QKeySequence(QtGui.QKeySequence.Save)], 'shortcuts/fileOpenItem': [QtGui.QKeySequence(QtGui.QKeySequence.Open)], 'shortcuts/goLive': [], - 'shortcuts/HelpItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents)], + 'shortcuts/userManualItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents)], 'shortcuts/importThemeItem': [], 'shortcuts/importBibleItem': [], 'shortcuts/listViewBiblesDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete)], diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6e6101562..ec585790c 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -52,7 +52,7 @@ from openlp.core.ui.lib.mediadockmanager import MediaDockManager log = logging.getLogger(__name__) MEDIA_MANAGER_STYLE = """ -::tab { +::tab#media_tool_box { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 palette(button), stop: 1.0 palette(mid)); border: 0; @@ -61,10 +61,8 @@ MEDIA_MANAGER_STYLE = """ margin-bottom: 0; text-align: left; } -::tab:selected { - border: 1px solid palette(highlight); - font-weight: bold; -} +/* This is here to make the tabs on KDE with the Breeze theme work */ +::tab:selected {} """ PROGRESSBAR_STYLE = """ @@ -310,10 +308,9 @@ class Ui_MainWindow(object): elif is_macosx(): self.local_help_file = os.path.join(AppLocation.get_directory(AppLocation.AppDir), '..', 'Resources', 'OpenLP.help') - self.on_help_item = create_action(main_window, 'HelpItem', - icon=':/system/system_help_contents.png', - can_shortcuts=True, - category=UiStrings().Help, triggers=self.on_help_clicked) + self.user_manual_item = create_action(main_window, 'userManualItem', icon=':/system/system_help_contents.png', + can_shortcuts=True, category=UiStrings().Help, + triggers=self.on_help_clicked) self.web_site_item = create_action(main_window, 'webSiteItem', can_shortcuts=True, category=UiStrings().Help) # Shortcuts not connected to buttons or menu entries. self.search_shortcut_action = create_action(main_window, @@ -352,7 +349,7 @@ class Ui_MainWindow(object): add_actions(self.tools_menu, (self.tools_open_data_folder, None)) add_actions(self.tools_menu, (self.tools_first_time_wizard, None)) add_actions(self.tools_menu, [self.update_theme_images]) - add_actions(self.help_menu, (self.on_help_item, None, self.web_site_item, self.about_item)) + add_actions(self.help_menu, (self.user_manual_item, None, self.web_site_item, self.about_item)) add_actions(self.menu_bar, (self.file_menu.menuAction(), self.view_menu.menuAction(), self.tools_menu.menuAction(), self.settings_menu.menuAction(), self.help_menu.menuAction())) add_actions(self, [self.search_shortcut_action]) @@ -448,7 +445,7 @@ class Ui_MainWindow(object): 'from here.')) self.about_item.setText(translate('OpenLP.MainWindow', '&About')) self.about_item.setStatusTip(translate('OpenLP.MainWindow', 'More information about OpenLP.')) - self.on_help_item.setText(translate('OpenLP.MainWindow', '&User Manual')) + self.user_manual_item.setText(translate('OpenLP.MainWindow', '&User Manual')) self.search_shortcut_action.setText(UiStrings().Search) self.search_shortcut_action.setToolTip( translate('OpenLP.MainWindow', 'Jump to the search box of the current active plugin.')) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 95262cf8f..7eac787d9 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -44,9 +44,9 @@ class Ui_ThemeWizard(object): theme_wizard.setModal(True) theme_wizard.setOptions(QtWidgets.QWizard.IndependentPages | QtWidgets.QWizard.NoBackButtonOnStartPage | QtWidgets.QWizard.HaveCustomButton1) + theme_wizard.setFixedWidth(640) if is_macosx(): theme_wizard.setPixmap(QtWidgets.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png')) - theme_wizard.resize(646, 400) else: theme_wizard.setWizardStyle(QtWidgets.QWizard.ModernStyle) self.spacer = QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) diff --git a/tests/functional/openlp_core_ui/test_shortcutlistdialog.py b/tests/functional/openlp_core_ui/test_shortcutlistdialog.py new file mode 100644 index 000000000..2f39cb34a --- /dev/null +++ b/tests/functional/openlp_core_ui/test_shortcutlistdialog.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2016 OpenLP Developers # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +Package to test the openlp.core.ui.shortcutlistdialog package. +""" +from PyQt5 import QtCore, QtGui, QtWidgets + +from openlp.core.ui.shortcutlistdialog import CaptureShortcutButton, ShortcutTreeWidget + +from tests.interfaces import MagicMock, patch + + +def test_key_press_event(): + """ + Test the keyPressEvent method + """ + # GIVEN: A checked button and a mocked event + button = CaptureShortcutButton() + button.setChecked(True) + mocked_event = MagicMock() + mocked_event.key.return_value = QtCore.Qt.Key_Space + + # WHEN: keyPressEvent is called with an event that should be ignored + button.keyPressEvent(mocked_event) + + # THEN: The ignore() method on the event should have been called + mocked_event.ignore.assert_called_once_with() + + +def test_keyboard_search(): + """ + Test the keyboardSearch method of the ShortcutTreeWidget + """ + # GIVEN: A ShortcutTreeWidget + widget = ShortcutTreeWidget() + + # WHEN: keyboardSearch() is called + widget.keyboardSearch('') + + # THEN: Nothing happens + assert True diff --git a/tests/functional/test_init.py b/tests/functional/test_init.py index 825de57f3..504489416 100644 --- a/tests/functional/test_init.py +++ b/tests/functional/test_init.py @@ -102,7 +102,7 @@ class TestInit(TestCase, TestMixin): mocked_question.return_value = QtWidgets.QMessageBox.No # WHEN: We check if a backup should be created - self.openlp.backup_on_upgrade(old_install) + self.openlp.backup_on_upgrade(old_install, False) # THEN: It should not ask if we want to create a backup self.assertEqual(Settings().value('core/application version'), '2.2.0', 'Version should be the same!') @@ -120,14 +120,18 @@ class TestInit(TestCase, TestMixin): 'build': 'bzr000' } Settings().setValue('core/application version', '2.0.5') + self.openlp.splash = MagicMock() + self.openlp.splash.isVisible.return_value = True with patch('openlp.core.get_application_version') as mocked_get_application_version,\ patch('openlp.core.QtWidgets.QMessageBox.question') as mocked_question: mocked_get_application_version.return_value = MOCKED_VERSION mocked_question.return_value = QtWidgets.QMessageBox.No # WHEN: We check if a backup should be created - self.openlp.backup_on_upgrade(old_install) + self.openlp.backup_on_upgrade(old_install, True) # THEN: It should ask if we want to create a backup self.assertEqual(Settings().value('core/application version'), '2.2.0', 'Version should be upgraded!') self.assertEqual(mocked_question.call_count, 1, 'A question should have been asked!') + self.openlp.splash.hide.assert_called_once_with() + self.openlp.splash.show.assert_called_once_with()