code and settings test done

This commit is contained in:
robbiejackson 2021-08-18 18:59:29 +01:00
parent e048348890
commit cdc1234ebb
4 changed files with 39 additions and 1 deletions

View File

@ -156,6 +156,7 @@ class Settings(QtCore.QSettings):
'advanced/ignore aspect ratio': False, 'advanced/ignore aspect ratio': False,
'advanced/is portable': False, 'advanced/is portable': False,
'advanced/max recent files': 20, 'advanced/max recent files': 20,
'advanced/new service message': True,
'advanced/print file meta data': False, 'advanced/print file meta data': False,
'advanced/print notes': False, 'advanced/print notes': False,
'advanced/print slide text': False, 'advanced/print slide text': False,

View File

@ -33,7 +33,6 @@ from openlp.core.ui.style import HAS_DARK_STYLE
from openlp.core.widgets.buttons import ColorButton from openlp.core.widgets.buttons import ColorButton
from openlp.core.widgets.edits import PathEdit from openlp.core.widgets.edits import PathEdit
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -41,6 +40,7 @@ class GeneralTab(SettingsTab):
""" """
GeneralTab is the general settings tab in the settings dialog. GeneralTab is the general settings tab in the settings dialog.
""" """
def __init__(self, parent): def __init__(self, parent):
""" """
Initialise the general settings tab Initialise the general settings tab
@ -166,6 +166,9 @@ class GeneralTab(SettingsTab):
self.enable_auto_close_check_box = QtWidgets.QCheckBox(self.ui_group_box) self.enable_auto_close_check_box = QtWidgets.QCheckBox(self.ui_group_box)
self.enable_auto_close_check_box.setObjectName('enable_auto_close_check_box') self.enable_auto_close_check_box.setObjectName('enable_auto_close_check_box')
self.ui_layout.addRow(self.enable_auto_close_check_box) self.ui_layout.addRow(self.enable_auto_close_check_box)
self.new_service_message_check_box = QtWidgets.QCheckBox(self.ui_group_box)
self.new_service_message_check_box.setObjectName('new_service_message_check_box')
self.ui_layout.addRow(self.new_service_message_check_box)
if not is_win() and HAS_DARK_STYLE: if not is_win() and HAS_DARK_STYLE:
self.use_dark_style_checkbox = QtWidgets.QCheckBox(self.ui_group_box) self.use_dark_style_checkbox = QtWidgets.QCheckBox(self.ui_group_box)
self.use_dark_style_checkbox.setObjectName('use_dark_style_checkbox') self.use_dark_style_checkbox.setObjectName('use_dark_style_checkbox')
@ -245,6 +248,8 @@ class GeneralTab(SettingsTab):
self.enable_auto_close_check_box.setText(translate('OpenLP.AdvancedTab', self.enable_auto_close_check_box.setText(translate('OpenLP.AdvancedTab',
'Enable application exit confirmation')) 'Enable application exit confirmation'))
self.slide_no_in_footer_checkbox.setText(translate('SongsPlugin.GeneralTab', 'Include slide number in footer')) self.slide_no_in_footer_checkbox.setText(translate('SongsPlugin.GeneralTab', 'Include slide number in footer'))
self.new_service_message_check_box.setText(translate('OpenLP.AdvancedTab',
'Alert if New clicked on blank service'))
self.search_as_type_check_box.setText(translate('SongsPlugin.GeneralTab', 'Enable search as you type')) self.search_as_type_check_box.setText(translate('SongsPlugin.GeneralTab', 'Enable search as you type'))
if not is_win() and HAS_DARK_STYLE: if not is_win() and HAS_DARK_STYLE:
self.use_dark_style_checkbox.setText(translate('OpenLP.AdvancedTab', 'Use dark style (needs restart)')) self.use_dark_style_checkbox.setText(translate('OpenLP.AdvancedTab', 'Use dark style (needs restart)'))
@ -285,6 +290,7 @@ class GeneralTab(SettingsTab):
self.autoscroll_combo_box.setCurrentIndex(i) self.autoscroll_combo_box.setCurrentIndex(i)
self.enable_auto_close_check_box.setChecked(self.settings.value('advanced/enable exit confirmation')) self.enable_auto_close_check_box.setChecked(self.settings.value('advanced/enable exit confirmation'))
self.slide_no_in_footer_checkbox.setChecked(self.settings.value('advanced/slide numbers in footer')) self.slide_no_in_footer_checkbox.setChecked(self.settings.value('advanced/slide numbers in footer'))
self.new_service_message_check_box.setChecked(self.settings.value('advanced/new service message'))
if not is_win() and HAS_DARK_STYLE: if not is_win() and HAS_DARK_STYLE:
self.use_dark_style_checkbox.setChecked(self.settings.value('advanced/use_dark_style')) self.use_dark_style_checkbox.setChecked(self.settings.value('advanced/use_dark_style'))
self.hide_mouse_check_box.setChecked(self.settings.value('advanced/hide mouse')) self.hide_mouse_check_box.setChecked(self.settings.value('advanced/hide mouse'))
@ -317,6 +323,7 @@ class GeneralTab(SettingsTab):
self.settings.setValue('advanced/autoscrolling', self.autoscroll_map[self.autoscroll_combo_box.currentIndex()]) self.settings.setValue('advanced/autoscrolling', self.autoscroll_map[self.autoscroll_combo_box.currentIndex()])
self.settings.setValue('advanced/slide numbers in footer', self.slide_no_in_footer_checkbox.isChecked()) self.settings.setValue('advanced/slide numbers in footer', self.slide_no_in_footer_checkbox.isChecked())
self.settings.setValue('advanced/enable exit confirmation', self.enable_auto_close_check_box.isChecked()) self.settings.setValue('advanced/enable exit confirmation', self.enable_auto_close_check_box.isChecked())
self.settings.setValue('advanced/new service message', self.new_service_message_check_box.isChecked())
self.settings.setValue('advanced/hide mouse', self.hide_mouse_check_box.isChecked()) self.settings.setValue('advanced/hide mouse', self.hide_mouse_check_box.isChecked())
self.settings.setValue('advanced/search as type', self.is_search_as_you_type_enabled) self.settings.setValue('advanced/search as type', self.is_search_as_you_type_enabled)
if not is_win() and HAS_DARK_STYLE: if not is_win() and HAS_DARK_STYLE:

