diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 243e6016a..a5b76c6cf 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -120,9 +120,8 @@ class UiStrings(object): self.NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular') self.NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural') self.NoResults = translate('OpenLP.Ui', 'No Search Results') - self.OLP = translate('OpenLP.Ui', 'OpenLP') - self.OLPV2 = "{name} {version}".format(name=self.OLP, version="2") - self.OLPV2x = "{name} {version}".format(name=self.OLP, version="2.4") + self.OpenLP = translate('OpenLP.Ui', 'OpenLP') + self.OpenLPv2AndUp = translate('OpenLP.Ui', 'OpenLP 2.0 and up') self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?') self.OpenService = translate('OpenLP.Ui', 'Open service.') self.OptionalShowInFooter = translate('OpenLP.Ui', 'Optional, this will be displayed in footer.') diff --git a/openlp/core/ui/lib/pathedit.py b/openlp/core/ui/lib/pathedit.py index 9c66478b2..99d448bd6 100755 --- a/openlp/core/ui/lib/pathedit.py +++ b/openlp/core/ui/lib/pathedit.py @@ -1,205 +1,205 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2017 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 # -############################################################################### -from enum import Enum -import os.path - -from PyQt5 import QtCore, QtWidgets - -from openlp.core.common import UiStrings, translate -from openlp.core.lib import build_icon - - -class PathType(Enum): - Files = 1 - Directories = 2 - - -class PathEdit(QtWidgets.QWidget): - """ - The :class:`~openlp.core.ui.lib.pathedit.PathEdit` class subclasses QWidget to create a custom widget for use when - a file or directory needs to be selected. - """ - pathChanged = QtCore.pyqtSignal(str) - - def __init__(self, parent=None, path_type=PathType.Files, default_path=None, dialog_caption=None, show_revert=True): - """ - Initalise the PathEdit widget - - :param parent: The parent of the widget. This is just passed to the super method. - :type parent: QWidget or None - - :param dialog_caption: Used to customise the caption in the QFileDialog. - :type dialog_caption: str - - :param default_path: The default path. This is set as the path when the revert button is clicked - :type default_path: str - - :param show_revert: Used to determin if the 'revert button' should be visible. - :type show_revert: bool - - :return: None - :rtype: None - """ - super().__init__(parent) - self.default_path = default_path - self.dialog_caption = dialog_caption - self._path_type = path_type - self._path = None - self.filters = '{all_files} (*)'.format(all_files=UiStrings().AllFiles) - self._setup(show_revert) - - def _setup(self, show_revert): - """ - Set up the widget - :param show_revert: Show or hide the revert button - :type show_revert: bool - - :return: None - :rtype: None - """ - widget_layout = QtWidgets.QHBoxLayout() - widget_layout.setContentsMargins(0, 0, 0, 0) - self.line_edit = QtWidgets.QLineEdit(self) - self.line_edit.setText(self._path) - widget_layout.addWidget(self.line_edit) - self.browse_button = QtWidgets.QToolButton(self) - self.browse_button.setIcon(build_icon(':/general/general_open.png')) - widget_layout.addWidget(self.browse_button) - self.revert_button = QtWidgets.QToolButton(self) - self.revert_button.setIcon(build_icon(':/general/general_revert.png')) - self.revert_button.setVisible(show_revert) - widget_layout.addWidget(self.revert_button) - self.setLayout(widget_layout) - # Signals and Slots - self.browse_button.clicked.connect(self.on_browse_button_clicked) - self.revert_button.clicked.connect(self.on_revert_button_clicked) - self.line_edit.editingFinished.connect(self.on_line_edit_editing_finished) - self.update_button_tool_tips() - - @property - def path(self): - """ - A property getter method to return the selected path. - - :return: The selected path - :rtype: str - """ - return self._path - - @path.setter - def path(self, path): - """ - A Property setter method to set the selected path - - :param path: The path to set the widget to - :type path: str - """ - self._path = path - self.line_edit.setText(path) - self.line_edit.setToolTip(path) - - @property - def path_type(self): - """ - A property getter method to return the path_type. Path type allows you to sepecify if the user is restricted to - selecting a file or directory. - - :return: The type selected - :rtype: Enum of PathEdit - """ - return self._path_type - - @path_type.setter - def path_type(self, path_type): - """ - A Property setter method to set the path type - - :param path: The type of path to select - :type path: Enum of PathEdit - """ - self._path_type = path_type - self.update_button_tool_tips() - - def update_button_tool_tips(self): - """ - Called to update the tooltips on the buttons. This is changing path types, and when the widget is initalised - :return: None - """ - if self._path_type == PathType.Directories: - self.browse_button.setToolTip(translate('OpenLP.PathEdit', 'Browse for directory.')) - self.revert_button.setToolTip(translate('OpenLP.PathEdit', 'Revert to default directory.')) - else: - self.browse_button.setToolTip(translate('OpenLP.PathEdit', 'Browse for file.')) - self.revert_button.setToolTip(translate('OpenLP.PathEdit', 'Revert to default file.')) - - def on_browse_button_clicked(self): - """ - A handler to handle a click on the browse button. - - Show the QFileDialog and process the input from the user - :return: None - """ - caption = self.dialog_caption - path = '' - if self._path_type == PathType.Directories: - if not caption: - caption = translate('OpenLP.PathEdit', 'Select Directory') - path = QtWidgets.QFileDialog.getExistingDirectory(self, caption, - self._path, QtWidgets.QFileDialog.ShowDirsOnly) - elif self._path_type == PathType.Files: - if not caption: - caption = self.dialog_caption = translate('OpenLP.PathEdit', 'Select File') - path, filter_used = QtWidgets.QFileDialog.getOpenFileName(self, caption, self._path, self.filters) - if path: - path = os.path.normpath(path) - self.on_new_path(path) - - def on_revert_button_clicked(self): - """ - A handler to handle a click on the revert button. - - Set the new path to the value of the default_path instance variable. - :return: None - """ - self.on_new_path(self.default_path) - - def on_line_edit_editing_finished(self): - """ - A handler to handle when the line edit has finished being edited. - :return: None - """ - self.on_new_path(self.line_edit.text()) - - def on_new_path(self, path): - """ - A method called to validate and set a new path. - - Emits the pathChanged Signal - - :param path: The new path - :type path: str - - :return: None - """ - if self._path != path: - self.path = path - self.pathChanged.emit(path) +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2017 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 # +############################################################################### +from enum import Enum +import os.path + +from PyQt5 import QtCore, QtWidgets + +from openlp.core.common import UiStrings, translate +from openlp.core.lib import build_icon + + +class PathType(Enum): + Files = 1 + Directories = 2 + + +class PathEdit(QtWidgets.QWidget): + """ + The :class:`~openlp.core.ui.lib.pathedit.PathEdit` class subclasses QWidget to create a custom widget for use when + a file or directory needs to be selected. + """ + pathChanged = QtCore.pyqtSignal(str) + + def __init__(self, parent=None, path_type=PathType.Files, default_path=None, dialog_caption=None, show_revert=True): + """ + Initalise the PathEdit widget + + :param parent: The parent of the widget. This is just passed to the super method. + :type parent: QWidget or None + + :param dialog_caption: Used to customise the caption in the QFileDialog. + :type dialog_caption: str + + :param default_path: The default path. This is set as the path when the revert button is clicked + :type default_path: str + + :param show_revert: Used to determin if the 'revert button' should be visible. + :type show_revert: bool + + :return: None + :rtype: None + """ + super().__init__(parent) + self.default_path = default_path + self.dialog_caption = dialog_caption + self._path_type = path_type + self._path = None + self.filters = '{all_files} (*)'.format(all_files=UiStrings().AllFiles) + self._setup(show_revert) + + def _setup(self, show_revert): + """ + Set up the widget + :param show_revert: Show or hide the revert button + :type show_revert: bool + + :return: None + :rtype: None + """ + widget_layout = QtWidgets.QHBoxLayout() + widget_layout.setContentsMargins(0, 0, 0, 0) + self.line_edit = QtWidgets.QLineEdit(self) + self.line_edit.setText(self._path) + widget_layout.addWidget(self.line_edit) + self.browse_button = QtWidgets.QToolButton(self) + self.browse_button.setIcon(build_icon(':/general/general_open.png')) + widget_layout.addWidget(self.browse_button) + self.revert_button = QtWidgets.QToolButton(self) + self.revert_button.setIcon(build_icon(':/general/general_revert.png')) + self.revert_button.setVisible(show_revert) + widget_layout.addWidget(self.revert_button) + self.setLayout(widget_layout) + # Signals and Slots + self.browse_button.clicked.connect(self.on_browse_button_clicked) + self.revert_button.clicked.connect(self.on_revert_button_clicked) + self.line_edit.editingFinished.connect(self.on_line_edit_editing_finished) + self.update_button_tool_tips() + + @property + def path(self): + """ + A property getter method to return the selected path. + + :return: The selected path + :rtype: str + """ + return self._path + + @path.setter + def path(self, path): + """ + A Property setter method to set the selected path + + :param path: The path to set the widget to + :type path: str + """ + self._path = path + self.line_edit.setText(path) + self.line_edit.setToolTip(path) + + @property + def path_type(self): + """ + A property getter method to return the path_type. Path type allows you to sepecify if the user is restricted to + selecting a file or directory. + + :return: The type selected + :rtype: Enum of PathEdit + """ + return self._path_type + + @path_type.setter + def path_type(self, path_type): + """ + A Property setter method to set the path type + + :param path: The type of path to select + :type path: Enum of PathEdit + """ + self._path_type = path_type + self.update_button_tool_tips() + + def update_button_tool_tips(self): + """ + Called to update the tooltips on the buttons. This is changing path types, and when the widget is initalised + :return: None + """ + if self._path_type == PathType.Directories: + self.browse_button.setToolTip(translate('OpenLP.PathEdit', 'Browse for directory.')) + self.revert_button.setToolTip(translate('OpenLP.PathEdit', 'Revert to default directory.')) + else: + self.browse_button.setToolTip(translate('OpenLP.PathEdit', 'Browse for file.')) + self.revert_button.setToolTip(translate('OpenLP.PathEdit', 'Revert to default file.')) + + def on_browse_button_clicked(self): + """ + A handler to handle a click on the browse button. + + Show the QFileDialog and process the input from the user + :return: None + """ + caption = self.dialog_caption + path = '' + if self._path_type == PathType.Directories: + if not caption: + caption = translate('OpenLP.PathEdit', 'Select Directory') + path = QtWidgets.QFileDialog.getExistingDirectory(self, caption, + self._path, QtWidgets.QFileDialog.ShowDirsOnly) + elif self._path_type == PathType.Files: + if not caption: + caption = self.dialog_caption = translate('OpenLP.PathEdit', 'Select File') + path, filter_used = QtWidgets.QFileDialog.getOpenFileName(self, caption, self._path, self.filters) + if path: + path = os.path.normpath(path) + self.on_new_path(path) + + def on_revert_button_clicked(self): + """ + A handler to handle a click on the revert button. + + Set the new path to the value of the default_path instance variable. + :return: None + """ + self.on_new_path(self.default_path) + + def on_line_edit_editing_finished(self): + """ + A handler to handle when the line edit has finished being edited. + :return: None + """ + self.on_new_path(self.line_edit.text()) + + def on_new_path(self, path): + """ + A method called to validate and set a new path. + + Emits the pathChanged Signal + + :param path: The new path + :type path: str + + :return: None + """ + if self._path != path: + self.path = path + self.pathChanged.emit(path) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 43da129b5..683df48de 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -34,12 +34,12 @@ from tempfile import gettempdir from PyQt5 import QtCore, QtGui, QtWidgets -from openlp.core.common import Registry, RegistryProperties, AppLocation, LanguageManager, Settings, \ +from openlp.core.common import Registry, RegistryProperties, AppLocation, LanguageManager, Settings, UiStrings, \ check_directory_exists, translate, is_win, is_macosx, add_actions from openlp.core.common.actions import ActionList, CategoryOrder from openlp.core.common.versionchecker import get_application_version from openlp.core.lib import Renderer, PluginManager, ImageManager, PluginStatus, ScreenList, build_icon -from openlp.core.lib.ui import UiStrings, create_action +from openlp.core.lib.ui import create_action from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, LiveController, PluginForm, \ ShortcutListForm, FormattingTagForm, PreviewController from openlp.core.ui.firsttimeform import FirstTimeForm @@ -370,7 +370,7 @@ class Ui_MainWindow(object): """ Set up the translation system """ - main_window.setWindowTitle(UiStrings().OLP) + main_window.setWindowTitle(UiStrings().OpenLP) self.file_menu.setTitle(translate('OpenLP.MainWindow', '&File')) self.file_import_menu.setTitle(translate('OpenLP.MainWindow', '&Import')) self.file_export_menu.setTitle(translate('OpenLP.MainWindow', '&Export')) @@ -1150,9 +1150,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties): :param file_name: The file name of the service file. """ if modified: - title = '{title} - {name}*'.format(title=UiStrings().OLP, name=file_name) + title = '{title} - {name}*'.format(title=UiStrings().OpenLP, name=file_name) else: - title = '{title} - {name}'.format(title=UiStrings().OLP, name=file_name) + title = '{title} - {name}'.format(title=UiStrings().OpenLP, name=file_name) self.setWindowTitle(title) def show_status_message(self, message): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 00e9ed6e8..b1033646f 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -31,7 +31,7 @@ from xml.etree.ElementTree import ElementTree, XML from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, OpenLPMixin, RegistryMixin, \ - check_directory_exists, UiStrings, translate, is_win, get_filesystem_encoding, delete_file + UiStrings, check_directory_exists, translate, is_win, get_filesystem_encoding, delete_file from openlp.core.lib import FileDialog, ImageSource, ValidationError, get_text_file_string, build_icon, \ check_item_selected, create_thumb, validate_thumb from openlp.core.lib.theme import Theme, BackgroundType diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 037a53e9d..481c3f299 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -24,12 +24,12 @@ import logging from PyQt5 import QtGui -from openlp.core.common import Settings, translate +from openlp.core.common import Settings, UiStrings, translate from openlp.core.common.actions import ActionList from openlp.core.lib import Plugin, StringContent, build_icon from openlp.core.lib.db import Manager from openlp.core.lib.theme import VerticalType -from openlp.core.lib.ui import create_action, UiStrings +from openlp.core.lib.ui import create_action from openlp.core.ui import AlertLocation from openlp.plugins.alerts.forms import AlertForm from openlp.plugins.alerts.lib import AlertsManager, AlertsTab diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index f3808dc31..1dfe0a7c3 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -105,7 +105,7 @@ class AlertsTab(SettingsTab): self.timeout_label.setText(translate('AlertsPlugin.AlertsTab', 'Alert timeout:')) self.timeout_spin_box.setSuffix(' {unit}'.format(unit=UiStrings().Seconds)) self.preview_group_box.setTitle(UiStrings().Preview) - self.font_preview.setText(UiStrings().OLPV2x) + self.font_preview.setText(UiStrings().OpenLP) def on_background_color_changed(self, color): """ diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 3c321329b..607dcfbd9 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -22,9 +22,10 @@ import logging +from openlp.core.common import UiStrings from openlp.core.common.actions import ActionList from openlp.core.lib import Plugin, StringContent, build_icon, translate -from openlp.core.lib.ui import UiStrings, create_action +from openlp.core.lib.ui import create_action from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem, LayoutStyle, DisplayStyle, \ LanguageSelection from openlp.plugins.bibles.lib.mediaitem import BibleSearch diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 09ab940e7..3bd726027 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -34,15 +34,15 @@ from openlp.core.common import is_win, Settings if is_win(): from win32com.client import Dispatch import win32con - import winreg - import win32ui import win32gui + import win32ui + import winreg import pywintypes +from openlp.core.common import Registry, UiStrings, trace_error_handler from openlp.core.lib import ScreenList -from openlp.core.lib.ui import UiStrings, critical_error_message_box, translate -from openlp.core.common import trace_error_handler, Registry +from openlp.core.lib.ui import critical_error_message_box, translate from openlp.plugins.presentations.lib.presentationcontroller import PresentationController, PresentationDocument log = logging.getLogger(__name__) diff --git a/openlp/plugins/remotes/lib/httprouter.py b/openlp/plugins/remotes/lib/httprouter.py index fcaeb6f21..9e66189b6 100644 --- a/openlp/plugins/remotes/lib/httprouter.py +++ b/openlp/plugins/remotes/lib/httprouter.py @@ -277,7 +277,7 @@ class HttpRouter(RegistryProperties): Create a needs authorisation http header. """ self.send_response(401) - header = 'Basic realm=\"{}\"'.format(UiStrings().OLPV2) + header = 'Basic realm=\"{}\"'.format(UiStrings().OpenLP) self.send_header('WWW-Authenticate', header) self.send_header('Content-type', 'text/html') self.set_cache_headers() @@ -322,10 +322,10 @@ class HttpRouter(RegistryProperties): chords = translate('RemotePlugin.Mobile', 'Chords View') live = translate('RemotePlugin.Mobile', 'Live View') self.template_vars = { - 'app_title': "{main} {remote}".format(main=UiStrings().OLPV2x, remote=remote), - 'stage_title': "{main} {stage}".format(main=UiStrings().OLPV2x, stage=stage), - 'chords_title': "{main} {chords}".format(main=UiStrings().OLPV2x, chords=chords), - 'live_title': "{main} {live}".format(main=UiStrings().OLPV2x, live=live), + 'app_title': "{main} {remote}".format(main=UiStrings().OpenLP, remote=remote), + 'stage_title': "{main} {stage}".format(main=UiStrings().OpenLP, stage=stage), + 'chords_title': "{main} {chords}".format(main=UiStrings().OpenLP, chords=chords), + 'live_title': "{main} {live}".format(main=UiStrings().OpenLP, live=live), 'service_manager': translate('RemotePlugin.Mobile', 'Service Manager'), 'slide_controller': translate('RemotePlugin.Mobile', 'Slide Controller'), 'alerts': translate('RemotePlugin.Mobile', 'Alerts'), diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index e87d1d4ea..4826b1a5d 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -22,10 +22,10 @@ from PyQt5 import QtWidgets -from openlp.core.ui.lib import SpellTextEdit +from openlp.core.common import Settings, UiStrings from openlp.core.lib import build_icon, translate -from openlp.core.lib.ui import UiStrings, create_button_box -from openlp.core.common import Settings +from openlp.core.lib.ui import create_button_box +from openlp.core.ui.lib import SpellTextEdit from openlp.plugins.songs.lib import VerseType diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 3d4d059da..9f925b35c 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -206,7 +206,7 @@ class SongFormat(object): }, OpenLP2: { 'class': OpenLPSongImport, - 'name': UiStrings().OLPV2, + 'name': UiStrings().OpenLPv2AndUp, 'prefix': 'openLP2', 'selectMode': SongFormatSelect.SingleFile, 'filter': '{text} (*.sqlite)'.format(text=translate('SongsPlugin.ImportWizardForm', 'OpenLP 2 Databases')) diff --git a/tests/functional/openlp_core/test_init.py b/tests/functional/openlp_core/test_init.py index e18d0f376..dfe0c34cb 100644 --- a/tests/functional/openlp_core/test_init.py +++ b/tests/functional/openlp_core/test_init.py @@ -23,7 +23,7 @@ import sys from unittest import TestCase, skip from unittest.mock import MagicMock, patch -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core import OpenLP, parse_options @@ -225,3 +225,49 @@ class TestOpenLP(TestCase): MockedStandardButtons.assert_called_once_with(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No) mocked_critical.assert_called_once_with(None, 'Error', 'OpenLP is already running. Do you wish to continue?', 0) assert result is True + + def test_process_events(self): + """ + Test that the app.process_events() method simply calls the Qt method + """ + # GIVEN: An app + app = OpenLP([]) + + # WHEN: process_events() is called + with patch.object(app, 'processEvents') as mocked_processEvents: + app.process_events() + + # THEN: processEvents was called + mocked_processEvents.assert_called_once_with() + + def test_set_busy_cursor(self): + """ + Test that the set_busy_cursor() method sets the cursor + """ + # GIVEN: An app + app = OpenLP([]) + + # WHEN: set_busy_cursor() is called + with patch.object(app, 'setOverrideCursor') as mocked_setOverrideCursor, \ + patch.object(app, 'processEvents') as mocked_processEvents: + app.set_busy_cursor() + + # THEN: The cursor should have been set + mocked_setOverrideCursor.assert_called_once_with(QtCore.Qt.BusyCursor) + mocked_processEvents.assert_called_once_with() + + def test_set_normal_cursor(self): + """ + Test that the set_normal_cursor() method resets the cursor + """ + # GIVEN: An app + app = OpenLP([]) + + # WHEN: set_normal_cursor() is called + with patch.object(app, 'restoreOverrideCursor') as mocked_restoreOverrideCursor, \ + patch.object(app, 'processEvents') as mocked_processEvents: + app.set_normal_cursor() + + # THEN: The cursor should have been set + mocked_restoreOverrideCursor.assert_called_once_with() + mocked_processEvents.assert_called_once_with() diff --git a/tests/functional/openlp_core_ui/test_mainwindow.py b/tests/functional/openlp_core_ui/test_mainwindow.py index e5f9dd745..62540b3b7 100644 --- a/tests/functional/openlp_core_ui/test_mainwindow.py +++ b/tests/functional/openlp_core_ui/test_mainwindow.py @@ -28,9 +28,8 @@ from unittest.mock import MagicMock, patch from PyQt5 import QtWidgets +from openlp.core.common import Registry, UiStrings from openlp.core.ui.mainwindow import MainWindow -from openlp.core.lib.ui import UiStrings -from openlp.core.common.registry import Registry from tests.helpers.testmixin import TestMixin from tests.utils.constants import TEST_RESOURCES_PATH @@ -109,9 +108,9 @@ class TestMainWindow(TestCase, TestMixin): # WHEN no changes are made to the service - # THEN the main window's title shoud be the same as the OLP string in the UiStrings class - self.assertEqual(self.main_window.windowTitle(), UiStrings().OLP, - 'The main window\'s title should be the same as the OLP string in UiStrings class') + # THEN the main window's title shoud be the same as the OpenLP string in the UiStrings class + self.assertEqual(self.main_window.windowTitle(), UiStrings().OpenLP, + 'The main window\'s title should be the same as the OpenLP string in UiStrings class') def test_set_service_modifed(self): """ @@ -123,8 +122,8 @@ class TestMainWindow(TestCase, TestMixin): self.main_window.set_service_modified(True, 'test.osz') # THEN the main window's title should be set to the - self.assertEqual(self.main_window.windowTitle(), '%s - %s*' % (UiStrings().OLP, 'test.osz'), - 'The main window\'s title should be set to " - test.osz*"') + self.assertEqual(self.main_window.windowTitle(), '%s - %s*' % (UiStrings().OpenLP, 'test.osz'), + 'The main window\'s title should be set to " - test.osz*"') def test_set_service_unmodified(self): """ @@ -136,8 +135,8 @@ class TestMainWindow(TestCase, TestMixin): self.main_window.set_service_modified(False, 'test.osz') # THEN the main window's title should be set to the - self.assertEqual(self.main_window.windowTitle(), '%s - %s' % (UiStrings().OLP, 'test.osz'), - 'The main window\'s title should be set to " - test.osz"') + self.assertEqual(self.main_window.windowTitle(), '%s - %s' % (UiStrings().OpenLP, 'test.osz'), + 'The main window\'s title should be set to " - test.osz"') def test_mainwindow_configuration(self): """