From 58124c01d2145e030ea73e8566e8c3d512dd87bf Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 16 Oct 2015 17:09:35 +0100 Subject: [PATCH] Add advanced --- openlp/core/ui/advancedtab.py | 13 ++++ .../openlp_core_ui/test_advancedtab.py | 70 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 tests/functional/openlp_core_ui/test_advancedtab.py diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index bd727f44d..d7e3084a3 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -80,6 +80,9 @@ class AdvancedTab(SettingsTab): self.expand_service_item_check_box = QtGui.QCheckBox(self.ui_group_box) self.expand_service_item_check_box.setObjectName('expand_service_item_check_box') self.ui_layout.addRow(self.expand_service_item_check_box) + self.search_as_type_check_box = QtGui.QCheckBox(self.ui_group_box) + self.search_as_type_check_box.setObjectName('SearchAsType_check_box') + self.ui_layout.addRow(self.search_as_type_check_box) self.enable_auto_close_check_box = QtGui.QCheckBox(self.ui_group_box) self.enable_auto_close_check_box.setObjectName('enable_auto_close_check_box') self.ui_layout.addRow(self.enable_auto_close_check_box) @@ -251,6 +254,7 @@ class AdvancedTab(SettingsTab): self.end_slide_radio_button.clicked.connect(self.on_end_slide_button_clicked) self.wrap_slide_radio_button.clicked.connect(self.on_wrap_slide_button_clicked) self.next_item_radio_button.clicked.connect(self.on_next_item_button_clicked) + self.search_as_type_check_box.stateChanged.connect(self.on_search_as_type_check_box_changed) def retranslateUi(self): """ @@ -319,6 +323,7 @@ class AdvancedTab(SettingsTab): self.end_slide_radio_button.setText(translate('OpenLP.GeneralTab', '&Remain on Slide')) self.wrap_slide_radio_button.setText(translate('OpenLP.GeneralTab', '&Wrap around')) self.next_item_radio_button.setText(translate('OpenLP.GeneralTab', '&Move to next/previous service item')) + self.search_as_type_check_box.setText(translate('SongsPlugin.GeneralTab', 'Enable search as you type')) def load(self): """ @@ -349,6 +354,8 @@ class AdvancedTab(SettingsTab): self.default_color = settings.value('default color') self.default_file_edit.setText(settings.value('default image')) self.slide_limits = settings.value('slide limits') + self.search_as_you_type = settings.value('search as type') + self.search_as_type_check_box.setChecked(self.search_as_you_type) # Prevent the dialog displayed by the alternate_rows_check_box to display. self.alternate_rows_check_box.blockSignals(True) self.alternate_rows_check_box.setChecked(settings.value('alternate rows')) @@ -424,8 +431,14 @@ class AdvancedTab(SettingsTab): settings.setValue('x11 bypass wm', self.x11_bypass_check_box.isChecked()) self.settings_form.register_post_process('config_screen_changed') self.settings_form.register_post_process('slidecontroller_update_slide_limits') + settings.setValue('search as type', self.search_as_you_type) settings.endGroup() + def on_search_as_type_check_box_changed(self, check_state): + self.search_as_you_type = (check_state == QtCore.Qt.Checked) + self.settings_form.register_post_process('songs_config_updated') + self.settings_form.register_post_process('custom_config_updated') + def cancel(self): """ Dialogue was cancelled, remove any pending data path change. diff --git a/tests/functional/openlp_core_ui/test_advancedtab.py b/tests/functional/openlp_core_ui/test_advancedtab.py new file mode 100644 index 000000000..dc316b454 --- /dev/null +++ b/tests/functional/openlp_core_ui/test_advancedtab.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2015 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.advancedtab package. +""" +from unittest import TestCase + +from openlp.core.common import Registry +from openlp.core.ui.advancedtab import AdvancedTab +from openlp.core.ui.settingsform import SettingsForm + +from tests.helpers.testmixin import TestMixin + + +class TestAdvancedTab(TestCase, TestMixin): + + def setUp(self): + """ + Set up a few things for the tests + """ + Registry.create() + + def test_creation(self): + """ + Test that Advanced Tab is created. + """ + # GIVEN: A new Advanced Tab + settings_form = SettingsForm(None) + + # WHEN: I create an advanced tab + advanced_tab = AdvancedTab(settings_form) + + # THEN: + self.assertEqual("Advanced", advanced_tab.tab_title, 'The tab title should be Advanced') + + def test_change_search_as_type(self): + """ + Test that when search as type is changed custom and song configs are updated + """ + # GIVEN: A new Advanced Tab + settings_form = SettingsForm(None) + advanced_tab = AdvancedTab(settings_form) + + # WHEN: I change search as type check box + advanced_tab.on_search_as_type_check_box_changed(True) + + # THEN: we should have two post save processed to run + self.assertEqual(2, len(settings_form.processes), 'Two post save processes should be created') + self.assertTrue("songs_config_updated" in settings_form.processes, 'The songs plugin should be called') + self.assertTrue("custom_config_updated" in settings_form.processes, 'The custom plugin should be called') +