From df1faa2a8dfc71f5c7dac57aa0b197c4c80e1343 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Mon, 25 Mar 2013 21:17:46 +0100 Subject: [PATCH 01/27] - Fixed traceback on canceling the 'choose group' dialog - Clear the 'new group' lineedit in the 'choose group' dialog --- openlp/plugins/images/forms/choosegroupform.py | 1 + openlp/plugins/images/lib/mediaitem.py | 1 + 2 files changed, 2 insertions(+) diff --git a/openlp/plugins/images/forms/choosegroupform.py b/openlp/plugins/images/forms/choosegroupform.py index bbb57255c..f5478d014 100644 --- a/openlp/plugins/images/forms/choosegroupform.py +++ b/openlp/plugins/images/forms/choosegroupform.py @@ -50,6 +50,7 @@ class ChooseGroupForm(QtGui.QDialog, Ui_ChooseGroupDialog): ``selected_group`` The ID of the group that should be selected by default when showing the dialog """ + self.new_group_edit.clear() if selected_group is not None: for i in range(self.group_combobox.count()): if self.group_combobox.itemData(i) == selected_group: diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 1b2fe512e..ceb67f74b 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -394,6 +394,7 @@ class ImageMediaItem(MediaManagerItem): ``initial_load`` When set to False, the busy cursor and progressbar will be shown while loading images """ + parent_group = None if target_group is None: # Find out if a group must be pre-selected preselect_group = None From 44547769c637a46210f488ce751b1968a84d5bd4 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Tue, 26 Mar 2013 10:47:05 +0100 Subject: [PATCH 02/27] - Fixed traceback on adding multiple image groups to the service in one go - Cleaned up obsolete line in imagetab --- openlp/core/lib/mediamanageritem.py | 2 +- openlp/plugins/images/lib/imagetab.py | 1 - openlp/plugins/images/lib/mediaitem.py | 117 ++++++++++++++----------- 3 files changed, 65 insertions(+), 55 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index e261bfe59..960708620 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -464,7 +464,7 @@ class MediaManagerItem(QtGui.QWidget): translate('OpenLP.MediaManagerItem', 'You must select one or more items to preview.')) else: log.debug(u'%s Preview requested', self.plugin.name) - service_item = self.build_service_item() + service_item = self.build_service_item(context=ServiceItemContext.Preview) if service_item: service_item.from_plugin = True self.preview_controller.add_service_item(service_item) diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index 83d015cb8..b43b19097 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -32,7 +32,6 @@ from PyQt4 import QtGui from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate - class ImageTab(SettingsTab): """ ImageTab is the images settings tab in the settings dialog. diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index ceb67f74b..9bdd1dd11 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, ServiceItemContext, Settings, \ +from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, ServiceItem, ServiceItemContext, Settings, \ StringContent, TreeWidgetWithDnD, UiStrings, build_icon, check_directory_exists, check_item_selected, \ create_thumb, translate, validate_thumb from openlp.core.lib.ui import create_widget_action, critical_error_message_box @@ -538,63 +538,74 @@ class ImageMediaItem(MediaManagerItem): """ background = QtGui.QColor(Settings().value(self.settings_section + u'/background color')) if item: - items = [item] + new_items = [item] else: - items = self.list_view.selectedItems() - if not items: + new_items = self.list_view.selectedItems() + if not new_items: return False - # Determine service item title - if isinstance(items[0].data(0, QtCore.Qt.UserRole), ImageGroups): - service_item.title = items[0].text(0) - else: - service_item.title = unicode(self.plugin.name_strings[u'plural']) - service_item.add_capability(ItemCapabilities.CanMaintain) - service_item.add_capability(ItemCapabilities.CanPreview) - service_item.add_capability(ItemCapabilities.CanLoop) - service_item.add_capability(ItemCapabilities.CanAppend) - # force a nonexistent theme - service_item.theme = -1 - missing_items = [] - missing_items_filenames = [] - # Expand groups to images - for bitem in items: + for bitem in new_items: + new_service_item = ServiceItem(self.plugin) + new_service_item.add_icon(self.plugin.icon_path) + # Determine service item title + if isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageGroups): + new_service_item.title = bitem.text(0) + else: + new_service_item.title = unicode(self.plugin.name_strings[u'plural']) + new_service_item.add_capability(ItemCapabilities.CanMaintain) + new_service_item.add_capability(ItemCapabilities.CanPreview) + new_service_item.add_capability(ItemCapabilities.CanLoop) + new_service_item.add_capability(ItemCapabilities.CanAppend) + # force a nonexistent theme + new_service_item.theme = -1 + sub_images = [] + missing_items = [] + missing_items_filenames = [] + # Expand groups to images if isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageGroups) or bitem.data(0, QtCore.Qt.UserRole) is None: for index in range(0, bitem.childCount()): if isinstance(bitem.child(index).data(0, QtCore.Qt.UserRole), ImageFilenames): - items.append(bitem.child(index)) - items.remove(bitem) - # Don't try to display empty groups - if not items: - return False - # Find missing files - for bitem in items: - filename = bitem.data(0, QtCore.Qt.UserRole).filename - if not os.path.exists(filename): - missing_items.append(bitem) - missing_items_filenames.append(filename) - for item in missing_items: - items.remove(item) - # We cannot continue, as all images do not exist. - if not items: - if not remote: - critical_error_message_box( - translate('ImagePlugin.MediaItem', 'Missing Image(s)'), - translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s') % - u'\n'.join(missing_items_filenames)) - return False - # We have missing as well as existing images. We ask what to do. - elif missing_items and QtGui.QMessageBox.question(self, - translate('ImagePlugin.MediaItem', 'Missing Image(s)'), - translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s\n' - 'Do you want to add the other images anyway?') % u'\n'.join(missing_items_filenames), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: - return False - # Continue with the existing images. - for bitem in items: - filename = bitem.data(0, QtCore.Qt.UserRole).filename - name = os.path.split(filename)[1] - service_item.add_from_image(filename, name, background) - return True + sub_images.append(bitem.child(index)) + # Don't try to display empty groups + if not sub_images: + return False + # Find missing files + for bitem in sub_images: + filename = bitem.data(0, QtCore.Qt.UserRole).filename + if not os.path.exists(filename): + missing_items.append(bitem) + missing_items_filenames.append(filename) + for item in missing_items: + sub_images.remove(item) + # We cannot continue, as all images do not exist. + if not sub_images: + if not remote: + critical_error_message_box( + translate('ImagePlugin.MediaItem', 'Missing Image(s)'), + translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s') % + u'\n'.join(missing_items_filenames)) + return False + # We have missing as well as existing images. We ask what to do. + elif missing_items and QtGui.QMessageBox.question(self, + translate('ImagePlugin.MediaItem', 'Missing Image(s)'), + translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s\n' + 'Do you want to add the other images anyway?') % u'\n'.join(missing_items_filenames), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == \ + QtGui.QMessageBox.No: + return False + # Continue with the existing images. + for sub_image in sub_images: + filename = sub_image.data(0, QtCore.Qt.UserRole).filename + name = os.path.split(filename)[1] + new_service_item.add_from_image(filename, name, background) + # Add the service item to the correct controller + if context == ServiceItemContext.Service: + self.service_manager.add_service_item(new_service_item) + elif context == ServiceItemContext.Preview: + self.preview_controller.add_service_item(new_service_item) + elif context == ServiceItemContext.Live: + self.live_controller.add_service_item(new_service_item) + # Return False because we added the service item ourselves + return False def check_group_exists(self, new_group): """ From 6b032d52e554a2080ef9fb3127df1d2c0ccd5bf8 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Tue, 26 Mar 2013 11:32:22 +0100 Subject: [PATCH 03/27] - Fixed adding single images --- openlp/plugins/images/lib/mediaitem.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 163d7094e..75c6a1216 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -565,6 +565,8 @@ class ImageMediaItem(MediaManagerItem): for index in range(0, bitem.childCount()): if isinstance(bitem.child(index).data(0, QtCore.Qt.UserRole), ImageFilenames): sub_images.append(bitem.child(index)) + if isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageFilenames): + sub_images.append(bitem) # Don't try to display empty groups if not sub_images: return False From 28f8e31bf0223b206e94f622e791f0069a28275e Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Fri, 29 Mar 2013 13:00:06 +0100 Subject: [PATCH 04/27] Added a simple test for onResetClick() --- .../functional/openlp_plugins/images/test_lib.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/functional/openlp_plugins/images/test_lib.py b/tests/functional/openlp_plugins/images/test_lib.py index a355e956b..6349745c2 100644 --- a/tests/functional/openlp_plugins/images/test_lib.py +++ b/tests/functional/openlp_plugins/images/test_lib.py @@ -23,6 +23,7 @@ class TestImageMediaItem(TestCase): Registry.create() Registry().register(u'service_list', MagicMock()) Registry().register(u'main_window', self.mocked_main_window) + Registry().register(u'live_controller', MagicMock()) mocked_parent = MagicMock() mocked_plugin = MagicMock() with patch(u'openlp.plugins.images.lib.mediaitem.ImageMediaItem.__init__') as mocked_init: @@ -110,3 +111,17 @@ class TestImageMediaItem(TestCase): # THEN: loadFullList() should not have been called assert self.media_item.manager.save_object.call_count == 2, \ u'loadFullList() should have been called only once' + + def on_reset_click_test(self): + """ + Test that onResetClick() actually resets the background + """ + # GIVEN: + self.media_item.resetAction = MagicMock() + + # WHEN: + self.media_item.onResetClick() + + # THEN: + self.media_item.resetAction.setVisible.assert_called_with(False) + self.media_item.live_controller.display.reset_image.assert_called_with() From e8dbbdfc896a68e9c353ef707254b8019e0c0ba2 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Fri, 29 Mar 2013 15:15:16 +0100 Subject: [PATCH 05/27] Added a test for recursively_delete_group() --- .../openlp_plugins/images/test_lib.py | 59 ++++++++++++++++-- tests/interfaces/openlp_plugins/__init__.pyc | Bin 184 -> 0 bytes 2 files changed, 55 insertions(+), 4 deletions(-) delete mode 100644 tests/interfaces/openlp_plugins/__init__.pyc diff --git a/tests/functional/openlp_plugins/images/test_lib.py b/tests/functional/openlp_plugins/images/test_lib.py index 6349745c2..bdfe29373 100644 --- a/tests/functional/openlp_plugins/images/test_lib.py +++ b/tests/functional/openlp_plugins/images/test_lib.py @@ -9,7 +9,7 @@ from unittest import TestCase from mock import MagicMock, patch from openlp.core.lib import Registry -from openlp.plugins.images.lib.db import ImageFilenames +from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups from openlp.plugins.images.lib.mediaitem import ImageMediaItem @@ -116,12 +116,63 @@ class TestImageMediaItem(TestCase): """ Test that onResetClick() actually resets the background """ - # GIVEN: + # GIVEN: A mocked version of resetAction self.media_item.resetAction = MagicMock() - # WHEN: + # WHEN: onResetClick is called self.media_item.onResetClick() - # THEN: + # THEN: the resetAction should be set visible, and the image should be reset self.media_item.resetAction.setVisible.assert_called_with(False) self.media_item.live_controller.display.reset_image.assert_called_with() + + def recursively_delete_group_side_effect(*args, **kwargs): + """ + Side effect method that creates custom retun values for the recursively_delete_group method + """ + if args[1] == ImageFilenames and args[2]: + # Create some fake objects that should be removed + returned_object1 = ImageFilenames() + returned_object1.id = 1 + returned_object1.filename = u'/tmp/test_file_1.jpg' + returned_object2 = ImageFilenames() + returned_object2.id = 2 + returned_object2.filename = u'/tmp/test_file_2.jpg' + returned_object3 = ImageFilenames() + returned_object3.id = 3 + returned_object3.filename = u'/tmp/test_file_3.jpg' + return [returned_object1, returned_object2, returned_object3] + if args[1] == ImageGroups and args[2]: + # Change the parent_id that is matched so we don't get into an endless loop + ImageGroups.parent_id = 0 + # Create a fake group that will be used in the next run + returned_object1 = ImageGroups() + returned_object1.id = 1 + return [returned_object1] + return [] + + def recursively_delete_group_test(self): + """ + Test that recursively_delete_group() works + """ + # GIVEN: An ImageGroups object and mocked functions + with patch(u'openlp.core.utils.delete_file') as mocked_delete_file: + ImageFilenames.group_id = 1 + ImageGroups.parent_id = 1 + self.media_item.manager = MagicMock() + self.media_item.manager.get_all_objects.side_effect = self.recursively_delete_group_side_effect + self.media_item.servicePath = "" + test_group = ImageGroups() + test_group.id = 1 + + # WHEN: recursively_delete_group() is called + self.media_item.recursively_delete_group(test_group) + + # THEN: + assert mocked_delete_file.call_count == 0, u'delete_file() should not be called' + assert self.media_item.manager.delete_object.call_count == 7, \ + u'manager.delete_object() should be called exactly 7 times' + + # CLEANUP: Remove added attribute from ImageFilenames and ImageGroups + delattr(ImageFilenames, 'group_id') + delattr(ImageGroups, 'parent_id') diff --git a/tests/interfaces/openlp_plugins/__init__.pyc b/tests/interfaces/openlp_plugins/__init__.pyc deleted file mode 100644 index 0d24c9eff54ac7d86f14523ef46194c4bbc24cad..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 184 zcmZ9GO$q`r423JY5W#!QX3Pa-@BpGC9-x#qGe-JH(*ZrLhY(zw0apgz3w(L-vV3nh zpI3LW>NgA72NAEtoKn|jCZ|SB{TUl!a7zKfL|4!-^d;TVR)%xNc Date: Sun, 21 Apr 2013 16:53:51 +0100 Subject: [PATCH 06/27] Final tidyups --- openlp/core/lib/mediamanageritem.py | 8 ++-- openlp/core/ui/servicemanager.py | 17 ++------- openlp/plugins/custom/lib/mediaitem.py | 7 ++-- openlp/plugins/songs/lib/mediaitem.py | 53 ++++++++++++++++---------- 4 files changed, 44 insertions(+), 41 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 01329b842..331a9033a 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -102,7 +102,6 @@ class MediaManagerItem(QtGui.QWidget): self.setupUi() self.retranslateUi() self.auto_select_id = -1 - Registry().register_function(u'%s_service_load' % self.plugin.name, self.service_load) # Need to use event as called across threads and UI is updated QtCore.QObject.connect(self, QtCore.SIGNAL(u'%s_go_live' % self.plugin.name), self.go_live_remote) QtCore.QObject.connect(self, QtCore.SIGNAL(u'%s_add_to_service' % self.plugin.name), self.add_to_service_remote) @@ -585,12 +584,15 @@ class MediaManagerItem(QtGui.QWidget): else: return None - def service_load(self, message): + def service_load(self, item): """ Method to add processing when a service has been loaded and individual service items need to be processed by the plugins. + + ``item`` + The item to be processed and returned. """ - pass + return item def check_search_result(self): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index f12d55207..5674554e2 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -715,13 +715,10 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): else: service_item.set_from_service(item, self.servicePath) service_item.validate_item(self.suffixes) - self.load_item_unique_identifier = 0 if service_item.is_capable(ItemCapabilities.OnLoadUpdate): - Registry().execute(u'%s_service_load' % service_item.name.lower(), service_item) - # if the item has been processed - if service_item.unique_identifier == self.load_item_unique_identifier: - service_item.edit_id = int(self.load_item_edit_id) - service_item.temporary_edit = self.load_item_temporary + new_item = Registry().get(service_item.name).service_load(service_item) + if new_item: + service_item = new_item self.add_service_item(service_item, repaint=False) delete_file(p_file) self.main_window.add_recent_file(file_name) @@ -1260,14 +1257,6 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.repaint_service_list(-1, -1) self.application.set_normal_cursor() - def service_item_update(self, edit_id, unique_identifier, temporary=False): - """ - Triggered from plugins to update service items. Save the values as they will be used as part of the service load - """ - self.load_item_unique_identifier = unique_identifier - self.load_item_edit_id = int(edit_id) - self.load_item_temporary = str_to_bool(temporary) - def replace_service_item(self, newItem): """ Using the service item passed replace the one with the same edit id if found. diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 071f68839..657e138df 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -40,6 +40,7 @@ from openlp.plugins.custom.lib.db import CustomSlide log = logging.getLogger(__name__) + class CustomSearch(object): """ An enumeration for custom search methods. @@ -216,7 +217,6 @@ class CustomMediaItem(MediaManagerItem): Settings().setValue(u'%s/last search type' % self.settings_section, self.search_text_edit.current_search_type()) # Reload the list considering the new search type. search_keywords = self.search_text_edit.displayText() - search_results = [] search_type = self.search_text_edit.current_search_type() if search_type == CustomSearch.Titles: log.debug(u'Titles Search') @@ -255,7 +255,8 @@ class CustomMediaItem(MediaManagerItem): and_(CustomSlide.title == item.title, CustomSlide.theme_name == item.theme, CustomSlide.credits == item.raw_footer[0][len(item.title) + 1:])) if custom: - self.service_manager.service_item_update(custom.id, item.unique_identifier) + item.edit_id = custom.id + return item else: if self.add_custom_from_service: self.create_from_service_item(item) @@ -284,8 +285,6 @@ class CustomMediaItem(MediaManagerItem): custom.text = unicode(custom_xml.extract_xml(), u'utf-8') self.plugin.manager.save_object(custom) self.on_search_text_button_clicked() - if item.name.lower() == u'custom': - Registry().execute(u'service_item_update', u'%s:%s:%s' % (custom.id, item.unique_identifier, False)) def onClearTextButtonClick(self): """ diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 1565169e2..82ec1086c 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -160,7 +160,6 @@ class SongMediaItem(MediaManagerItem): Settings().setValue(u'%s/last search type' % self.settings_section, self.search_text_edit.current_search_type()) # Reload the list considering the new search type. search_keywords = unicode(self.search_text_edit.displayText()) - search_results = [] search_type = self.search_text_edit.current_search_type() if search_type == SongSearch.Entire: log.debug(u'Entire Song Search') @@ -463,16 +462,7 @@ class SongMediaItem(MediaManagerItem): for slide in verses: service_item.add_from_text(unicode(slide)) service_item.title = song.title - author_list = [unicode(author.display_name) for author in song.authors] - service_item.raw_footer.append(song.title) - service_item.raw_footer.append(create_separated_list(author_list)) - service_item.raw_footer.append(song.copyright) - if Settings().value(u'core/ccli number'): - service_item.raw_footer.append(translate('SongsPlugin.MediaItem', 'CCLI License: ') + - Settings().value(u'core/ccli number')) - service_item.audit = [ - song.title, author_list, song.copyright, unicode(song.ccli_number) - ] + author_list = self.generate_footer(service_item, song) service_item.data_string = {u'title': song.search_title, u'authors': u', '.join(author_list)} service_item.xml_version = self.openLyrics.song_to_xml(song) # Add the audio file to the service item. @@ -481,6 +471,30 @@ class SongMediaItem(MediaManagerItem): service_item.background_audio = [m.file_name for m in song.media_files] return True + def generate_footer(self, item, song): + """ + Generates the song footer based on a song and adds details to a service item. + author_list is only required for initial song generation. + + ``item`` + The service item to be amended + + ``song`` + The song to be used to generate the footer + """ + author_list = [unicode(author.display_name) for author in song.authors] + item.audit = [ + song.title, author_list, song.copyright, unicode(song.ccli_number) + ] + item.raw_footer = [] + item.raw_footer.append(song.title) + item.raw_footer.append(create_separated_list(author_list)) + item.raw_footer.append(song.copyright) + if Settings().value(u'core/ccli number'): + item.raw_footer.append(translate('SongsPlugin.MediaItem', 'CCLI License: ') + + Settings().value(u'core/ccli number')) + return author_list + def service_load(self, item): """ Triggered by a song being loaded by the service manager. @@ -499,9 +513,8 @@ class SongMediaItem(MediaManagerItem): else: search_results = self.plugin.manager.get_all_objects(Song, Song.search_title == item.data_string[u'title'], Song.search_title.asc()) - editId = 0 + edit_id = 0 add_song = True - temporary = False if search_results: for song in search_results: author_list = item.data_string[u'authors'] @@ -514,7 +527,7 @@ class SongMediaItem(MediaManagerItem): break if same_authors and author_list.strip(u', ') == u'': add_song = False - editId = song.id + edit_id = song.id break # If there's any backing tracks, copy them over. if item.background_audio: @@ -524,7 +537,7 @@ class SongMediaItem(MediaManagerItem): # If there's any backing tracks, copy them over. if item.background_audio: self._updateBackgroundAudio(song, item) - editId = song.id + edit_id = song.id self.on_search_text_button_clicked() elif add_song and not self.addSongFromService: # Make sure we temporary import formatting tags. @@ -532,11 +545,11 @@ class SongMediaItem(MediaManagerItem): # If there's any backing tracks, copy them over. if item.background_audio: self._updateBackgroundAudio(song, item) - editId = song.id - temporary = True - # Update service with correct song id. - if editId: - self.service_manager.service_item_update(editId, item.unique_identifier, temporary) + edit_id = song.id + # Update service with correct song id and return it to caller. + item.edit_id = edit_id + self.generate_footer(item, song) + return item def search(self, string, showError): """ From fba86c5552749c09f3b483f6011908ed946db597 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 23 Apr 2013 20:08:07 +0100 Subject: [PATCH 07/27] Add tests --- openlp/plugins/songs/forms/__init__.py | 1 + openlp/plugins/songs/lib/mediaitem.py | 9 +- openlp/plugins/songs/songsplugin.py | 3 +- .../functional/openlp_core_lib/test_screen.py | 2 +- .../openlp_plugins/songs/test_mediaitem.py | 125 ++++++++++++++++++ 5 files changed, 134 insertions(+), 6 deletions(-) create mode 100644 tests/functional/openlp_plugins/songs/test_mediaitem.py diff --git a/openlp/plugins/songs/forms/__init__.py b/openlp/plugins/songs/forms/__init__.py index a1c177a9d..d6aef47dc 100644 --- a/openlp/plugins/songs/forms/__init__.py +++ b/openlp/plugins/songs/forms/__init__.py @@ -52,3 +52,4 @@ This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality, so that it is easier to recreate the GUI from the .ui files later if necessary. """ +from editsongform import EditSongForm \ No newline at end of file diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 82ec1086c..f1ae52d07 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -72,10 +72,7 @@ class SongMediaItem(MediaManagerItem): def __init__(self, parent, plugin): self.icon_path = u'songs/song' MediaManagerItem.__init__(self, parent, plugin) - self.editSongForm = EditSongForm(self, self.main_window, self.plugin.manager) - self.openLyrics = OpenLyrics(self.plugin.manager) self.single_service_item = False - self.songMaintenanceForm = SongMaintenanceForm(self.plugin.manager, self) # Holds information about whether the edit is remotely triggered and # which Song is required. self.remoteSong = -1 @@ -135,6 +132,12 @@ class SongMediaItem(MediaManagerItem): 'Maintain the lists of authors, topics and books.')) def initialise(self): + """ + Initialise variables when they cannot be initialised in the constructor. + """ + self.songMaintenanceForm = SongMaintenanceForm(self.plugin.manager, self) + self.editSongForm = EditSongForm(self, self.main_window, self.plugin.manager) + self.openLyrics = OpenLyrics(self.plugin.manager) self.search_text_edit.set_search_types([ (SongSearch.Entire, u':/songs/song_search_all.png', translate('SongsPlugin.MediaItem', 'Entire Song'), diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 65056ee5b..4355bc7e5 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -235,8 +235,7 @@ class SongsPlugin(Plugin): u'delete': translate('SongsPlugin', 'Delete the selected song.'), u'preview': translate('SongsPlugin', 'Preview the selected song.'), u'live': translate('SongsPlugin', 'Send the selected song live.'), - u'service': translate('SongsPlugin', - 'Add the selected song to the service.') + u'service': translate('SongsPlugin', 'Add the selected song to the service.') } self.set_plugin_ui_text_strings(tooltips) diff --git a/tests/functional/openlp_core_lib/test_screen.py b/tests/functional/openlp_core_lib/test_screen.py index 007889a12..7c1bcaf24 100644 --- a/tests/functional/openlp_core_lib/test_screen.py +++ b/tests/functional/openlp_core_lib/test_screen.py @@ -1,7 +1,7 @@ """ Package to test the openlp.core.lib.screenlist package. """ -import copy + from unittest import TestCase from mock import MagicMock diff --git a/tests/functional/openlp_plugins/songs/test_mediaitem.py b/tests/functional/openlp_plugins/songs/test_mediaitem.py new file mode 100644 index 000000000..5f5c161eb --- /dev/null +++ b/tests/functional/openlp_plugins/songs/test_mediaitem.py @@ -0,0 +1,125 @@ +""" +This module contains tests for the lib submodule of the Songs plugin. +""" +import os +from tempfile import mkstemp +from unittest import TestCase + +from mock import patch, MagicMock + +from PyQt4 import QtGui + +from openlp.core.lib import Registry, ServiceItem, Settings + +from openlp.plugins.songs.lib.mediaitem import SongMediaItem + + +class TestMediaItem(TestCase): + """ + Test the functions in the :mod:`lib` module. + """ + def setUp(self): + """ + Set up the components need for all tests. + """ + Registry.create() + Registry().register(u'service_list', MagicMock()) + + with patch('openlp.core.lib.mediamanageritem.MediaManagerItem.__init__'), \ + patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__') : + self.media_item = SongMediaItem(MagicMock(), MagicMock()) + + fd, self.ini_file = mkstemp(u'.ini') + Settings().set_filename(self.ini_file) + self.application = QtGui.QApplication.instance() + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.application + # Not all tests use settings! + try: + os.unlink(self.ini_file) + os.unlink(Settings().fileName()) + except: + pass + + def build_song_footer_one_author_test(self): + """ + Test build songs footer with basic song and one author + """ + # GIVEN: A Song and a Service Item + mock_song = MagicMock() + mock_song.title = u'My Song' + mock_author = MagicMock() + mock_author.display_name = u'my author' + mock_song.authors = [] + mock_song.authors.append(mock_author) + mock_song.copyright = u'My copyright' + service_item = ServiceItem(None) + + # WHEN: I generate the Footer with default settings + author_list = self.media_item.generate_footer(service_item, mock_song) + + # THEN: I get the following Array returned + self.assertEqual(service_item.raw_footer, [u'My Song', u'my author', u'My copyright'], + u'The array should be returned correctly with a song, one author and copyright') + self.assertEqual(author_list, [u'my author'], + u'The author list should be returned correctly with one author') + + def build_song_footer_two_authors_test(self): + """ + Test build songs footer with basic song and two authors + """ + # GIVEN: A Song and a Service Item + mock_song = MagicMock() + mock_song.title = u'My Song' + mock_author = MagicMock() + mock_author.display_name = u'my author' + mock_song.authors = [] + mock_song.authors.append(mock_author) + mock_author = MagicMock() + mock_author.display_name = u'another author' + mock_song.authors.append(mock_author) + mock_song.copyright = u'My copyright' + service_item = ServiceItem(None) + + # WHEN: I generate the Footer with default settings + author_list = self.media_item.generate_footer(service_item, mock_song) + + # THEN: I get the following Array returned + self.assertEqual(service_item.raw_footer, [u'My Song', u'my author and another author', u'My copyright'], + u'The array should be returned correctly with a song, two authors and copyright') + self.assertEqual(author_list, [u'my author', u'another author'], + u'The author list should be returned correctly with two authors') + + def build_song_footer_base_ccli_test(self): + """ + Test build songs footer with basic song and two authors + """ + # GIVEN: A Song and a Service Item and a configured CCLI license + mock_song = MagicMock() + mock_song.title = u'My Song' + mock_author = MagicMock() + mock_author.display_name = u'my author' + mock_song.authors = [] + mock_song.authors.append(mock_author) + mock_song.copyright = u'My copyright' + service_item = ServiceItem(None) + Settings().setValue(u'core/ccli number', u'1234') + + # WHEN: I generate the Footer with default settings + self.media_item.generate_footer(service_item, mock_song) + + # THEN: I get the following Array returned + self.assertEqual(service_item.raw_footer, [u'My Song', u'my author', u'My copyright', u'CCLI License: 1234'], + u'The array should be returned correctly with a song, an author, copyright and ccli') + + # WHEN: I amend the CCLI value + Settings().setValue(u'core/ccli number', u'4321') + self.media_item.generate_footer(service_item, mock_song) + + # THEN: I would get an amended footer string + self.assertEqual(service_item.raw_footer, [u'My Song', u'my author', u'My copyright', u'CCLI License: 4321'], + u'The array should be returned correctly with a song, an author, copyright and amended ccli') \ No newline at end of file From 0ef65fb8d2f9e2a758de47574b7b47f14d10a080 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 23 Apr 2013 20:17:25 +0100 Subject: [PATCH 08/27] minor fixes --- openlp/plugins/songs/forms/__init__.py | 2 +- tests/functional/openlp_plugins/songs/test_mediaitem.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/forms/__init__.py b/openlp/plugins/songs/forms/__init__.py index d6aef47dc..588f359f6 100644 --- a/openlp/plugins/songs/forms/__init__.py +++ b/openlp/plugins/songs/forms/__init__.py @@ -52,4 +52,4 @@ This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality, so that it is easier to recreate the GUI from the .ui files later if necessary. """ -from editsongform import EditSongForm \ No newline at end of file +from editsongform import EditSongForm diff --git a/tests/functional/openlp_plugins/songs/test_mediaitem.py b/tests/functional/openlp_plugins/songs/test_mediaitem.py index 5f5c161eb..a0f81bde8 100644 --- a/tests/functional/openlp_plugins/songs/test_mediaitem.py +++ b/tests/functional/openlp_plugins/songs/test_mediaitem.py @@ -26,7 +26,7 @@ class TestMediaItem(TestCase): Registry().register(u'service_list', MagicMock()) with patch('openlp.core.lib.mediamanageritem.MediaManagerItem.__init__'), \ - patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__') : + patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__'): self.media_item = SongMediaItem(MagicMock(), MagicMock()) fd, self.ini_file = mkstemp(u'.ini') @@ -42,7 +42,7 @@ class TestMediaItem(TestCase): try: os.unlink(self.ini_file) os.unlink(Settings().fileName()) - except: + except Exception: pass def build_song_footer_one_author_test(self): @@ -122,4 +122,4 @@ class TestMediaItem(TestCase): # THEN: I would get an amended footer string self.assertEqual(service_item.raw_footer, [u'My Song', u'my author', u'My copyright', u'CCLI License: 4321'], - u'The array should be returned correctly with a song, an author, copyright and amended ccli') \ No newline at end of file + u'The array should be returned correctly with a song, an author, copyright and amended ccli') From d3195dccf7294eda0808ddbcc05f5ce8a5c82e85 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 23 Apr 2013 21:31:19 +0100 Subject: [PATCH 09/27] Swap round urls --- openlp/plugins/remotes/html/openlp.js | 2 +- openlp/plugins/remotes/html/stage.js | 6 +++--- openlp/plugins/remotes/lib/httpserver.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 3cbe65366..10bc9e328 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -147,7 +147,7 @@ window.OpenLP = { }, pollServer: function () { $.getJSON( - "/stage/api/poll", + "/stage/poll", function (data, status) { var prevItem = OpenLP.currentItem; OpenLP.currentSlide = data.results.slide; diff --git a/openlp/plugins/remotes/html/stage.js b/openlp/plugins/remotes/html/stage.js index dff51537c..42b7712f9 100644 --- a/openlp/plugins/remotes/html/stage.js +++ b/openlp/plugins/remotes/html/stage.js @@ -26,7 +26,7 @@ window.OpenLP = { loadService: function (event) { $.getJSON( - "/stage/api/service/list", + "/stage/service/list", function (data, status) { OpenLP.nextSong = ""; $("#notes").html(""); @@ -46,7 +46,7 @@ window.OpenLP = { }, loadSlides: function (event) { $.getJSON( - "/stage/api/controller/live/text", + "/stage/controller/live/text", function (data, status) { OpenLP.currentSlides = data.results.slides; OpenLP.currentSlide = 0; @@ -137,7 +137,7 @@ window.OpenLP = { }, pollServer: function () { $.getJSON( - "/stage/api/poll", + "/stage/poll", function (data, status) { OpenLP.updateClock(data); if (OpenLP.currentItem != data.results.item || diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 878b197b3..eedc30102 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -267,11 +267,11 @@ class HttpRouter(object): (u'^/(stage)$', self.serve_file), (r'^/files/(.*)$', self.serve_file), (r'^/api/poll$', self.poll), - (r'^/stage/api/poll$', self.poll), + (r'^/stage/poll$', self.poll), (r'^/api/controller/(live|preview)/(.*)$', self.controller), - (r'^/stage/api/controller/(live|preview)/(.*)$', self.controller), + (r'^/stage/controller/(live|preview)/(.*)$', self.controller), (r'^/api/service/(.*)$', self.service), - (r'^/stage/api/service/(.*)$', self.service), + (r'^/stage/service/(.*)$', self.service), (r'^/api/display/(hide|show|blank|theme|desktop)$', self.display), (r'^/api/alert$', self.alert), (r'^/api/plugin/(search)$', self.plugin_info), From 22541e729785ed93d15115404ae6b0c194d5edcf Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 24 Apr 2013 21:05:34 +0200 Subject: [PATCH 10/27] use true division (py3) --- openlp/core/lib/__init__.py | 9 +++++---- openlp/core/lib/dockwidget.py | 3 ++- openlp/core/lib/htmlbuilder.py | 4 ++-- openlp/core/lib/renderer.py | 12 ++++++------ openlp/core/lib/screen.py | 5 +++-- openlp/core/lib/searchedit.py | 6 +++--- openlp/core/ui/maindisplay.py | 7 ++++--- openlp/core/ui/themestab.py | 4 +++- 8 files changed, 28 insertions(+), 22 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 155c10141..14d67e914 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -30,6 +30,7 @@ The :mod:`lib` module contains most of the components and libraries that make OpenLP work. """ +from __future__ import division from distutils.version import LooseVersion import logging import os @@ -207,7 +208,7 @@ def create_thumb(image_path, thumb_path, return_icon=True, size=None): ext = os.path.splitext(thumb_path)[1].lower() reader = QtGui.QImageReader(image_path) if size is None: - ratio = float(reader.size().width()) / float(reader.size().height()) + ratio = reader.size().width() / reader.size().height() reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88)) else: reader.setScaledSize(size) @@ -260,8 +261,8 @@ def resize_image(image_path, width, height, background=u'#000000'): log.debug(u'resize_image - start') reader = QtGui.QImageReader(image_path) # The image's ratio. - image_ratio = float(reader.size().width()) / float(reader.size().height()) - resize_ratio = float(width) / float(height) + image_ratio = reader.size().width() / reader.size().height() + resize_ratio = width / height # Figure out the size we want to resize the image to (keep aspect ratio). if image_ratio == resize_ratio: size = QtCore.QSize(width, height) @@ -282,7 +283,7 @@ def resize_image(image_path, width, height, background=u'#000000'): new_image = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied) painter = QtGui.QPainter(new_image) painter.fillRect(new_image.rect(), QtGui.QColor(background)) - painter.drawImage((width - real_width) / 2, (height - real_height) / 2, preview) + painter.drawImage((width - real_width) // 2, (height - real_height) // 2, preview) return new_image diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index 30182c901..15c116e0f 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -30,6 +30,7 @@ """ Provide additional functionality required by OpenLP from the inherited QDockWidget. """ +from __future__ import division import logging from PyQt4 import QtGui @@ -55,7 +56,7 @@ class OpenLPDockWidget(QtGui.QDockWidget): self.setWindowIcon(build_icon(icon)) # Sort out the minimum width. screens = ScreenList() - main_window_docbars = screens.current[u'size'].width() / 5 + main_window_docbars = screens.current[u'size'].width() // 5 if main_window_docbars > 300: self.setMinimumWidth(300) else: diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 9c8b04076..d4e22b0dd 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -26,7 +26,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +from __future__ import division import logging from PyQt4 import QtWebKit @@ -276,7 +276,7 @@ def build_background_css(item, width): ``item`` Service Item containing theme and location information """ - width = int(width) / 2 + width = int(width) // 2 theme = item.themedata background = u'background-color: black' if theme: diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index c426e8871..5161246c0 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -26,7 +26,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +from __future__ import division import logging from PyQt4 import QtGui, QtCore, QtWebKit @@ -327,7 +327,7 @@ class Renderer(object): screen_size = self.screens.current[u'size'] self.width = screen_size.width() self.height = screen_size.height() - self.screen_ratio = float(self.height) / float(self.width) + self.screen_ratio = self.height / self.width log.debug(u'_calculate default %s, %f' % (screen_size, self.screen_ratio)) # 90% is start of footer self.footer_start = int(self.height * 0.90) @@ -546,15 +546,15 @@ class Renderer(object): """ smallest_index = 0 highest_index = len(html_list) - 1 - index = int(highest_index / 2) + index = highest_index // 2 while True: if not self._text_fits_on_slide(previous_html + separator.join(html_list[:index + 1]).strip()): # We know that it does not fit, so change/calculate the new index and highest_index accordingly. highest_index = index - index = int(index - (index - smallest_index) / 2) + index = index - (index - smallest_index) // 2 else: smallest_index = index - index = int(index + (highest_index - index) / 2) + index = index + (highest_index - index) // 2 # We found the number of words which will fit. if smallest_index == index or highest_index == index: index = smallest_index @@ -582,7 +582,7 @@ class Renderer(object): html_list[0] = html_tags + html_list[0] smallest_index = 0 highest_index = len(html_list) - 1 - index = int(highest_index / 2) + index = highest_index // 2 return previous_html, previous_raw def _text_fits_on_slide(self, text): diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index 84e7e4258..146b492db 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -30,6 +30,7 @@ The :mod:`screen` module provides management functionality for a machines' displays. """ +from __future__ import division import logging import copy @@ -232,8 +233,8 @@ class ScreenList(object): ``window`` A QWidget we are finding the location of. """ - x = window.x() + (window.width() / 2) - y = window.y() + (window.height() / 2) + x = window.x() + (window.width() // 2) + y = window.y() + (window.height() // 2) for screen in self.screen_list: size = screen[u'size'] if x >= size.x() and x <= (size.x() + size.width()) and y >= size.y() and y <= (size.y() + size.height()): diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 9623b0f53..a0c51cb74 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -26,7 +26,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - +from __future__ import division import logging from PyQt4 import QtCore, QtGui @@ -85,10 +85,10 @@ class SearchEdit(QtGui.QLineEdit): size = self.clear_button.size() frame_width = self.style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth) self.clear_button.move(self.rect().right() - frame_width - size.width(), - (self.rect().bottom() + 1 - size.height()) / 2) + (self.rect().bottom() + 1 - size.height()) // 2) if hasattr(self, u'menu_button'): size = self.menu_button.size() - self.menu_button.move(self.rect().left() + frame_width + 2, (self.rect().bottom() + 1 - size.height()) / 2) + self.menu_button.move(self.rect().left() + frame_width + 2, (self.rect().bottom() + 1 - size.height()) // 2) def current_search_type(self): """ diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 2504520c0..02ae469d6 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -35,6 +35,7 @@ Some of the code for this form is based on the examples at: * `http://html5demos.com/two-videos`_ """ +from __future__ import division import cgi import logging import sys @@ -207,8 +208,8 @@ class MainDisplay(Display): painter_image.begin(self.initial_fame) painter_image.fillRect(self.initial_fame.rect(), background_color) painter_image.drawImage( - (self.screen[u'size'].width() - splash_image.width()) / 2, - (self.screen[u'size'].height() - splash_image.height()) / 2, + (self.screen[u'size'].width() - splash_image.width()) // 2, + (self.screen[u'size'].height() - splash_image.height()) // 2, splash_image) service_item = ServiceItem() service_item.bg_image_bytes = image_to_byte(self.initial_fame) @@ -268,7 +269,7 @@ class MainDisplay(Display): self.resize(self.width(), alert_height) self.setVisible(True) if location == AlertLocation.Middle: - self.move(self.screen[u'size'].left(), (self.screen[u'size'].height() - alert_height) / 2) + self.move(self.screen[u'size'].left(), (self.screen[u'size'].height() - alert_height) // 2) elif location == AlertLocation.Bottom: self.move(self.screen[u'size'].left(), self.screen[u'size'].height() - alert_height) else: diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index f0f821494..d6dba2880 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -29,6 +29,8 @@ """ The Themes configuration tab """ +from __future__ import division + from PyQt4 import QtCore, QtGui from openlp.core.lib import Registry, Settings, SettingsTab, UiStrings, translate @@ -90,7 +92,7 @@ class ThemesTab(SettingsTab): self.global_level_label.setObjectName(u'global_level_label') self.level_layout.addRow(self.global_level_radio_button, self.global_level_label) label_top_margin = (self.song_level_radio_button.sizeHint().height() - - self.song_level_label.sizeHint().height()) / 2 + self.song_level_label.sizeHint().height()) // 2 for label in [self.song_level_label, self.service_level_label, self.global_level_label]: rect = label.rect() rect.setTop(rect.top() + label_top_margin) From 9d54944ad43643e6826e2712ead113a2fccef864 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 24 Apr 2013 22:47:30 +0200 Subject: [PATCH 11/27] use true division (py3) --- openlp/core/lib/settingstab.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index d63f9c678..ab775599a 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -30,6 +30,7 @@ The :mod:`~openlp.core.lib.settingstab` module contains the base SettingsTab class which plugins use for adding their own tab to the settings dialog. """ +from __future__ import division from PyQt4 import QtGui @@ -90,7 +91,7 @@ class SettingsTab(QtGui.QWidget): QtGui.QWidget.resizeEvent(self, event) width = self.width() - self.tab_layout.spacing() - \ self.tab_layout.contentsMargins().left() - self.tab_layout.contentsMargins().right() - left_width = min(width - self.right_column.minimumSizeHint().width(), width / 2) + left_width = min(width - self.right_column.minimumSizeHint().width(), width // 2) left_width = max(left_width, self.left_column.minimumSizeHint().width()) self.left_column.setFixedWidth(left_width) From d7eb6b20c3452ebe0d041639d2d602632f770467 Mon Sep 17 00:00:00 2001 From: Patrick Zimmermann Date: Thu, 25 Apr 2013 19:58:37 +0200 Subject: [PATCH 12/27] Correct the naming of the preWizard -> pre_wizard. --- openlp/plugins/bibles/forms/bibleimportform.py | 2 +- openlp/plugins/bibles/forms/bibleupgradeform.py | 4 ++-- openlp/plugins/songs/forms/songexportform.py | 2 +- openlp/plugins/songs/forms/songimportform.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 6920be61c..0662f78db 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -511,7 +511,7 @@ class BibleImportForm(OpenLPWizard): name = bible[u'abbreviation'] self.web_bible_list[download_type][version] = name.strip() - def preWizard(self): + def pre_wizard(self): """ Prepare the UI for the import. """ diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index d8f329ee7..caba4b30f 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -105,7 +105,7 @@ class BibleUpgradeForm(OpenLPWizard): Perform necessary functions depending on which wizard page is active. """ if self.page(pageId) == self.progress_page: - self.preWizard() + self.pre_wizard() self.performWizard() self.post_wizard() elif self.page(pageId) == self.selectPage and not self.files: @@ -329,7 +329,7 @@ class BibleUpgradeForm(OpenLPWizard): self.cancel_button.setVisible(True) settings.endGroup() - def preWizard(self): + def pre_wizard(self): """ Prepare the UI for the upgrade. """ diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index f0554f588..36ed50cee 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -235,7 +235,7 @@ class SongExportForm(OpenLPWizard): self.availableListWidget.addItem(item) self.application.set_normal_cursor() - def preWizard(self): + def pre_wizard(self): """ Perform pre export tasks. """ diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 4c749f4d0..add306505 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -325,7 +325,7 @@ class SongImportForm(OpenLPWizard): self.error_copy_to_button.setHidden(True) self.error_save_to_button.setHidden(True) - def preWizard(self): + def pre_wizard(self): """ Perform pre import tasks """ From 2d22e8420a4f08f21de84d9884f066c274a182a1 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 28 Apr 2013 19:17:45 +0200 Subject: [PATCH 13/27] do not pass QImages to build_icon (if not needed) --- openlp/core/lib/__init__.py | 2 +- openlp/core/ui/servicemanager.py | 4 ++-- openlp/plugins/alerts/forms/alertdialog.py | 6 +++--- openlp/plugins/media/lib/mediaitem.py | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 155c10141..9a367c9b5 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -155,7 +155,7 @@ def build_icon(icon): ``icon`` The icon to build. This can be a QIcon, a resource string in the form ``:/resource/file.png``, or a file - location like ``/path/to/file.png``. + location like ``/path/to/file.png``. However, the **recommended** way is to specify a resource string. """ button_icon = QtGui.QIcon() if isinstance(icon, QtGui.QIcon): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 43280aef8..1929f444c 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -295,8 +295,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Sets up the service manager, toolbars, list view, et al. """ QtGui.QWidget.__init__(self, parent) - self.active = build_icon(QtGui.QImage(u':/media/auto-start_active.png')) - self.inactive = build_icon(QtGui.QImage(u':/media/auto-start_inactive.png')) + self.active = build_icon(u':/media/auto-start_active.png') + self.inactive = build_icon(u':/media/auto-start_inactive.png') Registry().register(u'service_manager', self) self.service_items = [] self.suffixes = [] diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index e8a50d183..db2579298 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -75,9 +75,9 @@ class Ui_AlertDialog(object): self.manage_button_layout.addWidget(self.delete_button) self.manage_button_layout.addStretch() self.alert_dialog_layout.addLayout(self.manage_button_layout, 1, 1) - displayIcon = build_icon(u':/general/general_live.png') - self.display_button = create_button(alert_dialog, u'display_button', icon=displayIcon, enabled=False) - self.display_close_button = create_button(alert_dialog, u'display_close_button', icon=displayIcon, + display_icon = build_icon(u':/general/general_live.png') + self.display_button = create_button(alert_dialog, u'display_button', icon=display_icon, enabled=False) + self.display_close_button = create_button(alert_dialog, u'display_close_button', icon=display_icon, enabled=False) self.button_box = create_button_box(alert_dialog, u'button_box', [u'close'], [self.display_button, self.display_close_button]) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 2037346ad..243fcd158 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -44,10 +44,10 @@ log = logging.getLogger(__name__) CLAPPERBOARD = u':/media/slidecontroller_multimedia.png' -VIDEO_ICON = build_icon(QtGui.QImage(u':/media/media_video.png')) -AUDIO_ICON = build_icon(QtGui.QImage(u':/media/media_audio.png')) -DVD_ICON = build_icon(QtGui.QImage(u':/media/media_video.png')) -ERROR_ICON = build_icon(QtGui.QImage(u':/general/general_delete.png')) +VIDEO_ICON = build_icon(u':/media/media_video.png') +AUDIO_ICON = build_icon(u':/media/media_audio.png') +DVD_ICON = build_icon(u':/media/media_video.png') +ERROR_ICON = build_icon(u':/general/general_delete.png') class MediaMediaItem(MediaManagerItem): From 75c8382188a0ff39d1ac516d4d14b0df256ec3c6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 12 May 2013 14:02:48 +0200 Subject: [PATCH 14/27] added test --- tests/functional/openlp_core_lib/test_settings.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/functional/openlp_core_lib/test_settings.py b/tests/functional/openlp_core_lib/test_settings.py index 786a884a0..754d82256 100644 --- a/tests/functional/openlp_core_lib/test_settings.py +++ b/tests/functional/openlp_core_lib/test_settings.py @@ -30,6 +30,19 @@ class TestSettings(TestCase): os.unlink(self.ini_file) os.unlink(Settings().fileName()) + def extend_default_settings_test(self): + """ + Test the static extend_default_settings() method. + """ + with self.assertRaises(KeyError) as context: + Settings().value(u'core/does not exist') + self.assertEqual(context.exception[0], u'core/does not exist') + + Settings.extend_default_settings({u'core/does exist': True}) + value = Settings().value(u'core/does exist') + assert value and isinstance(value, bool) + + def settings_basic_test(self): """ Test the Settings creation and its default usage From d03a9a8eeca21eae468a177b6c5339bf9f780c56 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 12 May 2013 14:04:15 +0200 Subject: [PATCH 15/27] added comments --- tests/functional/openlp_core_lib/test_settings.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_lib/test_settings.py b/tests/functional/openlp_core_lib/test_settings.py index 754d82256..714ee6fb5 100644 --- a/tests/functional/openlp_core_lib/test_settings.py +++ b/tests/functional/openlp_core_lib/test_settings.py @@ -32,14 +32,24 @@ class TestSettings(TestCase): def extend_default_settings_test(self): """ - Test the static extend_default_settings() method. + Test the static extend_default_settings() method """ + # GIVEN: + + # WHEN: Try to access not existing setting. with self.assertRaises(KeyError) as context: Settings().value(u'core/does not exist') + + # THEN: An exception should be raised. self.assertEqual(context.exception[0], u'core/does not exist') + # GIVEN: Extended setting. Settings.extend_default_settings({u'core/does exist': True}) + + # WHEN: Try to access it. value = Settings().value(u'core/does exist') + + # THEN: The correct value should be returned. assert value and isinstance(value, bool) From d323f9d746adb00b179092b65d2f3bd886cd2477 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Tue, 14 May 2013 15:58:07 +0200 Subject: [PATCH 16/27] Reverted 'adding multiple service items' functionality --- openlp/plugins/images/lib/mediaitem.py | 119 +++++++++++-------------- 1 file changed, 53 insertions(+), 66 deletions(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index e8a81d886..dc2aa3660 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, ServiceItem, ServiceItemContext, Settings, \ +from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, ServiceItemContext, Settings, \ StringContent, TreeWidgetWithDnD, UiStrings, build_icon, check_directory_exists, check_item_selected, \ create_thumb, translate, validate_thumb from openlp.core.lib.ui import create_widget_action, critical_error_message_box @@ -538,76 +538,63 @@ class ImageMediaItem(MediaManagerItem): """ background = QtGui.QColor(Settings().value(self.settings_section + u'/background color')) if item: - new_items = [item] + items = [item] else: - new_items = self.list_view.selectedItems() - if not new_items: + items = self.list_view.selectedItems() + if not items: return False - for bitem in new_items: - new_service_item = ServiceItem(self.plugin) - new_service_item.add_icon(self.plugin.icon_path) - # Determine service item title - if isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageGroups): - new_service_item.title = bitem.text(0) - else: - new_service_item.title = unicode(self.plugin.name_strings[u'plural']) - new_service_item.add_capability(ItemCapabilities.CanMaintain) - new_service_item.add_capability(ItemCapabilities.CanPreview) - new_service_item.add_capability(ItemCapabilities.CanLoop) - new_service_item.add_capability(ItemCapabilities.CanAppend) - # force a nonexistent theme - new_service_item.theme = -1 - sub_images = [] - missing_items = [] - missing_items_filenames = [] - # Expand groups to images + # Determine service item title + if isinstance(items[0].data(0, QtCore.Qt.UserRole), ImageGroups): + service_item.title = items[0].text(0) + else: + service_item.title = unicode(self.plugin.name_strings[u'plural']) + service_item.add_capability(ItemCapabilities.CanMaintain) + service_item.add_capability(ItemCapabilities.CanPreview) + service_item.add_capability(ItemCapabilities.CanLoop) + service_item.add_capability(ItemCapabilities.CanAppend) + # force a nonexistent theme + service_item.theme = -1 + missing_items = [] + missing_items_filenames = [] + # Expand groups to images + for bitem in items: if isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageGroups) or bitem.data(0, QtCore.Qt.UserRole) is None: for index in range(0, bitem.childCount()): if isinstance(bitem.child(index).data(0, QtCore.Qt.UserRole), ImageFilenames): - sub_images.append(bitem.child(index)) - if isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageFilenames): - sub_images.append(bitem) - # Don't try to display empty groups - if not sub_images: - return False - # Find missing files - for bitem in sub_images: - filename = bitem.data(0, QtCore.Qt.UserRole).filename - if not os.path.exists(filename): - missing_items.append(bitem) - missing_items_filenames.append(filename) - for item in missing_items: - sub_images.remove(item) - # We cannot continue, as all images do not exist. - if not sub_images: - if not remote: - critical_error_message_box( - translate('ImagePlugin.MediaItem', 'Missing Image(s)'), - translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s') % - u'\n'.join(missing_items_filenames)) - return False - # We have missing as well as existing images. We ask what to do. - elif missing_items and QtGui.QMessageBox.question(self, - translate('ImagePlugin.MediaItem', 'Missing Image(s)'), - translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s\n' - 'Do you want to add the other images anyway?') % u'\n'.join(missing_items_filenames), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == \ - QtGui.QMessageBox.No: - return False - # Continue with the existing images. - for sub_image in sub_images: - filename = sub_image.data(0, QtCore.Qt.UserRole).filename - name = os.path.split(filename)[1] - new_service_item.add_from_image(filename, name, background) - # Add the service item to the correct controller - if context == ServiceItemContext.Service: - self.service_manager.add_service_item(new_service_item) - elif context == ServiceItemContext.Preview: - self.preview_controller.add_service_item(new_service_item) - elif context == ServiceItemContext.Live: - self.live_controller.add_service_item(new_service_item) - # Return False because we added the service item ourselves - return False + items.append(bitem.child(index)) + items.remove(bitem) + # Don't try to display empty groups + if not items: + return False + # Find missing files + for bitem in items: + filename = bitem.data(0, QtCore.Qt.UserRole).filename + if not os.path.exists(filename): + missing_items.append(bitem) + missing_items_filenames.append(filename) + for item in missing_items: + items.remove(item) + # We cannot continue, as all images do not exist. + if not items: + if not remote: + critical_error_message_box( + translate('ImagePlugin.MediaItem', 'Missing Image(s)'), + translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s') % + u'\n'.join(missing_items_filenames)) + return False + # We have missing as well as existing images. We ask what to do. + elif missing_items and QtGui.QMessageBox.question(self, + translate('ImagePlugin.MediaItem', 'Missing Image(s)'), + translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s\n' + 'Do you want to add the other images anyway?') % u'\n'.join(missing_items_filenames), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: + return False + # Continue with the existing images. + for bitem in items: + filename = bitem.data(0, QtCore.Qt.UserRole).filename + name = os.path.split(filename)[1] + service_item.add_from_image(filename, name, background) + return True def check_group_exists(self, new_group): """ From 71335357dd8a3178b1873af4a7a5064171dc9fbc Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Tue, 14 May 2013 16:17:56 +0200 Subject: [PATCH 17/27] - Fixed traceback on adding multiple image groups to the service in one go --- openlp/plugins/images/lib/mediaitem.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index dc2aa3660..cb4656539 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -554,28 +554,23 @@ class ImageMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.CanAppend) # force a nonexistent theme service_item.theme = -1 - missing_items = [] missing_items_filenames = [] + images_filenames = [] # Expand groups to images for bitem in items: if isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageGroups) or bitem.data(0, QtCore.Qt.UserRole) is None: for index in range(0, bitem.childCount()): if isinstance(bitem.child(index).data(0, QtCore.Qt.UserRole), ImageFilenames): - items.append(bitem.child(index)) - items.remove(bitem) + images_filenames.append(bitem.child(index).data(0, QtCore.Qt.UserRole).filename) # Don't try to display empty groups - if not items: + if not images_filenames: return False # Find missing files - for bitem in items: - filename = bitem.data(0, QtCore.Qt.UserRole).filename + for filename in images_filenames: if not os.path.exists(filename): - missing_items.append(bitem) missing_items_filenames.append(filename) - for item in missing_items: - items.remove(item) # We cannot continue, as all images do not exist. - if not items: + if not images_filenames: if not remote: critical_error_message_box( translate('ImagePlugin.MediaItem', 'Missing Image(s)'), @@ -583,15 +578,14 @@ class ImageMediaItem(MediaManagerItem): u'\n'.join(missing_items_filenames)) return False # We have missing as well as existing images. We ask what to do. - elif missing_items and QtGui.QMessageBox.question(self, + elif missing_items_filenames and QtGui.QMessageBox.question(self, translate('ImagePlugin.MediaItem', 'Missing Image(s)'), translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s\n' 'Do you want to add the other images anyway?') % u'\n'.join(missing_items_filenames), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: return False # Continue with the existing images. - for bitem in items: - filename = bitem.data(0, QtCore.Qt.UserRole).filename + for filename in images_filenames: name = os.path.split(filename)[1] service_item.add_from_image(filename, name, background) return True From 673a87a65d14042632d5c7f6ea8802a4f8a0ff24 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Tue, 14 May 2013 16:48:49 +0200 Subject: [PATCH 18/27] - Fixed a bug where new image groups added from the 'choose group' popup weren't added to the 'add group' and 'choose group' popup selectboxes --- openlp/plugins/images/lib/mediaitem.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index cb4656539..8a564fa2c 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -440,6 +440,8 @@ class ImageMediaItem(MediaManagerItem): parent_group.parent_id = 0 parent_group.group_name = self.choose_group_form.new_group_edit.text() self.manager.save_object(parent_group) + self.fill_groups_combobox(self.choose_group_form.group_combobox) + self.fill_groups_combobox(self.add_group_form.parent_group_combobox) else: parent_group = target_group.data(0, QtCore.Qt.UserRole) if isinstance(parent_group, ImageFilenames): From 6572ab31e818e254843c68b11baf866c97e833c2 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Tue, 14 May 2013 17:05:41 +0200 Subject: [PATCH 19/27] - Fixed adding single images again --- openlp/plugins/images/lib/mediaitem.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 328ba462a..deed14594 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -561,6 +561,8 @@ class ImageMediaItem(MediaManagerItem): for index in range(0, bitem.childCount()): if isinstance(bitem.child(index).data(0, QtCore.Qt.UserRole), ImageFilenames): images_filenames.append(bitem.child(index).data(0, QtCore.Qt.UserRole).filename) + elif isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageFilenames): + images_filenames.append(bitem.data(0, QtCore.Qt.UserRole).filename) # Don't try to display empty groups if not images_filenames: return False From 7a42cd3769ac06eb55cf956ccb34cb795f84b703 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 18 May 2013 10:44:03 +0200 Subject: [PATCH 20/27] added test --- openlp/core/lib/__init__.py | 3 +- tests/functional/openlp_core_lib/test_lib.py | 61 ++++++++++++++++---- 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 911ba4703..d6c338271 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -203,7 +203,8 @@ def create_thumb(image_path, thumb_path, return_icon=True, size=None): States if an icon should be build and returned from the thumb. Defaults to ``True``. ``size`` - Allows to state a own size to use. Defaults to ``None``, which means that a default height of 88 is used. + Allows to state a own size (QtCore.QSize) to use. Defaults to ``None``, which means that a default height of 88 + is used. """ ext = os.path.splitext(thumb_path)[1].lower() reader = QtGui.QImageReader(image_path) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index c03a11265..b0d1a4bed 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -1,13 +1,20 @@ """ Package to test the openlp.core.lib package. """ +import os + from unittest import TestCase from datetime import datetime, timedelta from mock import MagicMock, patch +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import str_to_bool, create_thumb, translate, check_directory_exists, get_text_file_string, \ + build_icon, image_to_byte, check_item_selected, validate_thumb, create_separated_list, clean_tags, expand_tags + + +TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', u'resources')) -from openlp.core.lib import str_to_bool, translate, check_directory_exists, get_text_file_string, build_icon, \ - image_to_byte, check_item_selected, validate_thumb, create_separated_list, clean_tags, expand_tags class TestLib(TestCase): @@ -125,7 +132,7 @@ class TestLib(TestCase): Test the check_directory_exists() function """ with patch(u'openlp.core.lib.os.path.exists') as mocked_exists, \ - patch(u'openlp.core.lib.os.makedirs') as mocked_makedirs: + patch(u'openlp.core.lib.os.makedirs') as mocked_makedirs: # GIVEN: A directory to check and a mocked out os.makedirs and os.path.exists directory_to_check = u'existing/directory' @@ -219,7 +226,7 @@ class TestLib(TestCase): Test the build_icon() function with a resource URI """ with patch(u'openlp.core.lib.QtGui') as MockedQtGui, \ - patch(u'openlp.core.lib.QtGui.QPixmap') as MockedQPixmap: + patch(u'openlp.core.lib.QtGui.QPixmap') as MockedQPixmap: # GIVEN: A mocked QIcon and a mocked QPixmap MockedQtGui.QIcon = MagicMock MockedQtGui.QIcon.Normal = 1 @@ -261,9 +268,43 @@ class TestLib(TestCase): mocked_byte_array.toBase64.assert_called_with() assert result == u'base64mock', u'The result should be the return value of the mocked out base64 method' + def create_thumb_with_size_test(self): + """ + Test the create_thumb() function + """ + # GIVEN: An image to create a thumb of. + image_path = os.path.join(TEST_PATH, u'church.jpg') + thumb_path = os.path.join(TEST_PATH, u'church_thumb.jpg') + thumb_size = QtCore.QSize(10, 20) + + # Remove the thumb so that the test actually tests if the thumb will be created. Maybe it was not deleted in the + # last test. + try: + os.remove(thumb_path) + except: + pass + + # Only continue when the thumb does not exist. + assert not os.path.exists(thumb_path), u'Test was not ran, because the thumb already exists.' + + # WHEN: Create the thumb. + icon = create_thumb(image_path, thumb_path, size=thumb_size) + + # THEN: Check if the thumb was created. + assert os.path.exists(thumb_path), u'Test was not ran, because the thumb already exists.' + assert isinstance(icon, QtGui.QIcon), u'The icon should be a QIcon.' + assert not icon.isNull(), u'The icon should not be null.' + assert QtGui.QImageReader(thumb_path).size() == thumb_size, u'The thumb should have the given size.' + + # Remove the thumb so that the test actually tests if the thumb will be created. + try: + os.remove(thumb_path) + except: + pass + def check_item_selected_true_test(self): """ - Test that the check_item_selected() function returns True when there are selected indexes. + Test that the check_item_selected() function returns True when there are selected indexes """ # GIVEN: A mocked out QtGui module and a list widget with selected indexes MockedQtGui = patch(u'openlp.core.lib.QtGui') @@ -423,7 +464,7 @@ class TestLib(TestCase): def create_separated_list_qlocate_test(self): """ - Test the create_separated_list function using the Qt provided method. + Test the create_separated_list function using the Qt provided method """ with patch(u'openlp.core.lib.Qt') as mocked_qt, \ patch(u'openlp.core.lib.QtCore.QLocale.createSeparatedList') as mocked_createSeparatedList: @@ -442,7 +483,7 @@ class TestLib(TestCase): def create_separated_list_empty_list_test(self): """ - Test the create_separated_list function with an empty list. + Test the create_separated_list function with an empty list """ with patch(u'openlp.core.lib.Qt') as mocked_qt: # GIVEN: An empty list and the mocked Qt module. @@ -458,7 +499,7 @@ class TestLib(TestCase): def create_separated_list_with_one_item_test(self): """ - Test the create_separated_list function with a list consisting of only one entry. + Test the create_separated_list function with a list consisting of only one entry """ with patch(u'openlp.core.lib.Qt') as mocked_qt: # GIVEN: A list with a string and the mocked Qt module. @@ -474,7 +515,7 @@ class TestLib(TestCase): def create_separated_list_with_two_items_test(self): """ - Test the create_separated_list function with a list of two entries. + Test the create_separated_list function with a list of two entries """ with patch(u'openlp.core.lib.Qt') as mocked_qt, patch(u'openlp.core.lib.translate') as mocked_translate: # GIVEN: A list of strings and the mocked Qt module. @@ -491,7 +532,7 @@ class TestLib(TestCase): def create_separated_list_with_three_items_test(self): """ - Test the create_separated_list function with a list of three items. + Test the create_separated_list function with a list of three items """ with patch(u'openlp.core.lib.Qt') as mocked_qt, patch(u'openlp.core.lib.translate') as mocked_translate: # GIVEN: A list with a string and the mocked Qt module. From 6e66edce03060b6c2f5823c7fdea3577b5c78229 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 18 May 2013 10:49:21 +0200 Subject: [PATCH 21/27] removed test --- .../openlp_core_lib/test_settings.py | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_settings.py b/tests/functional/openlp_core_lib/test_settings.py index 714ee6fb5..786a884a0 100644 --- a/tests/functional/openlp_core_lib/test_settings.py +++ b/tests/functional/openlp_core_lib/test_settings.py @@ -30,29 +30,6 @@ class TestSettings(TestCase): os.unlink(self.ini_file) os.unlink(Settings().fileName()) - def extend_default_settings_test(self): - """ - Test the static extend_default_settings() method - """ - # GIVEN: - - # WHEN: Try to access not existing setting. - with self.assertRaises(KeyError) as context: - Settings().value(u'core/does not exist') - - # THEN: An exception should be raised. - self.assertEqual(context.exception[0], u'core/does not exist') - - # GIVEN: Extended setting. - Settings.extend_default_settings({u'core/does exist': True}) - - # WHEN: Try to access it. - value = Settings().value(u'core/does exist') - - # THEN: The correct value should be returned. - assert value and isinstance(value, bool) - - def settings_basic_test(self): """ Test the Settings creation and its default usage From 255ed90d972d2565abe929be8f9913c2a1d34f0c Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Sun, 19 May 2013 13:31:02 +0200 Subject: [PATCH 22/27] Change helper method to private --- tests/functional/openlp_plugins/images/test_lib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_plugins/images/test_lib.py b/tests/functional/openlp_plugins/images/test_lib.py index 2e9432eaf..0aecc0a7f 100644 --- a/tests/functional/openlp_plugins/images/test_lib.py +++ b/tests/functional/openlp_plugins/images/test_lib.py @@ -126,7 +126,7 @@ class TestImageMediaItem(TestCase): self.media_item.reset_action.setVisible.assert_called_with(False) self.media_item.live_controller.display.reset_image.assert_called_with() - def recursively_delete_group_side_effect(*args, **kwargs): + def _recursively_delete_group_side_effect(*args, **kwargs): """ Side effect method that creates custom retun values for the recursively_delete_group method """ @@ -160,7 +160,7 @@ class TestImageMediaItem(TestCase): ImageFilenames.group_id = 1 ImageGroups.parent_id = 1 self.media_item.manager = MagicMock() - self.media_item.manager.get_all_objects.side_effect = self.recursively_delete_group_side_effect + self.media_item.manager.get_all_objects.side_effect = self._recursively_delete_group_side_effect self.media_item.servicePath = "" test_group = ImageGroups() test_group.id = 1 From f22254501aa0f975cdf65530614e57e247ecc529 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Thu, 23 May 2013 09:31:12 +0200 Subject: [PATCH 23/27] Reverted another change from the 'adding multiple service items' functionality --- openlp/core/lib/mediamanageritem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 2fde4a821..c3e1fa366 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -466,7 +466,7 @@ class MediaManagerItem(QtGui.QWidget): translate('OpenLP.MediaManagerItem', 'You must select one or more items to preview.')) else: log.debug(u'%s Preview requested', self.plugin.name) - service_item = self.build_service_item(context=ServiceItemContext.Preview) + service_item = self.build_service_item() if service_item: service_item.from_plugin = True self.preview_controller.add_service_item(service_item) From 3961db8b67822df688dd8732b08e6f2221b9afc6 Mon Sep 17 00:00:00 2001 From: "Peter S. Bentley" Date: Thu, 23 May 2013 17:15:15 +0100 Subject: [PATCH 24/27] Fix invalid object names --- openlp/plugins/songs/lib/mediaitem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 5d0bc086c..b60c0b162 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -132,8 +132,8 @@ class SongMediaItem(MediaManagerItem): """ Initialise variables when they cannot be initialised in the constructor. """ - self.songMaintenanceForm = SongMaintenanceForm(self.plugin.manager, self) - self.editSongForm = EditSongForm(self, self.main_window, self.plugin.manager) + self.song_maintenance_form = SongMaintenanceForm(self.plugin.manager, self) + self.edit_song_form = EditSongForm(self, self.main_window, self.plugin.manager) self.openLyrics = OpenLyrics(self.plugin.manager) self.search_text_edit.set_search_types([ (SongSearch.Entire, u':/songs/song_search_all.png', From 4b2868b27173df83c9a0edc48f3070714e09598e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 24 May 2013 21:17:47 +0100 Subject: [PATCH 25/27] Fox presentations and refactor service item --- openlp/core/lib/serviceitem.py | 35 ++++++++++--------- openlp/core/ui/media/mediacontroller.py | 4 +-- openlp/plugins/media/lib/mediaitem.py | 11 +++--- openlp/plugins/presentations/lib/mediaitem.py | 18 +++++----- .../presentations/lib/messagelistener.py | 3 +- .../lib/presentationcontroller.py | 5 +-- .../presentations/presentationplugin.py | 2 +- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index c4ac846c9..b32e1aaf0 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -58,8 +58,7 @@ class ItemCapabilities(object): Provides an enumeration of a service item's capabilities ``CanPreview`` - The capability to allow the ServiceManager to add to the preview - tab when making the previous item live. + The capability to allow the ServiceManager to add to the preview tab when making the previous item live. ``CanEdit`` The capability to allow the ServiceManager to allow the item to be edited @@ -71,8 +70,7 @@ class ItemCapabilities(object): Determines is the service_item needs a Media Player ``CanLoop`` - The capability to allow the SlideController to allow the loop - processing. + The capability to allow the SlideController to allow the loop processing. ``CanAppend`` The capability to allow the ServiceManager to add leaves to the @@ -82,22 +80,19 @@ class ItemCapabilities(object): The capability to remove lines breaks in the renderer ``OnLoadUpdate`` - The capability to update MediaManager when a service Item is - loaded. + The capability to update MediaManager when a service Item is loaded. ``AddIfNewItem`` Not Used ``ProvidesOwnDisplay`` - The capability to tell the SlideController the service Item has a - different display. + The capability to tell the SlideController the service Item has a different display. ``HasDetailedTitleDisplay`` - ServiceItem provides a title + Being Removed and decommissioned. ``HasVariableStartTime`` - The capability to tell the ServiceManager that a change to start - time is possible. + The capability to tell the ServiceManager that a change to start time is possible. ``CanSoftBreak`` The capability to tell the renderer that Soft Break is allowed @@ -149,7 +144,7 @@ class ServiceItem(object): if plugin: self.name = plugin.name self.title = u'' - self.shortname = u'' + self.processor = None self.audit = u'' self.items = [] self.iconic_representation = None @@ -353,7 +348,8 @@ class ServiceItem(object): u'media_length': self.media_length, u'background_audio': self.background_audio, u'theme_overwritten': self.theme_overwritten, - u'will_auto_start': self.will_auto_start + u'will_auto_start': self.will_auto_start, + u'processor': self.processor } service_data = [] if self.service_item_type == ServiceItemType.Text: @@ -387,7 +383,6 @@ class ServiceItem(object): self.title = header[u'title'] self.name = header[u'name'] self.service_item_type = header[u'type'] - self.shortname = header[u'plugin'] self.theme = header[u'theme'] self.add_icon(header[u'icon']) self.raw_footer = header[u'footer'] @@ -406,7 +401,13 @@ class ServiceItem(object): self.auto_play_slides_loop = header.get(u'auto_play_slides_loop', False) self.timed_slide_interval = header.get(u'timed_slide_interval', 0) self.will_auto_start = header.get(u'will_auto_start', False) + self.processor = header.get(u'processor', None) self.has_original_files = True + #TODO Remove me in 2,3 build phase + if self.is_capable(ItemCapabilities.HasDetailedTitleDisplay): + self.capabilities.remove(ItemCapabilities.HasDetailedTitleDisplay) + self.processor = self.title + self.title = None if u'background_audio' in header: self.background_audio = [] for filename in header[u'background_audio']: @@ -429,6 +430,8 @@ class ServiceItem(object): self.add_from_image(text_image[u'path'], text_image[u'title'], background) elif self.service_item_type == ServiceItemType.Command: for text_image in serviceitem[u'serviceitem'][u'data']: + if not self.title: + self.title = text_image[u'title'] if path: self.has_original_files = False self.add_from_command(path, text_image[u'title'], text_image[u'image']) @@ -443,9 +446,7 @@ class ServiceItem(object): if self.is_text(): return self.title else: - if ItemCapabilities.HasDetailedTitleDisplay in self.capabilities: - return self._raw_frames[0][u'title'] - elif len(self._raw_frames) > 1: + if len(self._raw_frames) > 1: return self.title else: return self._raw_frames[0][u'title'] diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 1e011a84d..71f2b4b10 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -466,8 +466,8 @@ class MediaController(object): The ServiceItem containing the details to be played. """ used_players = get_media_players()[0] - if service_item.title != UiStrings().Automatic: - used_players = [service_item.title.lower()] + if service_item.processor != UiStrings().Automatic: + used_players = [service_item.processor.lower()] if controller.media_info.file_info.isFile(): suffix = u'*.%s' % controller.media_info.file_info.suffix().lower() for title in used_players: diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 243fcd158..2f07110fe 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -155,7 +155,7 @@ class MediaMediaItem(MediaManagerItem): if os.path.exists(filename): service_item = ServiceItem() service_item.title = u'webkit' - service_item.shortname = service_item.title + service_item.processor = u'webkit' (path, name) = os.path.split(filename) service_item.add_from_command(path, name,CLAPPERBOARD) if self.media_controller.video(DisplayControllerType.Live, service_item, video_behind_text=True): @@ -185,9 +185,9 @@ class MediaMediaItem(MediaManagerItem): translate('MediaPlugin.MediaItem', 'Missing Media File'), translate('MediaPlugin.MediaItem', 'The file %s no longer exists.') % filename) return False - service_item.title = self.display_type_combo_box.currentText() - service_item.shortname = service_item.title (path, name) = os.path.split(filename) + service_item.title = name + service_item.processor = self.display_type_combo_box.currentText() service_item.add_from_command(path, name, CLAPPERBOARD) # Only get start and end times if going to a service if context == ServiceItemContext.Service: @@ -196,7 +196,6 @@ class MediaMediaItem(MediaManagerItem): return False service_item.add_capability(ItemCapabilities.CanAutoStartForLive) service_item.add_capability(ItemCapabilities.RequiresMedia) - service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay) if Settings().value(self.settings_section + u'/media auto start') == QtCore.Qt.Checked: service_item.will_auto_start = True # force a non-existent theme @@ -208,6 +207,7 @@ class MediaMediaItem(MediaManagerItem): self.list_view.setIconSize(QtCore.QSize(88, 50)) self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settings_section), u'thumbnails') check_directory_exists(self.servicePath) + print self.settings_section + u'/media files' self.load_list(Settings().value(self.settings_section + u'/media files')) self.populateDisplayTypes() @@ -260,8 +260,7 @@ class MediaMediaItem(MediaManagerItem): Settings().setValue(self.settings_section + u'/media files', self.get_file_list()) def load_list(self, media, target_group=None): - # Sort the media by its filename considering language specific - # characters. + # Sort the media by its filename considering language specific characters. media.sort(key=lambda filename: get_locale_key(os.path.split(unicode(filename))[1])) for track in media: track_info = QtCore.QFileInfo(track) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 2f48b99c1..fcfc495ed 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -244,22 +244,20 @@ class PresentationMediaItem(MediaManagerItem): items = self.list_view.selectedItems() if len(items) > 1: return False - service_item.title = self.display_type_combo_box.currentText() - service_item.shortname = self.display_type_combo_box.currentText() + service_item.processor = self.display_type_combo_box.currentText() service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay) - service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay) - shortname = service_item.shortname - if not shortname: + if not self.display_type_combo_box.currentText(): return False for bitem in items: filename = bitem.data(QtCore.Qt.UserRole) + (path, name) = os.path.split(filename) + service_item.title = name if os.path.exists(filename): - if shortname == self.Automatic: - service_item.shortname = self.findControllerByType(filename) - if not service_item.shortname: + if service_item.processor == self.Automatic: + service_item.processor = self.findControllerByType(filename) + if not service_item.processor: return False - controller = self.controllers[service_item.shortname] - (path, name) = os.path.split(filename) + controller = self.controllers[service_item.processor] doc = controller.add_document(filename) if doc.get_thumbnail_path(1, True) is None: doc.load_presentation() diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 330c36f5c..cd7c654a2 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -36,6 +36,7 @@ from openlp.core.ui import HideMode log = logging.getLogger(__name__) + class Controller(object): """ This is the Presentation listener who acts on events from the slide controller and passes the messages on the the @@ -314,7 +315,7 @@ class MessageListener(object): item = message[0] hide_mode = message[2] file = item.get_frame_path() - self.handler = item.title + self.handler = item.processor if self.handler == self.media_item.Automatic: self.handler = self.media_item.findControllerByType(file) if not self.handler: diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 7501fd6df..85ebc42ad 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -38,6 +38,7 @@ from openlp.core.utils import AppLocation log = logging.getLogger(__name__) + class PresentationDocument(object): """ Base class for presentation documents to inherit from. Loads and closes the presentation as well as triggering the @@ -322,7 +323,7 @@ class PresentationController(object): ``supports`` The primary native file types this application supports. - ``alsosupports`` + ``also_supports`` Other file types the application can import, although not necessarily the first choice due to potential incompatibilities. @@ -358,7 +359,7 @@ class PresentationController(object): Name of the application, to appear in the application """ self.supports = [] - self.alsosupports = [] + self.also_supports = [] self.docs = [] self.plugin = plugin self.name = name diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 1cb966aa5..cc1516b69 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -49,7 +49,7 @@ __default_settings__ = { u'presentations/Powerpoint': QtCore.Qt.Checked, u'presentations/Powerpoint Viewer': QtCore.Qt.Checked, u'presentations/presentations files': [] - } +} class PresentationPlugin(Plugin): From 6dd070f60ecca6356593a4412463535fdb18e1a3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 25 May 2013 06:48:08 +0100 Subject: [PATCH 26/27] Add migration test --- .../openlp_core_lib/test_serviceitem.py | 21 +++- tests/resources/migrate_video_20_22.osd | 98 +++++++++++++++++++ 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 tests/resources/migrate_video_20_22.osd diff --git a/tests/functional/openlp_core_lib/test_serviceitem.py b/tests/functional/openlp_core_lib/test_serviceitem.py index 26e9e7d44..e051f8c76 100644 --- a/tests/functional/openlp_core_lib/test_serviceitem.py +++ b/tests/functional/openlp_core_lib/test_serviceitem.py @@ -210,7 +210,6 @@ class TestServiceItem(TestCase): # THEN: We should get back a valid service item assert service_item.is_valid is True, u'The new service item should be valid' - print service_item.get_rendered_frame(0) assert service_item.get_rendered_frame(0) == test_file, u'The first frame should match the path to the image' assert service_item.get_frames()[0] == frame_array, u'The return should match frame array1' assert service_item.get_frame_path(0) == test_file, u'The frame path should match the full path to the image' @@ -268,6 +267,26 @@ class TestServiceItem(TestCase): assert service_item.is_capable(ItemCapabilities.CanAppend) is True, \ u'This service item should be able to have new items added to it' + def serviceitem_migrate_test_20_22(self): + """ + Test the Service Item - migrating a media only service item from 2.0 to 2.2 format + """ + # GIVEN: A new service item and a mocked add icon function + service_item = ServiceItem(None) + service_item.add_icon = MagicMock() + + # WHEN: adding an media from a saved Service and mocked exists + line = self.convert_file_service_item(u'migrate_video_20_22.osd') + with patch('os.path.exists'): + service_item.set_from_service(line, TEST_PATH) + + # THEN: We should get back a converted service item + assert service_item.is_valid is True, u'The new service item should be valid' + assert service_item.processor is None, u'The Processor should have been set' + assert service_item.title is None, u'The title should be set to a value' + assert service_item.is_capable(ItemCapabilities.HasDetailedTitleDisplay) is False, \ + u'The Capability should have been removed' + def convert_file_service_item(self, name): service_file = os.path.join(TEST_PATH, name) try: diff --git a/tests/resources/migrate_video_20_22.osd b/tests/resources/migrate_video_20_22.osd new file mode 100644 index 000000000..ee4b2c0c4 --- /dev/null +++ b/tests/resources/migrate_video_20_22.osd @@ -0,0 +1,98 @@ +(lp1 +(dp2 +Vserviceitem +p3 +(dp4 +Vheader +p5 +(dp6 +Vxml_version +p7 +NsVauto_play_slides_loop +p8 +I00 +sVauto_play_slides_once +p9 +I00 +sVwill_auto_start +p10 +I01 +sVtitle +p11 +VVLC +p12 +sVcapabilities +p13 +(lp14 +I12 +aI16 +aI4 +aI11 +asVtheme +p15 +I-1 +sVbackground_audio +p16 +(lp17 +sVicon +p18 +V:/plugins/plugin_media.png +p19 +sVtype +p20 +I3 +sVstart_time +p21 +I0 +sVfrom_plugin +p22 +I00 +sVmedia_length +p23 +I144 +sVdata +p24 +V +sVtimed_slide_interval +p25 +I0 +sVaudit +p26 +V +sVsearch +p27 +V +sVname +p28 +Vmedia +p29 +sVfooter +p30 +(lp31 +sVnotes +p32 +V +sVplugin +p33 +g29 +sVtheme_overwritten +p34 +I00 +sVend_time +p35 +I0 +ssg24 +(lp36 +(dp37 +Vpath +p38 +V/home/tim/Videos/puppets +p39 +sVimage +p40 +V:/media/slidecontroller_multimedia.png +p41 +sg11 +VMVI_3405.MOV +p42 +sassa. \ No newline at end of file From 0a8db629d9ecb7f50ca7df07af4694817354ae74 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 25 May 2013 06:54:25 +0100 Subject: [PATCH 27/27] Remove Print --- openlp/plugins/media/lib/mediaitem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 2f07110fe..30748a225 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -207,7 +207,6 @@ class MediaMediaItem(MediaManagerItem): self.list_view.setIconSize(QtCore.QSize(88, 50)) self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settings_section), u'thumbnails') check_directory_exists(self.servicePath) - print self.settings_section + u'/media files' self.load_list(Settings().value(self.settings_section + u'/media files')) self.populateDisplayTypes()