From cd4034ebf117dd064f7e2d18a78910ec48ede407 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 15 Oct 2015 18:56:17 +0100 Subject: [PATCH 01/21] settings --- openlp/core/common/settings.py | 47 ++++------------------------------ 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index 76c1b03cb..9584728cc 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -118,6 +118,7 @@ class Settings(QtCore.QSettings): 'advanced/slide limits': SlideLimits.End, 'advanced/single click preview': False, 'advanced/x11 bypass wm': X11_BYPASS_DEFAULT, + 'advanced/search as type': True, 'crashreport/last directory': '', 'formattingTags/html_tags': '', 'core/audio repeat list': False, @@ -321,48 +322,10 @@ class Settings(QtCore.QSettings): } __file_path__ = '' __obsolete_settings__ = [ - # Changed during 1.9.x development. - ('bibles/bookname language', 'bibles/book name language', []), - ('general/enable slide loop', 'advanced/slide limits', [(SlideLimits.Wrap, True), (SlideLimits.End, False)]), - ('songs/ccli number', 'core/ccli number', []), - ('media/use phonon', '', []), - # Changed during 2.1.x development. - ('advanced/stylesheet fix', '', []), - ('bibles/last directory 1', 'bibles/last directory import', []), - ('media/background color', 'players/background color', []), - ('themes/last directory', 'themes/last directory import', []), - ('themes/last directory 1', 'themes/last directory export', []), - ('songs/last directory 1', 'songs/last directory import', []), - ('songusage/last directory 1', 'songusage/last directory export', []), - ('user interface/mainwindow splitter geometry', 'user interface/main window splitter geometry', []), - ('shortcuts/makeLive', 'shortcuts/make_live', []), - ('general/audio repeat list', 'core/audio repeat list', []), - ('general/auto open', 'core/auto open', []), - ('general/auto preview', 'core/auto preview', []), - ('general/audio start paused', 'core/audio start paused', []), - ('general/auto unblank', 'core/auto unblank', []), - ('general/blank warning', 'core/blank warning', []), - ('general/ccli number', 'core/ccli number', []), - ('general/has run wizard', 'core/has run wizard', []), - ('general/language', 'core/language', []), - ('general/last version test', 'core/last version test', []), - ('general/loop delay', 'core/loop delay', []), - ('general/recent files', 'core/recent files', [(recent_files_conv, None)]), - ('general/save prompt', 'core/save prompt', []), - ('general/screen blank', 'core/screen blank', []), - ('general/show splash', 'core/show splash', []), - ('general/songselect password', 'core/songselect password', []), - ('general/songselect username', 'core/songselect username', []), - ('general/update check', 'core/update check', []), - ('general/view mode', 'core/view mode', []), - ('general/display on monitor', 'core/display on monitor', []), - ('general/override position', 'core/override position', []), - ('general/x position', 'core/x position', []), - ('general/y position', 'core/y position', []), - ('general/monitor', 'core/monitor', []), - ('general/height', 'core/height', []), - ('general/monitor', 'core/monitor', []), - ('general/width', 'core/width', []) + # Changed during 2.2.x development. + #('advanced/stylesheet fix', '', []), + #('general/recent files', 'core/recent files', [(recent_files_conv, None)]), + ('songs/search as type', 'advanced/search as type', []) ] @staticmethod From ccd604b3be139670231636e633142bcb41087055 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 15 Oct 2015 19:00:39 +0100 Subject: [PATCH 02/21] Strings --- openlp/core/common/settings.py | 4 ++-- openlp/core/common/uistrings.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index 9584728cc..41c3d4d0f 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -323,8 +323,8 @@ class Settings(QtCore.QSettings): __file_path__ = '' __obsolete_settings__ = [ # Changed during 2.2.x development. - #('advanced/stylesheet fix', '', []), - #('general/recent files', 'core/recent files', [(recent_files_conv, None)]), + # ('advanced/stylesheet fix', '', []), + # ('general/recent files', 'core/recent files', [(recent_files_conv, None)]), ('songs/search as type', 'advanced/search as type', []) ] diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 8add1a35c..5b230baa6 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -108,8 +108,9 @@ class UiStrings(object): self.NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural') self.NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular') self.NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural') - self.OLPV2 = translate('OpenLP.Ui', 'OpenLP 2') - self.OLPV2x = translate('OpenLP.Ui', 'OpenLP 2.2') + self.OLP = translate('OpenLP.Ui', 'OpenLP') + self.OLPV2 = "%s %s" % (self.OLP, "2") + self.OLPV2x = "%s %s" % (self.OLP, "2.4") self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?') self.OpenService = translate('OpenLP.Ui', 'Open service.') self.PlaySlidesInLoop = translate('OpenLP.Ui', 'Play Slides in Loop') From 925623bf74240e7a9ff97164d2a20b63ed94e794 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 15 Oct 2015 19:03:57 +0100 Subject: [PATCH 03/21] core_int --- openlp/core/__init__.py | 50 ++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index fa6f59a4d..fd45f6933 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -30,7 +30,7 @@ logging and a plugin framework are contained within the openlp.core module. import os import sys import logging -from optparse import OptionParser +import argparse from traceback import format_exception import shutil import time @@ -274,7 +274,7 @@ class OpenLP(OpenLPMixin, QtGui.QApplication): return QtGui.QApplication.event(self, event) -def parse_options(args): +def parse_options(): """ Parse the command line arguments @@ -282,19 +282,23 @@ def parse_options(args): :return: a tuple of parsed options of type optparse.Value and a list of remaining argsZ """ # Set up command line options. - usage = 'Usage: %prog [options] [qt-options]' - parser = OptionParser(usage=usage) - parser.add_option('-e', '--no-error-form', dest='no_error_form', action='store_true', - help='Disable the error notification form.') - parser.add_option('-l', '--log-level', dest='loglevel', default='warning', metavar='LEVEL', - help='Set logging to LEVEL level. Valid values are "debug", "info", "warning".') - parser.add_option('-p', '--portable', dest='portable', action='store_true', - help='Specify if this should be run as a portable app, off a USB flash drive (not implemented).') - parser.add_option('-d', '--dev-version', dest='dev_version', action='store_true', - help='Ignore the version file and pull the version directly from Bazaar') - parser.add_option('-s', '--style', dest='style', help='Set the Qt4 style (passed directly to Qt4).') + parser = argparse.ArgumentParser(prog='openlp.py') + parser.add_argument('-e', '--no-error-form', dest='no_error_form', action='store_true', + help='Disable the error notification form.') + parser.add_argument('-l', '--log-level', dest='loglevel', default='warning', metavar='LEVEL', + help='Set logging to LEVEL level. Valid values are "debug", "info", "warning".') + parser.add_argument('-p', '--portable', dest='portable', action='store_true', + help='Specify if this should be run as a portable app, off a USB flash drive (not implemented).') + parser.add_argument('-d', '--dev-version', dest='dev_version', action='store_true', + help='Ignore the version file and pull the version directly from Bazaar') + parser.add_argument('-s', '--style', dest='style', help='Set the Qt4 style (passed directly to Qt4).') + parser.add_argument('rargs', nargs='?', default=[]) # Parse command line options and deal with them. Use args supplied pragmatically if possible. - return parser.parse_args(args) if args else parser.parse_args() + try: + return_args = parser.parse_args() + except: + return_args = None + return return_args def set_up_logging(log_path): @@ -312,24 +316,24 @@ def set_up_logging(log_path): print('Logging to: %s' % filename) -def main(args=None): +def main(): """ The main function which parses command line options and then runs :param args: Some args """ - (options, args) = parse_options(args) + args = parse_options() qt_args = [] - if options.loglevel.lower() in ['d', 'debug']: + if args and args.loglevel.lower() in ['d', 'debug']: log.setLevel(logging.DEBUG) - elif options.loglevel.lower() in ['w', 'warning']: + elif args and args.loglevel.lower() in ['w', 'warning']: log.setLevel(logging.WARNING) else: log.setLevel(logging.INFO) - if options.style: - qt_args.extend(['-style', options.style]) + if args and args.style: + qt_args.extend(['-style', args.style]) # Throw the rest of the arguments at Qt, just in case. - qt_args.extend(args) + qt_args.extend(args.rargs) # Bug #1018855: Set the WM_CLASS property in X11 if not is_win() and not is_macosx(): qt_args.append('OpenLP') @@ -339,7 +343,7 @@ def main(args=None): application = OpenLP(qt_args) application.setOrganizationName('OpenLP') application.setOrganizationDomain('openlp.org') - if options.portable: + if args and args.portable: application.setApplicationName('OpenLPPortable') Settings.setDefaultFormat(Settings.IniFormat) # Get location OpenLPPortable.ini @@ -383,6 +387,6 @@ def main(args=None): application.installTranslator(default_translator) else: log.debug('Could not find default_translator.') - if not options.no_error_form: + if args and not args.no_error_form: sys.excepthook = application.hook_exception sys.exit(application.run(qt_args)) From 8be1450eaea9ed5b0f2460983358bd1b9650dd60 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 15 Oct 2015 19:06:16 +0100 Subject: [PATCH 04/21] core_int_test --- tests/functional/openlp_core/test_init.py | 145 ++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 tests/functional/openlp_core/test_init.py diff --git a/tests/functional/openlp_core/test_init.py b/tests/functional/openlp_core/test_init.py new file mode 100644 index 000000000..623221f7d --- /dev/null +++ b/tests/functional/openlp_core/test_init.py @@ -0,0 +1,145 @@ +# -*- 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 # +############################################################################### + +import sys +from unittest import TestCase + +from openlp.core import parse_options +from tests.helpers.testmixin import TestMixin + + +class TestInitFunctions(TestMixin, TestCase): + + def parse_options_basic_test(self): + """ + Test the parse options process works + + """ + # GIVEN: a a set of system arguments. + sys.argv[1:] = [] + # WHEN: We we parse them to expand to options + args = parse_options() + # THEN: the following fields will have been extracted. + self.assertFalse(args.dev_version, 'The dev_version flag should be False') + self.assertEquals(args.loglevel, 'warning', 'The log level should be set to warning') + self.assertFalse(args.no_error_form, 'The no_error_form should be set to False') + self.assertFalse(args.portable, 'The portable flag should be set to false') + self.assertEquals(args.style, None, 'There are no style flags to be processed') + self.assertEquals(args.rargs, [], 'The service file should be blank') + + def parse_options_debug_test(self): + """ + Test the parse options process works for debug only + + """ + # GIVEN: a a set of system arguments. + sys.argv[1:] = ['-l debug'] + # WHEN: We we parse them to expand to options + args = parse_options() + # THEN: the following fields will have been extracted. + self.assertFalse(args.dev_version, 'The dev_version flag should be False') + self.assertEquals(args.loglevel, ' debug', 'The log level should be set to debug') + self.assertFalse(args.no_error_form, 'The no_error_form should be set to False') + self.assertFalse(args.portable, 'The portable flag should be set to false') + self.assertEquals(args.style, None, 'There are no style flags to be processed') + self.assertEquals(args.rargs, [], 'The service file should be blank') + + def parse_options_debug_and_portable_test(self): + """ + Test the parse options process works for debug and portable + + """ + # GIVEN: a a set of system arguments. + sys.argv[1:] = ['--portable'] + # WHEN: We we parse them to expand to options + args = parse_options() + # THEN: the following fields will have been extracted. + self.assertFalse(args.dev_version, 'The dev_version flag should be False') + self.assertEquals(args.loglevel, 'warning', 'The log level should be set to warning') + self.assertFalse(args.no_error_form, 'The no_error_form should be set to False') + self.assertTrue(args.portable, 'The portable flag should be set to true') + self.assertEquals(args.style, None, 'There are no style flags to be processed') + self.assertEquals(args.rargs, [], 'The service file should be blank') + + def parse_options_all_no_file_test(self): + """ + Test the parse options process works with two options + + """ + # GIVEN: a a set of system arguments. + sys.argv[1:] = ['-l debug', '-d'] + # WHEN: We we parse them to expand to options + args = parse_options() + # THEN: the following fields will have been extracted. + self.assertTrue(args.dev_version, 'The dev_version flag should be True') + self.assertEquals(args.loglevel, ' debug', 'The log level should be set to debug') + self.assertFalse(args.no_error_form, 'The no_error_form should be set to False') + self.assertFalse(args.portable, 'The portable flag should be set to false') + self.assertEquals(args.style, None, 'There are no style flags to be processed') + self.assertEquals(args.rargs, [], 'The service file should be blank') + + def parse_options_file_test(self): + """ + Test the parse options process works with a file + + """ + # GIVEN: a a set of system arguments. + sys.argv[1:] = ['dummy_temp'] + # WHEN: We we parse them to expand to options + args = parse_options() + # THEN: the following fields will have been extracted. + self.assertFalse(args.dev_version, 'The dev_version flag should be False') + self.assertEquals(args.loglevel, 'warning', 'The log level should be set to warning') + self.assertFalse(args.no_error_form, 'The no_error_form should be set to False') + self.assertFalse(args.portable, 'The portable flag should be set to false') + self.assertEquals(args.style, None, 'There are no style flags to be processed') + self.assertEquals(args.rargs, 'dummy_temp', 'The service file should not be blank') + + def parse_options_file_and_debug_test(self): + """ + Test the parse options process works with a file + + """ + # GIVEN: a a set of system arguments. + sys.argv[1:] = ['-l debug', 'dummy_temp'] + # WHEN: We we parse them to expand to options + args = parse_options() + # THEN: the following fields will have been extracted. + self.assertFalse(args.dev_version, 'The dev_version flag should be False') + self.assertEquals(args.loglevel, ' debug', 'The log level should be set to debug') + self.assertFalse(args.no_error_form, 'The no_error_form should be set to False') + self.assertFalse(args.portable, 'The portable flag should be set to false') + self.assertEquals(args.style, None, 'There are no style flags to be processed') + self.assertEquals(args.rargs, 'dummy_temp', 'The service file should not be blank') + + def parse_options_two_files_test(self): + """ + Test the parse options process works with a file + + """ + # GIVEN: a a set of system arguments. + sys.argv[1:] = ['dummy_temp', 'dummy_temp2'] + # WHEN: We we parse them to expand to options + args = parse_options() + # THEN: the following fields will have been extracted. + self.assertEquals(args, None, 'The args should be None') + From 3bc0dbe4d9b7c93614ee4456aa1ee20cc743798e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 15 Oct 2015 19:15:55 +0100 Subject: [PATCH 05/21] func test pass --- .../functional/openlp_core_utils/test_init.py | 2 +- tests/functional/test_init.py | 57 ------------------- 2 files changed, 1 insertion(+), 58 deletions(-) diff --git a/tests/functional/openlp_core_utils/test_init.py b/tests/functional/openlp_core_utils/test_init.py index 2bf28923a..9a6f9fc39 100644 --- a/tests/functional/openlp_core_utils/test_init.py +++ b/tests/functional/openlp_core_utils/test_init.py @@ -25,7 +25,7 @@ Package to test the openlp.core.utils.actions package. from unittest import TestCase from openlp.core.common.settings import Settings -from openlp.core.utils import VersionThread, get_application_version, get_uno_command +from openlp.core.utils import VersionThread, get_uno_command from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin diff --git a/tests/functional/test_init.py b/tests/functional/test_init.py index b0c289b54..d3a9dff6e 100644 --- a/tests/functional/test_init.py +++ b/tests/functional/test_init.py @@ -132,60 +132,3 @@ class TestInit(TestCase, TestMixin): # 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!') - - @patch(u'openlp.core.OptionParser') - def parse_options_test(self, MockedOptionParser): - """ - Test that parse_options sets up OptionParser correctly and parses the options given - """ - # GIVEN: A list of valid options and a mocked out OptionParser object - options = ['-e', '-l', 'debug', '-pd', '-s', 'style', 'extra', 'qt', 'args'] - mocked_parser = MagicMock() - MockedOptionParser.return_value = mocked_parser - expected_calls = [ - call('-e', '--no-error-form', dest='no_error_form', action='store_true', - help='Disable the error notification form.'), - call('-l', '--log-level', dest='loglevel', default='warning', metavar='LEVEL', - help='Set logging to LEVEL level. Valid values are "debug", "info", "warning".'), - call('-p', '--portable', dest='portable', action='store_true', - help='Specify if this should be run as a portable app, off a USB flash drive (not implemented).'), - call('-d', '--dev-version', dest='dev_version', action='store_true', - help='Ignore the version file and pull the version directly from Bazaar'), - call('-s', '--style', dest='style', help='Set the Qt4 style (passed directly to Qt4).') - ] - - # WHEN: Calling parse_options - parse_options(options) - - # THEN: A tuple should be returned with the parsed options and left over options - MockedOptionParser.assert_called_with(usage='Usage: %prog [options] [qt-options]') - self.assertEquals(expected_calls, mocked_parser.add_option.call_args_list) - mocked_parser.parse_args.assert_called_with(options) - - @patch(u'openlp.core.OptionParser') - def parse_options_from_sys_argv_test(self, MockedOptionParser): - """ - Test that parse_options sets up OptionParser correctly and parses sys.argv - """ - # GIVEN: A list of valid options and a mocked out OptionParser object - mocked_parser = MagicMock() - MockedOptionParser.return_value = mocked_parser - expected_calls = [ - call('-e', '--no-error-form', dest='no_error_form', action='store_true', - help='Disable the error notification form.'), - call('-l', '--log-level', dest='loglevel', default='warning', metavar='LEVEL', - help='Set logging to LEVEL level. Valid values are "debug", "info", "warning".'), - call('-p', '--portable', dest='portable', action='store_true', - help='Specify if this should be run as a portable app, off a USB flash drive (not implemented).'), - call('-d', '--dev-version', dest='dev_version', action='store_true', - help='Ignore the version file and pull the version directly from Bazaar'), - call('-s', '--style', dest='style', help='Set the Qt4 style (passed directly to Qt4).') - ] - - # WHEN: Calling parse_options - parse_options([]) - - # THEN: A tuple should be returned with the parsed options and left over options - MockedOptionParser.assert_called_with(usage='Usage: %prog [options] [qt-options]') - self.assertEquals(expected_calls, mocked_parser.add_option.call_args_list) - mocked_parser.parse_args.assert_called_with() From 9ea1cab296f44026838e5ed3f316128b21c59dd3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 15 Oct 2015 19:21:04 +0100 Subject: [PATCH 06/21] code fix --- tests/functional/test_init.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/functional/test_init.py b/tests/functional/test_init.py index d3a9dff6e..d13958a58 100644 --- a/tests/functional/test_init.py +++ b/tests/functional/test_init.py @@ -33,7 +33,6 @@ from openlp.core.common import Settings from tests.helpers.testmixin import TestMixin from tests.functional import MagicMock, patch, call - TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'resources')) From 58124c01d2145e030ea73e8566e8c3d512dd87bf Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 16 Oct 2015 17:09:35 +0100 Subject: [PATCH 07/21] 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') + From a5b8827c9613fcfdf368183a7e9a82be69b2df2f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 16 Oct 2015 17:17:38 +0100 Subject: [PATCH 08/21] Pep 8 --- openlp/core/__init__.py | 3 ++- tests/functional/openlp_core/test_init.py | 3 +-- tests/functional/openlp_core_ui/test_advancedtab.py | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index fd45f6933..04268619e 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -288,7 +288,8 @@ def parse_options(): parser.add_argument('-l', '--log-level', dest='loglevel', default='warning', metavar='LEVEL', help='Set logging to LEVEL level. Valid values are "debug", "info", "warning".') parser.add_argument('-p', '--portable', dest='portable', action='store_true', - help='Specify if this should be run as a portable app, off a USB flash drive (not implemented).') + help='Specify if this should be run as a portable app, ' + 'off a USB flash drive (not implemented).') parser.add_argument('-d', '--dev-version', dest='dev_version', action='store_true', help='Ignore the version file and pull the version directly from Bazaar') parser.add_argument('-s', '--style', dest='style', help='Set the Qt4 style (passed directly to Qt4).') diff --git a/tests/functional/openlp_core/test_init.py b/tests/functional/openlp_core/test_init.py index 623221f7d..8ae42b990 100644 --- a/tests/functional/openlp_core/test_init.py +++ b/tests/functional/openlp_core/test_init.py @@ -31,7 +31,7 @@ class TestInitFunctions(TestMixin, TestCase): def parse_options_basic_test(self): """ - Test the parse options process works + Test the parse options process works """ # GIVEN: a a set of system arguments. @@ -142,4 +142,3 @@ class TestInitFunctions(TestMixin, TestCase): args = parse_options() # THEN: the following fields will have been extracted. self.assertEquals(args, None, 'The args should be None') - diff --git a/tests/functional/openlp_core_ui/test_advancedtab.py b/tests/functional/openlp_core_ui/test_advancedtab.py index dc316b454..72f135818 100644 --- a/tests/functional/openlp_core_ui/test_advancedtab.py +++ b/tests/functional/openlp_core_ui/test_advancedtab.py @@ -67,4 +67,3 @@ class TestAdvancedTab(TestCase, TestMixin): 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') - From 742e0c912b96dfc238e5a66cf1a43b0bf6b5455b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 16 Oct 2015 17:26:01 +0100 Subject: [PATCH 09/21] Plug item --- openlp/core/lib/plugin.py | 8 +------- openlp/core/lib/serviceitem.py | 7 +------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 8a54f08f0..05b4164bf 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -288,13 +288,7 @@ class Plugin(QtCore.QObject, RegistryProperties): """ Perform tasks on application startup """ - # FIXME: Remove after 2.2 release. - # This is needed to load the list of media/presentation from the config saved before the settings rewrite. - if self.media_item_class is not None and self.name != 'images': - loaded_list = Settings().get_files_from_config(self) - # Now save the list to the config using our Settings class. - if loaded_list: - Settings().setValue('%s/%s files' % (self.settings_section, self.name), loaded_list) + pass def uses_theme(self, theme): """ diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 445eb079a..229bcd403 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -129,7 +129,7 @@ class ItemCapabilities(object): OnLoadUpdate = 8 AddIfNewItem = 9 ProvidesOwnDisplay = 10 - HasDetailedTitleDisplay = 11 + #HasDetailedTitleDisplay = 11 HasVariableStartTime = 12 CanSoftBreak = 13 CanWordSplit = 14 @@ -415,11 +415,6 @@ class ServiceItem(RegistryProperties): self.will_auto_start = header.get('will_auto_start', False) self.processor = header.get('processor', None) self.has_original_files = True - # TODO: Remove me in 2,3 build phase - if self.is_capable(ItemCapabilities.HasDetailedTitleDisplay): - self.capabilities.remove(ItemCapabilities.HasDetailedTitleDisplay) - self.processor = self.title - self.title = None if 'background_audio' in header: self.background_audio = [] for filename in header['background_audio']: From 6b605737408b3503d1d3d959ce0fc8d1f1dae884 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 16 Oct 2015 17:30:13 +0100 Subject: [PATCH 10/21] UI changes --- openlp/core/lib/serviceitem.py | 2 +- openlp/core/ui/mainwindow.py | 30 +++++++++++++----------------- openlp/core/ui/plugindialog.py | 2 +- openlp/core/ui/printserviceform.py | 2 +- openlp/core/ui/thememanager.py | 19 +++++++++++++------ 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 229bcd403..873dee902 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -129,7 +129,7 @@ class ItemCapabilities(object): OnLoadUpdate = 8 AddIfNewItem = 9 ProvidesOwnDisplay = 10 - #HasDetailedTitleDisplay = 11 + # HasDetailedTitleDisplay = 11 HasVariableStartTime = 12 CanSoftBreak = 13 CanWordSplit = 14 diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 1e02c2394..10c67e79a 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -389,7 +389,7 @@ class Ui_MainWindow(object): 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')) - self.recent_files_menu.setTitle(translate('OpenLP.MainWindow', '&Recent Files')) + self.recent_files_menu.setTitle(translate('OpenLP.MainWindow', '&Recent Services')) self.view_menu.setTitle(translate('OpenLP.MainWindow', '&View')) self.view_mode_menu.setTitle(translate('OpenLP.MainWindow', 'M&ode')) self.tools_menu.setTitle(translate('OpenLP.MainWindow', '&Tools')) @@ -400,16 +400,16 @@ class Ui_MainWindow(object): self.service_manager_dock.setWindowTitle(translate('OpenLP.MainWindow', 'Service Manager')) self.theme_manager_dock.setWindowTitle(translate('OpenLP.MainWindow', 'Theme Manager')) self.projector_manager_dock.setWindowTitle(translate('OpenLP.MainWindow', 'Projector Manager')) - self.file_new_item.setText(translate('OpenLP.MainWindow', '&New')) + self.file_new_item.setText(translate('OpenLP.MainWindow', '&New Service')) self.file_new_item.setToolTip(UiStrings().NewService) self.file_new_item.setStatusTip(UiStrings().CreateService) - self.file_open_item.setText(translate('OpenLP.MainWindow', '&Open')) + self.file_open_item.setText(translate('OpenLP.MainWindow', '&Open Service')) self.file_open_item.setToolTip(UiStrings().OpenService) self.file_open_item.setStatusTip(translate('OpenLP.MainWindow', 'Open an existing service.')) - self.file_save_item.setText(translate('OpenLP.MainWindow', '&Save')) + self.file_save_item.setText(translate('OpenLP.MainWindow', '&Save Service')) self.file_save_item.setToolTip(UiStrings().SaveService) self.file_save_item.setStatusTip(translate('OpenLP.MainWindow', 'Save the current service to disk.')) - self.file_save_as_item.setText(translate('OpenLP.MainWindow', 'Save &As...')) + self.file_save_as_item.setText(translate('OpenLP.MainWindow', 'Save Service &As...')) self.file_save_as_item.setToolTip(translate('OpenLP.MainWindow', 'Save Service As')) self.file_save_as_item.setStatusTip(translate('OpenLP.MainWindow', 'Save the current service under a new name.')) @@ -456,7 +456,7 @@ class Ui_MainWindow(object): self.lock_panel.setText(translate('OpenLP.MainWindow', 'L&ock Panels')) self.lock_panel.setStatusTip(translate('OpenLP.MainWindow', 'Prevent the panels being moved.')) self.view_live_panel.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the live panel.')) - self.settings_plugin_list_item.setText(translate('OpenLP.MainWindow', '&Plugin List')) + self.settings_plugin_list_item.setText(translate('OpenLP.MainWindow', '&Manage Plugins')) self.settings_plugin_list_item.setStatusTip(translate('OpenLP.MainWindow', 'List the Plugins')) self.about_item.setText(translate('OpenLP.MainWindow', '&About')) self.about_item.setStatusTip(translate('OpenLP.MainWindow', 'More information about OpenLP')) @@ -505,7 +505,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): super(MainWindow, self).__init__() Registry().register('main_window', self) self.clipboard = self.application.clipboard() - self.arguments = self.application.args + self.arguments = ''.join(self.application.args) # Set up settings sections for the main application (not for use by plugins). self.ui_settings_section = 'user interface' self.general_settings_section = 'core' @@ -634,7 +634,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): self.live_controller.display.setFocus() self.activateWindow() if self.arguments: - self.open_cmd_line_files() + self.open_cmd_line_files(self.arguments) elif Settings().value(self.general_settings_section + '/auto open'): self.service_manager_contents.load_last_file() view_mode = Settings().value('%s/view mode' % self.general_settings_section) @@ -1416,15 +1416,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): settings.remove('advanced/data path') self.application.set_normal_cursor() - def open_cmd_line_files(self): + def open_cmd_line_files(self, filename): """ Open files passed in through command line arguments """ - args = [] - for a in self.arguments: - args.extend([a]) - for filename in args: - if not isinstance(filename, str): - filename = str(filename, sys.getfilesystemencoding()) - if filename.endswith(('.osz', '.oszl')): - self.service_manager_contents.load_file(filename) + if not isinstance(filename, str): + filename = str(filename, sys.getfilesystemencoding()) + if filename.endswith(('.osz', '.oszl')): + self.service_manager_contents.load_file(filename) diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index a1d067203..6146730d9 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -78,7 +78,7 @@ class Ui_PluginViewDialog(object): """ Translate the UI on the fly """ - pluginViewDialog.setWindowTitle(translate('OpenLP.PluginForm', 'Plugin List')) + pluginViewDialog.setWindowTitle(translate('OpenLP.PluginForm', 'Manage Plugins')) self.plugin_info_group_box.setTitle(translate('OpenLP.PluginForm', 'Plugin Details')) self.version_label.setText('%s:' % UiStrings().Version) self.about_label.setText('%s:' % UiStrings().About) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 05e60b911..d1c47fbef 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -162,7 +162,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog, RegistryProperties) html_data = self._add_element('html') self._add_element('head', parent=html_data) self._add_element('title', self.title_line_edit.text(), html_data.head) - css_path = os.path.join(AppLocation.get_data_path(), 'service_print.css') + css_path = os.path.join(AppLocation.get_data_path(), 'serviceprint', 'service_print.css') custom_css = get_text_file_string(css_path) if not custom_css: custom_css = DEFAULT_CSS diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index e4e07214c..33fc614b0 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -755,12 +755,19 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R return False # check for use in the system else where. if test_plugin: + plugin_usage = "" for plugin in self.plugin_manager.plugins: - if plugin.uses_theme(theme): - critical_error_message_box(translate('OpenLP.ThemeManager', 'Validation Error'), - translate('OpenLP.ThemeManager', - 'Theme %s is used in the %s plugin.') - % (theme, plugin.name)) - return False + used_count = plugin.uses_theme(theme) + if used_count: + plugin_usage = "%s%s" % (plugin_usage, (translate('OpenLP.ThemeManager', + '%s time(s) by %s') % + (used_count, plugin.name))) + plugin_usage = "%s\n" % plugin_usage + if plugin_usage: + critical_error_message_box(translate('OpenLP.ThemeManager', 'Unable to delete theme'), + translate('OpenLP.ThemeManager', 'Theme is currently used \n\n%s') % + plugin_usage) + + return False return True return False From ff5513f630088c929cae522fafd6f9a7dd5e8ad7 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 16 Oct 2015 17:33:33 +0100 Subject: [PATCH 11/21] add test --- tests/functional/openlp_core_ui/test_mainwindow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_core_ui/test_mainwindow.py b/tests/functional/openlp_core_ui/test_mainwindow.py index b912d488a..440fd275c 100644 --- a/tests/functional/openlp_core_ui/test_mainwindow.py +++ b/tests/functional/openlp_core_ui/test_mainwindow.py @@ -71,7 +71,7 @@ class TestMainWindow(TestCase, TestMixin): with patch('openlp.core.ui.servicemanager.ServiceManager.load_file') as mocked_load_path: # WHEN the argument is processed - self.main_window.open_cmd_line_files() + self.main_window.open_cmd_line_files(service) # THEN the service from the arguments is loaded mocked_load_path.assert_called_with(service), 'load_path should have been called with the service\'s path' @@ -86,7 +86,7 @@ class TestMainWindow(TestCase, TestMixin): with patch('openlp.core.ui.servicemanager.ServiceManager.load_file') as mocked_load_path: # WHEN the argument is processed - self.main_window.open_cmd_line_files() + self.main_window.open_cmd_line_files("") # THEN the file should not be opened assert not mocked_load_path.called, 'load_path should not have been called' From ae1124f8bde59eab7c4f4b1d6492c5b7a1daf2b2 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 16 Oct 2015 17:38:39 +0100 Subject: [PATCH 12/21] bible --- openlp/plugins/bibles/bibleplugin.py | 8 +++++--- openlp/plugins/bibles/lib/db.py | 10 ---------- openlp/plugins/bibles/lib/manager.py | 5 ----- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 59203e682..e95cc0875 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -178,12 +178,14 @@ class BiblePlugin(Plugin): def uses_theme(self, theme): """ - Called to find out if the bible plugin is currently using a theme. Returns ``True`` if the theme is being used, - otherwise returns ``False``. + Called to find out if the bible plugin is currently using a theme. Returns ``1`` if the theme is being used, + otherwise returns ``0``. :param theme: The theme """ - return str(self.settings_tab.bible_theme) == theme + if str(self.settings_tab.bible_theme) == theme: + return 1 + return 0 def rename_theme(self, old_theme, new_theme): """ diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 1f5986ad7..e6ca14027 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -476,16 +476,6 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): self.save_meta('language_id', language_id) return language_id - def is_old_database(self): - """ - Returns ``True`` if it is a bible database, which has been created prior to 1.9.6. - """ - try: - self.session.query(Book).all() - except: - return True - return False - def dump_bible(self): """ Utility debugging method to dump the contents of a bible. diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 742671ac1..8b7cfa18e 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -129,11 +129,6 @@ class BibleManager(RegistryProperties): bible.session.close() delete_file(os.path.join(self.path, filename)) continue - # Find old database versions. - if bible.is_old_database(): - self.old_bible_databases.append([filename, name]) - bible.session.close() - continue log.debug('Bible Name: "%s"', name) self.db_cache[name] = bible # Look to see if lazy load bible exists and get create getter. From e8f08443396f2438ec9a36cb49ebe41f6ba0a232 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 16 Oct 2015 17:43:48 +0100 Subject: [PATCH 13/21] custom --- openlp/plugins/custom/customplugin.py | 6 ++---- openlp/plugins/custom/lib/mediaitem.py | 12 +++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index e2087b92a..4f0741266 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -72,11 +72,9 @@ class CustomPlugin(Plugin): """ Called to find out if the custom plugin is currently using a theme. - Returns True if the theme is being used, otherwise returns False. + Returns count of the times the theme is used. """ - if self.db_manager.get_all_objects(CustomSlide, CustomSlide.theme_name == theme): - return True - return False + return len(self.db_manager.get_all_objects(CustomSlide, CustomSlide.theme_name == theme)) def rename_theme(self, old_theme, new_theme): """ diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index dc0411ad8..d01b5b1a4 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -85,6 +85,7 @@ class CustomMediaItem(MediaManagerItem): """ log.debug('Config loaded') self.add_custom_from_service = Settings().value(self.settings_section + '/add custom from service') + self.search_as_you_type = Settings().value('advanced/search as type') def retranslateUi(self): """ @@ -269,11 +270,12 @@ class CustomMediaItem(MediaManagerItem): :param text: The search text """ - search_length = 2 - if len(text) > search_length: - self.on_search_text_button_clicked() - elif not text: - self.on_clear_text_button_click() + if self.search_as_you_type: + search_length = 2 + if len(text) > search_length: + self.on_search_text_button_clicked() + elif not text: + self.on_clear_text_button_click() def service_load(self, item): """ From 9590de703aa12c425b0f36bf1bbec305043bc515 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 16 Oct 2015 17:49:58 +0100 Subject: [PATCH 14/21] plugins again --- openlp/plugins/images/imageplugin.py | 25 +------------------ openlp/plugins/images/lib/mediaitem.py | 16 ++++++------ .../presentations/presentationplugin.py | 16 ------------ 3 files changed, 9 insertions(+), 48 deletions(-) diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 743c20ad9..a1a09854f 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -67,36 +67,13 @@ class ImagePlugin(Plugin): 'provided by the theme.') return about_text - def app_startup(self): - """ - Perform tasks on application startup. - """ - # TODO: Can be removed when the upgrade path from 2.0.x to 2.2.x is no longer needed - Plugin.app_startup(self) - # Convert old settings-based image list to the database. - files_from_config = Settings().get_files_from_config(self) - if files_from_config: - for file in files_from_config: - filename = os.path.split(file)[1] - thumb = os.path.join(self.media_item.service_path, filename) - try: - os.remove(thumb) - except: - pass - log.debug('Importing images list from old config: %s' % files_from_config) - self.media_item.save_new_images_list(files_from_config) - def upgrade_settings(self, settings): """ Upgrade the settings of this plugin. :param settings: The Settings object containing the old settings. """ - # TODO: Can be removed when the upgrade path from 2.0.x to 2.2.x is no longer needed - files_from_config = settings.get_files_from_config(self) - if files_from_config: - log.debug('Importing images list from old config: %s' % files_from_config) - self.media_item.save_new_images_list(files_from_config) + pass def set_plugin_text_strings(self): """ diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 31e39c655..e2e1d26e8 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -119,14 +119,6 @@ class ImageMediaItem(MediaManagerItem): icon=':/general/general_edit.png', triggers=self.on_edit_click) create_widget_action(self.list_view, separator=True) - if self.has_delete_icon: - create_widget_action( - self.list_view, - 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Delete.title()), - text=self.plugin.get_string(StringContent.Delete)['title'], - icon=':/general/general_delete.png', - can_shortcuts=True, triggers=self.on_delete_click) - create_widget_action(self.list_view, separator=True) create_widget_action( self.list_view, 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Preview.title()), @@ -155,6 +147,14 @@ class ImageMediaItem(MediaManagerItem): text=translate('OpenLP.MediaManagerItem', '&Add to selected Service Item'), icon=':/general/general_add.png', triggers=self.on_add_edit_click) + create_widget_action(self.list_view, separator=True) + if self.has_delete_icon: + create_widget_action( + self.list_view, + 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Delete.title()), + text=self.plugin.get_string(StringContent.Delete)['title'], + icon=':/general/general_delete.png', + can_shortcuts=True, triggers=self.on_delete_click) self.add_custom_context_actions() # Create the context menu and add all actions from the list_view. self.menu = QtGui.QMenu() diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 361df514c..b2118ce46 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -137,22 +137,6 @@ class PresentationPlugin(Plugin): self.register_controllers(controller) return bool(self.controllers) - def app_startup(self): - """ - Perform tasks on application startup. - """ - # TODO: Can be removed when the upgrade path from 2.0.x to 2.2.x is no longer needed - super().app_startup() - files_from_config = Settings().value('presentations/presentations files') - for file in files_from_config: - try: - self.media_item.clean_up_thumbnails(file, True) - except AttributeError: - pass - self.media_item.list_view.clear() - Settings().setValue('presentations/thumbnail_scheme', 'md5') - self.media_item.validate_and_load(files_from_config) - def about(self): """ Return information about this plugin. From 375884b1bb96526a8acd5337ea42a06ff1063373 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 16 Oct 2015 17:58:22 +0100 Subject: [PATCH 15/21] Songs --- openlp/plugins/remotes/html/openlp.js | 8 +++++++- openlp/plugins/songs/forms/editsongform.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 4 ++-- openlp/plugins/songs/lib/openlyricsxml.py | 12 +----------- openlp/plugins/songs/lib/songstab.py | 8 -------- openlp/plugins/songs/songsplugin.py | 7 ++----- 6 files changed, 13 insertions(+), 28 deletions(-) diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index aac244dd5..9bf34a1cc 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -271,9 +271,15 @@ window.OpenLP = { if (typeof value[0] !== "number"){ value[0] = OpenLP.escapeString(value[0]) } + var txt = ""; + if (value[2].length > 0) { + txt = value[1] + " ( " + value[2] + " )"; + } else { + txt = value[1]; + } ul.append($("
  • ").append($("").attr("href", "#options") .attr("data-rel", "dialog").attr("value", value[0]) - .click(OpenLP.showOptions).text(value[1]))); + .click(OpenLP.showOptions).text(txt))); }); } ul.listview("refresh"); diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index d617d4941..6be8cb52c 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -178,7 +178,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): if invalid_verses: valid = create_separated_list(verse_names) if len(invalid_verses) > 1: - msg = translate('SongsPlugin.EditSongForm', 'There are no verses corresponding to "%(invalid)s".' + msg = translate('SongsPlugin.EditSongForm', 'There are no verses corresponding to "%(invalid)s". ' 'Valid entries are %(valid)s.\nPlease enter the verses separated by spaces.') % \ {'invalid': ', '.join(invalid_verses), 'valid': valid} else: diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index c0c58ff90..75f8f54fd 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -115,7 +115,7 @@ class SongMediaItem(MediaManagerItem): Is triggered when the songs config is updated """ log.debug('config_updated') - self.search_as_you_type = Settings().value(self.settings_section + '/search as type') + self.search_as_you_type = Settings().value('advanced/search as type') self.update_service_on_edit = Settings().value(self.settings_section + '/update service on edit') self.add_song_from_service = Settings().value(self.settings_section + '/add song from service') self.display_songbook = Settings().value(self.settings_section + '/display songbook') @@ -590,4 +590,4 @@ class SongMediaItem(MediaManagerItem): :param show_error: Is this an error? """ search_results = self.search_entire(string) - return [[song.id, song.title] for song in search_results] + return [[song.id, song.title, song.alternate_title] for song in search_results] diff --git a/openlp/plugins/songs/lib/openlyricsxml.py b/openlp/plugins/songs/lib/openlyricsxml.py index 13be57350..5c6951dfd 100644 --- a/openlp/plugins/songs/lib/openlyricsxml.py +++ b/openlp/plugins/songs/lib/openlyricsxml.py @@ -121,17 +121,7 @@ class SongXML(object): """ self.song_xml = None verse_list = [] - if not xml.startswith('') - self.lyrics = etree.SubElement(self.song_xml, 'lyrics') - verses = xml.split('\n\n') - for count, verse in enumerate(verses): - verse_list.append([{'type': 'v', 'label': str(count)}, str(verse)]) - self.add_verse_to_lyrics('v', str(count), verse) - return verse_list - elif xml.startswith(' Date: Sat, 17 Oct 2015 19:11:04 +0100 Subject: [PATCH 17/21] Refactor tests --- tests/utils/test_bzr_tags.py | 42 +++++++++--------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py index 0ea353a49..34158d85c 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_bzr_tags.py @@ -23,39 +23,13 @@ Package to test for proper bzr tags. """ import os -import re from unittest import TestCase from subprocess import Popen, PIPE -TAGS = [ - ['1.9.0', '1'], - ['1.9.1', '775'], - ['1.9.2', '890'], - ['1.9.3', '1063'], - ['1.9.4', '1196'], - ['1.9.5', '1421'], - ['1.9.6', '1657'], - ['1.9.7', '1761'], - ['1.9.8', '1856'], - ['1.9.9', '1917'], - ['1.9.10', '2003'], - ['1.9.11', '2039'], - ['1.9.12', '2063'], - ['2.0', '2118'], - ['2.1.0', '2119'], - ['2.1.1', '2438'], - ['2.1.2', '2488'], - ['2.1.3', '2513'], - ['2.1.4', '2532'], - ['2.1.5', '2543'], - ['2.1.6', '2550'], - ['2.2', '2562'] -] -# Depending on the repository, we sometimes have the 2.0.x tags in the repo too. They come up with a revision number of -# "?", which I suspect is due to the fact that we're using shared repositories. This regular expression matches all -# 2.0.x tags. -TAG_SEARCH = re.compile('2\.0\.\d') +TAGS1 = {'1.9.0', '1.9.1', '1.9.2', '1.9.3', '1.9.4', '1.9.5', '1.9.6', '1.9.7', '1.9.8', '1.9.9', '1.9.10', + '1.9.11', '1.9.12', '2.0', '2.1.0', '2.1.1', '2.1.2', '2.1.3', '2.1.4', '2.1.5', '2.1.6', '2.2' + } class TestBzrTags(TestCase): @@ -70,8 +44,12 @@ class TestBzrTags(TestCase): # WHEN getting the branches tags bzr = Popen(('bzr', 'tags', '--directory=' + path), stdout=PIPE) std_out = bzr.communicate()[0] - tags = [line.decode('utf-8').split() for line in std_out.splitlines()] - tags = [t_r for t_r in tags if t_r[1] != '?' or not (t_r[1] == '?' and TAG_SEARCH.search(t_r[0]))] + count = len(TAGS1) + tags = [line.decode('utf-8').split()[0] for line in std_out.splitlines()] + count1 = 0 + for t in tags: + if t in TAGS1: + count1 += 1 # THEN the tags should match the accepted tags - self.assertEqual(TAGS, tags, 'List of tags should match') + self.assertEqual(count, count1, 'List of tags should match') From a197e92f7d642ff7b82ba91880abc0f2b9e70607 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 22 Oct 2015 17:23:40 +0100 Subject: [PATCH 18/21] Missing strings --- openlp/plugins/remotes/lib/httprouter.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/remotes/lib/httprouter.py b/openlp/plugins/remotes/lib/httprouter.py index d12898514..000d743cd 100644 --- a/openlp/plugins/remotes/lib/httprouter.py +++ b/openlp/plugins/remotes/lib/httprouter.py @@ -309,10 +309,13 @@ class HttpRouter(RegistryProperties): """ Translate various strings in the mobile app. """ + remote = translate('RemotePlugin.Mobile', 'Remote') + stage = translate('RemotePlugin.Mobile', 'Stage View') + live = translate('RemotePlugin.Mobile', 'Live View') self.template_vars = { - 'app_title': translate('RemotePlugin.Mobile', 'OpenLP 2.2 Remote'), - 'stage_title': translate('RemotePlugin.Mobile', 'OpenLP 2.2 Stage View'), - 'live_title': translate('RemotePlugin.Mobile', 'OpenLP 2.2 Live View'), + 'app_title': "%s %s" % (UiStrings().OLPV2x, remote), + 'stage_title': "%s %s" % (UiStrings().OLPV2x, stage), + 'live_title': "%s %s" % (UiStrings().OLPV2x, live), 'service_manager': translate('RemotePlugin.Mobile', 'Service Manager'), 'slide_controller': translate('RemotePlugin.Mobile', 'Slide Controller'), 'alerts': translate('RemotePlugin.Mobile', 'Alerts'), From 89d9d7d73a80ba9897a7f5ffb4aacc9632665112 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 28 Oct 2015 21:21:05 +0000 Subject: [PATCH 19/21] replace code removed in error --- openlp/core/__init__.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 04268619e..4734fa0c5 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -274,7 +274,7 @@ class OpenLP(OpenLPMixin, QtGui.QApplication): return QtGui.QApplication.event(self, event) -def parse_options(): +def parse_options(args): """ Parse the command line arguments @@ -295,11 +295,7 @@ def parse_options(): parser.add_argument('-s', '--style', dest='style', help='Set the Qt4 style (passed directly to Qt4).') parser.add_argument('rargs', nargs='?', default=[]) # Parse command line options and deal with them. Use args supplied pragmatically if possible. - try: - return_args = parser.parse_args() - except: - return_args = None - return return_args + return parser.parse_args(args) if args else parser.parse_args() def set_up_logging(log_path): @@ -317,13 +313,13 @@ def set_up_logging(log_path): print('Logging to: %s' % filename) -def main(): +def main(args=None): """ The main function which parses command line options and then runs :param args: Some args """ - args = parse_options() + args = parse_options(args) qt_args = [] if args and args.loglevel.lower() in ['d', 'debug']: log.setLevel(logging.DEBUG) From d165010aaaa311f9f90e80783b7d83e252bed6fc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 2 Nov 2015 20:52:22 +0000 Subject: [PATCH 20/21] minor fix ups --- openlp/core/ui/plugindialog.py | 22 +++++++++++----------- openlp/plugins/custom/lib/mediaitem.py | 4 ++-- openlp/plugins/songs/lib/mediaitem.py | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index 6146730d9..aa7284981 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -33,21 +33,21 @@ class Ui_PluginViewDialog(object): """ The UI of the plugin view dialog """ - def setupUi(self, pluginViewDialog): + def setupUi(self, plugin_view_dialog): """ Set up the UI """ - pluginViewDialog.setObjectName('pluginViewDialog') - pluginViewDialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) - pluginViewDialog.setWindowModality(QtCore.Qt.ApplicationModal) - self.plugin_layout = QtGui.QVBoxLayout(pluginViewDialog) + plugin_view_dialog.setObjectName('plugin_view_dialog') + plugin_view_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) + plugin_view_dialog.setWindowModality(QtCore.Qt.ApplicationModal) + self.plugin_layout = QtGui.QVBoxLayout(plugin_view_dialog) self.plugin_layout.setObjectName('plugin_layout') self.list_layout = QtGui.QHBoxLayout() self.list_layout.setObjectName('list_layout') - self.plugin_list_widget = QtGui.QListWidget(pluginViewDialog) + self.plugin_list_widget = QtGui.QListWidget(plugin_view_dialog) self.plugin_list_widget.setObjectName('plugin_list_widget') self.list_layout.addWidget(self.plugin_list_widget) - self.plugin_info_group_box = QtGui.QGroupBox(pluginViewDialog) + self.plugin_info_group_box = QtGui.QGroupBox(plugin_view_dialog) self.plugin_info_group_box.setObjectName('plugin_info_group_box') self.plugin_info_layout = QtGui.QFormLayout(self.plugin_info_group_box) self.plugin_info_layout.setObjectName('plugin_info_layout') @@ -70,15 +70,15 @@ class Ui_PluginViewDialog(object): self.plugin_info_layout.addRow(self.about_label, self.about_text_browser) self.list_layout.addWidget(self.plugin_info_group_box) self.plugin_layout.addLayout(self.list_layout) - self.button_box = create_button_box(pluginViewDialog, 'button_box', ['ok']) + self.button_box = create_button_box(plugin_view_dialog, 'button_box', ['ok']) self.plugin_layout.addWidget(self.button_box) - self.retranslateUi(pluginViewDialog) + self.retranslateUi(plugin_view_dialog) - def retranslateUi(self, pluginViewDialog): + def retranslateUi(self, plugin_view_dialog): """ Translate the UI on the fly """ - pluginViewDialog.setWindowTitle(translate('OpenLP.PluginForm', 'Manage Plugins')) + plugin_view_dialog.setWindowTitle(translate('OpenLP.PluginForm', 'Manage Plugins')) self.plugin_info_group_box.setTitle(translate('OpenLP.PluginForm', 'Plugin Details')) self.version_label.setText('%s:' % UiStrings().Version) self.about_label.setText('%s:' % UiStrings().About) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index d01b5b1a4..a2799618e 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -85,7 +85,7 @@ class CustomMediaItem(MediaManagerItem): """ log.debug('Config loaded') self.add_custom_from_service = Settings().value(self.settings_section + '/add custom from service') - self.search_as_you_type = Settings().value('advanced/search as type') + self.is_search_as_you_type_enabled = Settings().value('advanced/search as type') def retranslateUi(self): """ @@ -270,7 +270,7 @@ class CustomMediaItem(MediaManagerItem): :param text: The search text """ - if self.search_as_you_type: + if self.is_search_as_you_type_enabled: search_length = 2 if len(text) > search_length: self.on_search_text_button_clicked() diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 75f8f54fd..a45e9ed38 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -115,7 +115,7 @@ class SongMediaItem(MediaManagerItem): Is triggered when the songs config is updated """ log.debug('config_updated') - self.search_as_you_type = Settings().value('advanced/search as type') + self.is_search_as_you_type_enabled = Settings().value('advanced/search as type') self.update_service_on_edit = Settings().value(self.settings_section + '/update service on edit') self.add_song_from_service = Settings().value(self.settings_section + '/add song from service') self.display_songbook = Settings().value(self.settings_section + '/display songbook') @@ -279,7 +279,7 @@ class SongMediaItem(MediaManagerItem): If search as type enabled invoke the search on each key press. If the Lyrics are being searched do not start till 7 characters have been entered. """ - if self.search_as_you_type: + if self.is_search_as_you_type_enabled: search_length = 1 if self.search_text_edit.current_search_type() == SongSearch.Entire: search_length = 4 From a888a4a4aa036a1a4dcbee13f07d476d9f9238ed Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 4 Nov 2015 18:37:06 +0000 Subject: [PATCH 21/21] more missed --- openlp/core/ui/advancedtab.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index d7e3084a3..d93515cd3 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -354,8 +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) + self.is_search_as_you_type_enabled = settings.value('search as type') + self.search_as_type_check_box.setChecked(self.is_search_as_you_type_enabled) # 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')) @@ -431,11 +431,11 @@ 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.setValue('search as type', self.is_search_as_you_type_enabled) settings.endGroup() def on_search_as_type_check_box_changed(self, check_state): - self.search_as_you_type = (check_state == QtCore.Qt.Checked) + self.is_search_as_you_type_enabled = (check_state == QtCore.Qt.Checked) self.settings_form.register_post_process('songs_config_updated') self.settings_form.register_post_process('custom_config_updated')