From 12f71b3eecabd0c835b3b6105d5bde72c8b463ce Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Mon, 4 Jan 2016 01:01:23 +0100 Subject: [PATCH 01/22] Add coveragerc --- .bzrignore | 1 + .coveragerc | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 .coveragerc diff --git a/.bzrignore b/.bzrignore index 272c37e88..68fa826de 100644 --- a/.bzrignore +++ b/.bzrignore @@ -43,3 +43,4 @@ __pycache__ .coverage cover *.kdev4 +coverage diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..f8f529f44 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[run] +source = openlp + +[html] +directory = coverage From 4206d11228e19112a17c5645521da2e505ea6e55 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Mon, 4 Jan 2016 01:18:01 +0100 Subject: [PATCH 02/22] Make methods static where possible --- openlp/plugins/alerts/alertsplugin.py | 9 ++++++--- openlp/plugins/bibles/bibleplugin.py | 3 ++- openlp/plugins/custom/customplugin.py | 3 ++- openlp/plugins/images/imageplugin.py | 3 ++- openlp/plugins/media/mediaplugin.py | 3 ++- openlp/plugins/presentations/presentationplugin.py | 3 ++- openlp/plugins/remotes/remoteplugin.py | 3 ++- openlp/plugins/songs/songsplugin.py | 6 ++++-- openlp/plugins/songusage/songusageplugin.py | 5 +++-- 9 files changed, 25 insertions(+), 13 deletions(-) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 9e1f44613..14b1f7805 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -191,7 +191,8 @@ class AlertsPlugin(Plugin): self.alert_form.load_list() self.alert_form.exec() - def about(self): + @staticmethod + def about(): """ Plugin Alerts about method @@ -215,7 +216,8 @@ class AlertsPlugin(Plugin): 'title': translate('AlertsPlugin', 'Alerts', 'container title') } - def get_display_javascript(self): + @staticmethod + def get_display_javascript(): """ Add Javascript to the main display. """ @@ -229,7 +231,8 @@ class AlertsPlugin(Plugin): return CSS % (align, self.settings_tab.font_face, self.settings_tab.font_size, self.settings_tab.font_color, self.settings_tab.background_color) - def get_display_html(self): + @staticmethod + def get_display_html(): """ Add HTML to the main display. """ diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 022790c58..289f8cc32 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -167,7 +167,8 @@ class BiblePlugin(Plugin): if self.media_item: self.media_item.on_import_click() - def about(self): + @staticmethod + def about(): """ Return the about text for the plugin manager """ diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index c5412199d..d9b3369af 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -62,7 +62,8 @@ class CustomPlugin(Plugin): self.icon_path = ':/plugins/plugin_custom.png' self.icon = build_icon(self.icon_path) - def about(self): + @staticmethod + def about(): about_text = translate('CustomPlugin', 'Custom Slide Plugin
The custom slide plugin ' 'provides the ability to set up custom text slides that can be displayed on the screen ' 'the same way songs are. This plugin provides greater freedom over the songs plugin.') diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 4ec0f9c2b..f3b84943d 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -53,7 +53,8 @@ class ImagePlugin(Plugin): self.icon_path = ':/plugins/plugin_images.png' self.icon = build_icon(self.icon_path) - def about(self): + @staticmethod + def about(): about_text = translate('ImagePlugin', 'Image Plugin' '
The image plugin provides displaying of images.
One ' 'of the distinguishing features of this plugin is the ability to ' diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 8c83acfef..a1e54a132 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -84,7 +84,8 @@ class MediaPlugin(Plugin): visible_name = self.get_string(StringContent.VisibleName) self.settings_tab = MediaTab(parent, self.name, visible_name['title'], self.icon_path) - def about(self): + @staticmethod + def about(): """ Return the about text for the plugin manager """ diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 0d5dde029..e076922cd 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -137,7 +137,8 @@ class PresentationPlugin(Plugin): self.register_controllers(controller) return bool(self.controllers) - def about(self): + @staticmethod + def about(): """ Return information about this plugin. """ diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 27bf6f16f..0d093fab5 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -88,7 +88,8 @@ class RemotesPlugin(Plugin): self.server.stop_server() self.server = None - def about(self): + @staticmethod + def about(): """ Information about this plugin """ diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 1dc486182..ba35f8be9 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -211,7 +211,8 @@ class SongsPlugin(Plugin): if self.media_item: self.media_item.on_export_click() - def about(self): + @staticmethod + def about(): """ Provides information for the plugin manager to display. @@ -343,7 +344,8 @@ class SongsPlugin(Plugin): for song in songs: self.manager.delete_object(Song, song.id) - def _count_songs(self, db_file): + @staticmethod + def _count_songs(db_file): """ Provide a count of the songs in the database diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 0bf8ed9a5..b433d96e0 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -226,8 +226,9 @@ class SongUsagePlugin(Plugin): """ self.song_usage_detail_form.initialise() self.song_usage_detail_form.exec() - - def about(self): + + @staticmethod + def about(): """ The plugin about text From 8121f77e2d8b1c40a817d13985be2a2f0d8ef1b8 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Mon, 4 Jan 2016 01:27:56 +0100 Subject: [PATCH 03/22] Add test for about() function of SongUsagePlugin --- .../openlp_plugins/songusage/__init__.py | 24 ++++++++++++ .../songusage/test_songusage.py | 37 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 tests/functional/openlp_plugins/songusage/__init__.py create mode 100644 tests/functional/openlp_plugins/songusage/test_songusage.py diff --git a/tests/functional/openlp_plugins/songusage/__init__.py b/tests/functional/openlp_plugins/songusage/__init__.py new file mode 100644 index 000000000..917bf47cd --- /dev/null +++ b/tests/functional/openlp_plugins/songusage/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2016 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 # +############################################################################### +""" +Tests for the Songusage plugin +""" diff --git a/tests/functional/openlp_plugins/songusage/test_songusage.py b/tests/functional/openlp_plugins/songusage/test_songusage.py new file mode 100644 index 000000000..25f6cd5ac --- /dev/null +++ b/tests/functional/openlp_plugins/songusage/test_songusage.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2016 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 # +############################################################################### +""" +This module contains tests for the Songusage plugin. +""" +from unittest import TestCase +from openlp.plugins.songusage.songusageplugin import SongUsagePlugin + +class TestSongUsage(TestCase): + + def test_about_text(self): + # GIVEN: The SongUsagePlugin + # WHEN: Retrieving the about text + # THEN: about() should return a string object + self.assertIsInstance(SongUsagePlugin.about(), str) + # THEN: about() should return a non-empty string + self.assertNotEquals(len(SongUsagePlugin.about()), 0) + self.assertNotEquals(len(SongUsagePlugin.about()), 0) From 7ed23514b4cf2f3bf75d117c0a51d83375d1177d Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Mon, 4 Jan 2016 01:28:13 +0100 Subject: [PATCH 04/22] Add test for about() function of MediaPlugin --- tests/functional/openlp_plugins/media/test_mediaplugin.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/functional/openlp_plugins/media/test_mediaplugin.py b/tests/functional/openlp_plugins/media/test_mediaplugin.py index 10e1852d6..99fa61f82 100644 --- a/tests/functional/openlp_plugins/media/test_mediaplugin.py +++ b/tests/functional/openlp_plugins/media/test_mediaplugin.py @@ -57,3 +57,11 @@ class MediaPluginTest(TestCase, TestMixin): mocked_settings.get_files_from_config.assert_called_with(media_plugin) mocked_settings.setValue.assert_called_with('media/media files', True) mocked_initialise.assert_called_with() + + def test_about_text(self): + # GIVEN: The MediaPlugin + # WHEN: Retrieving the about text + # THEN: about() should return a string object + self.assertIsInstance(MediaPlugin.about(), str) + # THEN: about() should return a non-empty string + self.assertNotEquals(len(MediaPlugin.about()), 0) From c467c321b475ba08ea75a3ed8cbfb2a9c2a985af Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Mon, 4 Jan 2016 13:21:58 +0100 Subject: [PATCH 05/22] Make methods static that don't need to rely on instance data --- openlp/core/lib/renderer.py | 12 ++++--- openlp/core/ui/servicemanager.py | 23 +++++++------ openlp/plugins/songs/forms/songexportform.py | 16 +++++---- .../songs/lib/importers/foilpresenter.py | 33 ++++++++++--------- openlp/plugins/songs/songsplugin.py | 2 +- 5 files changed, 47 insertions(+), 39 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 5273493ed..a0dc14117 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -273,7 +273,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): except ValueError: text_to_render = text.split('\n[---]\n')[0] text = '' - text_to_render, raw_tags, html_tags = self._get_start_tags(text_to_render) + text_to_render, raw_tags, html_tags = Renderer._get_start_tags(text_to_render) if text: text = raw_tags + text else: @@ -441,7 +441,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): previous_raw = line + line_end continue # Figure out how many words of the line will fit on screen as the line will not fit as a whole. - raw_words = self._words_split(line) + raw_words = Renderer._words_split(line) html_words = list(map(expand_tags, raw_words)) previous_html, previous_raw = \ self._binary_chop(formatted, previous_html, previous_raw, html_words, raw_words, ' ', line_end) @@ -451,7 +451,8 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): formatted.append(previous_raw) return formatted - def _get_start_tags(self, raw_text): + @staticmethod + def _get_start_tags(raw_text): """ Tests the given text for not closed formatting tags and returns a tuple consisting of three unicode strings:: @@ -521,7 +522,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): if smallest_index == index or highest_index == index: index = smallest_index text = previous_raw.rstrip('
') + separator.join(raw_list[:index + 1]) - text, raw_tags, html_tags = self._get_start_tags(text) + text, raw_tags, html_tags = Renderer._get_start_tags(text) formatted.append(text) previous_html = '' previous_raw = '' @@ -556,7 +557,8 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): self.web_frame.evaluateJavaScript('show_text("%s")' % text.replace('\\', '\\\\').replace('\"', '\\\"')) return self.web_frame.contentsSize().height() <= self.empty_height - def _words_split(self, line): + @staticmethod + def _words_split(line): """ Split the slide up by word so can wrap better diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 6cb53ab67..06005bb60 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -144,8 +144,8 @@ class Ui_ServiceManager(object): self.service_manager_list.customContextMenuRequested.connect(self.context_menu) self.service_manager_list.setObjectName('service_manager_list') # enable drop - self.service_manager_list.__class__.dragEnterEvent = self.drag_enter_event - self.service_manager_list.__class__.dragMoveEvent = self.drag_enter_event + self.service_manager_list.__class__.dragEnterEvent = Ui_ServiceManager.drag_enter_event + self.service_manager_list.__class__.dragMoveEvent = Ui_ServiceManager.drag_enter_event self.service_manager_list.__class__.dropEvent = self.drop_event self.layout.addWidget(self.service_manager_list) # Add the bottom toolbar @@ -293,7 +293,8 @@ class Ui_ServiceManager(object): Registry().register_function('theme_update_global', self.theme_change) Registry().register_function('mediaitem_suffix_reset', self.reset_supported_suffixes) - def drag_enter_event(self, event): + @staticmethod + def drag_enter_event(event): """ Accept Drag events @@ -1585,7 +1586,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa if item is None: end_pos = len(self.service_items) else: - end_pos = self._get_parent_item_data(item) - 1 + end_pos = ServiceManager._get_parent_item_data(item) - 1 service_item = self.service_items[start_pos] self.service_items.remove(service_item) self.service_items.insert(end_pos, service_item) @@ -1598,21 +1599,21 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa self.drop_position = len(self.service_items) else: # we are over something so lets investigate - pos = self._get_parent_item_data(item) - 1 + pos = ServiceManager._get_parent_item_data(item) - 1 service_item = self.service_items[pos] if (plugin == service_item['service_item'].name and service_item['service_item'].is_capable(ItemCapabilities.CanAppend)): action = self.dnd_menu.exec(QtGui.QCursor.pos()) # New action required if action == self.new_action: - self.drop_position = self._get_parent_item_data(item) + self.drop_position = ServiceManager._get_parent_item_data(item) # Append to existing action if action == self.add_to_action: - self.drop_position = self._get_parent_item_data(item) + self.drop_position = ServiceManager._get_parent_item_data(item) item.setSelected(True) replace = True else: - self.drop_position = self._get_parent_item_data(item) - 1 + self.drop_position = ServiceManager._get_parent_item_data(item) - 1 Registry().execute('%s_add_service_item' % plugin, replace) def update_theme_list(self, theme_list): @@ -1656,7 +1657,8 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa self.service_items[item]['service_item'].update_theme(theme) self.regenerate_service_items(True) - def _get_parent_item_data(self, item): + @staticmethod + def _get_parent_item_data(item): """ Finds and returns the parent item for any item @@ -1668,7 +1670,8 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa else: return parent_item.data(0, QtCore.Qt.UserRole) - def print_service_order(self, field=None): + @staticmethod + def print_service_order(field=None): """ Print a Service Order Sheet. """ diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 337720794..b9ff2d2f6 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -72,7 +72,7 @@ class SongExportForm(OpenLPWizard): """ Song wizard specific signals. """ - self.available_list_widget.itemActivated.connect(self.on_item_activated) + self.available_list_widget.itemActivated.connect(SongExportForm.on_item_activated) self.search_line_edit.textEdited.connect(self.on_search_line_edit_changed) self.uncheck_button.clicked.connect(self.on_uncheck_button_clicked) self.check_button.clicked.connect(self.on_check_button_clicked) @@ -172,7 +172,7 @@ class SongExportForm(OpenLPWizard): return True elif self.currentPage() == self.available_songs_page: items = [ - item for item in self._find_list_widget_items(self.available_list_widget) if item.checkState() + item for item in SongExportForm._find_list_widget_items(self.available_list_widget) if item.checkState() ] if not items: critical_error_message_box( @@ -241,7 +241,7 @@ class SongExportForm(OpenLPWizard): """ songs = [ song.data(QtCore.Qt.UserRole) - for song in self._find_list_widget_items(self.selected_list_widget) + for song in SongExportForm._find_list_widget_items(self.selected_list_widget) ] exporter = OpenLyricsExport(self, songs, self.directory_line_edit.text()) try: @@ -255,7 +255,8 @@ class SongExportForm(OpenLPWizard): self.progress_label.setText(translate('SongsPlugin.SongExportForm', 'Your song export failed because this ' 'error occurred: %s') % ose.strerror) - def _find_list_widget_items(self, list_widget, text=''): + @staticmethod + def _find_list_widget_items(list_widget, text=''): """ Returns a list of *QListWidgetItem*s of the ``list_widget``. Note, that hidden items are included. @@ -266,7 +267,8 @@ class SongExportForm(OpenLPWizard): item for item in list_widget.findItems(text, QtCore.Qt.MatchContains) ] - def on_item_activated(self, item): + @staticmethod + def on_item_activated(item): """ Called, when an item in the *available_list_widget* has been triggered. The item is check if it was not checked, whereas it is unchecked when it @@ -286,9 +288,9 @@ class SongExportForm(OpenLPWizard): :param text: The text of the *search_line_edit*. """ search_result = [ - song for song in self._find_list_widget_items(self.available_list_widget, text) + song for song in SongExportForm._find_list_widget_items(self.available_list_widget, text) ] - for item in self._find_list_widget_items(self.available_list_widget): + for item in SongExportForm._find_list_widget_items(self.available_list_widget): item.setHidden(item not in search_result) def on_uncheck_button_clicked(self): diff --git a/openlp/plugins/songs/lib/importers/foilpresenter.py b/openlp/plugins/songs/lib/importers/foilpresenter.py index f17235535..2d9c6cd4c 100644 --- a/openlp/plugins/songs/lib/importers/foilpresenter.py +++ b/openlp/plugins/songs/lib/importers/foilpresenter.py @@ -234,7 +234,8 @@ class FoilPresenter(object): clean_song(self.manager, song) self.manager.save_object(song) - def _child(self, element): + @staticmethod + def _child(element): """ This returns the text of an element as unicode string. @@ -253,7 +254,7 @@ class FoilPresenter(object): """ authors = [] try: - copyright = self._child(foilpresenterfolie.copyright.text_) + copyright = FoilPresenter._child(foilpresenterfolie.copyright.text_) except AttributeError: copyright = None if copyright: @@ -346,7 +347,7 @@ class FoilPresenter(object): :param song: The song object. """ try: - song.ccli_number = self._child(foilpresenterfolie.ccliid) + song.ccli_number = FoilPresenter._child(foilpresenterfolie.ccliid) except AttributeError: song.ccli_number = '' @@ -358,7 +359,7 @@ class FoilPresenter(object): :param song: The song object. """ try: - song.comments = self._child(foilpresenterfolie.notiz) + song.comments = FoilPresenter._child(foilpresenterfolie.notiz) except AttributeError: song.comments = '' @@ -370,7 +371,7 @@ class FoilPresenter(object): :param song: The song object. """ try: - song.copyright = self._child(foilpresenterfolie.copyright.text_) + song.copyright = FoilPresenter._child(foilpresenterfolie.copyright.text_) except AttributeError: song.copyright = '' @@ -396,19 +397,19 @@ class FoilPresenter(object): VerseType.tags[VerseType.PreChorus]: 1 } if not hasattr(foilpresenterfolie.strophen, 'strophe'): - self.importer.log_error(self._child(foilpresenterfolie.titel), + self.importer.log_error(FoilPresenter._child(foilpresenterfolie.titel), str(translate('SongsPlugin.FoilPresenterSongImport', 'Invalid Foilpresenter song file. No verses found.'))) self.save_song = False return for strophe in foilpresenterfolie.strophen.strophe: - text = self._child(strophe.text_) if hasattr(strophe, 'text_') else '' - verse_name = self._child(strophe.key) + text = FoilPresenter._child(strophe.text_) if hasattr(strophe, 'text_') else '' + verse_name = FoilPresenter._child(strophe.key) children = strophe.getchildren() sortnr = False for child in children: if child.tag == 'sortnr': - verse_sortnr = self._child(strophe.sortnr) + verse_sortnr = FoilPresenter._child(strophe.sortnr) sortnr = True # In older Version there is no sortnr, but we need one if not sortnr: @@ -484,7 +485,7 @@ class FoilPresenter(object): song.song_number = '' try: for bucheintrag in foilpresenterfolie.buch.bucheintrag: - book_name = self._child(bucheintrag.name) + book_name = FoilPresenter._child(bucheintrag.name) if book_name: book = self.manager.get_object_filtered(Book, Book.name == book_name) if book is None: @@ -493,8 +494,8 @@ class FoilPresenter(object): self.manager.save_object(book) song.song_book_id = book.id try: - if self._child(bucheintrag.nummer): - song.song_number = self._child(bucheintrag.nummer) + if FoilPresenter._child(bucheintrag.nummer): + song.song_number = FoilPresenter._child(bucheintrag.nummer) except AttributeError: pass # We only support one song book, so take the first one. @@ -512,13 +513,13 @@ class FoilPresenter(object): try: for title_string in foilpresenterfolie.titel.titelstring: if not song.title: - song.title = self._child(title_string) + song.title = FoilPresenter._child(title_string) song.alternate_title = '' else: - song.alternate_title = self._child(title_string) + song.alternate_title = FoilPresenter._child(title_string) except AttributeError: # Use first line of first verse - first_line = self._child(foilpresenterfolie.strophen.strophe.text_) + first_line = FoilPresenter._child(foilpresenterfolie.strophen.strophe.text_) song.title = first_line.split('\n')[0] def _process_topics(self, foilpresenterfolie, song): @@ -530,7 +531,7 @@ class FoilPresenter(object): """ try: for name in foilpresenterfolie.kategorien.name: - topic_text = self._child(name) + topic_text = FoilPresenter._child(name) if topic_text: topic = self.manager.get_object_filtered(Topic, Topic.name == topic_text) if topic is None: diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index ba35f8be9..b7f6a36bb 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -297,7 +297,7 @@ class SongsPlugin(Plugin): if sfile.startswith('songs_') and sfile.endswith('.sqlite'): self.application.process_events() song_dbs.append(os.path.join(db_dir, sfile)) - song_count += self._count_songs(os.path.join(db_dir, sfile)) + song_count += SongsPlugin._count_songs(os.path.join(db_dir, sfile)) if not song_dbs: return self.application.process_events() From 5bc13e45e3869e96cd8909482e3d494f6a1e3506 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Tue, 5 Jan 2016 23:28:48 +0100 Subject: [PATCH 06/22] Move some static methods out of their classes where it makes sense --- openlp/core/lib/renderer.py | 94 +++++++++---------- openlp/core/ui/mainwindow.py | 3 +- openlp/core/ui/servicemanager.py | 58 +++++------- openlp/plugins/songs/forms/songexportform.py | 57 ++++++----- .../songs/lib/importers/foilpresenter.py | 53 ++++++----- .../songs/test_foilpresenterimport.py | 2 +- 6 files changed, 126 insertions(+), 141 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index a0dc14117..395c3d469 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -451,43 +451,6 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): formatted.append(previous_raw) return formatted - @staticmethod - def _get_start_tags(raw_text): - """ - Tests the given text for not closed formatting tags and returns a tuple consisting of three unicode strings:: - - ('{st}{r}Text text text{/r}{/st}', '{st}{r}', '') - - The first unicode string is the text, with correct closing tags. The second unicode string are OpenLP's opening - formatting tags and the third unicode string the html opening formatting tags. - - :param raw_text: The text to test. The text must **not** contain html tags, only OpenLP formatting tags - are allowed:: - {st}{r}Text text text - """ - raw_tags = [] - html_tags = [] - for tag in FormattingTags.get_html_tags(): - if tag['start tag'] == '{br}': - continue - if raw_text.count(tag['start tag']) != raw_text.count(tag['end tag']): - raw_tags.append((raw_text.find(tag['start tag']), tag['start tag'], tag['end tag'])) - html_tags.append((raw_text.find(tag['start tag']), tag['start html'])) - # Sort the lists, so that the tags which were opened first on the first slide (the text we are checking) will be - # opened first on the next slide as well. - raw_tags.sort(key=lambda tag: tag[0]) - html_tags.sort(key=lambda tag: tag[0]) - # Create a list with closing tags for the raw_text. - end_tags = [] - start_tags = [] - for tag in raw_tags: - start_tags.append(tag[1]) - end_tags.append(tag[2]) - end_tags.reverse() - # Remove the indexes. - html_tags = [tag[1] for tag in html_tags] - return raw_text + ''.join(end_tags), ''.join(start_tags), ''.join(html_tags) - def _binary_chop(self, formatted, previous_html, previous_raw, html_list, raw_list, separator, line_end): """ This implements the binary chop algorithm for faster rendering. This algorithm works line based (line by line) @@ -522,7 +485,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): if smallest_index == index or highest_index == index: index = smallest_index text = previous_raw.rstrip('
') + separator.join(raw_list[:index + 1]) - text, raw_tags, html_tags = Renderer._get_start_tags(text) + text, raw_tags, html_tags = _get_start_tags(text) formatted.append(text) previous_html = '' previous_raw = '' @@ -557,13 +520,50 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): self.web_frame.evaluateJavaScript('show_text("%s")' % text.replace('\\', '\\\\').replace('\"', '\\\"')) return self.web_frame.contentsSize().height() <= self.empty_height - @staticmethod - def _words_split(line): - """ - Split the slide up by word so can wrap better - :param line: Line to be split - """ - # this parse we are to be wordy - line = line.replace('\n', ' ') - return line.split(' ') +def _words_split(line): + """ + Split the slide up by word so can wrap better + + :param line: Line to be split + """ + # this parse we are to be wordy + line = line.replace('\n', ' ') + return line.split(' ') + +def _get_start_tags(raw_text): + """ + Tests the given text for not closed formatting tags and returns a tuple consisting of three unicode strings:: + + ('{st}{r}Text text text{/r}{/st}', '{st}{r}', '') + + The first unicode string is the text, with correct closing tags. The second unicode string are OpenLP's opening + formatting tags and the third unicode string the html opening formatting tags. + + :param raw_text: The text to test. The text must **not** contain html tags, only OpenLP formatting tags + are allowed:: + {st}{r}Text text text + """ + raw_tags = [] + html_tags = [] + for tag in FormattingTags.get_html_tags(): + if tag['start tag'] == '{br}': + continue + if raw_text.count(tag['start tag']) != raw_text.count(tag['end tag']): + raw_tags.append((raw_text.find(tag['start tag']), tag['start tag'], tag['end tag'])) + html_tags.append((raw_text.find(tag['start tag']), tag['start html'])) + # Sort the lists, so that the tags which were opened first on the first slide (the text we are checking) will be + # opened first on the next slide as well. + raw_tags.sort(key=lambda tag: tag[0]) + html_tags.sort(key=lambda tag: tag[0]) + # Create a list with closing tags for the raw_text. + end_tags = [] + start_tags = [] + for tag in raw_tags: + start_tags.append(tag[1]) + end_tags.append(tag[2]) + end_tags.reverse() + # Remove the indexes. + html_tags = [tag[1] for tag in html_tags] + return raw_text + ''.join(end_tags), ''.join(start_tags), ''.join(html_tags) + diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index aed44468e..4427de655 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -47,6 +47,7 @@ from openlp.core.utils import LanguageManager, add_actions, get_application_vers from openlp.core.utils.actions import ActionList, CategoryOrder from openlp.core.ui.firsttimeform import FirstTimeForm from openlp.core.ui.projector.manager import ProjectorManager +from openlp.core.ui.printserviceform import PrintServiceForm log = logging.getLogger(__name__) @@ -197,7 +198,7 @@ class Ui_MainWindow(object): triggers=self.service_manager_contents.save_file_as) self.print_service_order_item = create_action(main_window, 'printServiceItem', can_shortcuts=True, category=UiStrings().File, - triggers=self.service_manager_contents.print_service_order) + triggers=lambda x: PrintServiceForm().exec()) self.file_exit_item = create_action(main_window, 'fileExitItem', icon=':/system/system_exit.png', can_shortcuts=True, category=UiStrings().File, triggers=main_window.close) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 06005bb60..3904d28da 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -144,8 +144,8 @@ class Ui_ServiceManager(object): self.service_manager_list.customContextMenuRequested.connect(self.context_menu) self.service_manager_list.setObjectName('service_manager_list') # enable drop - self.service_manager_list.__class__.dragEnterEvent = Ui_ServiceManager.drag_enter_event - self.service_manager_list.__class__.dragMoveEvent = Ui_ServiceManager.drag_enter_event + self.service_manager_list.__class__.dragEnterEvent = lambda x, event: event.accept() + self.service_manager_list.__class__.dragMoveEvent = lambda x, event: event.accept() self.service_manager_list.__class__.dropEvent = self.drop_event self.layout.addWidget(self.service_manager_list) # Add the bottom toolbar @@ -293,15 +293,6 @@ class Ui_ServiceManager(object): Registry().register_function('theme_update_global', self.theme_change) Registry().register_function('mediaitem_suffix_reset', self.reset_supported_suffixes) - @staticmethod - def drag_enter_event(event): - """ - Accept Drag events - - :param event: Handle of the event passed - """ - event.accept() - class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceManager, RegistryProperties): """ @@ -1586,7 +1577,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa if item is None: end_pos = len(self.service_items) else: - end_pos = ServiceManager._get_parent_item_data(item) - 1 + end_pos = _get_parent_item_data(item) - 1 service_item = self.service_items[start_pos] self.service_items.remove(service_item) self.service_items.insert(end_pos, service_item) @@ -1599,21 +1590,21 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa self.drop_position = len(self.service_items) else: # we are over something so lets investigate - pos = ServiceManager._get_parent_item_data(item) - 1 + pos = _get_parent_item_data(item) - 1 service_item = self.service_items[pos] if (plugin == service_item['service_item'].name and service_item['service_item'].is_capable(ItemCapabilities.CanAppend)): action = self.dnd_menu.exec(QtGui.QCursor.pos()) # New action required if action == self.new_action: - self.drop_position = ServiceManager._get_parent_item_data(item) + self.drop_position = _get_parent_item_data(item) # Append to existing action if action == self.add_to_action: - self.drop_position = ServiceManager._get_parent_item_data(item) + self.drop_position = _get_parent_item_data(item) item.setSelected(True) replace = True else: - self.drop_position = ServiceManager._get_parent_item_data(item) - 1 + self.drop_position = _get_parent_item_data(item) - 1 Registry().execute('%s_add_service_item' % plugin, replace) def update_theme_list(self, theme_list): @@ -1657,29 +1648,22 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa self.service_items[item]['service_item'].update_theme(theme) self.regenerate_service_items(True) - @staticmethod - def _get_parent_item_data(item): - """ - Finds and returns the parent item for any item - - :param item: The service item list item to be checked. - """ - parent_item = item.parent() - if parent_item is None: - return item.data(0, QtCore.Qt.UserRole) - else: - return parent_item.data(0, QtCore.Qt.UserRole) - - @staticmethod - def print_service_order(field=None): - """ - Print a Service Order Sheet. - """ - setting_dialog = PrintServiceForm() - setting_dialog.exec() - def get_drop_position(self): """ Getter for drop_position. Used in: MediaManagerItem """ return self.drop_position + + +def _get_parent_item_data(item): + """ + Finds and returns the parent item for any item + + :param item: The service item list item to be checked. + """ + parent_item = item.parent() + if parent_item is None: + return item.data(0, QtCore.Qt.UserRole) + else: + return parent_item.data(0, QtCore.Qt.UserRole) + diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index b9ff2d2f6..31e490aa0 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -72,7 +72,7 @@ class SongExportForm(OpenLPWizard): """ Song wizard specific signals. """ - self.available_list_widget.itemActivated.connect(SongExportForm.on_item_activated) + self.available_list_widget.itemActivated.connect(_on_item_activated) self.search_line_edit.textEdited.connect(self.on_search_line_edit_changed) self.uncheck_button.clicked.connect(self.on_uncheck_button_clicked) self.check_button.clicked.connect(self.on_check_button_clicked) @@ -172,7 +172,7 @@ class SongExportForm(OpenLPWizard): return True elif self.currentPage() == self.available_songs_page: items = [ - item for item in SongExportForm._find_list_widget_items(self.available_list_widget) if item.checkState() + item for item in _find_list_widget_items(self.available_list_widget) if item.checkState() ] if not items: critical_error_message_box( @@ -241,7 +241,7 @@ class SongExportForm(OpenLPWizard): """ songs = [ song.data(QtCore.Qt.UserRole) - for song in SongExportForm._find_list_widget_items(self.selected_list_widget) + for song in _find_list_widget_items(self.selected_list_widget) ] exporter = OpenLyricsExport(self, songs, self.directory_line_edit.text()) try: @@ -255,30 +255,6 @@ class SongExportForm(OpenLPWizard): self.progress_label.setText(translate('SongsPlugin.SongExportForm', 'Your song export failed because this ' 'error occurred: %s') % ose.strerror) - @staticmethod - def _find_list_widget_items(list_widget, text=''): - """ - Returns a list of *QListWidgetItem*s of the ``list_widget``. Note, that hidden items are included. - - :param list_widget: The widget to get all items from. (QListWidget) - :param text: The text to search for. (unicode string) - """ - return [ - item for item in list_widget.findItems(text, QtCore.Qt.MatchContains) - ] - - @staticmethod - def on_item_activated(item): - """ - Called, when an item in the *available_list_widget* has been triggered. - The item is check if it was not checked, whereas it is unchecked when it - was checked. - - :param item: The *QListWidgetItem* which was triggered. - """ - item.setCheckState( - QtCore.Qt.Unchecked if item.checkState() else QtCore.Qt.Checked) - def on_search_line_edit_changed(self, text): """ The *search_line_edit*'s text has been changed. Update the list of @@ -288,9 +264,9 @@ class SongExportForm(OpenLPWizard): :param text: The text of the *search_line_edit*. """ search_result = [ - song for song in SongExportForm._find_list_widget_items(self.available_list_widget, text) + song for song in _find_list_widget_items(self.available_list_widget, text) ] - for item in SongExportForm._find_list_widget_items(self.available_list_widget): + for item in _find_list_widget_items(self.available_list_widget): item.setHidden(item not in search_result) def on_uncheck_button_clicked(self): @@ -319,3 +295,26 @@ class SongExportForm(OpenLPWizard): self.get_folder( translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'), self.directory_line_edit, 'last directory export') + + +def _find_list_widget_items(list_widget, text=''): + """ + Returns a list of *QListWidgetItem*s of the ``list_widget``. Note, that hidden items are included. + + :param list_widget: The widget to get all items from. (QListWidget) + :param text: The text to search for. (unicode string) + """ + return [ + item for item in list_widget.findItems(text, QtCore.Qt.MatchContains) + ] + +def _on_item_activated(item): + """ + Called, when an item in the *available_list_widget* has been triggered. + The item is check if it was not checked, whereas it is unchecked when it + was checked. + + :param item: The *QListWidgetItem* which was triggered. + """ + item.setCheckState(QtCore.Qt.Unchecked if item.checkState() else QtCore.Qt.Checked) + diff --git a/openlp/plugins/songs/lib/importers/foilpresenter.py b/openlp/plugins/songs/lib/importers/foilpresenter.py index 2d9c6cd4c..5827086c0 100644 --- a/openlp/plugins/songs/lib/importers/foilpresenter.py +++ b/openlp/plugins/songs/lib/importers/foilpresenter.py @@ -234,17 +234,6 @@ class FoilPresenter(object): clean_song(self.manager, song) self.manager.save_object(song) - @staticmethod - def _child(element): - """ - This returns the text of an element as unicode string. - - :param element: The element - """ - if element is not None: - return str(element) - return '' - def _process_authors(self, foilpresenterfolie, song): """ Adds the authors specified in the XML to the song. @@ -254,7 +243,7 @@ class FoilPresenter(object): """ authors = [] try: - copyright = FoilPresenter._child(foilpresenterfolie.copyright.text_) + copyright = _child(foilpresenterfolie.copyright.text_) except AttributeError: copyright = None if copyright: @@ -347,7 +336,7 @@ class FoilPresenter(object): :param song: The song object. """ try: - song.ccli_number = FoilPresenter._child(foilpresenterfolie.ccliid) + song.ccli_number = _child(foilpresenterfolie.ccliid) except AttributeError: song.ccli_number = '' @@ -359,7 +348,7 @@ class FoilPresenter(object): :param song: The song object. """ try: - song.comments = FoilPresenter._child(foilpresenterfolie.notiz) + song.comments = _child(foilpresenterfolie.notiz) except AttributeError: song.comments = '' @@ -371,7 +360,7 @@ class FoilPresenter(object): :param song: The song object. """ try: - song.copyright = FoilPresenter._child(foilpresenterfolie.copyright.text_) + song.copyright = _child(foilpresenterfolie.copyright.text_) except AttributeError: song.copyright = '' @@ -397,19 +386,19 @@ class FoilPresenter(object): VerseType.tags[VerseType.PreChorus]: 1 } if not hasattr(foilpresenterfolie.strophen, 'strophe'): - self.importer.log_error(FoilPresenter._child(foilpresenterfolie.titel), + self.importer.log_error(_child(foilpresenterfolie.titel), str(translate('SongsPlugin.FoilPresenterSongImport', 'Invalid Foilpresenter song file. No verses found.'))) self.save_song = False return for strophe in foilpresenterfolie.strophen.strophe: - text = FoilPresenter._child(strophe.text_) if hasattr(strophe, 'text_') else '' - verse_name = FoilPresenter._child(strophe.key) + text = _child(strophe.text_) if hasattr(strophe, 'text_') else '' + verse_name = _child(strophe.key) children = strophe.getchildren() sortnr = False for child in children: if child.tag == 'sortnr': - verse_sortnr = FoilPresenter._child(strophe.sortnr) + verse_sortnr = _child(strophe.sortnr) sortnr = True # In older Version there is no sortnr, but we need one if not sortnr: @@ -485,7 +474,7 @@ class FoilPresenter(object): song.song_number = '' try: for bucheintrag in foilpresenterfolie.buch.bucheintrag: - book_name = FoilPresenter._child(bucheintrag.name) + book_name = _child(bucheintrag.name) if book_name: book = self.manager.get_object_filtered(Book, Book.name == book_name) if book is None: @@ -494,8 +483,8 @@ class FoilPresenter(object): self.manager.save_object(book) song.song_book_id = book.id try: - if FoilPresenter._child(bucheintrag.nummer): - song.song_number = FoilPresenter._child(bucheintrag.nummer) + if _child(bucheintrag.nummer): + song.song_number = _child(bucheintrag.nummer) except AttributeError: pass # We only support one song book, so take the first one. @@ -513,13 +502,13 @@ class FoilPresenter(object): try: for title_string in foilpresenterfolie.titel.titelstring: if not song.title: - song.title = FoilPresenter._child(title_string) + song.title = _child(title_string) song.alternate_title = '' else: - song.alternate_title = FoilPresenter._child(title_string) + song.alternate_title = _child(title_string) except AttributeError: # Use first line of first verse - first_line = FoilPresenter._child(foilpresenterfolie.strophen.strophe.text_) + first_line = _child(foilpresenterfolie.strophen.strophe.text_) song.title = first_line.split('\n')[0] def _process_topics(self, foilpresenterfolie, song): @@ -531,7 +520,7 @@ class FoilPresenter(object): """ try: for name in foilpresenterfolie.kategorien.name: - topic_text = FoilPresenter._child(name) + topic_text = _child(name) if topic_text: topic = self.manager.get_object_filtered(Topic, Topic.name == topic_text) if topic is None: @@ -541,3 +530,15 @@ class FoilPresenter(object): song.topics.append(topic) except AttributeError: pass + + +def _child(element): + """ + This returns the text of an element as unicode string. + + :param element: The element + """ + if element is not None: + return str(element) + return '' + diff --git a/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py b/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py index 87e5fc484..2eb55afc3 100644 --- a/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py +++ b/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py @@ -50,7 +50,7 @@ class TestFoilPresenter(TestCase): # _process_topics def setUp(self): - self.child_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._child') + self.child_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter._child') self.clean_song_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.clean_song') self.objectify_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.objectify') self.process_authors_patcher = \ From d5780b9f78de6472ed1122bb2bf7cff31e746b4b Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Thu, 7 Jan 2016 14:10:31 +0100 Subject: [PATCH 07/22] update functions that were previously methods to drop the '_' rename _child to to_str because of name conflicts --- openlp/core/lib/renderer.py | 10 +++--- openlp/core/ui/servicemanager.py | 12 +++---- openlp/plugins/songs/forms/songexportform.py | 14 ++++---- .../songs/lib/importers/foilpresenter.py | 32 +++++++++---------- .../songs/test_foilpresenterimport.py | 8 ++--- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 395c3d469..7de76166d 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -273,7 +273,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): except ValueError: text_to_render = text.split('\n[---]\n')[0] text = '' - text_to_render, raw_tags, html_tags = Renderer._get_start_tags(text_to_render) + text_to_render, raw_tags, html_tags = get_start_tags(text_to_render) if text: text = raw_tags + text else: @@ -441,7 +441,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): previous_raw = line + line_end continue # Figure out how many words of the line will fit on screen as the line will not fit as a whole. - raw_words = Renderer._words_split(line) + raw_words = Renderer.words_split(line) html_words = list(map(expand_tags, raw_words)) previous_html, previous_raw = \ self._binary_chop(formatted, previous_html, previous_raw, html_words, raw_words, ' ', line_end) @@ -485,7 +485,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): if smallest_index == index or highest_index == index: index = smallest_index text = previous_raw.rstrip('
') + separator.join(raw_list[:index + 1]) - text, raw_tags, html_tags = _get_start_tags(text) + text, raw_tags, html_tags = get_start_tags(text) formatted.append(text) previous_html = '' previous_raw = '' @@ -521,7 +521,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): return self.web_frame.contentsSize().height() <= self.empty_height -def _words_split(line): +def words_split(line): """ Split the slide up by word so can wrap better @@ -531,7 +531,7 @@ def _words_split(line): line = line.replace('\n', ' ') return line.split(' ') -def _get_start_tags(raw_text): +def get_start_tags(raw_text): """ Tests the given text for not closed formatting tags and returns a tuple consisting of three unicode strings:: diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 3904d28da..bec2340ce 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1577,7 +1577,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa if item is None: end_pos = len(self.service_items) else: - end_pos = _get_parent_item_data(item) - 1 + end_pos = get_parent_item_data(item) - 1 service_item = self.service_items[start_pos] self.service_items.remove(service_item) self.service_items.insert(end_pos, service_item) @@ -1590,21 +1590,21 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa self.drop_position = len(self.service_items) else: # we are over something so lets investigate - pos = _get_parent_item_data(item) - 1 + pos = get_parent_item_data(item) - 1 service_item = self.service_items[pos] if (plugin == service_item['service_item'].name and service_item['service_item'].is_capable(ItemCapabilities.CanAppend)): action = self.dnd_menu.exec(QtGui.QCursor.pos()) # New action required if action == self.new_action: - self.drop_position = _get_parent_item_data(item) + self.drop_position = get_parent_item_data(item) # Append to existing action if action == self.add_to_action: - self.drop_position = _get_parent_item_data(item) + self.drop_position = get_parent_item_data(item) item.setSelected(True) replace = True else: - self.drop_position = _get_parent_item_data(item) - 1 + self.drop_position = get_parent_item_data(item) - 1 Registry().execute('%s_add_service_item' % plugin, replace) def update_theme_list(self, theme_list): @@ -1655,7 +1655,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa return self.drop_position -def _get_parent_item_data(item): +def get_parent_item_data(item): """ Finds and returns the parent item for any item diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 31e490aa0..830924916 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -72,7 +72,7 @@ class SongExportForm(OpenLPWizard): """ Song wizard specific signals. """ - self.available_list_widget.itemActivated.connect(_on_item_activated) + self.available_list_widget.itemActivated.connect(on_item_activated) self.search_line_edit.textEdited.connect(self.on_search_line_edit_changed) self.uncheck_button.clicked.connect(self.on_uncheck_button_clicked) self.check_button.clicked.connect(self.on_check_button_clicked) @@ -172,7 +172,7 @@ class SongExportForm(OpenLPWizard): return True elif self.currentPage() == self.available_songs_page: items = [ - item for item in _find_list_widget_items(self.available_list_widget) if item.checkState() + item for item in find_list_widget_items(self.available_list_widget) if item.checkState() ] if not items: critical_error_message_box( @@ -241,7 +241,7 @@ class SongExportForm(OpenLPWizard): """ songs = [ song.data(QtCore.Qt.UserRole) - for song in _find_list_widget_items(self.selected_list_widget) + for song in find_list_widget_items(self.selected_list_widget) ] exporter = OpenLyricsExport(self, songs, self.directory_line_edit.text()) try: @@ -264,9 +264,9 @@ class SongExportForm(OpenLPWizard): :param text: The text of the *search_line_edit*. """ search_result = [ - song for song in _find_list_widget_items(self.available_list_widget, text) + song for song in find_list_widget_items(self.available_list_widget, text) ] - for item in _find_list_widget_items(self.available_list_widget): + for item in find_list_widget_items(self.available_list_widget): item.setHidden(item not in search_result) def on_uncheck_button_clicked(self): @@ -297,7 +297,7 @@ class SongExportForm(OpenLPWizard): self.directory_line_edit, 'last directory export') -def _find_list_widget_items(list_widget, text=''): +def find_list_widget_items(list_widget, text=''): """ Returns a list of *QListWidgetItem*s of the ``list_widget``. Note, that hidden items are included. @@ -308,7 +308,7 @@ def _find_list_widget_items(list_widget, text=''): item for item in list_widget.findItems(text, QtCore.Qt.MatchContains) ] -def _on_item_activated(item): +def on_item_activated(item): """ Called, when an item in the *available_list_widget* has been triggered. The item is check if it was not checked, whereas it is unchecked when it diff --git a/openlp/plugins/songs/lib/importers/foilpresenter.py b/openlp/plugins/songs/lib/importers/foilpresenter.py index 5827086c0..b6e66f0a5 100644 --- a/openlp/plugins/songs/lib/importers/foilpresenter.py +++ b/openlp/plugins/songs/lib/importers/foilpresenter.py @@ -243,7 +243,7 @@ class FoilPresenter(object): """ authors = [] try: - copyright = _child(foilpresenterfolie.copyright.text_) + copyright = to_str(foilpresenterfolie.copyright.text_) except AttributeError: copyright = None if copyright: @@ -336,7 +336,7 @@ class FoilPresenter(object): :param song: The song object. """ try: - song.ccli_number = _child(foilpresenterfolie.ccliid) + song.ccli_number = to_str(foilpresenterfolie.ccliid) except AttributeError: song.ccli_number = '' @@ -348,7 +348,7 @@ class FoilPresenter(object): :param song: The song object. """ try: - song.comments = _child(foilpresenterfolie.notiz) + song.comments = to_str(foilpresenterfolie.notiz) except AttributeError: song.comments = '' @@ -360,7 +360,7 @@ class FoilPresenter(object): :param song: The song object. """ try: - song.copyright = _child(foilpresenterfolie.copyright.text_) + song.copyright = to_str(foilpresenterfolie.copyright.text_) except AttributeError: song.copyright = '' @@ -386,19 +386,19 @@ class FoilPresenter(object): VerseType.tags[VerseType.PreChorus]: 1 } if not hasattr(foilpresenterfolie.strophen, 'strophe'): - self.importer.log_error(_child(foilpresenterfolie.titel), + self.importer.log_error(to_str(foilpresenterfolie.titel), str(translate('SongsPlugin.FoilPresenterSongImport', 'Invalid Foilpresenter song file. No verses found.'))) self.save_song = False return for strophe in foilpresenterfolie.strophen.strophe: - text = _child(strophe.text_) if hasattr(strophe, 'text_') else '' - verse_name = _child(strophe.key) + text = to_str(strophe.text_) if hasattr(strophe, 'text_') else '' + verse_name = to_str(strophe.key) children = strophe.getchildren() sortnr = False for child in children: if child.tag == 'sortnr': - verse_sortnr = _child(strophe.sortnr) + verse_sortnr = to_str(strophe.sortnr) sortnr = True # In older Version there is no sortnr, but we need one if not sortnr: @@ -474,7 +474,7 @@ class FoilPresenter(object): song.song_number = '' try: for bucheintrag in foilpresenterfolie.buch.bucheintrag: - book_name = _child(bucheintrag.name) + book_name = to_str(bucheintrag.name) if book_name: book = self.manager.get_object_filtered(Book, Book.name == book_name) if book is None: @@ -483,8 +483,8 @@ class FoilPresenter(object): self.manager.save_object(book) song.song_book_id = book.id try: - if _child(bucheintrag.nummer): - song.song_number = _child(bucheintrag.nummer) + if to_str(bucheintrag.nummer): + song.song_number = to_str(bucheintrag.nummer) except AttributeError: pass # We only support one song book, so take the first one. @@ -502,13 +502,13 @@ class FoilPresenter(object): try: for title_string in foilpresenterfolie.titel.titelstring: if not song.title: - song.title = _child(title_string) + song.title = to_str(title_string) song.alternate_title = '' else: - song.alternate_title = _child(title_string) + song.alternate_title = to_str(title_string) except AttributeError: # Use first line of first verse - first_line = _child(foilpresenterfolie.strophen.strophe.text_) + first_line = to_str(foilpresenterfolie.strophen.strophe.text_) song.title = first_line.split('\n')[0] def _process_topics(self, foilpresenterfolie, song): @@ -520,7 +520,7 @@ class FoilPresenter(object): """ try: for name in foilpresenterfolie.kategorien.name: - topic_text = _child(name) + topic_text = to_str(name) if topic_text: topic = self.manager.get_object_filtered(Topic, Topic.name == topic_text) if topic is None: @@ -532,7 +532,7 @@ class FoilPresenter(object): pass -def _child(element): +def to_str(element): """ This returns the text of an element as unicode string. diff --git a/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py b/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py index 2eb55afc3..36dd0904d 100644 --- a/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py +++ b/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py @@ -39,7 +39,7 @@ class TestFoilPresenter(TestCase): """ # TODO: The following modules still need tests written for # xml_to_song - # _child + # to_str # _process_authors # _process_cclinumber # _process_comments @@ -50,7 +50,7 @@ class TestFoilPresenter(TestCase): # _process_topics def setUp(self): - self.child_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter._child') + self.to_str_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.to_str') self.clean_song_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.clean_song') self.objectify_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.objectify') self.process_authors_patcher = \ @@ -72,7 +72,7 @@ class TestFoilPresenter(TestCase): self.song_xml_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.SongXML') self.translate_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.translate') - self.mocked_child = self.child_patcher.start() + self.mocked_child = self.to_str_patcher.start() self.mocked_clean_song = self.clean_song_patcher.start() self.mocked_objectify = self.objectify_patcher.start() self.mocked_process_authors = self.process_authors_patcher.start() @@ -92,7 +92,7 @@ class TestFoilPresenter(TestCase): self.mocked_song_import = MagicMock() def tearDown(self): - self.child_patcher.stop() + self.to_str_patcher.stop() self.clean_song_patcher.stop() self.objectify_patcher.stop() self.process_authors_patcher.stop() From 2c5475e8fa81a396bab9580e84d4d063cc4268bb Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Fri, 8 Jan 2016 14:47:52 +0100 Subject: [PATCH 08/22] Fix some pep issues in the changed files --- openlp/core/lib/plugin.py | 3 ++- openlp/plugins/custom/customplugin.py | 1 + openlp/plugins/images/imageplugin.py | 3 +-- openlp/plugins/presentations/presentationplugin.py | 4 +++- tests/functional/openlp_plugins/media/test_mediaplugin.py | 4 ++-- tests/functional/openlp_plugins/songusage/test_songusage.py | 1 + 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index adeacd81b..4e58fcdba 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -263,7 +263,8 @@ class Plugin(QtCore.QObject, RegistryProperties): else: self.media_item.on_add_click() - def about(self): + @staticmethod + def about(): """ Show a dialog when the user clicks on the 'About' button in the plugin manager. """ diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index d9b3369af..5c0de049c 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -74,6 +74,7 @@ class CustomPlugin(Plugin): Called to find out if the custom plugin is currently using a theme. Returns count of the times the theme is used. + :param theme: Theme to be queried """ return len(self.db_manager.get_all_objects(CustomSlide, CustomSlide.theme_name == theme)) diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index f3b84943d..26cba5a20 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -23,9 +23,8 @@ from PyQt5 import QtGui import logging -import os -from openlp.core.common import Registry, Settings, translate +from openlp.core.common import Settings, translate from openlp.core.lib import Plugin, StringContent, ImageSource, build_icon from openlp.core.lib.db import Manager from openlp.plugins.images.lib import ImageMediaItem, ImageTab diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index e076922cd..ff14d821c 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -28,7 +28,7 @@ import logging from PyQt5 import QtCore -from openlp.core.common import AppLocation, Settings, translate +from openlp.core.common import AppLocation, translate from openlp.core.lib import Plugin, StringContent, build_icon from openlp.plugins.presentations.lib import PresentationController, PresentationMediaItem, PresentationTab @@ -71,6 +71,7 @@ class PresentationPlugin(Plugin): def create_settings_tab(self, parent): """ Create the settings Tab. + :param parent: parent UI Element """ visible_name = self.get_string(StringContent.VisibleName) self.settings_tab = PresentationTab(parent, self.name, visible_name['title'], self.controllers, self.icon_path) @@ -112,6 +113,7 @@ class PresentationPlugin(Plugin): def register_controllers(self, controller): """ Register each presentation controller (Impress, PPT etc) and store for later use. + :param controller: controller to register """ self.controllers[controller.name] = controller diff --git a/tests/functional/openlp_plugins/media/test_mediaplugin.py b/tests/functional/openlp_plugins/media/test_mediaplugin.py index 99fa61f82..9bc53dee1 100644 --- a/tests/functional/openlp_plugins/media/test_mediaplugin.py +++ b/tests/functional/openlp_plugins/media/test_mediaplugin.py @@ -40,7 +40,7 @@ class MediaPluginTest(TestCase, TestMixin): @patch(u'openlp.plugins.media.mediaplugin.Plugin.initialise') @patch(u'openlp.plugins.media.mediaplugin.Settings') - def initialise_test(self, MockedSettings, mocked_initialise): + def initialise_test(self, mocked_settings, mocked_initialise): """ Test that the initialise() method overwrites the built-in one, but still calls it """ @@ -48,7 +48,7 @@ class MediaPluginTest(TestCase, TestMixin): media_plugin = MediaPlugin() mocked_settings = MagicMock() mocked_settings.get_files_from_config.return_value = True # Not the real value, just need something "true-ish" - MockedSettings.return_value = mocked_settings + mocked_settings.return_value = mocked_settings # WHEN: initialise() is called media_plugin.initialise() diff --git a/tests/functional/openlp_plugins/songusage/test_songusage.py b/tests/functional/openlp_plugins/songusage/test_songusage.py index 25f6cd5ac..04efd03cb 100644 --- a/tests/functional/openlp_plugins/songusage/test_songusage.py +++ b/tests/functional/openlp_plugins/songusage/test_songusage.py @@ -25,6 +25,7 @@ This module contains tests for the Songusage plugin. from unittest import TestCase from openlp.plugins.songusage.songusageplugin import SongUsagePlugin + class TestSongUsage(TestCase): def test_about_text(self): From bf4225838e79834a984fa8151b376d33abaf2175 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sat, 9 Jan 2016 01:15:23 +0100 Subject: [PATCH 09/22] Fix failing test due to name conflict --- tests/functional/openlp_plugins/media/test_mediaplugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_plugins/media/test_mediaplugin.py b/tests/functional/openlp_plugins/media/test_mediaplugin.py index 9bc53dee1..9dbab37cf 100644 --- a/tests/functional/openlp_plugins/media/test_mediaplugin.py +++ b/tests/functional/openlp_plugins/media/test_mediaplugin.py @@ -40,7 +40,7 @@ class MediaPluginTest(TestCase, TestMixin): @patch(u'openlp.plugins.media.mediaplugin.Plugin.initialise') @patch(u'openlp.plugins.media.mediaplugin.Settings') - def initialise_test(self, mocked_settings, mocked_initialise): + def initialise_test(self, _mocked_settings, mocked_initialise): """ Test that the initialise() method overwrites the built-in one, but still calls it """ @@ -48,7 +48,7 @@ class MediaPluginTest(TestCase, TestMixin): media_plugin = MediaPlugin() mocked_settings = MagicMock() mocked_settings.get_files_from_config.return_value = True # Not the real value, just need something "true-ish" - mocked_settings.return_value = mocked_settings + _mocked_settings.return_value = mocked_settings # WHEN: initialise() is called media_plugin.initialise() From afaf54a1421332f03c3fd9ad8ee8eab45a145841 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sat, 9 Jan 2016 17:26:14 +0100 Subject: [PATCH 10/22] Fix pep8 errors --- openlp/core/common/settings.py | 9 ++- openlp/core/lib/renderer.py | 2 +- openlp/core/lib/screen.py | 2 +- openlp/core/ui/aboutform.py | 3 +- openlp/core/ui/exceptionform.py | 3 +- openlp/core/ui/filerenameform.py | 2 +- openlp/core/ui/firsttimelanguageform.py | 3 +- openlp/core/ui/formattingtagform.py | 3 +- openlp/core/ui/media/webkitplayer.py | 4 +- openlp/core/ui/pluginform.py | 3 +- openlp/core/ui/printserviceform.py | 2 +- openlp/core/ui/projector/editform.py | 3 +- openlp/core/ui/projector/sourceselectform.py | 6 +- openlp/core/ui/serviceitemeditform.py | 2 +- openlp/core/ui/servicemanager.py | 3 +- openlp/core/ui/servicenoteform.py | 2 +- openlp/core/ui/settingsform.py | 3 +- openlp/core/ui/shortcutlistform.py | 3 +- openlp/core/ui/starttimeform.py | 2 +- openlp/plugins/alerts/forms/alertform.py | 2 +- .../plugins/bibles/forms/bibleimportform.py | 4 +- openlp/plugins/bibles/forms/booknameform.py | 3 +- openlp/plugins/bibles/forms/editbibleform.py | 3 +- openlp/plugins/bibles/forms/languageform.py | 3 +- openlp/plugins/custom/forms/editcustomform.py | 3 +- .../custom/forms/editcustomslideform.py | 3 +- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/images/forms/addgroupform.py | 3 +- .../plugins/images/forms/choosegroupform.py | 3 +- .../media/forms/mediaclipselectorform.py | 3 +- openlp/plugins/remotes/html/index.html | 8 +-- openlp/plugins/remotes/html/openlp.css | 4 ++ openlp/plugins/songs/forms/authorsform.py | 3 +- openlp/plugins/songs/forms/editsongform.py | 3 +- openlp/plugins/songs/forms/editverseform.py | 3 +- openlp/plugins/songs/forms/mediafilesform.py | 3 +- openlp/plugins/songs/forms/songbookform.py | 3 +- openlp/plugins/songs/forms/songexportform.py | 56 +++++++++---------- .../songs/forms/songmaintenanceform.py | 3 +- openlp/plugins/songs/forms/songselectform.py | 3 +- openlp/plugins/songs/forms/topicsform.py | 3 +- .../songs/lib/importers/foilpresenter.py | 1 - openlp/plugins/songs/lib/mediaitem.py | 2 +- .../songusage/forms/songusagedeleteform.py | 19 ++++--- .../songusage/forms/songusagedetailform.py | 3 +- openlp/plugins/songusage/songusageplugin.py | 2 +- .../openlp_core_lib/test_mediamanageritem.py | 1 - .../openlp_core_lib/test_projectordb.py | 1 - .../openlp_plugins/songs/test_songformat.py | 12 ++-- .../openlp_core_ui/test_projectoreditform.py | 2 - 50 files changed, 101 insertions(+), 126 deletions(-) diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index 0bedd69b6..68b0763df 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -252,7 +252,8 @@ class Settings(QtCore.QSettings): 'shortcuts/blankScreen': [QtGui.QKeySequence(QtCore.Qt.Key_Period)], 'shortcuts/collapse': [QtGui.QKeySequence(QtCore.Qt.Key_Minus)], 'shortcuts/desktopScreen': [QtGui.QKeySequence(QtCore.Qt.Key_D)], - 'shortcuts/delete': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), QtGui.QKeySequence(QtCore.Qt.Key_Delete)], + 'shortcuts/delete': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), + QtGui.QKeySequence(QtCore.Qt.Key_Delete)], 'shortcuts/down': [QtGui.QKeySequence(QtCore.Qt.Key_Down)], 'shortcuts/editSong': [], 'shortcuts/escapeItem': [QtGui.QKeySequence(QtCore.Qt.Key_Escape)], @@ -329,7 +330,8 @@ class Settings(QtCore.QSettings): 'shortcuts/moveBottom': [QtGui.QKeySequence(QtCore.Qt.Key_End)], 'shortcuts/moveDown': [QtGui.QKeySequence(QtCore.Qt.Key_PageDown)], 'shortcuts/nextTrackItem': [], - 'shortcuts/nextItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Down), QtGui.QKeySequence(QtCore.Qt.Key_PageDown)], + 'shortcuts/nextItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Down), + QtGui.QKeySequence(QtCore.Qt.Key_PageDown)], 'shortcuts/nextItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Down), QtGui.QKeySequence(QtCore.Qt.Key_PageDown)], 'shortcuts/nextService': [QtGui.QKeySequence(QtCore.Qt.Key_Right)], @@ -339,7 +341,8 @@ class Settings(QtCore.QSettings): QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F1)], 'shortcuts/openService': [], 'shortcuts/saveService': [], - 'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up), QtGui.QKeySequence(QtCore.Qt.Key_PageUp)], + 'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up), + QtGui.QKeySequence(QtCore.Qt.Key_PageUp)], 'shortcuts/playbackPause': [], 'shortcuts/playbackPlay': [], 'shortcuts/playbackStop': [], diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 7de76166d..0513b70e4 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -531,6 +531,7 @@ def words_split(line): line = line.replace('\n', ' ') return line.split(' ') + def get_start_tags(raw_text): """ Tests the given text for not closed formatting tags and returns a tuple consisting of three unicode strings:: @@ -566,4 +567,3 @@ def get_start_tags(raw_text): # Remove the indexes. html_tags = [tag[1] for tag in html_tags] return raw_text + ''.join(end_tags), ''.join(start_tags), ''.join(html_tags) - diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index 819ba9763..a527b3766 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -224,7 +224,7 @@ class ScreenList(object): y = window.y() + (window.height() // 2) for screen in self.screen_list: size = screen['size'] - if x >= size.x() and x <= (size.x() + size.width()) and y >= size.y() and y <= (size.y() + size.height()): + if size.x() <= x <= (size.x() + size.width()) and size.y() <= y <= (size.y() + size.height()): return screen['number'] def load_screen_settings(self): diff --git a/openlp/core/ui/aboutform.py b/openlp/core/ui/aboutform.py index 2c4eafb28..b376d4646 100644 --- a/openlp/core/ui/aboutform.py +++ b/openlp/core/ui/aboutform.py @@ -40,8 +40,7 @@ class AboutForm(QtWidgets.QDialog, UiAboutDialog): """ Do some initialisation stuff """ - super(AboutForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(AboutForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self._setup() def _setup(self): diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index a4cb39945..e985829ba 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -89,8 +89,7 @@ class ExceptionForm(QtWidgets.QDialog, Ui_ExceptionDialog, RegistryProperties): """ Constructor. """ - super(ExceptionForm, self).__init__(None, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(ExceptionForm, self).__init__(None, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.settings_section = 'crashreport' self.report_text = '**OpenLP Bug Report**\n' \ diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index bfe8dc3a6..3ab82cc12 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -39,7 +39,7 @@ class FileRenameForm(QtWidgets.QDialog, Ui_FileRenameDialog, RegistryProperties) Constructor """ super(FileRenameForm, self).__init__(Registry().get('main_window'), - QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self._setup() def _setup(self): diff --git a/openlp/core/ui/firsttimelanguageform.py b/openlp/core/ui/firsttimelanguageform.py index 07188ba5f..a55713bf0 100644 --- a/openlp/core/ui/firsttimelanguageform.py +++ b/openlp/core/ui/firsttimelanguageform.py @@ -37,8 +37,7 @@ class FirstTimeLanguageForm(QtWidgets.QDialog, Ui_FirstTimeLanguageDialog): """ Constructor """ - super(FirstTimeLanguageForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(FirstTimeLanguageForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.qm_list = LanguageManager.get_qm_list() self.language_combo_box.addItem('Autodetect') diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index acee3d56f..6fb658f06 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -51,8 +51,7 @@ class FormattingTagForm(QtWidgets.QDialog, Ui_FormattingTagDialog, FormattingTag """ Constructor """ - super(FormattingTagForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(FormattingTagForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self._setup() diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index ec17b97ee..0a35fe085 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -326,10 +326,10 @@ class WebkitPlayer(MediaPlayer): controller = display.controller if controller.media_info.is_flash: seek = seek_value - display.frame.evaluateJavaScript('show_flash("seek", null, null, "%s");' % (seek)) + display.frame.evaluateJavaScript('show_flash("seek", null, null, "%s");' % seek) else: seek = float(seek_value) / 1000 - display.frame.evaluateJavaScript('show_video("seek", null, null, null, "%f");' % (seek)) + display.frame.evaluateJavaScript('show_video("seek", null, null, null, "%f");' % seek) def reset(self, display): """ diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 03636a6da..9519838b2 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -41,8 +41,7 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): """ Constructor """ - super(PluginForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(PluginForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.active_plugin = None self.programatic_change = False self.setupUi(self) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index dd5548ea9..2d5b3d554 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -113,7 +113,7 @@ class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryPropert Constructor """ super(PrintServiceForm, self).__init__(Registry().get('main_window'), - QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.printer = QtPrintSupport.QPrinter() self.print_dialog = QtPrintSupport.QPrintDialog(self.printer, self) self.document = QtGui.QTextDocument() diff --git a/openlp/core/ui/projector/editform.py b/openlp/core/ui/projector/editform.py index 54c80ae38..4b06f486f 100644 --- a/openlp/core/ui/projector/editform.py +++ b/openlp/core/ui/projector/editform.py @@ -144,8 +144,7 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm): editProjector = pyqtSignal(object) def __init__(self, parent=None, projectordb=None): - super(ProjectorEditForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(ProjectorEditForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.projectordb = projectordb self.setupUi(self) self.button_box.accepted.connect(self.accept_me) diff --git a/openlp/core/ui/projector/sourceselectform.py b/openlp/core/ui/projector/sourceselectform.py index c46a61413..11efcdb08 100644 --- a/openlp/core/ui/projector/sourceselectform.py +++ b/openlp/core/ui/projector/sourceselectform.py @@ -236,8 +236,7 @@ class SourceSelectTabs(QDialog): :param projectordb: ProjectorDB session to use """ log.debug('Initializing SourceSelectTabs()') - super(SourceSelectTabs, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(SourceSelectTabs, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setMinimumWidth(350) self.projectordb = projectordb self.edit = edit @@ -386,8 +385,7 @@ class SourceSelectSingle(QDialog): """ log.debug('Initializing SourceSelectSingle()') self.projectordb = projectordb - super(SourceSelectSingle, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(SourceSelectSingle, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.edit = edit if self.edit: title = translate('OpenLP.SourceSelectForm', 'Edit Projector Source Text') diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index cb0652ff2..e7e2d9e6e 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -38,7 +38,7 @@ class ServiceItemEditForm(QtWidgets.QDialog, Ui_ServiceItemEditDialog, RegistryP Constructor """ super(ServiceItemEditForm, self).__init__(Registry().get('main_window'), - QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.item_list = [] self.list_widget.currentRowChanged.connect(self.on_current_row_changed) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index bec2340ce..caba6536b 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1131,6 +1131,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa :param item: The service item to be checked """ pos = item.data(0, QtCore.Qt.UserRole) + print('{}: {}; {}'.format(pos, len(self.service_items), item.text())) self.service_items[pos - 1]['expanded'] = False def on_expand_all(self, field=None): @@ -1149,6 +1150,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa :param item: The service item to be checked """ pos = item.data(0, QtCore.Qt.UserRole) + print('{}: {}; {}'.format(pos, len(self.service_items), item.text())) self.service_items[pos - 1]['expanded'] = True def on_service_top(self, field=None): @@ -1666,4 +1668,3 @@ def get_parent_item_data(item): return item.data(0, QtCore.Qt.UserRole) else: return parent_item.data(0, QtCore.Qt.UserRole) - diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index c62d3fe08..e998304f8 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -38,7 +38,7 @@ class ServiceNoteForm(QtWidgets.QDialog, RegistryProperties): Constructor """ super(ServiceNoteForm, self).__init__(Registry().get('main_window'), - QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi() self.retranslateUi() diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 9e4ec87f0..f8c3cbbc2 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -46,8 +46,7 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties): """ Registry().register('settings_form', self) Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up) - super(SettingsForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(SettingsForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.processes = [] self.setupUi(self) self.setting_list_widget.currentRowChanged.connect(self.list_item_changed) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 26b062d5e..dc91fa481 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -44,8 +44,7 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert """ Constructor """ - super(ShortcutListForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(ShortcutListForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.changed_actions = {} self.action_list = ActionList.get_instance() diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index 41e1efa5f..f6238a340 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -39,7 +39,7 @@ class StartTimeForm(QtWidgets.QDialog, Ui_StartTimeDialog, RegistryProperties): Constructor """ super(StartTimeForm, self).__init__(Registry().get('main_window'), - QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self): diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 593eb4b46..cb711b410 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -37,7 +37,7 @@ class AlertForm(QtWidgets.QDialog, Ui_AlertDialog): Initialise the alert form """ super(AlertForm, self).__init__(Registry().get('main_window'), - QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.manager = plugin.manager self.plugin = plugin self.item_id = None diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index cfaeba7d5..52417f2ef 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -69,8 +69,8 @@ class BibleImportForm(OpenLPWizard): """ self.manager = manager self.web_bible_list = {} - super(BibleImportForm, self).__init__( - parent, bible_plugin, 'bibleImportWizard', ':/wizards/wizard_importbible.bmp') + super(BibleImportForm, self).__init__(parent, bible_plugin, + 'bibleImportWizard', ':/wizards/wizard_importbible.bmp') def setupUi(self, image): """ diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 66f899af0..67565c915 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -49,8 +49,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog): """ Constructor """ - super(BookNameForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(BookNameForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.custom_signals() self.book_names = BibleStrings().BookNames diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index d1ca5b241..9eb64ee19 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -45,8 +45,7 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties): """ Constructor """ - super(EditBibleForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(EditBibleForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.media_item = media_item self.book_names = BibleStrings().BookNames self.setupUi(self) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index 040d73fa9..461f02c74 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -47,8 +47,7 @@ class LanguageForm(QDialog, Ui_LanguageDialog): """ Constructor """ - super(LanguageForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(LanguageForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self, bible_name): diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index dfde3126f..3aaee5290 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -44,8 +44,7 @@ class EditCustomForm(QtWidgets.QDialog, Ui_CustomEditDialog): """ Constructor """ - super(EditCustomForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(EditCustomForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.manager = manager self.media_item = media_item self.setupUi(self) diff --git a/openlp/plugins/custom/forms/editcustomslideform.py b/openlp/plugins/custom/forms/editcustomslideform.py index d1c8597d3..c57715adb 100644 --- a/openlp/plugins/custom/forms/editcustomslideform.py +++ b/openlp/plugins/custom/forms/editcustomslideform.py @@ -39,8 +39,7 @@ class EditCustomSlideForm(QtWidgets.QDialog, Ui_CustomSlideEditDialog): """ Constructor """ - super(EditCustomSlideForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(EditCustomSlideForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) # Connecting signals and slots self.insert_button.clicked.connect(self.on_insert_button_clicked) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index b5b536603..225226f7d 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -190,7 +190,7 @@ class CustomMediaItem(MediaManagerItem): if QtWidgets.QMessageBox.question( self, UiStrings().ConfirmDelete, translate('CustomPlugin.MediaItem', - 'Are you sure you want to delete the "%d" selected custom slide(s)?') %len(items), + 'Are you sure you want to delete the "%d" selected custom slide(s)?') % len(items), QtWidgets.QMessageBox.StandardButtons( QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No: diff --git a/openlp/plugins/images/forms/addgroupform.py b/openlp/plugins/images/forms/addgroupform.py index 9c343cc6b..309f6c518 100644 --- a/openlp/plugins/images/forms/addgroupform.py +++ b/openlp/plugins/images/forms/addgroupform.py @@ -35,8 +35,7 @@ class AddGroupForm(QtWidgets.QDialog, Ui_AddGroupDialog): """ Constructor """ - super(AddGroupForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(AddGroupForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self, clear=True, show_top_level_group=False, selected_group=None): diff --git a/openlp/plugins/images/forms/choosegroupform.py b/openlp/plugins/images/forms/choosegroupform.py index 4be34a2e6..dd1751092 100644 --- a/openlp/plugins/images/forms/choosegroupform.py +++ b/openlp/plugins/images/forms/choosegroupform.py @@ -33,8 +33,7 @@ class ChooseGroupForm(QtWidgets.QDialog, Ui_ChooseGroupDialog): """ Constructor """ - super(ChooseGroupForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(ChooseGroupForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self, selected_group=None): diff --git a/openlp/plugins/media/forms/mediaclipselectorform.py b/openlp/plugins/media/forms/mediaclipselectorform.py index 9770ce540..435129f10 100644 --- a/openlp/plugins/media/forms/mediaclipselectorform.py +++ b/openlp/plugins/media/forms/mediaclipselectorform.py @@ -52,8 +52,7 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro """ Constructor """ - super(MediaClipSelectorForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(MediaClipSelectorForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.vlc_instance = None self.vlc_media_player = None self.vlc_media = None diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index eb5ec2ff9..4cc0add39 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -48,7 +48,7 @@ @@ -62,7 +62,7 @@ @@ -93,7 +93,7 @@ @@ -144,7 +144,7 @@ diff --git a/openlp/plugins/remotes/html/openlp.css b/openlp/plugins/remotes/html/openlp.css index b243612d7..eb6e1b71e 100644 --- a/openlp/plugins/remotes/html/openlp.css +++ b/openlp/plugins/remotes/html/openlp.css @@ -29,3 +29,7 @@ .ui-li .ui-btn-text a.ui-link-inherit{ white-space: normal; } + +.hidden { + display: none; +} diff --git a/openlp/plugins/songs/forms/authorsform.py b/openlp/plugins/songs/forms/authorsform.py index 7e9933ddd..0d8fbf036 100644 --- a/openlp/plugins/songs/forms/authorsform.py +++ b/openlp/plugins/songs/forms/authorsform.py @@ -35,8 +35,7 @@ class AuthorsForm(QtWidgets.QDialog, Ui_AuthorsDialog): """ Set up the screen and common data """ - super(AuthorsForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(AuthorsForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.auto_display_name = False self.first_name_edit.textEdited.connect(self.on_first_name_edited) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 5286892e3..fa8e903cb 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -55,8 +55,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): """ Constructor """ - super(EditSongForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(EditSongForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.media_item = media_item self.song = None # can this be automated? diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 67693344a..9ff9ef54b 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -41,8 +41,7 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog): """ Constructor """ - super(EditVerseForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(EditVerseForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.has_single_verse = False self.insert_button.clicked.connect(self.on_insert_button_clicked) diff --git a/openlp/plugins/songs/forms/mediafilesform.py b/openlp/plugins/songs/forms/mediafilesform.py index 40d52ae0c..8920bc0ef 100644 --- a/openlp/plugins/songs/forms/mediafilesform.py +++ b/openlp/plugins/songs/forms/mediafilesform.py @@ -37,8 +37,7 @@ class MediaFilesForm(QtWidgets.QDialog, Ui_MediaFilesDialog): log.info('%s MediaFilesForm loaded', __name__) def __init__(self, parent): - super(MediaFilesForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(MediaFilesForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) def populate_files(self, files): diff --git a/openlp/plugins/songs/forms/songbookform.py b/openlp/plugins/songs/forms/songbookform.py index 015b18ecd..5571ac2b7 100644 --- a/openlp/plugins/songs/forms/songbookform.py +++ b/openlp/plugins/songs/forms/songbookform.py @@ -38,8 +38,7 @@ class SongBookForm(QtWidgets.QDialog, Ui_SongBookDialog): """ Constructor """ - super(SongBookForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(SongBookForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self, clear=True): diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 830924916..9bb00ea96 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -84,58 +84,56 @@ class SongExportForm(OpenLPWizard): """ # The page with all available songs. self.available_songs_page = QtWidgets.QWizardPage() - self.available_songs_page.setObjectName('available_songs_page') - self.available_songs_layout = QtWidgets.QHBoxLayout(self.available_songs_page) - self.available_songs_layout.setObjectName('available_songs_layout') - self.vertical_layout = QtWidgets.QVBoxLayout() - self.vertical_layout.setObjectName('vertical_layout') + available_songs_layout = QtWidgets.QHBoxLayout(self.available_songs_page) + available_songs_layout.setObjectName('available_songs_layout') + vertical_layout = QtWidgets.QVBoxLayout() + vertical_layout.setObjectName('vertical_layout') self.available_list_widget = QtWidgets.QListWidget(self.available_songs_page) self.available_list_widget.setObjectName('available_list_widget') - self.vertical_layout.addWidget(self.available_list_widget) - self.horizontal_layout = QtWidgets.QHBoxLayout() - self.horizontal_layout.setObjectName('horizontal_layout') + vertical_layout.addWidget(self.available_list_widget) + horizontal_layout = QtWidgets.QHBoxLayout() + horizontal_layout.setObjectName('horizontal_layout') self.search_label = QtWidgets.QLabel(self.available_songs_page) self.search_label.setObjectName('search_label') - self.horizontal_layout.addWidget(self.search_label) + horizontal_layout.addWidget(self.search_label) self.search_line_edit = QtWidgets.QLineEdit(self.available_songs_page) self.search_line_edit.setObjectName('search_line_edit') - self.horizontal_layout.addWidget(self.search_line_edit) + horizontal_layout.addWidget(self.search_line_edit) spacer_item = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - self.horizontal_layout.addItem(spacer_item) + horizontal_layout.addItem(spacer_item) self.uncheck_button = QtWidgets.QPushButton(self.available_songs_page) self.uncheck_button.setObjectName('uncheck_button') - self.horizontal_layout.addWidget(self.uncheck_button) + horizontal_layout.addWidget(self.uncheck_button) self.check_button = QtWidgets.QPushButton(self.available_songs_page) self.check_button.setObjectName('selectButton') - self.horizontal_layout.addWidget(self.check_button) - self.vertical_layout.addLayout(self.horizontal_layout) - self.available_songs_layout.addLayout(self.vertical_layout) + horizontal_layout.addWidget(self.check_button) + vertical_layout.addLayout(horizontal_layout) + available_songs_layout.addLayout(vertical_layout) self.addPage(self.available_songs_page) # The page with the selected songs. self.export_song_page = QtWidgets.QWizardPage() self.export_song_page.setObjectName('available_songs_page') - self.export_song_layout = QtWidgets.QHBoxLayout(self.export_song_page) - self.export_song_layout.setObjectName('export_song_layout') - self.grid_layout = QtWidgets.QGridLayout() - self.grid_layout.setObjectName('range_layout') + export_song_layout = QtWidgets.QHBoxLayout(self.export_song_page) + export_song_layout.setObjectName('export_song_layout') + grid_layout = QtWidgets.QGridLayout() + grid_layout.setObjectName('range_layout') self.selected_list_widget = QtWidgets.QListWidget(self.export_song_page) self.selected_list_widget.setObjectName('selected_list_widget') - self.grid_layout.addWidget(self.selected_list_widget, 1, 0, 1, 1) - # FIXME: self.horizontal_layout is already defined above?!?!? - self.horizontal_layout = QtWidgets.QHBoxLayout() - self.horizontal_layout.setObjectName('horizontal_layout') + grid_layout.addWidget(self.selected_list_widget, 1, 0, 1, 1) + horizontal_layout = QtWidgets.QHBoxLayout() + horizontal_layout.setObjectName('horizontal_layout') self.directory_label = QtWidgets.QLabel(self.export_song_page) self.directory_label.setObjectName('directory_label') - self.horizontal_layout.addWidget(self.directory_label) + horizontal_layout.addWidget(self.directory_label) self.directory_line_edit = QtWidgets.QLineEdit(self.export_song_page) self.directory_line_edit.setObjectName('directory_line_edit') - self.horizontal_layout.addWidget(self.directory_line_edit) + horizontal_layout.addWidget(self.directory_line_edit) self.directory_button = QtWidgets.QToolButton(self.export_song_page) self.directory_button.setIcon(build_icon(':/exports/export_load.png')) self.directory_button.setObjectName('directory_button') - self.horizontal_layout.addWidget(self.directory_button) - self.grid_layout.addLayout(self.horizontal_layout, 0, 0, 1, 1) - self.export_song_layout.addLayout(self.grid_layout) + horizontal_layout.addWidget(self.directory_button) + grid_layout.addLayout(horizontal_layout, 0, 0, 1, 1) + export_song_layout.addLayout(grid_layout) self.addPage(self.export_song_page) def retranslateUi(self): @@ -308,6 +306,7 @@ def find_list_widget_items(list_widget, text=''): item for item in list_widget.findItems(text, QtCore.Qt.MatchContains) ] + def on_item_activated(item): """ Called, when an item in the *available_list_widget* has been triggered. @@ -317,4 +316,3 @@ def on_item_activated(item): :param item: The *QListWidgetItem* which was triggered. """ item.setCheckState(QtCore.Qt.Unchecked if item.checkState() else QtCore.Qt.Checked) - diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index cbede3974..1fdfb74d4 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -44,8 +44,7 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP """ Constructor """ - super(SongMaintenanceForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(SongMaintenanceForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.manager = manager self.author_form = AuthorsForm(self) diff --git a/openlp/plugins/songs/forms/songselectform.py b/openlp/plugins/songs/forms/songselectform.py index a61bc0455..b6c161274 100755 --- a/openlp/plugins/songs/forms/songselectform.py +++ b/openlp/plugins/songs/forms/songselectform.py @@ -81,8 +81,7 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog): """ def __init__(self, parent=None, plugin=None, db_manager=None): - QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.plugin = plugin self.db_manager = db_manager self.setup_ui(self) diff --git a/openlp/plugins/songs/forms/topicsform.py b/openlp/plugins/songs/forms/topicsform.py index 39ce9c4d4..dd2c5eb5c 100644 --- a/openlp/plugins/songs/forms/topicsform.py +++ b/openlp/plugins/songs/forms/topicsform.py @@ -38,8 +38,7 @@ class TopicsForm(QtWidgets.QDialog, Ui_TopicsDialog): """ Constructor """ - super(TopicsForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(TopicsForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self, clear=True): diff --git a/openlp/plugins/songs/lib/importers/foilpresenter.py b/openlp/plugins/songs/lib/importers/foilpresenter.py index b6e66f0a5..b1b12960a 100644 --- a/openlp/plugins/songs/lib/importers/foilpresenter.py +++ b/openlp/plugins/songs/lib/importers/foilpresenter.py @@ -541,4 +541,3 @@ def to_str(element): if element is not None: return str(element) return '' - diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 9ac7afad3..51c560d37 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -365,7 +365,7 @@ class SongMediaItem(MediaManagerItem): if QtWidgets.QMessageBox.question( self, UiStrings().ConfirmDelete, translate('SongsPlugin.MediaItem', - 'Are you sure you want to delete the "%d" selected song(s)?') % len(items), + 'Are you sure you want to delete the "%d" selected song(s)?') % len(items), QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No: return diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index fc6d8d057..b97649fd9 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -36,8 +36,8 @@ class SongUsageDeleteForm(QtWidgets.QDialog, Ui_SongUsageDeleteDialog, RegistryP Constructor """ self.manager = manager - super(SongUsageDeleteForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(SongUsageDeleteForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | + QtCore.Qt.WindowTitleHint) self.setupUi(self) self.button_box.clicked.connect(self.on_button_box_clicked) @@ -48,13 +48,14 @@ class SongUsageDeleteForm(QtWidgets.QDialog, Ui_SongUsageDeleteDialog, RegistryP :param button: The button pressed """ if self.button_box.standardButton(button) == QtWidgets.QDialogButtonBox.Ok: - ret = QtWidgets.QMessageBox.question( - self, - translate('SongUsagePlugin.SongUsageDeleteForm', 'Delete Selected Song Usage Events?'), - translate('SongUsagePlugin.SongUsageDeleteForm', - 'Are you sure you want to delete selected Song Usage data?'), - QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), - QtWidgets.QMessageBox.No) + ret = QtWidgets.QMessageBox.question(self, + translate('SongUsagePlugin.SongUsageDeleteForm', + 'Delete Selected Song Usage Events?'), + translate('SongUsagePlugin.SongUsageDeleteForm', + 'Are you sure you want to delete selected Song Usage data?'), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.No) if ret == QtWidgets.QMessageBox.Yes: delete_date = self.delete_calendar.selectedDate().toPyDate() self.manager.delete_all_objects(SongUsageItem, SongUsageItem.usagedate <= delete_date) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 84f85d5d4..8edf9775f 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -44,8 +44,7 @@ class SongUsageDetailForm(QtWidgets.QDialog, Ui_SongUsageDetailDialog, RegistryP """ Initialise the form """ - super(SongUsageDetailForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint - | QtCore.Qt.WindowTitleHint) + super(SongUsageDetailForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.plugin = plugin self.setupUi(self) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index b433d96e0..0363d2b62 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -226,7 +226,7 @@ class SongUsagePlugin(Plugin): """ self.song_usage_detail_form.initialise() self.song_usage_detail_form.exec() - + @staticmethod def about(): """ diff --git a/tests/functional/openlp_core_lib/test_mediamanageritem.py b/tests/functional/openlp_core_lib/test_mediamanageritem.py index a3674f591..892b67f2d 100644 --- a/tests/functional/openlp_core_lib/test_mediamanageritem.py +++ b/tests/functional/openlp_core_lib/test_mediamanageritem.py @@ -75,7 +75,6 @@ class TestMediaManagerItem(TestCase, TestMixin): self.assertTrue(mmi.has_delete_icon, 'By default a delete icon should be present') self.assertFalse(mmi.add_to_service_item, 'There should be no add_to_service icon by default') - @patch(u'openlp.core.lib.mediamanageritem.Settings') @patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click') def on_double_clicked_go_live_test(self, mocked_on_live_click, MockedSettings): diff --git a/tests/functional/openlp_core_lib/test_projectordb.py b/tests/functional/openlp_core_lib/test_projectordb.py index 3559e9e8c..58eff13bc 100644 --- a/tests/functional/openlp_core_lib/test_projectordb.py +++ b/tests/functional/openlp_core_lib/test_projectordb.py @@ -185,4 +185,3 @@ class TestProjectorDB(TestCase): # THEN: Projector should have the same source entry item = self.projector.get_projector_by_id(item_id) self.assertTrue(compare_source(item.source_list[0], source)) - diff --git a/tests/functional/openlp_plugins/songs/test_songformat.py b/tests/functional/openlp_plugins/songs/test_songformat.py index eab9760b8..e7c84e7db 100644 --- a/tests/functional/openlp_plugins/songs/test_songformat.py +++ b/tests/functional/openlp_plugins/songs/test_songformat.py @@ -40,7 +40,7 @@ class TestSongFormat(TestCase): # WHEN: Retrieving the format list # THEN: All SongFormats should be returned self.assertEquals(len(SongFormat.get_format_list()), len(SongFormat.__attributes__), - "The returned SongFormats don't match the stored ones") + "The returned SongFormats don't match the stored ones") def test_get_attributed_no_attributes(self): """ @@ -51,7 +51,7 @@ class TestSongFormat(TestCase): for song_format in SongFormat.get_format_list(): # THEN: All attributes associated with the SongFormat should be returned self.assertEquals(SongFormat.get(song_format), SongFormat.__attributes__[song_format], - "The returned attributes don't match the stored ones") + "The returned attributes don't match the stored ones") def test_get_attributed_single_attribute(self): """ @@ -63,13 +63,13 @@ class TestSongFormat(TestCase): for attribute in SongFormat.get(song_format).keys(): # THEN: Return the attribute self.assertEquals(SongFormat.get(song_format, attribute), SongFormat.get(song_format)[attribute], - "The returned attribute doesn't match the stored one") + "The returned attribute doesn't match the stored one") # WHEN: Retrieving an attribute that was not overridden for attribute in SongFormat.__defaults__.keys(): if attribute not in SongFormat.get(song_format).keys(): # THEN: Return the default value self.assertEquals(SongFormat.get(song_format, attribute), SongFormat.__defaults__[attribute], - "The returned attribute does not match the default values stored") + "The returned attribute does not match the default values stored") def test_get_attributed_multiple_attributes(self): """ @@ -80,5 +80,5 @@ class TestSongFormat(TestCase): for song_format in SongFormat.get_format_list(): # THEN: Return all attributes that were specified self.assertEquals(len(SongFormat.get(song_format, 'canDisable', 'availability')), 2, - "Did not return the correct number of attributes when retrieving multiple attributes at once") - + "Did not return the correct number of attributes" + " when retrieving multiple attributes at once") diff --git a/tests/interfaces/openlp_core_ui/test_projectoreditform.py b/tests/interfaces/openlp_core_ui/test_projectoreditform.py index 0f42e38ae..7518f139e 100644 --- a/tests/interfaces/openlp_core_ui/test_projectoreditform.py +++ b/tests/interfaces/openlp_core_ui/test_projectoreditform.py @@ -103,5 +103,3 @@ class TestProjectorEditForm(TestCase, TestMixin): 'Projector edit form should be marked as existing entry') self.assertTrue((item.ip is TEST1_DATA['ip'] and item.name is TEST1_DATA['name']), 'Projector edit form should have TEST1_DATA() instance to edit') - - From 44cd766885618e1da020a081169f0fc9ec71366f Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sat, 9 Jan 2016 18:22:09 +0100 Subject: [PATCH 11/22] Remove code that was added by mistake --- openlp/core/ui/servicemanager.py | 2 -- openlp/plugins/remotes/html/index.html | 10 +++++----- openlp/plugins/remotes/html/openlp.css | 4 ---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index caba6536b..0a81686b8 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1131,7 +1131,6 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa :param item: The service item to be checked """ pos = item.data(0, QtCore.Qt.UserRole) - print('{}: {}; {}'.format(pos, len(self.service_items), item.text())) self.service_items[pos - 1]['expanded'] = False def on_expand_all(self, field=None): @@ -1150,7 +1149,6 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa :param item: The service item to be checked """ pos = item.data(0, QtCore.Qt.UserRole) - print('{}: {}; {}'.format(pos, len(self.service_items), item.text())) self.service_items[pos - 1]['expanded'] = True def on_service_top(self, field=None): diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index 4cc0add39..dcdd8d33d 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -48,7 +48,7 @@ @@ -62,7 +62,7 @@ @@ -93,7 +93,7 @@ @@ -144,7 +144,7 @@ @@ -167,7 +167,7 @@

${options}

- + ${go_live} ${add_to_service} ${add_and_go_to_service} diff --git a/openlp/plugins/remotes/html/openlp.css b/openlp/plugins/remotes/html/openlp.css index eb6e1b71e..b243612d7 100644 --- a/openlp/plugins/remotes/html/openlp.css +++ b/openlp/plugins/remotes/html/openlp.css @@ -29,7 +29,3 @@ .ui-li .ui-btn-text a.ui-link-inherit{ white-space: normal; } - -.hidden { - display: none; -} From faff2b7da48cf057d6d31db9f1af3c28ddabd79d Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sat, 9 Jan 2016 23:35:56 +0100 Subject: [PATCH 12/22] Undo changes to instance variables --- openlp/plugins/songs/forms/songexportform.py | 54 ++++++++++---------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 9bb00ea96..ee35ea7e5 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -84,56 +84,58 @@ class SongExportForm(OpenLPWizard): """ # The page with all available songs. self.available_songs_page = QtWidgets.QWizardPage() - available_songs_layout = QtWidgets.QHBoxLayout(self.available_songs_page) - available_songs_layout.setObjectName('available_songs_layout') - vertical_layout = QtWidgets.QVBoxLayout() - vertical_layout.setObjectName('vertical_layout') + self.available_songs_page.setObjectName('available_songs_page') + self.available_songs_layout = QtWidgets.QHBoxLayout(self.available_songs_page) + self.available_songs_layout.setObjectName('available_songs_layout') + self.vertical_layout = QtWidgets.QVBoxLayout() + self.vertical_layout.setObjectName('vertical_layout') self.available_list_widget = QtWidgets.QListWidget(self.available_songs_page) self.available_list_widget.setObjectName('available_list_widget') - vertical_layout.addWidget(self.available_list_widget) - horizontal_layout = QtWidgets.QHBoxLayout() - horizontal_layout.setObjectName('horizontal_layout') + self.vertical_layout.addWidget(self.available_list_widget) + self.horizontal_layout = QtWidgets.QHBoxLayout() + self.horizontal_layout.setObjectName('horizontal_layout') self.search_label = QtWidgets.QLabel(self.available_songs_page) self.search_label.setObjectName('search_label') - horizontal_layout.addWidget(self.search_label) + self.horizontal_layout.addWidget(self.search_label) self.search_line_edit = QtWidgets.QLineEdit(self.available_songs_page) self.search_line_edit.setObjectName('search_line_edit') - horizontal_layout.addWidget(self.search_line_edit) + self.horizontal_layout.addWidget(self.search_line_edit) spacer_item = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) - horizontal_layout.addItem(spacer_item) + self.horizontal_layout.addItem(spacer_item) self.uncheck_button = QtWidgets.QPushButton(self.available_songs_page) self.uncheck_button.setObjectName('uncheck_button') - horizontal_layout.addWidget(self.uncheck_button) + self.horizontal_layout.addWidget(self.uncheck_button) self.check_button = QtWidgets.QPushButton(self.available_songs_page) self.check_button.setObjectName('selectButton') - horizontal_layout.addWidget(self.check_button) - vertical_layout.addLayout(horizontal_layout) - available_songs_layout.addLayout(vertical_layout) + self.horizontal_layout.addWidget(self.check_button) + self.vertical_layout.addLayout(self.horizontal_layout) + self.available_songs_layout.addLayout(self.vertical_layout) self.addPage(self.available_songs_page) # The page with the selected songs. self.export_song_page = QtWidgets.QWizardPage() self.export_song_page.setObjectName('available_songs_page') - export_song_layout = QtWidgets.QHBoxLayout(self.export_song_page) - export_song_layout.setObjectName('export_song_layout') - grid_layout = QtWidgets.QGridLayout() - grid_layout.setObjectName('range_layout') + self.export_song_layout = QtWidgets.QHBoxLayout(self.export_song_page) + self.export_song_layout.setObjectName('export_song_layout') + self.grid_layout = QtWidgets.QGridLayout() + self.grid_layout.setObjectName('range_layout') self.selected_list_widget = QtWidgets.QListWidget(self.export_song_page) self.selected_list_widget.setObjectName('selected_list_widget') - grid_layout.addWidget(self.selected_list_widget, 1, 0, 1, 1) - horizontal_layout = QtWidgets.QHBoxLayout() - horizontal_layout.setObjectName('horizontal_layout') + self.grid_layout.addWidget(self.selected_list_widget, 1, 0, 1, 1) + # FIXME: self.horizontal_layout is already defined above?!?!? + self.horizontal_layout = QtWidgets.QHBoxLayout() + self.horizontal_layout.setObjectName('horizontal_layout') self.directory_label = QtWidgets.QLabel(self.export_song_page) self.directory_label.setObjectName('directory_label') - horizontal_layout.addWidget(self.directory_label) + self.horizontal_layout.addWidget(self.directory_label) self.directory_line_edit = QtWidgets.QLineEdit(self.export_song_page) self.directory_line_edit.setObjectName('directory_line_edit') - horizontal_layout.addWidget(self.directory_line_edit) + self.horizontal_layout.addWidget(self.directory_line_edit) self.directory_button = QtWidgets.QToolButton(self.export_song_page) self.directory_button.setIcon(build_icon(':/exports/export_load.png')) self.directory_button.setObjectName('directory_button') - horizontal_layout.addWidget(self.directory_button) - grid_layout.addLayout(horizontal_layout, 0, 0, 1, 1) - export_song_layout.addLayout(grid_layout) + self.horizontal_layout.addWidget(self.directory_button) + self.grid_layout.addLayout(self.horizontal_layout, 0, 0, 1, 1) + self.export_song_layout.addLayout(self.grid_layout) self.addPage(self.export_song_page) def retranslateUi(self): From 076cc57d390c7a3dfd2a598eccbc70dc502f85ce Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 10 Jan 2016 01:17:58 +0100 Subject: [PATCH 13/22] Fix Song import --- openlp/plugins/songs/lib/importer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 545e14d60..5e099dde9 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -390,7 +390,7 @@ class SongFormat(object): """ Return a list of the supported song formats. """ - return [ + return sorted([ SongFormat.OpenLyrics, SongFormat.OpenLP2, SongFormat.Generic, @@ -400,6 +400,7 @@ class SongFormat(object): SongFormat.EasyWorshipDB, SongFormat.EasyWorshipService, SongFormat.FoilPresenter, + SongFormat.Lyrix, SongFormat.MediaShout, SongFormat.OpenSong, SongFormat.PowerPraise, @@ -411,13 +412,12 @@ class SongFormat(object): SongFormat.SongShowPlus, SongFormat.SongsOfFellowship, SongFormat.SundayPlus, + SongFormat.VideoPsalm, SongFormat.WordsOfWorship, SongFormat.WorshipAssistant, SongFormat.WorshipCenterPro, SongFormat.ZionWorx, - SongFormat.Lyrix, - SongFormat.VideoPsalm - ] + ]) @staticmethod def get(song_format, *attributes): From 70e1f3926b5717d5b941dd558b4310348d47815a Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 10 Jan 2016 01:18:27 +0100 Subject: [PATCH 14/22] Add test for fix --- tests/functional/openlp_plugins/songs/test_songformat.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/functional/openlp_plugins/songs/test_songformat.py b/tests/functional/openlp_plugins/songs/test_songformat.py index 0c82b049c..3611bf749 100644 --- a/tests/functional/openlp_plugins/songs/test_songformat.py +++ b/tests/functional/openlp_plugins/songs/test_songformat.py @@ -81,3 +81,11 @@ class TestSongFormat(TestCase): # THEN: Return all attributes that were specified self.assertEquals(len(SongFormat.get(song_format, 'canDisable', 'availability')), 2, "Did not return the correct number of attributes when retrieving multiple attributes at once") + + def test_get_format_list_returns_ordered_list(self): + """ + Test that get_format_list() returns a list that is ordered + according to the order specified in SongFormat + """ + self.assertEquals(sorted(SongFormat.get_format_list()), SongFormat.get_format_list(), + "The list returned should be sorted according to the ordering in SongFormat") From 9525453679b9005219d55810d7f27d69835b9a71 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 10 Jan 2016 01:22:31 +0100 Subject: [PATCH 15/22] Ignore case when matching verse tags during SongBeamerImport --- .../plugins/songs/lib/importers/songbeamer.py | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/openlp/plugins/songs/lib/importers/songbeamer.py b/openlp/plugins/songs/lib/importers/songbeamer.py index 0146cb45b..71d047ab5 100644 --- a/openlp/plugins/songs/lib/importers/songbeamer.py +++ b/openlp/plugins/songs/lib/importers/songbeamer.py @@ -36,28 +36,28 @@ log = logging.getLogger(__name__) class SongBeamerTypes(object): MarkTypes = { - 'Refrain': VerseType.tags[VerseType.Chorus], - 'Chorus': VerseType.tags[VerseType.Chorus], - 'Vers': VerseType.tags[VerseType.Verse], - 'Verse': VerseType.tags[VerseType.Verse], - 'Strophe': VerseType.tags[VerseType.Verse], - 'Intro': VerseType.tags[VerseType.Intro], - 'Coda': VerseType.tags[VerseType.Ending], - 'Ending': VerseType.tags[VerseType.Ending], - 'Bridge': VerseType.tags[VerseType.Bridge], - 'Interlude': VerseType.tags[VerseType.Bridge], - 'Zwischenspiel': VerseType.tags[VerseType.Bridge], - 'Pre-Chorus': VerseType.tags[VerseType.PreChorus], - 'Pre-Refrain': VerseType.tags[VerseType.PreChorus], - 'Misc': VerseType.tags[VerseType.Other], - 'Pre-Bridge': VerseType.tags[VerseType.Other], - 'Pre-Coda': VerseType.tags[VerseType.Other], - 'Part': VerseType.tags[VerseType.Other], - 'Teil': VerseType.tags[VerseType.Other], - 'Unbekannt': VerseType.tags[VerseType.Other], - 'Unknown': VerseType.tags[VerseType.Other], - 'Unbenannt': VerseType.tags[VerseType.Other], - '$$M=': VerseType.tags[VerseType.Other] + 'refrain': VerseType.tags[VerseType.Chorus], + 'chorus': VerseType.tags[VerseType.Chorus], + 'vers': VerseType.tags[VerseType.Verse], + 'verse': VerseType.tags[VerseType.Verse], + 'strophe': VerseType.tags[VerseType.Verse], + 'intro': VerseType.tags[VerseType.Intro], + 'coda': VerseType.tags[VerseType.Ending], + 'ending': VerseType.tags[VerseType.Ending], + 'bridge': VerseType.tags[VerseType.Bridge], + 'interlude': VerseType.tags[VerseType.Bridge], + 'zwischenspiel': VerseType.tags[VerseType.Bridge], + 'pre-chorus': VerseType.tags[VerseType.PreChorus], + 'pre-refrain': VerseType.tags[VerseType.PreChorus], + 'misc': VerseType.tags[VerseType.Other], + 'pre-bridge': VerseType.tags[VerseType.Other], + 'pre-coda': VerseType.tags[VerseType.Other], + 'part': VerseType.tags[VerseType.Other], + 'teil': VerseType.tags[VerseType.Other], + 'unbekannt': VerseType.tags[VerseType.Other], + 'unknown': VerseType.tags[VerseType.Other], + 'unbenannt': VerseType.tags[VerseType.Other], + '$$m=': VerseType.tags[VerseType.Other] } @@ -267,20 +267,20 @@ class SongBeamerImport(SongImport): def check_verse_marks(self, line): """ - Check and add the verse's MarkType. Returns ``True`` if the given linE contains a correct verse mark otherwise + Check and add the verse's MarkType. Returns ``True`` if the given line contains a correct verse mark otherwise ``False``. :param line: The line to check for marks (unicode). """ marks = line.split(' ') - if len(marks) <= 2 and marks[0] in SongBeamerTypes.MarkTypes: - self.current_verse_type = SongBeamerTypes.MarkTypes[marks[0]] + if len(marks) <= 2 and marks[0].lower() in SongBeamerTypes.MarkTypes: + self.current_verse_type = SongBeamerTypes.MarkTypes[marks[0].lower()] if len(marks) == 2: # If we have a digit, we append it to current_verse_type. if marks[1].isdigit(): self.current_verse_type += marks[1] return True - elif marks[0].startswith('$$M='): # this verse-mark cannot be numbered - self.current_verse_type = SongBeamerTypes.MarkTypes['$$M='] + elif marks[0].lower().startswith('$$m='): # this verse-mark cannot be numbered + self.current_verse_type = SongBeamerTypes.MarkTypes['$$m='] return True return False From 0f1d6718bd1c118741b7b63edb079693f2f4ee83 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 10 Jan 2016 01:34:53 +0100 Subject: [PATCH 16/22] Add tests for ignored case --- .../songs/test_songbeamerimport.py | 23 +++++++++++++------ .../openlp_plugins/songs/test_songformat.py | 5 +++- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py index d4b23b207..9f20e6a08 100644 --- a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py +++ b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py @@ -28,7 +28,7 @@ from unittest import TestCase from tests.helpers.songfileimport import SongImportTestHelper from tests.functional import MagicMock, patch -from openlp.plugins.songs.lib.importers.songbeamer import SongBeamerImport +from openlp.plugins.songs.lib.importers.songbeamer import SongBeamerImport, SongBeamerTypes from openlp.core.common import Registry TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), @@ -131,22 +131,22 @@ class TestSongBeamerImport(TestCase): self.assertEqual(self.current_verse_type, 'c', ' should be interpreted as ') # GIVEN: line with unnumbered verse-type and trailing space - line = 'Refrain ' + line = 'ReFrain ' self.current_verse_type = None # WHEN: line is being checked for verse marks result = SongBeamerImport.check_verse_marks(self, line) # THEN: we should get back true and c as self.current_verse_type - self.assertTrue(result, 'Versemark for should be found, value true') - self.assertEqual(self.current_verse_type, 'c', ' should be interpreted as ') + self.assertTrue(result, 'Versemark for should be found, value true') + self.assertEqual(self.current_verse_type, 'c', ' should be interpreted as ') # GIVEN: line with numbered verse-type - line = 'Verse 1' + line = 'VersE 1' self.current_verse_type = None # WHEN: line is being checked for verse marks result = SongBeamerImport.check_verse_marks(self, line) # THEN: we should get back true and v1 as self.current_verse_type - self.assertTrue(result, 'Versemark for should be found, value true') - self.assertEqual(self.current_verse_type, 'v1', u' should be interpreted as ') + self.assertTrue(result, 'Versemark for should be found, value true') + self.assertEqual(self.current_verse_type, 'v1', u' should be interpreted as ') # GIVEN: line with special unnumbered verse-mark (used in Songbeamer to allow usage of non-supported tags) line = '$$M=special' @@ -192,3 +192,12 @@ class TestSongBeamerImport(TestCase): # THEN: we should get back false and none as self.current_verse_type self.assertFalse(result, 'No versemark for <> should be found, value false') self.assertIsNone(self.current_verse_type, '<> should be interpreted as none versemark') + + def test_verse_marks_defined_in_lowercase(self): + """ + Test that the verse marks are all defined in lowercase + """ + # GIVEN: SongBeamber MarkTypes + for tag in SongBeamerTypes.MarkTypes.keys(): + # THEN: tag should be defined in lowercase + self.assertEquals(tag, tag.lower(), 'Tags should be defined in lowercase') diff --git a/tests/functional/openlp_plugins/songs/test_songformat.py b/tests/functional/openlp_plugins/songs/test_songformat.py index 3611bf749..19e1470c3 100644 --- a/tests/functional/openlp_plugins/songs/test_songformat.py +++ b/tests/functional/openlp_plugins/songs/test_songformat.py @@ -87,5 +87,8 @@ class TestSongFormat(TestCase): Test that get_format_list() returns a list that is ordered according to the order specified in SongFormat """ + # GIVEN: The SongFormat class + # WHEN: Retrieving all formats + # THEN: The returned list should be sorted according to the ordering defined in SongFormat self.assertEquals(sorted(SongFormat.get_format_list()), SongFormat.get_format_list(), - "The list returned should be sorted according to the ordering in SongFormat") + "The list returned should be sorted according to the ordering in SongFormat") From 0e8dc032dac4e78809216c174d01de78fcb30634 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 10 Jan 2016 15:15:22 +0200 Subject: [PATCH 17/22] Release 2.3.2 bzr-revno: 2602 --- openlp/.version | 2 +- tests/utils/test_bzr_tags.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/.version b/openlp/.version index 2bf1c1ccf..f90b1afc0 100644 --- a/openlp/.version +++ b/openlp/.version @@ -1 +1 @@ -2.3.1 +2.3.2 diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py index 34066452f..a92253814 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_bzr_tags.py @@ -29,7 +29,7 @@ from subprocess import Popen, PIPE 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', - '2.3.1'} + '2.3.1', '2.3.2'} class TestBzrTags(TestCase): From e172e2aeb20949ef0105b0e0bf1977f55500c5f9 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 10 Jan 2016 17:00:05 +0100 Subject: [PATCH 18/22] Revert Changes --- openlp/core/lib/screen.py | 2 +- openlp/plugins/remotes/html/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index a527b3766..819ba9763 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -224,7 +224,7 @@ class ScreenList(object): y = window.y() + (window.height() // 2) for screen in self.screen_list: size = screen['size'] - if size.x() <= x <= (size.x() + size.width()) and size.y() <= y <= (size.y() + size.height()): + if x >= size.x() and x <= (size.x() + size.width()) and y >= size.y() and y <= (size.y() + size.height()): return screen['number'] def load_screen_settings(self): diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index dcdd8d33d..eb5ec2ff9 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -167,7 +167,7 @@

${options}

- + ${go_live} ${add_to_service} ${add_and_go_to_service} From a9df7771f654fdcb80f191ecd84afa6444457612 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 10 Jan 2016 17:09:18 -0500 Subject: [PATCH 19/22] Skip OpenOffice test if uno isn't available --- tests/functional/openlp_plugins/songs/test_openoffice.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_plugins/songs/test_openoffice.py b/tests/functional/openlp_plugins/songs/test_openoffice.py index 231193951..acb56939f 100644 --- a/tests/functional/openlp_plugins/songs/test_openoffice.py +++ b/tests/functional/openlp_plugins/songs/test_openoffice.py @@ -22,10 +22,13 @@ """ This module contains tests for the OpenOffice/LibreOffice importer. """ -from unittest import TestCase +from unittest import TestCase, SkipTest from openlp.core.common import Registry -from openlp.plugins.songs.lib.importers.openoffice import OpenOfficeImport +try: + from openlp.plugins.songs.lib.importers.openoffice import OpenOfficeImport +except ImportError: + raise SkipTest('Could not import OpenOfficeImport probably due to unavailability of uno') from tests.functional import MagicMock, patch from tests.helpers.testmixin import TestMixin From 263a7b2c62b2e0397178b4576be4aeeb08625c73 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 10 Jan 2016 17:10:05 -0500 Subject: [PATCH 20/22] Fix macosx_display_windows_flags_state test --- tests/functional/openlp_core_ui/test_maindisplay.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py index 1f4649dbc..563eb578d 100644 --- a/tests/functional/openlp_core_ui/test_maindisplay.py +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -141,14 +141,13 @@ class TestMainDisplay(TestCase, TestMixin): mocked_songs_plugin.refresh_css.assert_called_with(main_display.frame) mocked_bibles_plugin.refresh_css.assert_called_with(main_display.frame) - @skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.') - def macosx_display_window_flags_state_test(self, is_macosx): + @patch('openlp.core.ui.maindisplay.is_macosx') + def macosx_display_window_flags_state_test(self, mocked_is_macosx): """ Test that on Mac OS X we set the proper window flags """ - if not is_macosx(): - self.skipTest('Can only run test on Mac OS X due to pyobjc dependency.') # GIVEN: A new SlideController instance on Mac OS X. + mocked_is_macosx.return_value = True self.screens.set_current_display(0) display = MagicMock() From c07503f5dc0272fa3bd0b5431797ce204948db6e Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 10 Jan 2016 17:10:50 -0500 Subject: [PATCH 21/22] Fix import --- tests/functional/openlp_core_lib/test_projector_pjlink1.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_projector_pjlink1.py b/tests/functional/openlp_core_lib/test_projector_pjlink1.py index 4079ab9f0..92ce02acd 100644 --- a/tests/functional/openlp_core_lib/test_projector_pjlink1.py +++ b/tests/functional/openlp_core_lib/test_projector_pjlink1.py @@ -25,10 +25,9 @@ Package to test the openlp.core.lib.projector.pjlink1 package. from unittest import TestCase -from mock import MagicMock, patch - from openlp.core.lib.projector.pjlink1 import PJLink1 +from tests.functional import patch from tests.resources.projector.data import TEST_PIN, TEST_SALT, TEST_CONNECT_AUTHENTICATE pjlink_test = PJLink1(name='test', ip='127.0.0.1', pin=TEST_PIN, no_poll=True) From fc2efb73435ca12f1cd03031fbcfc777ab263ab0 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 10 Jan 2016 22:27:28 -0500 Subject: [PATCH 22/22] Fix Mac OS X display flags test --- tests/functional/openlp_core_ui/test_maindisplay.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py index 563eb578d..9c80740f2 100644 --- a/tests/functional/openlp_core_ui/test_maindisplay.py +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -141,13 +141,12 @@ class TestMainDisplay(TestCase, TestMixin): mocked_songs_plugin.refresh_css.assert_called_with(main_display.frame) mocked_bibles_plugin.refresh_css.assert_called_with(main_display.frame) - @patch('openlp.core.ui.maindisplay.is_macosx') - def macosx_display_window_flags_state_test(self, mocked_is_macosx): + @skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.') + def macosx_display_window_flags_state_test(self): """ Test that on Mac OS X we set the proper window flags """ # GIVEN: A new SlideController instance on Mac OS X. - mocked_is_macosx.return_value = True self.screens.set_current_display(0) display = MagicMock()