View File

@ -442,6 +442,18 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
elif result == QtWidgets.QMessageBox.Save: elif result == QtWidgets.QMessageBox.Save:
if not self.decide_save_method(): if not self.decide_save_method():
return False return False
if not self.service_items and self.settings.value('advanced/new service message'):
do_not_show_again = QtWidgets.QCheckBox(translate('OpenLP.Ui', 'Do not show this message again'), None)
message_box = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Information,
translate('OpenLP.Ui', 'Create a new service.'),
translate('OpenLP.Ui', 'You already have a blank new service.\n'
'Add some items to it then press Save'),
QtWidgets.QMessageBox.Ok,
self)
message_box.setCheckBox(do_not_show_again)
message_box.exec()
if message_box.checkBox().isChecked():
self.settings.setValue('advanced/new service message', False)
self.new_file() self.new_file()
def on_load_service_clicked(self, checked): def on_load_service_clicked(self, checked):

View File

@ -74,3 +74,21 @@ def test_slide_numbers_in_footer(settings):
# THEN: the settings should be updated # THEN: the settings should be updated
assert settings.value('advanced/slide numbers in footer') is True assert settings.value('advanced/slide numbers in footer') is True
def test_new_service_message(settings):
"""
Test that when the new service message option is changed then the settings are updated
"""
# GIVEN: Settings, a settings form and a general tab
settings.setValue('advanced/new service message', True)
settings_form = SettingsForm(None)
general_tab = GeneralTab(settings_form)
settings_form.insert_tab(general_tab, is_visible=True)
# WHEN: I click the checkbox and then save
QtTest.QTest.mouseClick(general_tab.new_service_message_check_box, QtCore.Qt.LeftButton)
settings_form.accept()
# THEN: the settings should be updated
assert settings.value('advanced/new service message') is False