From 2907cb4f144d82af66f8d770bcb7608e9d5a1480 Mon Sep 17 00:00:00 2001 From: robbie jackson Date: Wed, 25 Aug 2021 21:14:19 +0000 Subject: [PATCH] Improve help --- openlp/core/lib/ui.py | 4 ++ openlp/core/ui/firsttimeform.py | 13 +++++- openlp/core/ui/settingsdialog.py | 2 +- openlp/core/ui/settingsform.py | 8 +++- openlp/core/ui/themeform.py | 11 ++++- openlp/core/widgets/wizard.py | 10 +++++ openlp/plugins/alerts/forms/alertdialog.py | 2 +- openlp/plugins/alerts/forms/alertform.py | 8 +++- .../plugins/bibles/forms/bibleimportform.py | 8 +++- .../plugins/bibles/forms/editbibledialog.py | 2 +- openlp/plugins/bibles/forms/editbibleform.py | 8 +++- .../plugins/custom/forms/editcustomdialog.py | 2 +- openlp/plugins/custom/forms/editcustomform.py | 8 +++- openlp/plugins/songs/forms/editsongdialog.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 9 +++- openlp/plugins/songs/forms/songexportform.py | 8 +++- openlp/plugins/songs/forms/songimportform.py | 8 +++- .../songusage/forms/songusagedeletedialog.py | 2 +- .../songusage/forms/songusagedeleteform.py | 8 +++- .../songusage/forms/songusagedetaildialog.py | 2 +- .../songusage/forms/songusagedetailform.py | 8 +++- tests/openlp_core/ui/test_firsttimeform.py | 17 ++++++- tests/openlp_core/ui/test_settingsform.py | 17 ++++++- .../alerts/forms/test_alertform.py | 43 ++++++++++++++++++ .../bibles/forms/test_bibleimportform.py | 16 ++++++- .../bibles/forms/test_editbibleform.py | 44 +++++++++++++++++++ .../custom/forms/test_customform.py | 16 +++++++ .../songs/forms/test_editsongform.py | 22 +++++++++- .../forms/test_songusagedeleteform.py | 44 +++++++++++++++++++ .../forms/test_songusagedetailform.py | 44 +++++++++++++++++++ 30 files changed, 371 insertions(+), 25 deletions(-) create mode 100644 tests/openlp_plugins/alerts/forms/test_alertform.py create mode 100644 tests/openlp_plugins/bibles/forms/test_editbibleform.py create mode 100644 tests/openlp_plugins/songusage/forms/test_songusagedeleteform.py create mode 100644 tests/openlp_plugins/songusage/forms/test_songusagedetailform.py diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index eae8e1c04..fad17ab80 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -87,6 +87,8 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None): buttons |= QtWidgets.QDialogButtonBox.Cancel if 'close' in standard_buttons: buttons |= QtWidgets.QDialogButtonBox.Close + if 'help' in standard_buttons and hasattr(dialog, 'provide_help'): + buttons |= QtWidgets.QDialogButtonBox.Help if 'defaults' in standard_buttons: buttons |= QtWidgets.QDialogButtonBox.RestoreDefaults button_box = QtWidgets.QDialogButtonBox(dialog) @@ -99,6 +101,8 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None): button_box.addButton(*button) button_box.accepted.connect(dialog.accept) button_box.rejected.connect(dialog.reject) + if 'help' in standard_buttons and hasattr(dialog, 'provide_help'): + button_box.helpRequested.connect(dialog.provide_help) return button_box diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index e19487923..b4215ca25 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -30,7 +30,7 @@ import urllib.request from pathlib import Path from tempfile import gettempdir -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore, QtWidgets, QtGui from openlp.core.api.deploy import get_latest_size, download_and_check from openlp.core.common import trace_error_handler @@ -100,7 +100,8 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties): """ Create and set up the first time wizard. """ - super(FirstTimeForm, self).__init__(parent) + super(FirstTimeForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint | + QtCore.Qt.WindowCloseButtonHint) self.has_web_access = True self.web = '' self.is_index_downloaded = False @@ -109,6 +110,14 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties): self.themes_list_widget.itemSelectionChanged.connect(self.on_themes_list_widget_selection_changed) self.themes_deselect_all_button.clicked.connect(self.themes_list_widget.clearSelection) self.themes_select_all_button.clicked.connect(self.themes_list_widget.selectAll) + self.setOption(QtWidgets.QWizard.HaveHelpButton, True) + self.helpRequested.connect(self.provide_help) + + def provide_help(self): + """ + Provide help within the wizard by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/wizard.html")) def get_next_page_id(self): """ diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index 345af8d33..7f03607ca 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -51,7 +51,7 @@ class Ui_SettingsDialog(object): self.stacked_layout = QtWidgets.QStackedLayout() self.stacked_layout.setObjectName('stacked_layout') self.dialog_layout.addLayout(self.stacked_layout, 0, 1, 1, 1) - self.button_box = create_button_box(settings_dialog, 'button_box', ['cancel', 'ok']) + self.button_box = create_button_box(settings_dialog, 'button_box', ['cancel', 'ok', 'help']) self.dialog_layout.addWidget(self.button_box, 1, 1, 1, 1) self.retranslate_ui(settings_dialog) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 2f6d3896d..9ed4933b0 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -23,7 +23,7 @@ The :mod:`settingsform` provides a user interface for the OpenLP settings """ import logging -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore, QtWidgets, QtGui from openlp.core.state import State from openlp.core.api.tab import ApiTab @@ -210,3 +210,9 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties): """ if function not in self.processes: self.processes.append(function) + + def provide_help(self): + """ + Provide help within the form by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/configure.html")) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 9b4ea4941..a766d61d3 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -52,7 +52,8 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties): :param parent: The QWidget-derived parent of the wizard. """ - super(ThemeForm, self).__init__(parent) + super(ThemeForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint | + QtCore.Qt.WindowCloseButtonHint) self._setup() def _setup(self): @@ -75,6 +76,14 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties): self.main_area_page.shadow_size_changed.connect(self.calculate_lines) self.footer_area_page.font_name_changed.connect(self.update_theme) self.footer_area_page.font_size_changed.connect(self.update_theme) + self.setOption(QtWidgets.QWizard.HaveHelpButton, True) + self.helpRequested.connect(self.provide_help) + + def provide_help(self): + """ + Provide help within the wizard by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/themes.html")) def set_defaults(self): """ diff --git a/openlp/core/widgets/wizard.py b/openlp/core/widgets/wizard.py index eddf84cc3..80796690c 100644 --- a/openlp/core/widgets/wizard.py +++ b/openlp/core/widgets/wizard.py @@ -125,6 +125,10 @@ class OpenLPWizard(QtWidgets.QWizard, RegistryProperties): self.setModal(True) self.setOptions(QtWidgets.QWizard.IndependentPages | QtWidgets.QWizard.NoBackButtonOnStartPage | QtWidgets.QWizard.NoBackButtonOnLastPage) + # Set up a help button if the class of this instance has overridden the provide_help method + if (self.provide_help.__module__ != __name__): + self.setOption(QtWidgets.QWizard.HaveHelpButton, True) + self.helpRequested.connect(self.provide_help) if is_macosx(): self.setPixmap(QtWidgets.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png')) else: @@ -277,3 +281,9 @@ class OpenLPWizard(QtWidgets.QWizard, RegistryProperties): self.finish_button.setVisible(True) self.cancel_button.setVisible(False) self.application.process_events() + + def provide_help(self): + """ + Provide help - usually by opening the appropriate page of the openlp manual in the user's browser + """ + pass diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index de164ed65..73e065706 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -79,7 +79,7 @@ class AlertDialog(object): self.display_button = create_button(alert_dialog, 'display_button', icon=UiIcons().live, enabled=False) self.display_close_button = create_button(alert_dialog, 'display_close_button', icon=UiIcons().live, enabled=False) - self.button_box = create_button_box(alert_dialog, 'button_box', ['close'], + self.button_box = create_button_box(alert_dialog, 'button_box', ['close', 'help'], [self.display_button, self.display_close_button]) self.alert_dialog_layout.addWidget(self.button_box, 2, 0, 1, 2) self.retranslate_ui(alert_dialog) diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index b4d0c84e5..ae78e29b0 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -19,7 +19,7 @@ # along with this program. If not, see . # ########################################################################## -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore, QtWidgets, QtGui from openlp.core.common.i18n import translate from openlp.core.common.registry import Registry @@ -217,3 +217,9 @@ class AlertForm(QtWidgets.QDialog, AlertDialog): self.delete_button.setEnabled(True) # We do not need to enable the save button, as it is only enabled # when typing text in the "alert_text_edit". + + def provide_help(self): + """ + Provide help within the form by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/alert.html")) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 7287df906..427929086 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -25,7 +25,7 @@ import logging import urllib.error from lxml import etree -from PyQt5 import QtWidgets +from PyQt5 import QtWidgets, QtGui, QtCore try: from pysword import modules @@ -773,3 +773,9 @@ class BibleImportForm(OpenLPWizard): # Don't delete the db if it wasen't created if hasattr(importer, 'file'): delete_database(self.plugin.settings_section, importer.file) + + def provide_help(self): + """ + Provide help within the wizard by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/bibles.html")) diff --git a/openlp/plugins/bibles/forms/editbibledialog.py b/openlp/plugins/bibles/forms/editbibledialog.py index 9e51aeb64..8c8084ee1 100644 --- a/openlp/plugins/bibles/forms/editbibledialog.py +++ b/openlp/plugins/bibles/forms/editbibledialog.py @@ -123,7 +123,7 @@ class Ui_EditBibleDialog(object): self.bible_tab_widget.addTab(self.book_name_tab, '') # Last few bits self.dialog_layout.addWidget(self.bible_tab_widget) - self.button_box = create_button_box(edit_bible_dialog, 'button_box', ['cancel', 'save']) + self.button_box = create_button_box(edit_bible_dialog, 'button_box', ['cancel', 'save', 'help']) self.dialog_layout.addWidget(self.button_box) self.retranslate_ui(edit_bible_dialog) QtCore.QMetaObject.connectSlotsByName(edit_bible_dialog) diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index b00f279d1..5d121f620 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -22,7 +22,7 @@ import logging import re -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore, QtWidgets, QtGui from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.mixins import RegistryProperties @@ -213,3 +213,9 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties): 'The Book Name "{name}" has been entered more than once.').format(name=new_book_name)) return False return True + + def provide_help(self): + """ + Provide help within the form by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/bibles.html#edit-bible-data")) diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 3a394d5ea..1b3339167 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -94,7 +94,7 @@ class Ui_CustomEditDialog(object): self.bottom_form_layout.addRow(self.credit_label, self.credit_edit) self.dialog_layout.addLayout(self.bottom_form_layout) self.preview_button = QtWidgets.QPushButton() - self.button_box = create_button_box(custom_edit_dialog, 'button_box', ['cancel', 'save'], + self.button_box = create_button_box(custom_edit_dialog, 'button_box', ['cancel', 'save', 'help'], [self.preview_button]) self.save_button = self.button_box.button(QtWidgets.QDialogButtonBox.Save) self.dialog_layout.addWidget(self.button_box) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index a099e74f1..998b1c5db 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -21,7 +21,7 @@ import logging -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore, QtWidgets, QtGui from openlp.core.common.i18n import translate from openlp.core.common.registry import Registry @@ -244,3 +244,9 @@ class EditCustomForm(QtWidgets.QDialog, Ui_CustomEditDialog): 'You need to add at least one slide.')) return False return True + + def provide_help(self): + """ + Provide help within the form by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/custom_slides.html")) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index dd7c78bdc..adc3f7e94 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -289,7 +289,7 @@ class Ui_EditSongDialog(object): self.warning_label = QtWidgets.QLabel(edit_song_dialog) self.warning_label.setObjectName('warning_label') self.bottom_layout.addWidget(self.warning_label) - self.button_box = create_button_box(edit_song_dialog, 'button_box', ['cancel', 'save']) + self.button_box = create_button_box(edit_song_dialog, 'button_box', ['cancel', 'save', 'help']) self.bottom_layout.addWidget(self.button_box) self.dialog_layout.addLayout(self.bottom_layout) self.retranslate_ui(edit_song_dialog) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index a6664f6b9..63b31f2b0 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -26,7 +26,7 @@ import logging import re from shutil import copyfile -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore, QtWidgets, QtGui from openlp.core.state import State from openlp.core.common.applocation import AppLocation @@ -1099,3 +1099,10 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): clean_song(self.manager, self.song) self.manager.save_object(self.song) self.media_item.auto_select_id = self.song.id + + def provide_help(self): + """ + Provide help within the form by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/songs.html#creating-or-editing-a-song" + "-slide")) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 28041d038..d0a100b9c 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -24,7 +24,7 @@ OpenLyrics format. """ import logging -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore, QtWidgets, QtGui from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.registry import Registry @@ -290,6 +290,12 @@ class SongExportForm(OpenLPWizard): if not item.isHidden(): item.setCheckState(QtCore.Qt.Checked) + def provide_help(self): + """ + Provide help within the wizard by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/export_songs.html")) + def find_list_widget_items(list_widget, text=''): """ diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 1189914ac..2e7355df9 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -23,7 +23,7 @@ The song import functions for OpenLP. """ import logging -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore, QtWidgets, QtGui from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.mixins import RegistryProperties @@ -463,6 +463,12 @@ class SongImportForm(OpenLPWizard, RegistryProperties): self.format_widgets[this_format]['import_widget'] = import_widget return import_widget + def provide_help(self): + """ + Provide help within the wizard by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/songs.html#song-importer")) + class SongImportSourcePage(QtWidgets.QWizardPage): """ diff --git a/openlp/plugins/songusage/forms/songusagedeletedialog.py b/openlp/plugins/songusage/forms/songusagedeletedialog.py index 7a207c056..971547c92 100644 --- a/openlp/plugins/songusage/forms/songusagedeletedialog.py +++ b/openlp/plugins/songusage/forms/songusagedeletedialog.py @@ -52,7 +52,7 @@ class Ui_SongUsageDeleteDialog(object): self.delete_calendar.setVerticalHeaderFormat(QtWidgets.QCalendarWidget.NoVerticalHeader) self.delete_calendar.setObjectName('delete_calendar') self.vertical_layout.addWidget(self.delete_calendar) - self.button_box = create_button_box(song_usage_delete_dialog, 'button_box', ['cancel', 'ok']) + self.button_box = create_button_box(song_usage_delete_dialog, 'button_box', ['cancel', 'ok', 'help']) self.vertical_layout.addWidget(self.button_box) self.retranslate_ui(song_usage_delete_dialog) diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index 2638487e1..fc3009b0c 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -19,7 +19,7 @@ # along with this program. If not, see . # ########################################################################## -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore, QtWidgets, QtGui from openlp.core.common.i18n import translate from openlp.core.common.mixins import RegistryProperties @@ -65,3 +65,9 @@ class SongUsageDeleteForm(QtWidgets.QDialog, Ui_SongUsageDeleteDialog, RegistryP self.accept() else: self.reject() + + def provide_help(self): + """ + Provide help within the form by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/song_usage.html")) diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index 895420bf0..8b901c699 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -71,7 +71,7 @@ class Ui_SongUsageDetailDialog(object): self.report_path_edit = PathEdit(self.file_group_box, path_type=PathEditType.Directories, show_revert=False) self.file_horizontal_layout.addWidget(self.report_path_edit) self.vertical_layout.addWidget(self.file_group_box) - self.button_box = create_button_box(song_usage_detail_dialog, 'button_box', ['cancel', 'ok']) + self.button_box = create_button_box(song_usage_detail_dialog, 'button_box', ['cancel', 'ok', 'help']) self.vertical_layout.addWidget(self.button_box) self.retranslate_ui(song_usage_detail_dialog) self.report_path_edit.pathChanged.connect(song_usage_detail_dialog.on_report_path_edit_path_changed) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 6b335d4b7..0f1ef4004 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -20,7 +20,7 @@ ########################################################################## import logging -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore, QtWidgets, QtGui from sqlalchemy.sql import and_ from openlp.core.common.i18n import translate @@ -119,3 +119,9 @@ class SongUsageDetailForm(QtWidgets.QDialog, Ui_SongUsageDetailDialog, RegistryP 'An error occurred while creating the report: {error}' ).format(error=ose.strerror)) self.close() + + def provide_help(self): + """ + Provide help within the form by opening the appropriate page of the openlp manual in the user's browser + """ + QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/song_usage.html")) diff --git a/tests/openlp_core/ui/test_firsttimeform.py b/tests/openlp_core/ui/test_firsttimeform.py index 51e18deaf..e136c7034 100644 --- a/tests/openlp_core/ui/test_firsttimeform.py +++ b/tests/openlp_core/ui/test_firsttimeform.py @@ -25,7 +25,7 @@ import pytest from pathlib import Path from unittest.mock import MagicMock, call, patch, DEFAULT -from PyQt5 import QtCore, QtWidgets +from PyQt5 import QtCore, QtWidgets, QtTest from openlp.core.common.registry import Registry from openlp.core.ui.firsttimeform import FirstTimeForm, ThemeListWidgetItem @@ -482,3 +482,18 @@ def test_successful_download(mocked_build_icon, mocked_set_icon): # THEN: An icon should have been built from the downloaded file and used to replace the loading icon mocked_build_icon.assert_called_once_with(test_path) mocked_set_icon.assert_has_calls([call(UiIcons().picture), call(mocked_build_icon())]) + + +@patch.object(FirstTimeForm, 'provide_help') +def test_help(mocked_help, settings): + """ + Test the help button + """ + # GIVEN: A First Time Wizard and a patched help function + frw = FirstTimeForm(None) + + # WHEN: The Help button is clicked + QtTest.QTest.mouseClick(frw.button(QtWidgets.QWizard.HelpButton), QtCore.Qt.LeftButton) + + # THEN: The Help function should be called + mocked_help.assert_called_once() diff --git a/tests/openlp_core/ui/test_settingsform.py b/tests/openlp_core/ui/test_settingsform.py index fa891e80f..7b0572b46 100644 --- a/tests/openlp_core/ui/test_settingsform.py +++ b/tests/openlp_core/ui/test_settingsform.py @@ -23,7 +23,7 @@ Package to test the openlp.core.ui.settingsform package. """ from unittest.mock import MagicMock, patch -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets, QtTest from openlp.core.ui.settingsform import SettingsForm @@ -167,3 +167,18 @@ def test_register_post_process(registry): # THEN: The fake function should be in the settings form's list assert fake_function in settings_form.processes + + +@patch.object(SettingsForm, 'provide_help') +def test_help(mocked_help, settings): + """ + Test the help button + """ + # GIVEN: An initialised Settings form and a patched help function + settings_form = SettingsForm(None) + + # WHEN: The Help button is clicked + QtTest.QTest.mouseClick(settings_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton) + + # THEN: The Help function should be called + mocked_help.assert_called_once() diff --git a/tests/openlp_plugins/alerts/forms/test_alertform.py b/tests/openlp_plugins/alerts/forms/test_alertform.py new file mode 100644 index 000000000..0d54738ac --- /dev/null +++ b/tests/openlp_plugins/alerts/forms/test_alertform.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +########################################################################## +# OpenLP - Open Source Lyrics Projection # +# ---------------------------------------------------------------------- # +# Copyright (c) 2008-2021 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, either version 3 of the License, or # +# (at your option) any later version. # +# # +# 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, see . # +########################################################################## +""" +Package to test the openlp.plugins.alerts.forms.alertform package. +""" +from unittest.mock import MagicMock, patch + +from PyQt5 import QtWidgets, QtTest, QtCore + +from openlp.plugins.alerts.forms.alertform import AlertForm + + +@patch.object(AlertForm, 'provide_help') +def test_help(mocked_help, settings): + """ + Test the help button + """ + # GIVEN: An alert form and a patched help function + alert_form = AlertForm(MagicMock()) + + # WHEN: The Help button is clicked + QtTest.QTest.mouseClick(alert_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton) + + # THEN: The Help function should be called + mocked_help.assert_called_once() diff --git a/tests/openlp_plugins/bibles/forms/test_bibleimportform.py b/tests/openlp_plugins/bibles/forms/test_bibleimportform.py index 0e45ce473..23ba774d9 100644 --- a/tests/openlp_plugins/bibles/forms/test_bibleimportform.py +++ b/tests/openlp_plugins/bibles/forms/test_bibleimportform.py @@ -24,7 +24,7 @@ Package to test the openlp.plugins.bibles.forms.bibleimportform package. from unittest import TestCase, skip from unittest.mock import MagicMock, patch -from PyQt5 import QtWidgets +from PyQt5 import QtWidgets, QtTest, QtCore from openlp.core.common.registry import Registry from openlp.plugins.bibles.forms.bibleimportform import BibleImportForm @@ -89,3 +89,17 @@ class TestBibleImportForm(TestCase, TestMixin): # THEN: sword_tab_widget.setDisabled(True) should have been called self.form.sword_tab_widget.setDisabled.assert_called_with(True) + + @patch.object(BibleImportForm, 'provide_help') + def test_help(self, mocked_help, settings): + """ + Test the help button + """ + # GIVEN: A bible import wizard and a patched help function + bible_import_form = BibleImportForm(None, MagicMock(), None) + + # WHEN: The Help button is clicked + QtTest.QTest.mouseClick(bible_import_form.button(QtWidgets.QWizard.HelpButton), QtCore.Qt.LeftButton) + + # THEN: The Help function should be called + mocked_help.assert_called_once() diff --git a/tests/openlp_plugins/bibles/forms/test_editbibleform.py b/tests/openlp_plugins/bibles/forms/test_editbibleform.py new file mode 100644 index 000000000..df918b43e --- /dev/null +++ b/tests/openlp_plugins/bibles/forms/test_editbibleform.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +########################################################################## +# OpenLP - Open Source Lyrics Projection # +# ---------------------------------------------------------------------- # +# Copyright (c) 2008-2021 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, either version 3 of the License, or # +# (at your option) any later version. # +# # +# 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, see . # +########################################################################## +""" +Package to test the openlp.plugins.bibles.forms.editbibleform package. +""" +from unittest.mock import MagicMock, patch + +from PyQt5 import QtWidgets, QtTest, QtCore + +from openlp.plugins.bibles.forms.editbibleform import EditBibleForm + + +@patch.object(EditBibleForm, 'provide_help') +def test_help(mocked_help, settings): + """ + Test the help button + """ + # GIVEN: An edit bible form and a patched help function + main_window = QtWidgets.QMainWindow() + edit_bible_form = EditBibleForm(MagicMock(), main_window, MagicMock()) + + # WHEN: The Help button is clicked + QtTest.QTest.mouseClick(edit_bible_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton) + + # THEN: The Help function should be called + mocked_help.assert_called_once() diff --git a/tests/openlp_plugins/custom/forms/test_customform.py b/tests/openlp_plugins/custom/forms/test_customform.py index ee3d6827b..4759fea79 100644 --- a/tests/openlp_plugins/custom/forms/test_customform.py +++ b/tests/openlp_plugins/custom/forms/test_customform.py @@ -132,3 +132,19 @@ def test_update_slide_list(form): # THEN: The slides should be created in correct order form.slide_list_view.addItems.assert_called_with(['1st Slide', '2nd Slide', '3rd Slide']) + + +@patch.object(EditCustomForm, 'provide_help') +def test_help(mocked_help, settings): + """ + Test the help button + """ + # GIVEN: An edit custom slide form and a patched help function + main_window = QtWidgets.QMainWindow() + custom_form = EditCustomForm(MagicMock(), main_window, MagicMock()) + + # WHEN: The Help button is clicked + QtTest.QTest.mouseClick(custom_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton) + + # THEN: The Help function should be called + mocked_help.assert_called_once() diff --git a/tests/openlp_plugins/songs/forms/test_editsongform.py b/tests/openlp_plugins/songs/forms/test_editsongform.py index 640f3fddd..a95b467ab 100644 --- a/tests/openlp_plugins/songs/forms/test_editsongform.py +++ b/tests/openlp_plugins/songs/forms/test_editsongform.py @@ -22,9 +22,9 @@ Package to test the openlp.plugins.songs.forms.editsongform package. """ import pytest -from unittest.mock import MagicMock +from unittest.mock import MagicMock, patch -from PyQt5 import QtWidgets +from PyQt5 import QtWidgets, QtTest, QtCore from openlp.core.common.i18n import UiStrings from openlp.core.common.registry import Registry @@ -143,3 +143,21 @@ def test_verse_order_lowercase(form): # THEN: The verse order should be converted to uppercase assert form.verse_order_edit.text() == 'V1 V2 C1 V3 C1 V4 C1' + + +@patch.object(EditSongForm, 'provide_help') +def test_help(mocked_help, settings): + """ + Test the help button + """ + # GIVEN: An edit song form and a patched help function + main_window = QtWidgets.QMainWindow() + Registry().register('main_window', main_window) + Registry().register('theme_manager', MagicMock()) + edit_song_form = EditSongForm(MagicMock(), main_window, MagicMock()) + + # WHEN: The Help button is clicked + QtTest.QTest.mouseClick(edit_song_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton) + + # THEN: The Help function should be called + mocked_help.assert_called_once() diff --git a/tests/openlp_plugins/songusage/forms/test_songusagedeleteform.py b/tests/openlp_plugins/songusage/forms/test_songusagedeleteform.py new file mode 100644 index 000000000..3c482d4a2 --- /dev/null +++ b/tests/openlp_plugins/songusage/forms/test_songusagedeleteform.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +########################################################################## +# OpenLP - Open Source Lyrics Projection # +# ---------------------------------------------------------------------- # +# Copyright (c) 2008-2021 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, either version 3 of the License, or # +# (at your option) any later version. # +# # +# 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, see . # +########################################################################## +""" +Package to test the openlp.plugins.songusage.forms.songusagedeleteform package. +""" +from unittest.mock import MagicMock, patch + +from PyQt5 import QtWidgets, QtTest, QtCore + +from openlp.plugins.songusage.forms.songusagedeleteform import SongUsageDeleteForm + + +@patch.object(SongUsageDeleteForm, 'provide_help') +def test_help(mocked_help, settings): + """ + Test the help button + """ + # GIVEN: A songusage delete form and a patched help function + main_window = QtWidgets.QMainWindow() + delete_form = SongUsageDeleteForm(MagicMock(), main_window) + + # WHEN: The Help button is clicked + QtTest.QTest.mouseClick(delete_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton) + + # THEN: The Help function should be called + mocked_help.assert_called_once() diff --git a/tests/openlp_plugins/songusage/forms/test_songusagedetailform.py b/tests/openlp_plugins/songusage/forms/test_songusagedetailform.py new file mode 100644 index 000000000..f24a05025 --- /dev/null +++ b/tests/openlp_plugins/songusage/forms/test_songusagedetailform.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +########################################################################## +# OpenLP - Open Source Lyrics Projection # +# ---------------------------------------------------------------------- # +# Copyright (c) 2008-2021 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, either version 3 of the License, or # +# (at your option) any later version. # +# # +# 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, see . # +########################################################################## +""" +Package to test the openlp.plugins.songusage.forms.songusagedetailform package. +""" +from unittest.mock import MagicMock, patch + +from PyQt5 import QtWidgets, QtTest, QtCore + +from openlp.plugins.songusage.forms.songusagedetailform import SongUsageDetailForm + + +@patch.object(SongUsageDetailForm, 'provide_help') +def test_help(mocked_help, settings): + """ + Test the help button + """ + # GIVEN: A songusage detail form and a patched help function + main_window = QtWidgets.QMainWindow() + detail_form = SongUsageDetailForm(MagicMock(), main_window) + + # WHEN: The Help button is clicked + QtTest.QTest.mouseClick(detail_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton) + + # THEN: The Help function should be called + mocked_help.assert_called_once()