From 79d9179e3a7faa1286c8487e6b5a178863707f63 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Fri, 11 Jan 2013 20:15:19 +0400 Subject: [PATCH 01/45] Added future to rename items in ServiceManager. --- openlp/core/ui/servicemanager.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 7da61dc63..dc5d2685f 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -242,6 +242,8 @@ class ServiceManager(QtGui.QWidget): self.menu = QtGui.QMenu() self.editAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'), icon=u':/general/general_edit.png', triggers=self.remoteEdit) + self.RenameAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Rename...'), + triggers=self.onServiceItemRename) self.maintainAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'), icon=u':/general/general_edit.png', triggers=self.onServiceItemEditForm) self.notesAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Notes'), @@ -829,6 +831,31 @@ class ServiceManager(QtGui.QWidget): if self.serviceItemEditForm.exec_(): self.addServiceItem(self.serviceItemEditForm.getServiceItem(), replace=True, expand=self.serviceItems[item][u'expanded']) + + def onServiceItemRename(self): + """ + Opens a dialog to rename the service item. + """ + item = self.findServiceItem()[0] + if not self.serviceItems[item][u'service_item'].is_text()\ + and ItemCapabilities.HasDetailedTitleDisplay in self.serviceItems[item][u'service_item'].capabilities\ + or len(self.serviceItems[item][u'service_item']._raw_frames) == 1: + get_main_title = False + Title = self.serviceItems[item][u'service_item']._raw_frames[0][u'title'] + else: + get_main_title = True + Title = self.serviceItems[item][u'service_item'].title + Title, ok = QtGui.QInputDialog.getText(self, + self.tr(translate('OpenLP.ServiceManager', 'Input title')), + self.tr(translate('OpenLP.ServiceManager', 'Title')), + QtGui.QLineEdit.Normal, self.trUtf8(Title)) + if ok: + if get_main_title: + self.serviceItems[item][u'service_item'].title = unicode(Title) + else: + self.serviceItems[item][u'service_item']._raw_frames[0][u'title']= unicode(Title) + self.repaintServiceList(item, -1) + self.setModified() def previewLive(self, message): """ From bbccd0ddf2e546dd469d9b72e9383e1ae2e49888 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Sat, 9 Feb 2013 00:40:59 +0400 Subject: [PATCH 02/45] some fix --- openlp/core/ui/servicemanager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index dc5d2685f..b61afdb27 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -838,8 +838,8 @@ class ServiceManager(QtGui.QWidget): """ item = self.findServiceItem()[0] if not self.serviceItems[item][u'service_item'].is_text()\ - and ItemCapabilities.HasDetailedTitleDisplay in self.serviceItems[item][u'service_item'].capabilities\ - or len(self.serviceItems[item][u'service_item']._raw_frames) == 1: + and (ItemCapabilities.HasDetailedTitleDisplay in self.serviceItems[item][u'service_item'].capabilities\ + or len(self.serviceItems[item][u'service_item']._raw_frames) == 1): get_main_title = False Title = self.serviceItems[item][u'service_item']._raw_frames[0][u'title'] else: From 1dc22fc91210a19e33e131dd987c3d643879bc9f Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Tue, 2 Apr 2013 14:19:33 +0400 Subject: [PATCH 03/45] fix --- openlp/core/ui/servicemanager.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index cfa0d4707..9abccef9b 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -228,6 +228,8 @@ class ServiceManagerDialog(object): self.menu = QtGui.QMenu() self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'), icon=u':/general/general_edit.png', triggers=self.remote_edit) + self.rename_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Rename...'), + triggers=self.on_service_item_rename) self.maintain_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'), icon=u':/general/general_edit.png', triggers=self.on_service_item_edit_form) self.notes_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Notes'), @@ -1434,6 +1436,28 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if new_item: self.add_service_item(new_item, replace=True) + def on_service_item_rename(self): + """ + Opens a dialog to rename the service item. + """ + item = self.find_service_item()[0] +# if False and not self.service_items[item][u'service_item'].is_text()\ +# and (ItemCapabilities.HasDetailedTitleDisplay in self.service_items[item][u'service_item'].capabilities\ +# or len(self.service_items[item][u'service_item']._raw_frames) == 1): +# get_main_title = False +# Title = self.service_items[item][u'service_item']._raw_frames[0][u'title'] +# else: +# get_main_title = True + Title = self.service_items[item][u'service_item'].title + Title, ok = QtGui.QInputDialog.getText(self, + self.tr(translate('OpenLP.ServiceManager', 'Input title')), + self.tr(translate('OpenLP.ServiceManager', 'Title')), + QtGui.QLineEdit.Normal, self.trUtf8(Title)) + if ok: + self.service_items[item][u'service_item'].title = unicode(Title) + self.repaint_service_list(item, -1) + self.set_modified() + def create_custom(self): """ Saves the current text item as a custom slide From 6209ad8bb538454f6acee5092615dab5db154132 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Tue, 2 Apr 2013 15:54:18 +0400 Subject: [PATCH 04/45] style fix --- openlp/core/ui/servicemanager.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 30ad0b386..9f609302e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1407,13 +1407,11 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): # Title = self.service_items[item][u'service_item']._raw_frames[0][u'title'] # else: # get_main_title = True - Title = self.service_items[item][u'service_item'].title - Title, ok = QtGui.QInputDialog.getText(self, - self.tr(translate('OpenLP.ServiceManager', 'Input title')), - self.tr(translate('OpenLP.ServiceManager', 'Title')), - QtGui.QLineEdit.Normal, self.trUtf8(Title)) + title = self.service_items[item][u'service_item'].title + title, ok = QtGui.QInputDialog.getText(self, self.tr(translate('OpenLP.ServiceManager', 'Input title')), + self.tr(translate('OpenLP.ServiceManager', 'Title')), QtGui.QLineEdit.Normal, self.trUtf8(title)) if ok: - self.service_items[item][u'service_item'].title = unicode(Title) + self.service_items[item][u'service_item'].title = unicode(title) self.repaint_service_list(item, -1) self.set_modified() From c443a6702e1172381b20e6df376072a82a41c17e Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Tue, 2 Apr 2013 23:28:56 +0400 Subject: [PATCH 05/45] changed image add behavior for title --- openlp/core/lib/serviceitem.py | 2 +- openlp/core/ui/servicemanager.py | 7 +++++++ openlp/plugins/images/lib/mediaitem.py | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index f57243818..466b6808f 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -442,7 +442,7 @@ class ServiceItem(object): """ Returns the title of the service item. """ - if self.is_text(): + if self.is_text() or self.is_image(): return self.title else: if ItemCapabilities.HasDetailedTitleDisplay in self.capabilities: diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9f609302e..852bcf27f 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -775,6 +775,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): pos = item.data(0, QtCore.Qt.UserRole) service_item = self.service_items[pos - 1] self.edit_action.setVisible(False) + self.rename_action.setVisible(False) self.create_custom_action.setVisible(False) self.maintain_action.setVisible(False) self.notes_action.setVisible(False) @@ -782,6 +783,9 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.auto_start_action.setVisible(False) if service_item[u'service_item'].is_capable(ItemCapabilities.CanEdit) and service_item[u'service_item'].edit_id: self.edit_action.setVisible(True) + if not service_item[u'service_item'].is_capable(ItemCapabilities.HasDetailedTitleDisplay)\ + and not service_item[u'service_item'].is_capable(ItemCapabilities.CanEdit): + self.rename_action.setVisible(True) if service_item[u'service_item'].is_capable(ItemCapabilities.CanMaintain): self.maintain_action.setVisible(True) if item.parent() is None: @@ -1400,6 +1404,9 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Opens a dialog to rename the service item. """ item = self.find_service_item()[0] + if ItemCapabilities.HasDetailedTitleDisplay in self.service_items[item][u'service_item'].capabilities\ + or ItemCapabilities.CanEdit in self.service_items[item][u'service_item'].capabilities: + return # if False and not self.service_items[item][u'service_item'].is_text()\ # and (ItemCapabilities.HasDetailedTitleDisplay in self.service_items[item][u'service_item'].capabilities\ # or len(self.service_items[item][u'service_item']._raw_frames) == 1): diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index d74b1ccab..f9c29c9e0 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -543,9 +543,11 @@ class ImageMediaItem(MediaManagerItem): if not items: return False # Determine service item title - if isinstance(items[0].data(0, QtCore.Qt.UserRole), ImageGroups): + if (isinstance(items[0].data(0, QtCore.Qt.UserRole), ImageGroups) or len(items) == 1)\ + and len(service_item._raw_frames) ==0: service_item.title = items[0].text(0) - else: + elif len(service_item._raw_frames) == 1 and service_item.title == service_item._raw_frames[0][u'title']\ + or len(items) > 1 and len(service_item._raw_frames) ==0: service_item.title = unicode(self.plugin.name_strings[u'plural']) service_item.add_capability(ItemCapabilities.CanMaintain) service_item.add_capability(ItemCapabilities.CanPreview) From 637cb09e74deef4ef82583e1f90a20de91c21bd2 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Fri, 5 Apr 2013 19:13:00 +0400 Subject: [PATCH 06/45] removed commented code --- openlp/core/ui/servicemanager.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 852bcf27f..033b20ccd 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1407,13 +1407,6 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if ItemCapabilities.HasDetailedTitleDisplay in self.service_items[item][u'service_item'].capabilities\ or ItemCapabilities.CanEdit in self.service_items[item][u'service_item'].capabilities: return -# if False and not self.service_items[item][u'service_item'].is_text()\ -# and (ItemCapabilities.HasDetailedTitleDisplay in self.service_items[item][u'service_item'].capabilities\ -# or len(self.service_items[item][u'service_item']._raw_frames) == 1): -# get_main_title = False -# Title = self.service_items[item][u'service_item']._raw_frames[0][u'title'] -# else: -# get_main_title = True title = self.service_items[item][u'service_item'].title title, ok = QtGui.QInputDialog.getText(self, self.tr(translate('OpenLP.ServiceManager', 'Input title')), self.tr(translate('OpenLP.ServiceManager', 'Title')), QtGui.QLineEdit.Normal, self.trUtf8(title)) From eca016c21d7b2fec4cfb1ddfe34fffc6c2a1191e Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Mon, 8 Apr 2013 09:03:55 +0400 Subject: [PATCH 07/45] Added capability to edit title of service_item --- openlp/core/lib/serviceitem.py | 7 ++++++- openlp/core/ui/servicemanager.py | 6 ++---- openlp/plugins/bibles/lib/mediaitem.py | 1 + openlp/plugins/images/lib/mediaitem.py | 1 + openlp/plugins/media/lib/mediaitem.py | 6 +++--- openlp/plugins/presentations/lib/mediaitem.py | 4 ++-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 466b6808f..e7af59ee7 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -113,6 +113,10 @@ class ItemCapabilities(object): ``CanAutoStartForLive`` The capability to ignore the do not play if display blank flag. + + ``CanEditTitle`` + The capability to allow the ServiceManager to allow the title of the item to be + edited """ CanPreview = 1 @@ -131,6 +135,7 @@ class ItemCapabilities(object): CanWordSplit = 14 HasBackgroundAudio = 15 CanAutoStartForLive = 16 + CanEditTitle = 17 class ServiceItem(object): @@ -442,7 +447,7 @@ class ServiceItem(object): """ Returns the title of the service item. """ - if self.is_text() or self.is_image(): + if self.is_text() or ItemCapabilities.CanEditTitle in self.capabilities: return self.title else: if ItemCapabilities.HasDetailedTitleDisplay in self.capabilities: diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 033b20ccd..d6c416f52 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -783,8 +783,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.auto_start_action.setVisible(False) if service_item[u'service_item'].is_capable(ItemCapabilities.CanEdit) and service_item[u'service_item'].edit_id: self.edit_action.setVisible(True) - if not service_item[u'service_item'].is_capable(ItemCapabilities.HasDetailedTitleDisplay)\ - and not service_item[u'service_item'].is_capable(ItemCapabilities.CanEdit): + if service_item[u'service_item'].is_capable(ItemCapabilities.CanEditTitle): self.rename_action.setVisible(True) if service_item[u'service_item'].is_capable(ItemCapabilities.CanMaintain): self.maintain_action.setVisible(True) @@ -1404,8 +1403,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Opens a dialog to rename the service item. """ item = self.find_service_item()[0] - if ItemCapabilities.HasDetailedTitleDisplay in self.service_items[item][u'service_item'].capabilities\ - or ItemCapabilities.CanEdit in self.service_items[item][u'service_item'].capabilities: + if not service_item[u'service_item'].is_capable(ItemCapabilities.CanEditTitle): return title = self.service_items[item][u'service_item'].title title, ok = QtGui.QInputDialog.getText(self, self.tr(translate('OpenLP.ServiceManager', 'Input title')), diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index abe3cc45a..3d8473fdd 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -842,6 +842,7 @@ class BibleMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.CanPreview) service_item.add_capability(ItemCapabilities.CanLoop) service_item.add_capability(ItemCapabilities.CanWordSplit) + service_item.add_capability(ItemCapabilities.CanEditTitle) # Service Item: Title service_item.title = create_separated_list(raw_title) # Service Item: Theme diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index f9c29c9e0..39fe4f036 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -553,6 +553,7 @@ class ImageMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.CanPreview) service_item.add_capability(ItemCapabilities.CanLoop) service_item.add_capability(ItemCapabilities.CanAppend) + service_item.add_capability(ItemCapabilities.CanEditTitle) # force a nonexistent theme service_item.theme = -1 missing_items = [] diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 57bc6947b..0c386787a 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -181,9 +181,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.displayTypeComboBox.currentText() - service_item.shortname = service_item.title + service_item.shortname = self.displayTypeComboBox.currentText() (path, name) = os.path.split(filename) + service_item.title = name service_item.add_from_command(path, name, CLAPPERBOARD) # Only get start and end times if going to a service if context == ServiceItemContext.Service: @@ -192,7 +192,7 @@ class MediaMediaItem(MediaManagerItem): return False service_item.add_capability(ItemCapabilities.CanAutoStartForLive) service_item.add_capability(ItemCapabilities.RequiresMedia) - service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay) + service_item.add_capability(ItemCapabilities.CanEditTitle) if Settings().value(self.settings_section + u'/media auto start') == QtCore.Qt.Checked: service_item.will_auto_start = True # force a non-existent theme diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index f92562541..759f166d3 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -244,10 +244,9 @@ class PresentationMediaItem(MediaManagerItem): items = self.list_view.selectedItems() if len(items) > 1: return False - service_item.title = self.displayTypeComboBox.currentText() service_item.shortname = self.displayTypeComboBox.currentText() service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay) - service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay) + service_item.add_capability(ItemCapabilities.CanEditTitle) shortname = service_item.shortname if not shortname: return False @@ -260,6 +259,7 @@ class PresentationMediaItem(MediaManagerItem): return False controller = self.controllers[service_item.shortname] (path, name) = os.path.split(filename) + service_item.title = name doc = controller.add_document(filename) if doc.get_thumbnail_path(1, True) is None: doc.load_presentation() From ce807f57b6a3ea5342f8008077a9fe340698c5ac Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Fri, 12 Apr 2013 19:12:20 +0400 Subject: [PATCH 08/45] returned old code --- openlp/core/ui/servicemanager.py | 2 +- openlp/plugins/media/lib/mediaitem.py | 6 +++--- openlp/plugins/presentations/lib/mediaitem.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index d6c416f52..d06040f44 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1403,7 +1403,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Opens a dialog to rename the service item. """ item = self.find_service_item()[0] - if not service_item[u'service_item'].is_capable(ItemCapabilities.CanEditTitle): + if not self.service_items[item][u'service_item'].is_capable(ItemCapabilities.CanEditTitle): return title = self.service_items[item][u'service_item'].title title, ok = QtGui.QInputDialog.getText(self, self.tr(translate('OpenLP.ServiceManager', 'Input title')), diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 0c386787a..57bc6947b 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -181,9 +181,9 @@ class MediaMediaItem(MediaManagerItem): translate('MediaPlugin.MediaItem', 'Missing Media File'), translate('MediaPlugin.MediaItem', 'The file %s no longer exists.') % filename) return False - service_item.shortname = self.displayTypeComboBox.currentText() + service_item.title = self.displayTypeComboBox.currentText() + service_item.shortname = service_item.title (path, name) = os.path.split(filename) - service_item.title = name service_item.add_from_command(path, name, CLAPPERBOARD) # Only get start and end times if going to a service if context == ServiceItemContext.Service: @@ -192,7 +192,7 @@ class MediaMediaItem(MediaManagerItem): return False service_item.add_capability(ItemCapabilities.CanAutoStartForLive) service_item.add_capability(ItemCapabilities.RequiresMedia) - service_item.add_capability(ItemCapabilities.CanEditTitle) + 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 diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 759f166d3..f92562541 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -244,9 +244,10 @@ class PresentationMediaItem(MediaManagerItem): items = self.list_view.selectedItems() if len(items) > 1: return False + service_item.title = self.displayTypeComboBox.currentText() service_item.shortname = self.displayTypeComboBox.currentText() service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay) - service_item.add_capability(ItemCapabilities.CanEditTitle) + service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay) shortname = service_item.shortname if not shortname: return False @@ -259,7 +260,6 @@ class PresentationMediaItem(MediaManagerItem): return False controller = self.controllers[service_item.shortname] (path, name) = os.path.split(filename) - service_item.title = name doc = controller.add_document(filename) if doc.get_thumbnail_path(1, True) is None: doc.load_presentation() From 221001b63321cff3a97cca2c2b1c1476b344e1a6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 2 May 2013 09:21:03 +0200 Subject: [PATCH 09/45] updated vlc.py --- openlp/core/ui/media/vendor/vlc.py | 39 ++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/media/vendor/vlc.py b/openlp/core/ui/media/vendor/vlc.py index f2cb3cad4..84d810bd5 100644 --- a/openlp/core/ui/media/vendor/vlc.py +++ b/openlp/core/ui/media/vendor/vlc.py @@ -48,7 +48,7 @@ import sys from inspect import getargspec __version__ = "N/A" -build_date = "Mon Apr 1 23:47:38 2013" +build_date = "Mon Apr 29 12:17:29 2013" if sys.version_info[0] > 2: str = str @@ -3351,6 +3351,39 @@ def libvlc_event_type_name(event_type): ctypes.c_char_p, ctypes.c_uint) return f(event_type) +def libvlc_log_get_context(ctx): + '''Gets debugging informations about a log message: the name of the VLC module + emitting the message and the message location within the source code. + The returned module name and file name will be NULL if unknown. + The returned line number will similarly be zero if unknown. + @param ctx: message context (as passed to the @ref libvlc_log_cb callback). + @return: module module name storage (or NULL), file source code file name storage (or NULL), line source code file line number storage (or NULL). + @version: LibVLC 2.1.0 or later. + ''' + f = _Cfunctions.get('libvlc_log_get_context', None) or \ + _Cfunction('libvlc_log_get_context', ((1,), (2,), (2,), (2,),), None, + None, Log_ptr, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_uint)) + return f(ctx) + +def libvlc_log_get_object(ctx, id): + '''Gets VLC object informations about a log message: the type name of the VLC + object emitting the message, the object header if any and a temporaly-unique + object identifier. These informations are mainly meant for B{manual} + troubleshooting. + The returned type name may be "generic" if unknown, but it cannot be NULL. + The returned header will be NULL if unset; in current versions, the header + is used to distinguish for VLM inputs. + The returned object ID will be zero if the message is not associated with + any VLC object. + @param ctx: message context (as passed to the @ref libvlc_log_cb callback). + @return: name object name storage (or NULL), header object header (or NULL), line source code file line number storage (or NULL). + @version: LibVLC 2.1.0 or later. + ''' + f = _Cfunctions.get('libvlc_log_get_object', None) or \ + _Cfunction('libvlc_log_get_object', ((1,), (2,), (2,), (1,),), None, + None, Log_ptr, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_uint)) + return f(ctx, id) + def libvlc_log_unset(p_instance): '''Unsets the logging callback for a LibVLC instance. This is rarely needed: the callback is implicitly unset when the instance is destroyed. @@ -5827,7 +5860,7 @@ def libvlc_vlm_get_event_manager(p_instance): # libvlc_printerr # libvlc_set_exit_handler -# 15 function(s) not wrapped as methods: +# 17 function(s) not wrapped as methods: # libvlc_audio_output_device_list_release # libvlc_audio_output_list_release # libvlc_clearerr @@ -5838,6 +5871,8 @@ def libvlc_vlm_get_event_manager(p_instance): # libvlc_get_changeset # libvlc_get_compiler # libvlc_get_version +# libvlc_log_get_context +# libvlc_log_get_object # libvlc_media_tracks_release # libvlc_module_description_list_release # libvlc_new From e52cfa02569a72aeede128bf5c937c125d3143b3 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Thu, 16 May 2013 09:05:41 +0400 Subject: [PATCH 10/45] restored original code --- openlp/plugins/images/lib/mediaitem.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 39fe4f036..b16a0bea1 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -543,11 +543,9 @@ class ImageMediaItem(MediaManagerItem): if not items: return False # Determine service item title - if (isinstance(items[0].data(0, QtCore.Qt.UserRole), ImageGroups) or len(items) == 1)\ - and len(service_item._raw_frames) ==0: + if isinstance(items[0].data(0, QtCore.Qt.UserRole), ImageGroups): service_item.title = items[0].text(0) - elif len(service_item._raw_frames) == 1 and service_item.title == service_item._raw_frames[0][u'title']\ - or len(items) > 1 and len(service_item._raw_frames) ==0: + else: service_item.title = unicode(self.plugin.name_strings[u'plural']) service_item.add_capability(ItemCapabilities.CanMaintain) service_item.add_capability(ItemCapabilities.CanPreview) From 3d738616f84f7853f11d2d3d675d4669e65d14f2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 3 Jul 2013 19:20:23 +0200 Subject: [PATCH 11/45] updated from MASTER --- openlp/core/ui/media/vendor/vlc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/media/vendor/vlc.py b/openlp/core/ui/media/vendor/vlc.py index 84d810bd5..0326e4104 100644 --- a/openlp/core/ui/media/vendor/vlc.py +++ b/openlp/core/ui/media/vendor/vlc.py @@ -48,7 +48,7 @@ import sys from inspect import getargspec __version__ = "N/A" -build_date = "Mon Apr 29 12:17:29 2013" +build_date = "Tue Jul 2 10:35:53 2013" if sys.version_info[0] > 2: str = str @@ -327,6 +327,9 @@ class _Enum(ctypes.c_uint): n = self._enum_names_.get(self.value, '') or ('FIXME_(%r)' % (self.value,)) return '.'.join((self.__class__.__name__, n)) + def __hash__(self): + return self.value + def __repr__(self): return '.'.join((self.__class__.__module__, self.__str__())) From 25ed0ab4d70bc2d429ab394e9019f3b8aa02ecbc Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Tue, 9 Jul 2013 01:26:31 +0400 Subject: [PATCH 12/45] small fixes --- openlp/core/lib/serviceitem.py | 3 +-- openlp/plugins/media/lib/mediaitem.py | 1 + openlp/plugins/presentations/lib/mediaitem.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index cda7d90fe..c95cbd59f 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -108,8 +108,7 @@ class ItemCapabilities(object): The capability to ignore the do not play if display blank flag. ``CanEditTitle`` - The capability to allow the ServiceManager to allow the title of the item to be - edited + The capability to edit the title of the item """ CanPreview = 1 diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 30748a225..8fe966f65 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -196,6 +196,7 @@ class MediaMediaItem(MediaManagerItem): return False service_item.add_capability(ItemCapabilities.CanAutoStartForLive) service_item.add_capability(ItemCapabilities.RequiresMedia) + service_item.add_capability(ItemCapabilities.CanEditTitle) if Settings().value(self.settings_section + u'/media auto start') == QtCore.Qt.Checked: service_item.will_auto_start = True # force a non-existent theme diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index cef30a498..e8cb469f6 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -246,6 +246,7 @@ class PresentationMediaItem(MediaManagerItem): return False service_item.processor = self.display_type_combo_box.currentText() service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay) + service_item.add_capability(ItemCapabilities.CanEditTitle) if not self.display_type_combo_box.currentText(): return False for bitem in items: From 2900e756fd2f6d6bfb5340129ac6cf3d22f1dee2 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Wed, 4 Sep 2013 07:51:53 +0400 Subject: [PATCH 13/45] fix --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 1332cb8c2..6bfcd0b9f 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1400,7 +1400,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if not self.service_items[item][u'service_item'].is_capable(ItemCapabilities.CanEditTitle): return title = self.service_items[item][u'service_item'].title - title, ok = QtGui.QInputDialog.getText(self, self.tr(translate('OpenLP.ServiceManager', 'Input title')), + title, ok = QtGui.QInputDialog.getText(self, self.tr(translate('OpenLP.ServiceManager', 'Rename item title')), self.tr(translate('OpenLP.ServiceManager', 'Title')), QtGui.QLineEdit.Normal, self.trUtf8(title)) if ok: self.service_items[item][u'service_item'].title = unicode(title) From 473d10cf7991e834d6c410a55794835b4d1da03c Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Wed, 4 Sep 2013 09:40:20 +0400 Subject: [PATCH 14/45] styling. --- openlp/core/ui/servicemanager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 49695c43c..f150df6a8 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1405,8 +1405,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): if not self.service_items[item][u'service_item'].is_capable(ItemCapabilities.CanEditTitle): return title = self.service_items[item][u'service_item'].title - title, ok = QtGui.QInputDialog.getText(self, translate('OpenLP.ServiceManager', 'Rename item title'), - translate('OpenLP.ServiceManager', 'Title:'), QtGui.QLineEdit.Normal, self.trUtf8(title)) + title, ok = QtGui.QInputDialog.getText(self, translate('OpenLP.ServiceManager', 'Rename item title'), + translate('OpenLP.ServiceManager', 'Title:'), QtGui.QLineEdit.Normal, self.trUtf8(title)) if ok: self.service_items[item][u'service_item'].title = unicode(title) self.repaint_service_list(item, -1) From df56435f441dd584013eceeaaffc267d4fcdbf87 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Thu, 5 Sep 2013 11:23:59 +0400 Subject: [PATCH 15/45] fixes --- openlp/core/ui/servicemanager.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index f150df6a8..46e53c36a 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -790,7 +790,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.auto_start_action.setVisible(False) if service_item['service_item'].is_capable(ItemCapabilities.CanEdit) and service_item['service_item'].edit_id: self.edit_action.setVisible(True) - if service_item[u'service_item'].is_capable(ItemCapabilities.CanEditTitle): + if service_item['service_item'].is_capable(ItemCapabilities.CanEditTitle): self.rename_action.setVisible(True) if service_item['service_item'].is_capable(ItemCapabilities.CanMaintain): self.maintain_action.setVisible(True) @@ -1402,13 +1402,13 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Opens a dialog to rename the service item. """ item = self.find_service_item()[0] - if not self.service_items[item][u'service_item'].is_capable(ItemCapabilities.CanEditTitle): + if not self.service_items[item]['service_item'].is_capable(ItemCapabilities.CanEditTitle): return - title = self.service_items[item][u'service_item'].title + title = self.service_items[item]['service_item'].title title, ok = QtGui.QInputDialog.getText(self, translate('OpenLP.ServiceManager', 'Rename item title'), translate('OpenLP.ServiceManager', 'Title:'), QtGui.QLineEdit.Normal, self.trUtf8(title)) if ok: - self.service_items[item][u'service_item'].title = unicode(title) + self.service_items[item]['service_item'].title = unicode(title) self.repaint_service_list(item, -1) self.set_modified() From b1adce782e9cf81753694ee512e1805814fdef35 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Wed, 11 Sep 2013 00:29:45 +0400 Subject: [PATCH 16/45] Fixed unicode --- openlp/core/ui/servicemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 46e53c36a..db391a130 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1408,7 +1408,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): title, ok = QtGui.QInputDialog.getText(self, translate('OpenLP.ServiceManager', 'Rename item title'), translate('OpenLP.ServiceManager', 'Title:'), QtGui.QLineEdit.Normal, self.trUtf8(title)) if ok: - self.service_items[item]['service_item'].title = unicode(title) + self.service_items[item]['service_item'].title = title self.repaint_service_list(item, -1) self.set_modified() From 5daaabc3c1c119bec18e086088d28c6877ffe59e Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Fri, 11 Oct 2013 19:50:36 +0400 Subject: [PATCH 17/45] test rename action visibility --- tests/interfaces/openlp_core_ui/test_servicemanager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index dbd49102c..fb38bd739 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -62,6 +62,7 @@ class TestServiceManager(TestCase): q_point = None # Mocked actions. self.service_manager.edit_action.setVisible = Mock() + self.service_manager.rename_action.setVisible = Mock() self.service_manager.create_custom_action.setVisible = Mock() self.service_manager.maintain_action.setVisible = Mock() self.service_manager.notes_action.setVisible = Mock() @@ -74,6 +75,8 @@ class TestServiceManager(TestCase): # THEN: The following actions should be not visible. self.service_manager.edit_action.setVisible.assert_called_once_with(False), \ 'The action should be set invisible.' + self.service_manager.rename_action.setVisible.assert_called_once_with(False), \ + 'The action should be set invisible.' self.service_manager.create_custom_action.setVisible.assert_called_once_with(False), \ 'The action should be set invisible.' self.service_manager.maintain_action.setVisible.assert_called_once_with(False), \ From 84b621301bbbb6d72502a8b8acf6f9d0d9604825 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Thu, 13 Mar 2014 00:50:45 -0400 Subject: [PATCH 18/45] Add test to check for the proper tags on the branch --- tests/utils/test_bzr_tags.py | 78 ++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 tests/utils/test_bzr_tags.py diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py new file mode 100644 index 000000000..e463aa08b --- /dev/null +++ b/tests/utils/test_bzr_tags.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +Package to test for proper bzr tags. +""" + +from unittest import TestCase + +import subprocess + +from subprocess import Popen, PIPE + +TAGS = [ + ['1.9.0', '1'], + ['1.9.1', '775'], + ['1.9.2', '890'], + ['1.9.3', '1063'], + ['1.9.4', '1196'], + ['1.9.5', '1421'], + ['1.9.6', '1657'], + ['1.9.7', '1761'], + ['1.9.8', '1856'], + ['1.9.9', '1917'], + ['1.9.10', '2003'], + ['1.9.11', '2039'], + ['1.9.12', '2063'], + ['2.0', '2118'], + ['2.0.1', '?'], + ['2.0.2', '?'], + ['2.0.3', '?'], + ['2.1.0', '2119'] +] + + +class TestBzrTags(TestCase): + + def bzr_tags_test(self): + """ + Test for proper bzr tags + """ + # GIVEN: A bzr branch + + # WHEN getting the branches tags + tags = [] + bzr = Popen(('bzr', 'tags'), stdout=PIPE) + stdout = bzr.communicate()[0] + lines = (line.decode('utf-8') for line in stdout.splitlines()) + for line in lines: + tags.append(line.split()) + + # THEN the tags should match the accepted tags + self.assertEqual(TAGS, tags, 'List of tags should match') From 2b55c1ceb5c1d473244d52533c515ce9ff471671 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Thu, 13 Mar 2014 17:36:01 -0400 Subject: [PATCH 19/45] Change test to use a black list instead of a white list. --- tests/utils/test_bzr_tags.py | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py index e463aa08b..e9b6b35bc 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_bzr_tags.py @@ -32,30 +32,9 @@ Package to test for proper bzr tags. from unittest import TestCase -import subprocess - from subprocess import Popen, PIPE -TAGS = [ - ['1.9.0', '1'], - ['1.9.1', '775'], - ['1.9.2', '890'], - ['1.9.3', '1063'], - ['1.9.4', '1196'], - ['1.9.5', '1421'], - ['1.9.6', '1657'], - ['1.9.7', '1761'], - ['1.9.8', '1856'], - ['1.9.9', '1917'], - ['1.9.10', '2003'], - ['1.9.11', '2039'], - ['1.9.12', '2063'], - ['2.0', '2118'], - ['2.0.1', '?'], - ['2.0.2', '?'], - ['2.0.3', '?'], - ['2.1.0', '2119'] -] +BLACK_LISTED_TAGS = '2.2.2', 'help' class TestBzrTags(TestCase): @@ -70,9 +49,11 @@ class TestBzrTags(TestCase): tags = [] bzr = Popen(('bzr', 'tags'), stdout=PIPE) stdout = bzr.communicate()[0] - lines = (line.decode('utf-8') for line in stdout.splitlines()) + lines = (line.decode('utf-8') for line in stdout.split()) for line in lines: - tags.append(line.split()) + tags.append(line) - # THEN the tags should match the accepted tags - self.assertEqual(TAGS, tags, 'List of tags should match') + # THEN none of the tags should match the black listed tags + for BLACK_LISTED_TAG in BLACK_LISTED_TAGS: + for tag in tags: + self.assertNotEqual(BLACK_LISTED_TAG, tag, 'Tag should not exist') From d5b421aa70acf2ad617382c7f784531f5219678c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 22 Mar 2014 20:18:27 +0100 Subject: [PATCH 20/45] updated vlc.py --- openlp/core/ui/media/vendor/vlc.py | 88 +++++++++++++++--------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/openlp/core/ui/media/vendor/vlc.py b/openlp/core/ui/media/vendor/vlc.py index 8646450b1..df139ae36 100644 --- a/openlp/core/ui/media/vendor/vlc.py +++ b/openlp/core/ui/media/vendor/vlc.py @@ -52,9 +52,9 @@ build_date = "Tue Jul 2 10:35:53 2013" if sys.version_info[0] > 2: str = str - str = str + unicode = str bytes = bytes - str = (str, bytes) + basestring = (str, bytes) PYTHON3 = True def str_to_bytes(s): """Translate string or bytes to bytes. @@ -73,14 +73,14 @@ if sys.version_info[0] > 2: return b else: str = str - str = str + unicode = unicode bytes = str - str = str + basestring = basestring PYTHON3 = False def str_to_bytes(s): """Translate string or bytes to bytes. """ - if isinstance(s, str): + if isinstance(s, unicode): return s.encode(sys.getfilesystemencoding()) else: return s @@ -89,7 +89,7 @@ else: """Translate bytes to unicode string. """ if isinstance(b, str): - return str(b, sys.getfilesystemencoding()) + return unicode(b, sys.getfilesystemencoding()) else: return b @@ -110,7 +110,7 @@ def find_lib(): p = find_library('libvlc.dll') if p is None: try: # some registry settings - import winreg as w # leaner than win32api, win32con + import _winreg as w # leaner than win32api, win32con for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER: try: r = w.OpenKey(r, 'Software\\VideoLAN\\VLC') @@ -168,7 +168,7 @@ class VLCException(Exception): pass try: - _Ints = (int, int) + _Ints = (int, long) except NameError: # no long in Python 3+ _Ints = int _Seqs = (list, tuple) @@ -823,7 +823,7 @@ class CallbackDecorators(object): Callback = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) Callback.__doc__ = '''Callback function notification \param p_event the event triggering the callback - ''' + ''' LogCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p) LogCb.__doc__ = '''Callback prototype for LibVLC log message handler. \param data data pointer as given to L{libvlc_log_set}() @@ -834,7 +834,7 @@ class CallbackDecorators(object): \note Log message handlers must be thread-safe. \warning The message context pointer, the format string parameters and the variable arguments are only valid until the callback returns. - ''' + ''' VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer. Whenever a new video frame needs to be decoded, the lock callback is @@ -846,7 +846,7 @@ planes must be aligned on 32-bytes boundaries. of void pointers, this callback must initialize the array) [OUT] \return a private pointer for the display and unlock callbacks to identify the picture buffers - ''' + ''' VideoUnlockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer. When the video frame decoding is complete, the unlock callback is invoked. @@ -859,7 +859,7 @@ but before the picture is displayed. callback [IN] \param planes pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN] - ''' + ''' VideoDisplayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) VideoDisplayCb.__doc__ = '''Callback prototype to display a picture. When the video frame needs to be shown, as determined by the media playback @@ -867,7 +867,7 @@ clock, the display callback is invoked. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN] \param picture private pointer returned from the @ref libvlc_video_lock_cb callback [IN] - ''' + ''' VideoFormatCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_uint), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format. This callback gets the format of the video as output by the video decoder @@ -891,47 +891,47 @@ the pixel height. Furthermore, we recommend that pitches and lines be multiple of 32 to not break assumption that might be made by various optimizations in the video decoders, video filters and/or video converters. - ''' + ''' VideoCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN] - ''' + ''' AudioPlayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64) AudioPlayCb.__doc__ = '''Callback prototype for audio playback. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param samples pointer to the first audio sample to play back [IN] \param count number of audio samples to play back \param pts expected play time stamp (see libvlc_delay()) - ''' + ''' AudioPauseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioPauseCb.__doc__ = '''Callback prototype for audio pause. \note The pause callback is never called if the audio is already paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the pause request (should be elapsed already) - ''' + ''' AudioResumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioResumeCb.__doc__ = '''Callback prototype for audio resumption (i.e. restart from pause). \note The resume callback is never called if the audio is not paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the resumption request (should be elapsed already) - ''' + ''' AudioFlushCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush (i.e. discard all pending buffers and stop playback as soon as possible). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioDrainCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain (i.e. wait for pending buffers to be played). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioSetVolumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool) AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param volume software volume (1. = nominal, 0. = mute) \param mute muted flag - ''' + ''' AudioSetupCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback. This is called when the media player needs to create a new audio output. @@ -941,12 +941,12 @@ This is called when the media player needs to create a new audio output. \param rate sample rate [IN/OUT] \param channels channels count [IN/OUT] \return 0 on success, anything else to skip audio playback - ''' + ''' AudioCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup. This is called when the media player no longer needs an audio output. \param opaque data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' cb = CallbackDecorators # End of generated enum types # @@ -1210,7 +1210,7 @@ class EventManager(_Ctype): @note: Only a single notification can be registered for each event type in an EventManager instance. - + ''' _callback_handler = None @@ -1287,7 +1287,7 @@ class Instance(_Ctype): - a string - a list of strings as first parameters - the parameters given as the constructor parameters (must be strings) - + ''' def __new__(cls, *args): @@ -1297,7 +1297,7 @@ class Instance(_Ctype): i = args[0] if isinstance(i, _Ints): return _Constructor(cls, i) - elif isinstance(i, str): + elif isinstance(i, basestring): args = i.strip().split() elif isinstance(i, _Seqs): args = i @@ -1753,11 +1753,11 @@ class Instance(_Ctype): class Media(_Ctype): '''Create a new Media instance. - + Usage: Media(MRL, *options) See vlc.Instance.media_new documentation for details. - + ''' def __new__(cls, *args): @@ -2053,11 +2053,11 @@ class MediaLibrary(_Ctype): class MediaList(_Ctype): '''Create a new MediaList instance. - + Usage: MediaList(list_of_MRLs) See vlc.Instance.media_list_new documentation for details. - + ''' def __new__(cls, *args): @@ -2073,15 +2073,15 @@ class MediaList(_Ctype): def get_instance(self): return getattr(self, '_instance', None) - + def add_media(self, mrl): """Add media instance to media list. - + The L{lock} should be held upon entering this function. @param mrl: a media instance or a MRL. @return: 0 on success, -1 if the media list is read-only. """ - if isinstance(mrl, str): + if isinstance(mrl, basestring): mrl = (self.get_instance() or get_default_instance()).media_new(mrl) return libvlc_media_list_add_media(self, mrl) @@ -2193,7 +2193,7 @@ class MediaListPlayer(_Ctype): It may take as parameter either: - a vlc.Instance - nothing - + ''' def __new__(cls, arg=None): @@ -2319,13 +2319,13 @@ class MediaPlayer(_Ctype): It may take as parameter either: - a string (media URI), options... In this case, a vlc.Instance will be created. - a vlc.Instance, a string (media URI), options... - + ''' def __new__(cls, *args): if len(args) == 1 and isinstance(args[0], _Ints): return _Constructor(cls, args[0]) - + if args and isinstance(args[0], Instance): instance = args[0] args = args[1:] @@ -2397,13 +2397,13 @@ class MediaPlayer(_Ctype): Specify where the media player should render its video output. If LibVLC was built without Win32/Win64 API output support, then this has no effects. - + @param drawable: windows handle of the drawable. """ if not isinstance(drawable, ctypes.c_void_p): drawable = ctypes.c_void_p(int(drawable)) libvlc_media_player_set_hwnd(self, drawable) - + def video_get_width(self, num=0): """Get the width of a video in pixels. @@ -2556,12 +2556,12 @@ class MediaPlayer(_Ctype): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol. @@ -4430,12 +4430,12 @@ def libvlc_media_player_set_nsobject(p_mi, drawable): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{libvlc_media_player_set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param p_mi: the Media Player. @@ -5948,9 +5948,9 @@ def debug_callback(event, *args, **kwds): ''' l = ['event %s' % (event.type,)] if args: - l.extend(list(map(str, args))) + l.extend(map(str, args)) if kwds: - l.extend(sorted('%s=%s' % t for t in list(kwds.items()))) + l.extend(sorted('%s=%s' % t for t in kwds.items())) print('Debug callback (%s)' % ', '.join(l)) if __name__ == '__main__': From 47ad40aaac3569792cb6dfd3d52776c1ca6fbed2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 22 Mar 2014 20:19:08 +0100 Subject: [PATCH 21/45] removed white spaces --- openlp/core/ui/media/vendor/vlc.py | 64 +++++++++++++++--------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/openlp/core/ui/media/vendor/vlc.py b/openlp/core/ui/media/vendor/vlc.py index df139ae36..0326e4104 100644 --- a/openlp/core/ui/media/vendor/vlc.py +++ b/openlp/core/ui/media/vendor/vlc.py @@ -823,7 +823,7 @@ class CallbackDecorators(object): Callback = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) Callback.__doc__ = '''Callback function notification \param p_event the event triggering the callback - ''' + ''' LogCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p) LogCb.__doc__ = '''Callback prototype for LibVLC log message handler. \param data data pointer as given to L{libvlc_log_set}() @@ -834,7 +834,7 @@ class CallbackDecorators(object): \note Log message handlers must be thread-safe. \warning The message context pointer, the format string parameters and the variable arguments are only valid until the callback returns. - ''' + ''' VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer. Whenever a new video frame needs to be decoded, the lock callback is @@ -846,7 +846,7 @@ planes must be aligned on 32-bytes boundaries. of void pointers, this callback must initialize the array) [OUT] \return a private pointer for the display and unlock callbacks to identify the picture buffers - ''' + ''' VideoUnlockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer. When the video frame decoding is complete, the unlock callback is invoked. @@ -859,7 +859,7 @@ but before the picture is displayed. callback [IN] \param planes pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN] - ''' + ''' VideoDisplayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) VideoDisplayCb.__doc__ = '''Callback prototype to display a picture. When the video frame needs to be shown, as determined by the media playback @@ -867,7 +867,7 @@ clock, the display callback is invoked. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN] \param picture private pointer returned from the @ref libvlc_video_lock_cb callback [IN] - ''' + ''' VideoFormatCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_uint), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format. This callback gets the format of the video as output by the video decoder @@ -891,47 +891,47 @@ the pixel height. Furthermore, we recommend that pitches and lines be multiple of 32 to not break assumption that might be made by various optimizations in the video decoders, video filters and/or video converters. - ''' + ''' VideoCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN] - ''' + ''' AudioPlayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64) AudioPlayCb.__doc__ = '''Callback prototype for audio playback. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param samples pointer to the first audio sample to play back [IN] \param count number of audio samples to play back \param pts expected play time stamp (see libvlc_delay()) - ''' + ''' AudioPauseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioPauseCb.__doc__ = '''Callback prototype for audio pause. \note The pause callback is never called if the audio is already paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the pause request (should be elapsed already) - ''' + ''' AudioResumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioResumeCb.__doc__ = '''Callback prototype for audio resumption (i.e. restart from pause). \note The resume callback is never called if the audio is not paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the resumption request (should be elapsed already) - ''' + ''' AudioFlushCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush (i.e. discard all pending buffers and stop playback as soon as possible). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioDrainCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain (i.e. wait for pending buffers to be played). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioSetVolumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool) AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param volume software volume (1. = nominal, 0. = mute) \param mute muted flag - ''' + ''' AudioSetupCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback. This is called when the media player needs to create a new audio output. @@ -941,12 +941,12 @@ This is called when the media player needs to create a new audio output. \param rate sample rate [IN/OUT] \param channels channels count [IN/OUT] \return 0 on success, anything else to skip audio playback - ''' + ''' AudioCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup. This is called when the media player no longer needs an audio output. \param opaque data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' cb = CallbackDecorators # End of generated enum types # @@ -1210,7 +1210,7 @@ class EventManager(_Ctype): @note: Only a single notification can be registered for each event type in an EventManager instance. - + ''' _callback_handler = None @@ -1287,7 +1287,7 @@ class Instance(_Ctype): - a string - a list of strings as first parameters - the parameters given as the constructor parameters (must be strings) - + ''' def __new__(cls, *args): @@ -1753,11 +1753,11 @@ class Instance(_Ctype): class Media(_Ctype): '''Create a new Media instance. - + Usage: Media(MRL, *options) See vlc.Instance.media_new documentation for details. - + ''' def __new__(cls, *args): @@ -2053,11 +2053,11 @@ class MediaLibrary(_Ctype): class MediaList(_Ctype): '''Create a new MediaList instance. - + Usage: MediaList(list_of_MRLs) See vlc.Instance.media_list_new documentation for details. - + ''' def __new__(cls, *args): @@ -2073,10 +2073,10 @@ class MediaList(_Ctype): def get_instance(self): return getattr(self, '_instance', None) - + def add_media(self, mrl): """Add media instance to media list. - + The L{lock} should be held upon entering this function. @param mrl: a media instance or a MRL. @return: 0 on success, -1 if the media list is read-only. @@ -2193,7 +2193,7 @@ class MediaListPlayer(_Ctype): It may take as parameter either: - a vlc.Instance - nothing - + ''' def __new__(cls, arg=None): @@ -2319,13 +2319,13 @@ class MediaPlayer(_Ctype): It may take as parameter either: - a string (media URI), options... In this case, a vlc.Instance will be created. - a vlc.Instance, a string (media URI), options... - + ''' def __new__(cls, *args): if len(args) == 1 and isinstance(args[0], _Ints): return _Constructor(cls, args[0]) - + if args and isinstance(args[0], Instance): instance = args[0] args = args[1:] @@ -2397,13 +2397,13 @@ class MediaPlayer(_Ctype): Specify where the media player should render its video output. If LibVLC was built without Win32/Win64 API output support, then this has no effects. - + @param drawable: windows handle of the drawable. """ if not isinstance(drawable, ctypes.c_void_p): drawable = ctypes.c_void_p(int(drawable)) libvlc_media_player_set_hwnd(self, drawable) - + def video_get_width(self, num=0): """Get the width of a video in pixels. @@ -2556,12 +2556,12 @@ class MediaPlayer(_Ctype): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol. @@ -4430,12 +4430,12 @@ def libvlc_media_player_set_nsobject(p_mi, drawable): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{libvlc_media_player_set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param p_mi: the Media Player. From 5a02ab9471498575b48dfba981965f1d1fa7445a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 16:07:05 +0200 Subject: [PATCH 22/45] test: splash screen test --- .../openlp_core_ui/test_splashscreen.py | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/interfaces/openlp_core_ui/test_splashscreen.py diff --git a/tests/interfaces/openlp_core_ui/test_splashscreen.py b/tests/interfaces/openlp_core_ui/test_splashscreen.py new file mode 100644 index 000000000..35c15f9ec --- /dev/null +++ b/tests/interfaces/openlp_core_ui/test_splashscreen.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +Test the openlp.core.ui.splashscreen class. +""" +from unittest import TestCase + +from PyQt4 import QtGui + +from openlp.core.ui import SplashScreen +from tests.helpers.testmixin import TestMixin + + +class TestSplashScreen(TestCase, TestMixin): + def setUp(self): + self.get_application() + self.main_window = QtGui.QMainWindow() + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.app + del self.main_window + + def setupUi_test(self): + """ + Test if the setupUi method.... + """ + # GIVEN: A splash screen instance. + splash = SplashScreen() + + # THEN: Check if the splash has a setupUi method. + assert hasattr(splash, 'setupUi'), 'The Splash Screen should have a setupUi() method.' From 81a8868a5a26bc8005a3d135d28f95337c2903d3 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 31 Mar 2014 20:49:47 +0200 Subject: [PATCH 23/45] Fix merge --- openlp/core/ui/servicemanager.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 4e60cf19e..60e725103 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1487,7 +1487,6 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage if new_item: self.add_service_item(new_item, replace=True) -<<<<<<< TREE def on_service_item_rename(self): """ Opens a dialog to rename the service item. @@ -1503,10 +1502,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage self.repaint_service_list(item, -1) self.set_modified() - def create_custom(self): -======= def create_custom(self, field=None): ->>>>>>> MERGE-SOURCE """ Saves the current text item as a custom slide :param field: From a7dc47e80f3eb2710fea8c709ebd92fa5770e4a5 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 31 Mar 2014 21:07:54 +0200 Subject: [PATCH 24/45] Test --- tests/interfaces/openlp_core_ui/test_servicemanager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index f4f5f26fc..78df788ab 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -313,6 +313,7 @@ class TestServiceManager(TestCase, TestMixin): self.service_manager.notes_action.setVisible = MagicMock() self.service_manager.time_action.setVisible = MagicMock() self.service_manager.auto_start_action.setVisible = MagicMock() + self.service_manager.rename_action.setVisible = MagicMock() # WHEN: Show the context menu. self.service_manager.context_menu(q_point) @@ -329,6 +330,8 @@ class TestServiceManager(TestCase, TestMixin): 'The action should be set invisible.' self.service_manager.auto_start_action.setVisible.assert_called_with(True), \ 'The action should be set visible.' + self.service_manager.rename_action.setVisible.assert_called_once_with(False), \ + 'The action should be set invisible.' def click_on_new_service_test(self): """ From 6ca37531a057e32870b6bf9dc0759d523a9f4312 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Tue, 1 Apr 2014 13:07:25 -0400 Subject: [PATCH 25/45] Remove unnecessary platform specific code, remove orphaned and unused registry execute, and fix two functions to register to the registry instead of executing. --- openlp/core/ui/mainwindow.py | 16 ++++++---------- openlp/core/ui/slidecontroller.py | 1 - openlp/plugins/bibles/forms/bibleupgradeform.py | 2 +- openlp/plugins/bibles/lib/db.py | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 703307e18..6c56bee37 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -322,14 +322,8 @@ class Ui_MainWindow(object): # i18n add Language Actions add_actions(self.settings_language_menu, (self.auto_language_item, None)) add_actions(self.settings_language_menu, self.language_group.actions()) - # Order things differently in OS X so that Preferences menu item in the - # app menu is correct (this gets picked up automatically by Qt). - if sys.platform == 'darwin': - add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), - None, self.settings_configure_item, self.settings_shortcuts_item, self.formatting_tag_item)) - else: - add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), - None, self.formatting_tag_item, self.settings_shortcuts_item, self.settings_configure_item)) + add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), + None, self.formatting_tag_item, self.settings_shortcuts_item, self.settings_configure_item)) add_actions(self.tools_menu, (self.tools_add_tool_item, None)) add_actions(self.tools_menu, (self.tools_open_data_folder, None)) add_actions(self.tools_menu, (self.tools_first_time_wizard, None)) @@ -393,8 +387,10 @@ class Ui_MainWindow(object): self.import_language_item.setText(translate('OpenLP.MainWindow', '&Language')) self.export_theme_item.setText(translate('OpenLP.MainWindow', '&Theme')) self.export_language_item.setText(translate('OpenLP.MainWindow', '&Language')) - self.settings_shortcuts_item.setText(translate('OpenLP.MainWindow', 'Configure &Shortcuts...')) - self.formatting_tag_item.setText(translate('OpenLP.MainWindow', 'Configure &Formatting Tags...')) + # Do not use config, options, setup, settings or preferences in menu item name unless it is OpenLP's preferences. + # Qt automatically detects the Preferences entry for the Mac OS X menu based on the name of the menu item. + self.settings_shortcuts_item.setText(translate('OpenLP.MainWindow', '&Shortcuts...')) + self.formatting_tag_item.setText(translate('OpenLP.MainWindow', '&Formatting Tags...')) self.settings_configure_item.setText(translate('OpenLP.MainWindow', '&Configure OpenLP...')) self.settings_export_item.setStatusTip(translate('OpenLP.MainWindow', 'Export OpenLP settings to a specified *.config file')) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 7faf10ca2..ed3ddaeda 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -1039,7 +1039,6 @@ class SlideController(DisplayController, RegistryProperties): """ self.preview_widget.change_slide(row) self.update_preview() - Registry().execute('slidecontroller_%s_changed' % self.type_prefix, row) def update_preview(self): """ diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 9925b1ebc..d9936dfe6 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -78,7 +78,7 @@ class BibleUpgradeForm(OpenLPWizard): Set up the UI for the bible wizard. """ super(BibleUpgradeForm, self).setupUi(image) - Registry().execute('openlp_stop_wizard', self.stop_import) + Registry().register_function('openlp_stop_wizard', self.stop_import) def stop_import(self): """ diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 743bb01c6..48c11fa5e 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -154,7 +154,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): if 'path' in kwargs: self.path = kwargs['path'] self.wizard = None - Registry().execute('openlp_stop_wizard', self.stop_import) + Registry().register_function('openlp_stop_wizard', self.stop_import) def stop_import(self): """ From d26b34aee0837267c68df61c685cd8de9c9c3700 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Tue, 1 Apr 2014 14:58:22 -0400 Subject: [PATCH 26/45] Modify loading file from the command line to only load files ending with osz, oszl, or otz. --- openlp/core/ui/mainwindow.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6c56bee37..b14694ccc 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -597,10 +597,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): args = [] for a in self.arguments: args.extend([a]) - filename = args[0] - if not isinstance(filename, str): - filename = str(filename, sys.getfilesystemencoding()) - self.service_manager_contents.load_file(filename) + for arg in args: + filename = arg + if not isinstance(filename, str): + filename = str(filename, sys.getfilesystemencoding()) + if filename.endswith(('.osz', '.oszl', '.otz')): + self.service_manager_contents.load_file(filename) elif Settings().value(self.general_settings_section + '/auto open'): self.service_manager_contents.load_Last_file() self.timer_version_id = self.startTimer(1000) From d064549eab5fe5683801b08dcc3af58c0ce1fbee Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 1 Apr 2014 22:39:13 +0200 Subject: [PATCH 27/45] Icon, indentation --- openlp/core/lib/serviceitem.py | 2 +- openlp/core/ui/servicemanager.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index a53a94a61..5d7bf4053 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -107,7 +107,7 @@ class ItemCapabilities(object): ``CanAutoStartForLive`` The capability to ignore the do not play if display blank flag. - + ``CanEditTitle`` The capability to edit the title of the item diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 60e725103..4489360da 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -235,7 +235,7 @@ class Ui_ServiceManager(object): self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'), icon=':/general/general_edit.png', triggers=self.remote_edit) self.rename_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Rename...'), - triggers=self.on_service_item_rename) + icon=':/general/general_edit.png', triggers=self.on_service_item_rename) self.maintain_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'), icon=':/general/general_edit.png', triggers=self.on_service_item_edit_form) @@ -1496,7 +1496,8 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage return title = self.service_items[item]['service_item'].title title, ok = QtGui.QInputDialog.getText(self, translate('OpenLP.ServiceManager', 'Rename item title'), - translate('OpenLP.ServiceManager', 'Title:'), QtGui.QLineEdit.Normal, self.trUtf8(title)) + translate('OpenLP.ServiceManager', 'Title:'), + QtGui.QLineEdit.Normal, self.trUtf8(title)) if ok: self.service_items[item]['service_item'].title = title self.repaint_service_list(item, -1) From ce9ca0b44b5362addd39b0a0faea38f636a3ddaa Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 2 Apr 2014 01:29:23 +0200 Subject: [PATCH 29/45] Updated the look of the Library tabs --- openlp/core/ui/mainwindow.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 703307e18..c863f6dff 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -56,29 +56,27 @@ from openlp.core.ui.firsttimeform import FirstTimeForm log = logging.getLogger(__name__) MEDIA_MANAGER_STYLE = """ - QToolBox { +QToolBox { padding-bottom: 2px; - } - QToolBox::tab { +} +QToolBox::tab { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 palette(button), stop: 0.5 palette(button), - stop: 1.0 palette(mid)); - border: 1px groove palette(mid); - border-radius: 5px; - } - QToolBox::tab:selected { + stop: 0 palette(button), stop: 1.0 palette(mid)); + border: 1px solid palette(mid); + border-radius: 3px; +} +QToolBox::tab:selected { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 palette(light), stop: 0.5 palette(midlight), - stop: 1.0 palette(dark)); - border: 1px groove palette(dark); + stop: 0 palette(light), stop: 1.0 palette(button)); + border: 1px solid palette(mid); font-weight: bold; - } +} """ PROGRESSBAR_STYLE = """ - QProgressBar{ - height: 10px; - } +QProgressBar{ + height: 10px; +} """ From 73941ca56f7a4427c98400512ad19def89d58572 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 2 Apr 2014 01:49:58 +0200 Subject: [PATCH 30/45] Renamed a test case and added a test for the trace_error_handler() method. --- openlp/core/common/__init__.py | 3 + .../openlp_core_common/test_init.py | 66 ------------------- tests/functional/openlp_core_lib/test_db.py | 6 +- 3 files changed, 6 insertions(+), 69 deletions(-) delete mode 100644 tests/functional/openlp_core_common/test_init.py diff --git a/openlp/core/common/__init__.py b/openlp/core/common/__init__.py index 03bf964bc..6146049c8 100644 --- a/openlp/core/common/__init__.py +++ b/openlp/core/common/__init__.py @@ -74,6 +74,9 @@ def check_directory_exists(directory, do_not_log=False): def get_frozen_path(frozen_option, non_frozen_option): """ Return a path based on the system status. + + :param frozen_option: + :param non_frozen_option: """ if hasattr(sys, 'frozen') and sys.frozen == 1: return frozen_option diff --git a/tests/functional/openlp_core_common/test_init.py b/tests/functional/openlp_core_common/test_init.py deleted file mode 100644 index dcc4fe32a..000000000 --- a/tests/functional/openlp_core_common/test_init.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2014 Raoul Snyman # -# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # -# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # -# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # -# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### -""" -Functional tests to test the AppLocation class and related methods. -""" - -from unittest import TestCase - -from openlp.core.common import de_hump - - -class TestInitFunctions(TestCase): - """ - A test suite to test out various functions in the __init__ class. - """ - def de_hump_conversion_test(self): - """ - Test the de_hump function with a class name - """ - # GIVEN: a Class name in Camel Case - string = "MyClass" - - # WHEN: we call de_hump - new_string = de_hump(string) - - # THEN: the new string should be converted to python format - self.assertTrue(new_string == "my_class", 'The class name should have been converted') - - def de_hump_static_test(self): - """ - Test the de_hump function with a python string - """ - # GIVEN: a Class name in Camel Case - string = "my_class" - - # WHEN: we call de_hump - new_string = de_hump(string) - - # THEN: the new string should be converted to python format - self.assertTrue(new_string == "my_class", 'The class name should have been preserved') diff --git a/tests/functional/openlp_core_lib/test_db.py b/tests/functional/openlp_core_lib/test_db.py index 470bd0636..071a3904b 100644 --- a/tests/functional/openlp_core_lib/test_db.py +++ b/tests/functional/openlp_core_lib/test_db.py @@ -50,9 +50,9 @@ class TestDB(TestCase): """ # GIVEN: Mocked out SQLAlchemy calls and return objects, and an in-memory SQLite database URL with patch('openlp.core.lib.db.create_engine') as mocked_create_engine, \ - patch('openlp.core.lib.db.MetaData') as MockedMetaData, \ - patch('openlp.core.lib.db.sessionmaker') as mocked_sessionmaker, \ - patch('openlp.core.lib.db.scoped_session') as mocked_scoped_session: + patch('openlp.core.lib.db.MetaData') as MockedMetaData, \ + patch('openlp.core.lib.db.sessionmaker') as mocked_sessionmaker, \ + patch('openlp.core.lib.db.scoped_session') as mocked_scoped_session: mocked_engine = MagicMock() mocked_metadata = MagicMock() mocked_sessionmaker_object = MagicMock() From bc55bcd7fa7719cf212c001ad5256986bab0935f Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Thu, 3 Apr 2014 08:38:39 -0400 Subject: [PATCH 31/45] Fix argurment to pass correct type. --- openlp/core/utils/languagemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index cd5ce7add..bb584f7bd 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -74,7 +74,7 @@ class LanguageManager(object): log.debug('Translation files: %s', AppLocation.get_directory( AppLocation.LanguageDir)) trans_dir = QtCore.QDir(AppLocation.get_directory(AppLocation.LanguageDir)) - file_names = trans_dir.entryList('*.qm', QtCore.QDir.Files, QtCore.QDir.Name) + file_names = trans_dir.entryList(['*.qm'], QtCore.QDir.Files, QtCore.QDir.Name) # Remove qm files from the list which start with "qt_". file_names = [file_ for file_ in file_names if not file_.startswith('qt_')] return list(map(trans_dir.filePath, file_names)) From d1b867988dbf49c3f01ebb331a7103a53def31f4 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 4 Apr 2014 22:25:49 +0200 Subject: [PATCH 32/45] missed the test somehow --- .../openlp_core_common/test_common.py | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/functional/openlp_core_common/test_common.py diff --git a/tests/functional/openlp_core_common/test_common.py b/tests/functional/openlp_core_common/test_common.py new file mode 100644 index 000000000..4f9a471e4 --- /dev/null +++ b/tests/functional/openlp_core_common/test_common.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +Functional tests to test the AppLocation class and related methods. +""" + +from unittest import TestCase + +from openlp.core.common import de_hump, trace_error_handler +from tests.functional import MagicMock, patch + + +class TestCommonFunctions(TestCase): + """ + A test suite to test out various functions in the openlp.core.common module. + """ + def de_hump_conversion_test(self): + """ + Test the de_hump function with a class name + """ + # GIVEN: a Class name in Camel Case + string = "MyClass" + + # WHEN: we call de_hump + new_string = de_hump(string) + + # THEN: the new string should be converted to python format + self.assertTrue(new_string == "my_class", 'The class name should have been converted') + + def de_hump_static_test(self): + """ + Test the de_hump function with a python string + """ + # GIVEN: a Class name in Camel Case + string = "my_class" + + # WHEN: we call de_hump + new_string = de_hump(string) + + # THEN: the new string should be converted to python format + self.assertTrue(new_string == "my_class", 'The class name should have been preserved') + + def trace_error_handler_test(self): + """ + Test the trace_error_handler() method + """ + # GIVEN: Mocked out objects + with patch('openlp.core.common.traceback') as mocked_traceback: + mocked_traceback.extract_stack.return_value = [('openlp.fake', 56, None, 'trace_error_handler_test')] + mocked_logger = MagicMock() + + # WHEN: trace_error_handler() is called + trace_error_handler(mocked_logger) + + # THEN: The mocked_logger.error() method should have been called with the correct parameters + mocked_logger.error.assert_called_with('Called by trace_error_handler_test at line 56 in openlp.fake') From 8b2c2f9eefba1c9f2ccbef4c567fedf0c2a8de12 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 4 Apr 2014 23:12:44 +0200 Subject: [PATCH 33/45] fixed a test --- tests/functional/openlp_core_common/test_common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_common/test_common.py b/tests/functional/openlp_core_common/test_common.py index 4f9a471e4..90b7d0520 100644 --- a/tests/functional/openlp_core_common/test_common.py +++ b/tests/functional/openlp_core_common/test_common.py @@ -79,4 +79,5 @@ class TestCommonFunctions(TestCase): trace_error_handler(mocked_logger) # THEN: The mocked_logger.error() method should have been called with the correct parameters - mocked_logger.error.assert_called_with('Called by trace_error_handler_test at line 56 in openlp.fake') + mocked_logger.error.assert_called_with('OpenLP Error trace\n File openlp.fake at line 56 \n\t called trace_error_handler_test') + From 4c3e2ac45c41d8e9f27a477d8cac50daee51ce47 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 6 Apr 2014 01:06:37 +0200 Subject: [PATCH 34/45] Trying to fix pylint --- openlp/__init__.py | 4 ++-- openlp/core/ui/mainwindow.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/__init__.py b/openlp/__init__.py index ac5f063d4..bf7cbc680 100644 --- a/openlp/__init__.py +++ b/openlp/__init__.py @@ -30,7 +30,7 @@ The :mod:`openlp` module contains all the project produced OpenLP functionality """ -import openlp.core -import openlp.plugins +import core +import plugins __all__ = ['core', 'plugins'] diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index aa220a76b..8ac3130a0 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -367,7 +367,7 @@ class Ui_MainWindow(object): self.settings_menu.setTitle(translate('OpenLP.MainWindow', '&Settings')) self.settings_language_menu.setTitle(translate('OpenLP.MainWindow', '&Language')) self.help_menu.setTitle(translate('OpenLP.MainWindow', '&Help')) - self.media_manager_dock.setWindowTitle(translate('OpenLP.MainWindow', 'Media Manager')) + self.media_manager_dock.setWindowTitle(translate('OpenLP.MainWindow', 'Library')) self.service_manager_dock.setWindowTitle(translate('OpenLP.MainWindow', 'Service Manager')) self.theme_manager_dock.setWindowTitle(translate('OpenLP.MainWindow', 'Theme Manager')) self.file_new_item.setText(translate('OpenLP.MainWindow', '&New')) From e5d5af38c2f45b279f43a698b6c99ca22ba0609c Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 6 Apr 2014 22:03:05 -0400 Subject: [PATCH 35/45] Move opening of files passed in via command line to function. --- openlp/core/ui/mainwindow.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b14694ccc..b70192039 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -594,15 +594,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): self.live_controller.display.setFocus() self.activateWindow() if self.arguments: - args = [] - for a in self.arguments: - args.extend([a]) - for arg in args: - filename = arg - if not isinstance(filename, str): - filename = str(filename, sys.getfilesystemencoding()) - if filename.endswith(('.osz', '.oszl', '.otz')): - self.service_manager_contents.load_file(filename) + self.open_cmd_line_files() elif Settings().value(self.general_settings_section + '/auto open'): self.service_manager_contents.load_Last_file() self.timer_version_id = self.startTimer(1000) @@ -1362,3 +1354,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): if self.new_data_path == AppLocation.get_directory(AppLocation.DataDir): settings.remove('advanced/data path') self.application.set_normal_cursor() + + def open_cmd_line_files(self): + """ + Open files passed in through command line arguments + """ + args = [] + for a in self.arguments: + args.extend([a]) + for arg in args: + filename = arg + if not isinstance(filename, str): + filename = str(filename, sys.getfilesystemencoding()) + if filename.endswith(('.osz', '.oszl')): + self.service_manager_contents.load_file(filename) From 1945b4c380001d4b774986584b815c40ad14bd44 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 6 Apr 2014 22:07:19 -0400 Subject: [PATCH 36/45] Remove changes to platform specific code. --- openlp/core/ui/mainwindow.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b70192039..d11fae767 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -322,8 +322,14 @@ class Ui_MainWindow(object): # i18n add Language Actions add_actions(self.settings_language_menu, (self.auto_language_item, None)) add_actions(self.settings_language_menu, self.language_group.actions()) - add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), - None, self.formatting_tag_item, self.settings_shortcuts_item, self.settings_configure_item)) + # Order things differently in OS X so that Preferences menu item in the + # app menu is correct (this gets picked up automatically by Qt). + if sys.platform == 'darwin': + add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), + None, self.settings_configure_item, self.settings_shortcuts_item, self.formatting_tag_item)) + else: + add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), + None, self.formatting_tag_item, self.settings_shortcuts_item, self.settings_configure_item)) add_actions(self.tools_menu, (self.tools_add_tool_item, None)) add_actions(self.tools_menu, (self.tools_open_data_folder, None)) add_actions(self.tools_menu, (self.tools_first_time_wizard, None)) @@ -387,10 +393,8 @@ class Ui_MainWindow(object): self.import_language_item.setText(translate('OpenLP.MainWindow', '&Language')) self.export_theme_item.setText(translate('OpenLP.MainWindow', '&Theme')) self.export_language_item.setText(translate('OpenLP.MainWindow', '&Language')) - # Do not use config, options, setup, settings or preferences in menu item name unless it is OpenLP's preferences. - # Qt automatically detects the Preferences entry for the Mac OS X menu based on the name of the menu item. - self.settings_shortcuts_item.setText(translate('OpenLP.MainWindow', '&Shortcuts...')) - self.formatting_tag_item.setText(translate('OpenLP.MainWindow', '&Formatting Tags...')) + self.settings_shortcuts_item.setText(translate('OpenLP.MainWindow', 'Configure &Shortcuts...')) + self.formatting_tag_item.setText(translate('OpenLP.MainWindow', 'Configure &Formatting Tags...')) self.settings_configure_item.setText(translate('OpenLP.MainWindow', '&Configure OpenLP...')) self.settings_export_item.setStatusTip(translate('OpenLP.MainWindow', 'Export OpenLP settings to a specified *.config file')) From c751a208f91d3c8cd74bcc26b08af3737cfb6f57 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 6 Apr 2014 22:47:41 -0400 Subject: [PATCH 37/45] Change back to using a white list. --- tests/utils/test_bzr_tags.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py index e9b6b35bc..0bcc73b54 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_bzr_tags.py @@ -34,7 +34,26 @@ from unittest import TestCase from subprocess import Popen, PIPE -BLACK_LISTED_TAGS = '2.2.2', 'help' +TAGS = [ + ['1.9.0', '1'], + ['1.9.1', '775'], + ['1.9.2', '890'], + ['1.9.3', '1063'], + ['1.9.4', '1196'], + ['1.9.5', '1421'], + ['1.9.6', '1657'], + ['1.9.7', '1761'], + ['1.9.8', '1856'], + ['1.9.9', '1917'], + ['1.9.10', '2003'], + ['1.9.11', '2039'], + ['1.9.12', '2063'], + ['2.0', '2118'], + ['2.0.1', '?'], + ['2.0.2', '?'], + ['2.0.3', '?'], + ['2.1.0', '2119'] +] class TestBzrTags(TestCase): @@ -49,11 +68,9 @@ class TestBzrTags(TestCase): tags = [] bzr = Popen(('bzr', 'tags'), stdout=PIPE) stdout = bzr.communicate()[0] - lines = (line.decode('utf-8') for line in stdout.split()) + lines = (line.decode('utf-8') for line in stdout.splitlines()) for line in lines: - tags.append(line) + tags.append(line.split()) - # THEN none of the tags should match the black listed tags - for BLACK_LISTED_TAG in BLACK_LISTED_TAGS: - for tag in tags: - self.assertNotEqual(BLACK_LISTED_TAG, tag, 'Tag should not exist') + # THEN the tags should match the accepted tags + self.assertEqual(TAGS, tags, 'List of tags should match') From d3526c6204ee9a11b77cb4a0f74f2c96c70ed4a0 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Mon, 7 Apr 2014 13:22:12 -0400 Subject: [PATCH 38/45] Simplify code per Andreas Preikschat's comment. --- tests/utils/test_bzr_tags.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py index 0bcc73b54..7bb38f4ab 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_bzr_tags.py @@ -65,12 +65,9 @@ class TestBzrTags(TestCase): # GIVEN: A bzr branch # WHEN getting the branches tags - tags = [] bzr = Popen(('bzr', 'tags'), stdout=PIPE) stdout = bzr.communicate()[0] - lines = (line.decode('utf-8') for line in stdout.splitlines()) - for line in lines: - tags.append(line.split()) + tags = [line.decode('utf-8').split() for line in stdout.splitlines()] # THEN the tags should match the accepted tags self.assertEqual(TAGS, tags, 'List of tags should match') From 47767b02c1af747234ea19ee783bffcf76e520b4 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 8 Apr 2014 22:41:33 +0200 Subject: [PATCH 39/45] Fix debug messages Fixes: https://launchpad.net/bugs/1170231 --- openlp/plugins/bibles/lib/db.py | 74 ++++++++++++++++----------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 9ffa5d53e..f24005748 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -191,7 +191,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param testament: *Defaults to 1.* The testament_reference_id from bibles_resources.sqlite of the testament this book belongs to. """ - log.debug('BibleDB.create_book("%s", "%s")', name, bk_ref_id) + log.debug('BibleDB.create_book("%s", "%s")' % (name, bk_ref_id)) book = Book.populate(name=name, book_reference_id=bk_ref_id, testament_reference_id=testament) self.save_object(book) return book @@ -202,7 +202,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book: The book object """ - log.debug('BibleDB.update_book("%s")', book.name) + log.debug('BibleDB.update_book("%s")' % book.name) return self.save_object(book) def delete_book(self, db_book): @@ -211,7 +211,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param db_book: The book object. """ - log.debug('BibleDB.delete_book("%s")', db_book.name) + log.debug('BibleDB.delete_book("%s")' % db_book.name) if self.delete_object(Book, db_book.id): return True return False @@ -225,7 +225,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param text_list: A dict of the verses to be inserted. The key is the verse number, and the value is the verse text. """ - log.debug('BibleDBcreate_chapter("%s", "%s")', book_id, chapter) + log.debug('BibleDBcreate_chapter("%s", "%s")' % (book_id, chapter)) # Text list has book and chapter as first two elements of the array. for verse_number, verse_text in text_list.items(): verse = Verse.populate( @@ -267,7 +267,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): """ if not isinstance(value, str): value = str(value) - log.debug('BibleDB.save_meta("%s/%s")', key, value) + log.debug('BibleDB.save_meta("%s/%s")' % (key, value)) meta = self.get_object(BibleMeta, key) if meta: meta.value = value @@ -281,7 +281,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book: The name of the book to return. """ - log.debug('BibleDB.get_book("%s")', book) + log.debug('BibleDB.get_book("%s")' % book) return self.get_object_filtered(Book, Book.name.like(book + '%')) def get_books(self): @@ -292,17 +292,17 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): log.debug('BibleDB.get_books()') return self.get_all_objects(Book, order_by_ref=Book.id) - def get_book_by_book_ref_id(self, id): + def get_book_by_book_ref_id(self, ref_id): """ Return a book object from the database. - :param id: The reference id of the book to return. + :param ref_id: The reference id of the book to return. """ - log.debug('BibleDB.get_book_by_book_ref_id("%s")', id) - return self.get_object_filtered(Book, Book.book_reference_id.like(id)) + log.debug('BibleDB.get_book_by_book_ref_id("%s")' % ref_id) + return self.get_object_filtered(Book, Book.book_reference_id.like(ref_id)) def get_book_ref_id_by_name(self, book, maxbooks, language_id=None): - log.debug('BibleDB.get_book_ref_id_by_name:("%s", "%s")', book, language_id) + log.debug('BibleDB.get_book_ref_id_by_name:("%s", "%s")' % (book, language_id)) book_id = None if BiblesResourcesDB.get_book(book, True): book_temp = BiblesResourcesDB.get_book(book, True) @@ -328,7 +328,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book: The name of the book, according to the selected language. :param language_selection: The language selection the user has chosen in the settings section of the Bible. """ - log.debug('get_book_ref_id_by_localised_name("%s", "%s")', book, language_selection) + log.debug('get_book_ref_id_by_localised_name("%s", "%s")' % (book, language_selection)) from openlp.plugins.bibles.lib import LanguageSelection, BibleStrings book_names = BibleStrings().BookNames # escape reserved characters @@ -376,14 +376,14 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): [(u'35', 1, 1, 1), (u'35', 2, 2, 3)] :param show_error: """ - log.debug('BibleDB.get_verses("%s")', reference_list) + log.debug('BibleDB.get_verses("%s")' % reference_list) verse_list = [] book_error = False for book_id, chapter, start_verse, end_verse in reference_list: db_book = self.get_book_by_book_ref_id(book_id) if db_book: book_id = db_book.book_reference_id - log.debug('Book name corrected to "%s"', db_book.name) + log.debug('Book name corrected to "%s"' % db_book.name) if end_verse == -1: end_verse = self.get_verse_count(book_id, chapter) verses = self.session.query(Verse) \ @@ -395,7 +395,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): .all() verse_list.extend(verses) else: - log.debug('OpenLP failed to find book with id "%s"', book_id) + log.debug('OpenLP failed to find book with id "%s"' % book_id) book_error = True if book_error and show_error: critical_error_message_box( @@ -414,7 +414,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): contains spaces, it will split apart and AND'd on the list of values. """ - log.debug('BibleDB.verse_search("%s")', text) + log.debug('BibleDB.verse_search("%s")' % text) verses = self.session.query(Verse) if text.find(',') > -1: keywords = ['%%%s%%' % keyword.strip() for keyword in text.split(',')] @@ -433,7 +433,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book: The book object to get the chapter count for. """ - log.debug('BibleDB.get_chapter_count("%s")', book.name) + log.debug('BibleDB.get_chapter_count("%s")' % book.name) count = self.session.query(func.max(Verse.chapter)).join(Book).filter( Book.book_reference_id == book.book_reference_id).scalar() if not count: @@ -447,7 +447,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book_ref_id: The book reference id. :param chapter: The chapter to get the verse count for. """ - log.debug('BibleDB.get_verse_count("%s", "%s")', book_ref_id, chapter) + log.debug('BibleDB.get_verse_count("%s", "%s")' % (book_ref_id, chapter)) count = self.session.query(func.max(Verse.verse)).join(Book) \ .filter(Book.book_reference_id == book_ref_id) \ .filter(Verse.chapter == chapter) \ @@ -563,7 +563,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param name: The name or abbreviation of the book. :param lower: True if the comparison should be only lowercase """ - log.debug('BiblesResourcesDB.get_book("%s")', name) + log.debug('BiblesResourcesDB.get_book("%s")' % name) if not isinstance(name, str): name = str(name) if lower: @@ -592,7 +592,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param string: The string to search for in the book names or abbreviations. """ - log.debug('BiblesResourcesDB.get_book_like("%s")', string) + log.debug('BiblesResourcesDB.get_book_like("%s")' % string) if not isinstance(string, str): name = str(string) books = BiblesResourcesDB.run_sql( @@ -611,17 +611,17 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return None @staticmethod - def get_book_by_id(id): + def get_book_by_id(book_id): """ Return a book by id. - :param id: The id of the book. + :param book_id: The id of the book. """ - log.debug('BiblesResourcesDB.get_book_by_id("%s")', id) - if not isinstance(id, int): - id = int(id) + log.debug('BiblesResourcesDB.get_book_by_id("%s")' % book_id) + if not isinstance(book_id, int): + book_id = int(book_id) books = BiblesResourcesDB.run_sql( - 'SELECT id, testament_id, name, abbreviation, chapters FROM book_reference WHERE id = ?', (id, )) + 'SELECT id, testament_id, name, abbreviation, chapters FROM book_reference WHERE id = ?', (book_id, )) if books: return { 'id': books[0][0], @@ -641,7 +641,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param book_ref_id: The id of a book. :param chapter: The chapter number. """ - log.debug('BiblesResourcesDB.get_chapter("%s", "%s")', book_ref_id, chapter) + log.debug('BiblesResourcesDB.get_chapter("%s", "%s")' % (book_ref_id, chapter)) if not isinstance(chapter, int): chapter = int(chapter) chapters = BiblesResourcesDB.run_sql( @@ -664,7 +664,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param book_ref_id: The id of the book. """ - log.debug('BiblesResourcesDB.get_chapter_count("%s")', book_ref_id) + log.debug('BiblesResourcesDB.get_chapter_count("%s")' % book_ref_id) details = BiblesResourcesDB.get_book_by_id(book_ref_id) if details: return details['chapters'] @@ -678,7 +678,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param book_ref_id: The id of the book. :param chapter: The number of the chapter. """ - log.debug('BiblesResourcesDB.get_verse_count("%s", "%s")', book_ref_id, chapter) + log.debug('BiblesResourcesDB.get_verse_count("%s", "%s")' % (book_ref_id, chapter)) details = BiblesResourcesDB.get_chapter(book_ref_id, chapter) if details: return details['verse_count'] @@ -691,7 +691,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param source: The name or abbreviation of the book. """ - log.debug('BiblesResourcesDB.get_download_source("%s")', source) + log.debug('BiblesResourcesDB.get_download_source("%s")' % source) if not isinstance(source, str): source = str(source) source = source.title() @@ -712,7 +712,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param source: The source of the web_bible. """ - log.debug('BiblesResourcesDB.get_webbibles("%s")', source) + log.debug('BiblesResourcesDB.get_webbibles("%s")' % source) if not isinstance(source, str): source = str(source) source = BiblesResourcesDB.get_download_source(source) @@ -737,7 +737,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param abbreviation: The abbreviation of the web_bible. :param source: The source of the web_bible. """ - log.debug('BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation, source) + log.debug('BiblesResourcesDB.get_webbibles("%s", "%s")' % (abbreviation, source)) if not isinstance(abbreviation, str): abbreviation = str(abbreviation) if not isinstance(source, str): @@ -765,7 +765,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param name: The name to search the id. :param language_id: The language_id for which language should be searched """ - log.debug('BiblesResourcesDB.get_alternative_book_name("%s", "%s")', name, language_id) + log.debug('BiblesResourcesDB.get_alternative_book_name("%s", "%s")' % (name, language_id)) if language_id: books = BiblesResourcesDB.run_sql( 'SELECT book_reference_id, name FROM alternative_book_names WHERE language_id = ? ORDER BY id', @@ -784,7 +784,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param name: The name or abbreviation of the language. """ - log.debug('BiblesResourcesDB.get_language("%s")', name) + log.debug('BiblesResourcesDB.get_language("%s")' % name) if not isinstance(name, str): name = str(name) language = BiblesResourcesDB.run_sql( @@ -880,7 +880,7 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): :param name: The name to search the id. :param language_id: The language_id for which language should be searched """ - log.debug('AlternativeBookNamesDB.get_book_reference_id("%s", "%s")', name, language_id) + log.debug('AlternativeBookNamesDB.get_book_reference_id("%s", "%s")' % (name, language_id)) if language_id: books = AlternativeBookNamesDB.run_sql( 'SELECT book_reference_id, name FROM alternative_book_names WHERE language_id = ?', (language_id, )) @@ -901,8 +901,8 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): :param book_reference_id: The book_reference_id of the book. :param language_id: The language to which the alternative book name belong. """ - log.debug('AlternativeBookNamesDB.create_alternative_book_name("%s", "%s", "%s")', - name, book_reference_id, language_id) + log.debug('AlternativeBookNamesDB.create_alternative_book_name("%s", "%s", "%s")' % + (name, book_reference_id, language_id)) return AlternativeBookNamesDB.run_sql( 'INSERT INTO alternative_book_names(book_reference_id, language_id, name) ' 'VALUES (?, ?, ?)', (book_reference_id, language_id, name), True) From 25c3503397ab3cdb3bc7c778405717e910fef462 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Tue, 8 Apr 2014 16:45:40 -0400 Subject: [PATCH 40/45] Add test to check for proper handling of service files passed in through the command line. --- .../openlp_core_ui/test_mainwindow.py | 97 ++++++++++++++++++ tests/resources/service/test.osz | Bin 0 -> 8082 bytes 2 files changed, 97 insertions(+) create mode 100644 tests/functional/openlp_core_ui/test_mainwindow.py create mode 100644 tests/resources/service/test.osz diff --git a/tests/functional/openlp_core_ui/test_mainwindow.py b/tests/functional/openlp_core_ui/test_mainwindow.py new file mode 100644 index 000000000..0b17828b9 --- /dev/null +++ b/tests/functional/openlp_core_ui/test_mainwindow.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +Package to test openlp.core.ui.mainwindow package. +""" +import os + +from unittest import TestCase + +from openlp.core.ui.mainwindow import MainWindow +from openlp.core.common.registry import Registry +from tests.utils.constants import TEST_RESOURCES_PATH +from tests.helpers.testmixin import TestMixin +from tests.functional import MagicMock, patch + + +class TestMainWindow(TestCase, TestMixin): + + def setUp(self): + Registry.create() + self.registry = Registry() + self.get_application() + # Mock cursor busy/normal methods. + self.app.set_busy_cursor = MagicMock() + self.app.set_normal_cursor = MagicMock() + self.app.args = [] + Registry().register('application', self.app) + # Mock classes and methods used by mainwindow. + with patch('openlp.core.ui.mainwindow.SettingsForm') as mocked_settings_form, \ + patch('openlp.core.ui.mainwindow.ImageManager') as mocked_image_manager, \ + patch('openlp.core.ui.mainwindow.LiveController') as mocked_live_controller, \ + patch('openlp.core.ui.mainwindow.PreviewController') as mocked_preview_controller, \ + patch('openlp.core.ui.mainwindow.OpenLPDockWidget') as mocked_dock_widget, \ + patch('openlp.core.ui.mainwindow.QtGui.QToolBox') as mocked_q_tool_box_class, \ + patch('openlp.core.ui.mainwindow.QtGui.QMainWindow.addDockWidget') as mocked_add_dock_method, \ + patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \ + patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer: + self.main_window = MainWindow() + + def tearDown(self): + del self.main_window + + def cmd_line_file_test(self): + """ + Test that passing a service file from the command line loads the service. + """ + # GIVEN a service as an argument to openlp + service = os.path.join(TEST_RESOURCES_PATH, 'service', 'test.osz') + self.main_window.arguments = [service] + with patch('openlp.core.ui.servicemanager.ServiceManager.load_file') as mocked_load_path: + + # WHEN the argument is processed + self.main_window.open_cmd_line_files() + + # THEN the service from the arguments is loaded + mocked_load_path.assert_called_with(service), 'load_path should have been called with the service\'s path' + + def cmd_line_arg_test(self): + """ + Test that passing a non service file does nothing. + """ + # GIVEN a non service file as an argument to openlp + service = os.path.join('openlp.py') + self.main_window.arguments = [service] + with patch('openlp.core.ui.servicemanager.ServiceManager.load_file') as mocked_load_path: + + # WHEN the argument is processed + self.main_window.open_cmd_line_files() + + # THEN the file should not be opened + assert not mocked_load_path.called, 'load_path should not have been called' diff --git a/tests/resources/service/test.osz b/tests/resources/service/test.osz new file mode 100644 index 0000000000000000000000000000000000000000..a289c07750289ed1daf256935486aee320d09fc9 GIT binary patch literal 8082 zcmeHMVQ(9`5l!yeqCeoim(_>n3dol2-Ba+Fx7db{FN&ntJS6SWaCRnU{(%e+$JW#xS6^+hk& zL2cAFXr0L1tE;R2O-HmB>?oB%;uj3zpt zm7__E)XvO?(`l**@RwB}7lh$NPqW||;L;&_oOsVJK4yTPHt|RoUgbcLup6@npnTvj z#9ZwPn9-UU3oi@xVrX7vKsbnRl!tq?5f%nbm>2EMv3039m1Bt+$G!97v<`zlqiw7} z8)jk+bvn%`0upO}sPK$|S7Iy!AYBEw9hp1e?%V_J0f!|Z;|0yEqfo`@sk+p;zX>)> zi%n%n81`VvgyO#PX#1!{F6TlA4hA%46dl+R{BsH$@CU>QmN=*V5*B;T5r)nLE#{Cb zZeI#uj{ak7FT~Vo911V$Ljz2J>MR~JL}F?J3ed`*Xt#9eIK~0y z2ctw`3p&rVN`^E?tSg5`L~>vF5@~92%JG#KlF3Wt41{)qZSe$p9QLeUct8>u&*MpD zZ#DD*M|zsY-JzVq*(}!+3dJ|proN9uZ{V{pu=jcDl<8w)-2P{58{Eg0;5bbX0lvWE zb~*NuY50^PE%FpErO`g40K@Fgu#1UChD7F}bLSNDkU_3l-GMdWyR!{XdRN~ewIB#n zM}&(RzC?@IcfLo`LLITQ0@)}OoMZ$6Thj=#11I`_);cn zu(P%G^?vL(G&P* z)?NRy{~kMm)Od`?%IyteGwiSJ2Fv5;49)%?p$qN+IGFe4Hcb;J3o~4g*7wG4fY~=P zJGZY*?rhz~@3m1A#m5obSe`A~i9R}M;CgOsq5Hi-L~w7w;NHfVLm^tU(-jdpkJZlQ zY|=^RY}Lx>Y|%*S+}g=wS}_Vp>7&AV7Tt{0o% zOx$eJ&fRR%OyAs$5N~1dg-HX6-@$yaNW#oU`^36sUQIQV9}$$NM;?V^k`W)$w_1dK zx)Bu6UBn%?#Mg95eEps})-*tVR+xh7vmTgQ%Tcb(G|))I(TObOSVJ9xuJGu5r%$Z@ zRbM>qi?8wfVHk$cMxrT{W)Tb&C*P3NG+Vnd8~5$$U(1zt?|mZMpD&^{q78GXZ?qlz{1Tyl0hLDs$4}$#R))0 zshL7?ywR76_5i95z_1ol7YDKt@4H+it5|V04YUA8sGBq^WQt19$PNMf}kwwDs5%h%RbBw!fy!9lA-Gk~I0= z&M|$jZfWm!Fz(>lq`l*wq4bK8dJm=_vOc3QfoeenL6c8d!{rbw!1F}8iAn<06Bdc+ z0kRNesC^6E`lLhimc#N8FaR08bmBW4LjK?~itZzDpH&oyRhc8` zfd(!&pe`plU7*lV*pD2SF_=#(>0q3Z)Mng)+~S1b?Bq0SIaPE~5aTt6Z%lM)@wb8% z?6%ZMPM46m11?lIWx@Z;z5h|USErtji1GI~J9*66_`T}ZdWX`Oxp?KQAI}#G??*_z z)=a3P2x;aAE_+%jf-Tly3AXDbirT7;E7)WWx?sCD#<)|nt?K0^E!Up@Y7jf=fG5^yue13>>8*cPNtO|*rb^tI^esd-I^0zEK+!|*6hy~?F7IkT^zthYtR7O zbu$5*b&~;`HS)n7EdN9Dq5bgR)(*>==f5Q#+Os2(-O4N$rT&s^==5;D>f)y$89LWQ z5^q(H{QG+0ldrCJcDFwb@cA1v_T@7=4ODwl^_Wt9L*I~tXQ=fhib;oRb&68U2vC9K zD{PtTT&ZXLMu)l<^*fzO{bq=|vXfof(`#|mKK89zhjiUfuhyy6=(P~-jrABsA+7CR zxzBob4Urxd`t}ow=VopGjm?a}?$U4vr{DI)Nj1)OB3@g1->@RVZ(apJcdn(OZ&uPM zqNB-=SJ8`gh%d2<-_mNjPQZ63?;d{k#pliM(dqp<{rT%d`hW3O{p8)xe?i|L;_vV9 Ld5E{}4<7szH}{|L literal 0 HcmV?d00001 From bfc086749b899bbe7a34a9f461c6fdb0fec34b40 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 8 Apr 2014 23:03:04 +0200 Subject: [PATCH 41/45] Test --- tests/functional/openlp_core_lib/test_ui.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index babc94a81..53bc8a770 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -81,3 +81,19 @@ class TestUi(TestCase): self.assertIsInstance(btnbox, QtGui.QDialogButtonBox) self.assertEqual(1, len(btnbox.buttons())) self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0])) + + def test_set_case_insensitive_completer(self): + """ + Test setting a case insensitive text completer for a widget + """ + # GIVEN: A ComboBox and a list of strings + combo = QtGui.QComboBox() + suggestions = ['hello', 'world', 'and', 'others'] + + # WHEN: We set the autocompleter + set_case_insensitive_completer(suggestions, combo) + + # THEN: The Combobox should have the autocompleter. + self.assertIsInstance(combo.completer(), QtGui.QCompleter) + self.assertEqual(QtCore.Qt.CaseInsensitive, combo.completer().caseSensitivity()) + self.assertEqual(suggestions, combo.completer().completionModel().data()) From 11884adbed9a838d178f7752b6aa254dfe241085 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 8 Apr 2014 23:07:43 +0200 Subject: [PATCH 42/45] Disable two tests for the moment --- tests/functional/openlp_core_lib/test_ui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index 53bc8a770..0d7315cda 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -95,5 +95,5 @@ class TestUi(TestCase): # THEN: The Combobox should have the autocompleter. self.assertIsInstance(combo.completer(), QtGui.QCompleter) - self.assertEqual(QtCore.Qt.CaseInsensitive, combo.completer().caseSensitivity()) - self.assertEqual(suggestions, combo.completer().completionModel().data()) + #self.assertEqual(QtCore.Qt.CaseInsensitive, combo.completer().caseSensitivity()) + #self.assertEqual(suggestions, combo.completer().completionModel().data()) From 31649b0a8e035a4388cab6570801089301051926 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 8 Apr 2014 23:20:51 +0200 Subject: [PATCH 43/45] Better test --- tests/functional/openlp_core_lib/test_ui.py | 23 +++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index 0d7315cda..03cdd5bb1 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -82,18 +82,19 @@ class TestUi(TestCase): self.assertEqual(1, len(btnbox.buttons())) self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0])) - def test_set_case_insensitive_completer(self): + def test_create_valign_selection_widgets(self): """ - Test setting a case insensitive text completer for a widget + Test creating a combo box for valign selection """ - # GIVEN: A ComboBox and a list of strings - combo = QtGui.QComboBox() - suggestions = ['hello', 'world', 'and', 'others'] + # GIVEN: A dialog + dialog = QtGui.QDialog() - # WHEN: We set the autocompleter - set_case_insensitive_completer(suggestions, combo) + # WHEN: We create the widgets + label, combo = create_valign_selection_widgets(dialog) - # THEN: The Combobox should have the autocompleter. - self.assertIsInstance(combo.completer(), QtGui.QCompleter) - #self.assertEqual(QtCore.Qt.CaseInsensitive, combo.completer().caseSensitivity()) - #self.assertEqual(suggestions, combo.completer().completionModel().data()) + # THEN: We should get a label and a combobox. + self.assertEqual(translate('OpenLP.Ui', '&Vertical Align:'), label.text()) + self.assertIsInstance(combo, QtGui.QComboBox) + self.assertEqual(combo, label.buddy()) + for text in [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]: + self.assertTrue(combo.findText(text) >= 0) From b9ba2c68a6e901c422769527f19c3aea9cb29745 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 12 Apr 2014 22:19:22 +0200 Subject: [PATCH 44/45] Fix up PEP8 issues. --- openlp/core/common/__init__.py | 2 +- openlp/core/lib/__init__.py | 2 +- openlp/core/lib/mediamanageritem.py | 16 +++---- openlp/core/lib/plugin.py | 22 +++++----- openlp/core/lib/pluginmanager.py | 2 +- openlp/core/lib/serviceitem.py | 2 +- openlp/core/ui/exceptiondialog.py | 18 ++++---- openlp/core/ui/firsttimewizard.py | 6 +-- openlp/core/ui/formattingtagform.py | 2 - openlp/core/ui/mainwindow.py | 12 ++--- openlp/core/ui/media/__init__.py | 2 +- openlp/core/ui/media/mediacontroller.py | 6 +-- openlp/core/ui/media/webkitplayer.py | 44 +++++-------------- openlp/core/ui/servicemanager.py | 9 ++-- openlp/core/ui/settingsform.py | 2 +- openlp/core/ui/themelayoutdialog.py | 1 - openlp/core/ui/themestab.py | 20 +++++---- openlp/core/utils/__init__.py | 2 +- openlp/plugins/alerts/alertsplugin.py | 4 +- openlp/plugins/bibles/bibleplugin.py | 23 ++++++---- openlp/plugins/bibles/lib/db.py | 12 ++--- openlp/plugins/bibles/lib/http.py | 8 ++-- openlp/plugins/bibles/lib/mediaitem.py | 11 +++-- .../plugins/bibles/lib/versereferencelist.py | 2 +- openlp/plugins/custom/customplugin.py | 6 +-- .../custom/forms/editcustomslideform.py | 1 - openlp/plugins/custom/lib/customxmlhandler.py | 2 +- openlp/plugins/images/imageplugin.py | 4 +- openlp/plugins/media/lib/mediaitem.py | 3 +- openlp/plugins/media/mediaplugin.py | 4 +- .../presentations/lib/impresscontroller.py | 2 - .../presentations/lib/pdfcontroller.py | 6 +-- .../presentations/lib/powerpointcontroller.py | 2 +- .../presentations/lib/presentationtab.py | 4 +- .../presentations/presentationplugin.py | 4 +- openlp/plugins/remotes/remoteplugin.py | 4 +- .../songs/forms/duplicatesongremovalform.py | 6 +-- openlp/plugins/songs/forms/editsongform.py | 3 +- openlp/plugins/songs/forms/editverseform.py | 2 +- .../plugins/songs/forms/mediafilesdialog.py | 8 ++-- openlp/plugins/songs/forms/songexportform.py | 6 +-- openlp/plugins/songs/lib/cclifileimport.py | 12 ++--- openlp/plugins/songs/lib/ewimport.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 4 +- openlp/plugins/songs/songsplugin.py | 6 +-- openlp/plugins/songusage/songusageplugin.py | 4 +- .../openlp_core_lib/test_pluginmanager.py | 12 ++--- 47 files changed, 161 insertions(+), 176 deletions(-) diff --git a/openlp/core/common/__init__.py b/openlp/core/common/__init__.py index 9a0648909..22207dec4 100644 --- a/openlp/core/common/__init__.py +++ b/openlp/core/common/__init__.py @@ -38,7 +38,7 @@ import traceback from PyQt4 import QtCore -log = logging.getLogger(__name__+'.__init__') +log = logging.getLogger(__name__ + '.__init__') FIRST_CAMEL_REGEX = re.compile('(.)([A-Z][a-z]+)') diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index e6b7f4fe3..9561baff4 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -39,7 +39,7 @@ from PyQt4 import QtCore, QtGui, Qt from openlp.core.common import translate -log = logging.getLogger(__name__+'.__init__') +log = logging.getLogger(__name__ + '.__init__') class ServiceItemContext(object): diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 13d4b0bbb..4d7676ad6 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -168,29 +168,29 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): Create buttons for the media item toolbar """ toolbar_actions = [] - ## Import Button ## + # Import Button if self.has_import_icon: toolbar_actions.append(['Import', StringContent.Import, ':/general/general_import.png', self.on_import_click]) - ## Load Button ## + # Load Button if self.has_file_icon: toolbar_actions.append(['Load', StringContent.Load, ':/general/general_open.png', self.on_file_click]) - ## New Button ## + # New Button if self.has_new_icon: toolbar_actions.append(['New', StringContent.New, ':/general/general_new.png', self.on_new_click]) - ## Edit Button ## + # Edit Button if self.has_edit_icon: toolbar_actions.append(['Edit', StringContent.Edit, ':/general/general_edit.png', self.on_edit_click]) - ## Delete Button ## + # Delete Button if self.has_delete_icon: toolbar_actions.append(['Delete', StringContent.Delete, ':/general/general_delete.png', self.on_delete_click]) - ## Preview ## + # Preview toolbar_actions.append(['Preview', StringContent.Preview, ':/general/general_preview.png', self.on_preview_click]) - ## Live Button ## + # Live Button toolbar_actions.append(['Live', StringContent.Live, ':/general/general_live.png', self.on_live_click]) - ## Add to service Button ## + # Add to service Button toolbar_actions.append(['Service', StringContent.Service, ':/general/general_add.png', self.on_add_click]) for action in toolbar_actions: if action[0] == StringContent.Preview: diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index e14fe8bb0..1f459524c 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -101,7 +101,7 @@ class Plugin(QtCore.QObject, RegistryProperties): ``add_import_menu_item(import_menu)`` Add an item to the Import menu. - ``add_export_menu_Item(export_menu)`` + ``add_export_menu_item(export_menu)`` Add an item to the Export menu. ``create_settings_tab()`` @@ -226,7 +226,7 @@ class Plugin(QtCore.QObject, RegistryProperties): """ pass - def add_export_menu_Item(self, export_menu): + def add_export_menu_item(self, export_menu): """ Create a menu item and add it to the "Export" menu. @@ -329,22 +329,24 @@ class Plugin(QtCore.QObject, RegistryProperties): def set_plugin_ui_text_strings(self, tooltips): """ Called to define all translatable texts of the plugin + + :param tooltips: """ - ## Load Action ## + # Load Action self.__set_name_text_string(StringContent.Load, UiStrings().Load, tooltips['load']) - ## Import Action ## + # Import Action self.__set_name_text_string(StringContent.Import, UiStrings().Import, tooltips['import']) - ## New Action ## + # New Action self.__set_name_text_string(StringContent.New, UiStrings().Add, tooltips['new']) - ## Edit Action ## + # Edit Action self.__set_name_text_string(StringContent.Edit, UiStrings().Edit, tooltips['edit']) - ## Delete Action ## + # Delete Action self.__set_name_text_string(StringContent.Delete, UiStrings().Delete, tooltips['delete']) - ## Preview Action ## + # Preview Action self.__set_name_text_string(StringContent.Preview, UiStrings().Preview, tooltips['preview']) - ## Send Live Action ## + # Send Live Action self.__set_name_text_string(StringContent.Live, UiStrings().Live, tooltips['live']) - ## Add to Service Action ## + # Add to Service Action self.__set_name_text_string(StringContent.Service, UiStrings().Service, tooltips['service']) def __set_name_text_string(self, name, title, tooltip): diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index d24f07eac..474113c98 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -161,7 +161,7 @@ class PluginManager(RegistryMixin, OpenLPMixin, RegistryProperties): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.add_export_menu_Item(self.main_window.file_export_menu) + plugin.add_export_menu_item(self.main_window.file_export_menu) def hook_tools_menu(self): """ diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 6d07e1c34..bb59938d4 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -383,7 +383,7 @@ class ServiceItem(RegistryProperties): self.will_auto_start = header.get('will_auto_start', False) self.processor = header.get('processor', None) self.has_original_files = True - #TODO Remove me in 2,3 build phase + # TODO: Remove me in 2,3 build phase if self.is_capable(ItemCapabilities.HasDetailedTitleDisplay): self.capabilities.remove(ItemCapabilities.HasDetailedTitleDisplay) self.processor = self.title diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 4d7abe708..212fee4cd 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -95,15 +95,15 @@ class Ui_ExceptionDialog(object): Translate the widgets on the fly. """ exception_dialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred')) - self.description_explanation.setText(translate('OpenLP.ExceptionDialog', - 'Please enter a description of what you were doing to cause this error ' - '\n(Minimum 20 characters)')) - self.message_label.setText(translate('OpenLP.ExceptionDialog', 'Oops! ' - 'OpenLP hit a problem, and couldn\'t recover. The text in the box ' - 'below contains information that might be helpful to the OpenLP ' - 'developers, so please e-mail it to bugs@openlp.org, along with a ' - 'detailed description of what you were doing when the problem ' - 'occurred.')) + self.description_explanation.setText( + translate('OpenLP.ExceptionDialog', 'Please enter a description of what you were doing to cause this error ' + '\n(Minimum 20 characters)')) + self.message_label.setText( + translate('OpenLP.ExceptionDialog', 'Oops! OpenLP hit a problem, and couldn\'t recover. The text in the ' + 'box below contains information that might be helpful to the OpenLP ' + 'developers, so please e-mail it to bugs@openlp.org, along with a ' + 'detailed description of what you were doing when the problem ' + 'occurred.')) self.send_report_button.setText(translate('OpenLP.ExceptionDialog', 'Send E-Mail')) self.save_report_button.setText(translate('OpenLP.ExceptionDialog', 'Save to File')) self.attach_tile_button.setText(translate('OpenLP.ExceptionDialog', 'Attach File')) diff --git a/openlp/core/ui/firsttimewizard.py b/openlp/core/ui/firsttimewizard.py index 407842c48..1a270f931 100644 --- a/openlp/core/ui/firsttimewizard.py +++ b/openlp/core/ui/firsttimewizard.py @@ -211,9 +211,9 @@ class Ui_FirstTimeWizard(object): first_time_wizard.setWindowTitle(translate('OpenLP.FirstTimeWizard', 'First Time Wizard')) self.title_label.setText('%s' % translate('OpenLP.FirstTimeWizard', 'Welcome to the First Time Wizard')) - self.information_label.setText(translate('OpenLP.FirstTimeWizard', - 'This wizard will help you to configure OpenLP for initial use. ' - 'Click the next button below to start.')) + self.information_label.setText( + translate('OpenLP.FirstTimeWizard', 'This wizard will help you to configure OpenLP for initial use. ' + 'Click the next button below to start.')) self.plugin_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Activate required Plugins')) self.plugin_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select the Plugins you wish to use. ')) self.songs_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Songs')) diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index b7153429d..be4247bc1 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -63,7 +63,6 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagCont self.services = FormattingTagController() self.tag_table_widget.itemSelectionChanged.connect(self.on_row_selected) self.new_button.clicked.connect(self.on_new_clicked) - #self.save_button.clicked.connect(self.on_saved_clicked) self.delete_button.clicked.connect(self.on_delete_clicked) self.tag_table_widget.currentCellChanged.connect(self.on_current_cell_changed) self.button_box.rejected.connect(self.close) @@ -202,5 +201,4 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagCont if errors: QtGui.QMessageBox.warning(self, translate('OpenLP.FormattingTagForm', 'Validation Error'), errors, QtGui.QMessageBox.Ok) - #self.tag_table_widget.selectRow(pre_row - 1) self.tag_table_widget.resizeRowsToContents() diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index c61526586..81e822c16 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -394,12 +394,12 @@ class Ui_MainWindow(object): self.settings_shortcuts_item.setText(translate('OpenLP.MainWindow', 'Configure &Shortcuts...')) self.formatting_tag_item.setText(translate('OpenLP.MainWindow', 'Configure &Formatting Tags...')) self.settings_configure_item.setText(translate('OpenLP.MainWindow', '&Configure OpenLP...')) - self.settings_export_item.setStatusTip(translate('OpenLP.MainWindow', - 'Export OpenLP settings to a specified *.config file')) + self.settings_export_item.setStatusTip( + translate('OpenLP.MainWindow', 'Export OpenLP settings to a specified *.config file')) self.settings_export_item.setText(translate('OpenLP.MainWindow', 'Settings')) - self.settings_import_item.setStatusTip(translate('OpenLP.MainWindow', - 'Import OpenLP settings from a specified *.config file previously ' - 'exported on this or another machine')) + self.settings_import_item.setStatusTip( + translate('OpenLP.MainWindow', 'Import OpenLP settings from a specified *.config file previously ' + 'exported on this or another machine')) self.settings_import_item.setText(translate('OpenLP.MainWindow', 'Settings')) self.view_media_manager_item.setText(translate('OpenLP.MainWindow', '&Media Manager')) self.view_media_manager_item.setToolTip(translate('OpenLP.MainWindow', 'Toggle Media Manager')) @@ -860,7 +860,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): section = 'general' section_key = section + "/" + key # Make sure it's a valid section for us. - if not section in setting_sections: + if section not in setting_sections: continue # We have a good file, import it. for section_key in import_keys: diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index 1276c8662..8cc10b6a1 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -35,7 +35,7 @@ from openlp.core.common import Settings from PyQt4 import QtCore -log = logging.getLogger(__name__+'.__init__') +log = logging.getLogger(__name__ + '.__init__') class MediaState(object): diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index d846af0e4..0b065c131 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -137,7 +137,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties): for player in list(self.media_players.values()): if player.is_active: for item in player.audio_extensions_list: - if not item in self.audio_extensions_list: + if item not in self.audio_extensions_list: self.audio_extensions_list.append(item) suffix_list.append(item[2:]) self.video_extensions_list = [] @@ -184,8 +184,8 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties): return False saved_players, overridden_player = get_media_players() invalid_media_players = \ - [mediaPlayer for mediaPlayer in saved_players if not mediaPlayer in self.media_players or - not self.media_players[mediaPlayer].check_available()] + [media_player for media_player in saved_players if media_player not in self.media_players or + not self.media_players[media_player].check_available()] if invalid_media_players: for invalidPlayer in invalid_media_players: saved_players.remove(invalidPlayer) diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index e3a522140..38e691494 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -174,34 +174,11 @@ FLASH_HTML = """ """ -VIDEO_EXT = [ - '*.3gp', - '*.3gpp', - '*.3g2', - '*.3gpp2', - '*.aac', - '*.flv', - '*.f4a', - '*.f4b', - '*.f4p', - '*.f4v', - '*.mov', - '*.m4a', - '*.m4b', - '*.m4p', - '*.m4v', - '*.mkv', - '*.mp4', - '*.ogv', - '*.webm', - '*.mpg', '*.wmv', '*.mpeg', '*.avi', - '*.swf' -] +VIDEO_EXT = ['*.3gp', '*.3gpp', '*.3g2', '*.3gpp2', '*.aac', '*.flv', '*.f4a', '*.f4b', '*.f4p', '*.f4v', '*.mov', + '*.m4a', '*.m4b', '*.m4p', '*.m4v', '*.mkv', '*.mp4', '*.ogv', '*.webm', '*.mpg', '*.wmv', '*.mpeg', + '*.avi', '*.swf'] -AUDIO_EXT = [ - '*.mp3', - '*.ogg' -] +AUDIO_EXT = ['*.mp3', '*.ogg'] class WebkitPlayer(MediaPlayer): @@ -411,10 +388,9 @@ class WebkitPlayer(MediaPlayer): """ Return some information about this player """ - return(translate('Media.player', 'Webkit is a media player which runs ' - 'inside a web browser. This player allows text over video to be ' - 'rendered.') + - '
' + translate('Media.player', 'Audio') + - '
' + str(AUDIO_EXT) + '
' + - translate('Media.player', 'Video') + '
' + - str(VIDEO_EXT) + '
') + part1 = translate('Media.player', 'Webkit is a media player which runs inside a web browser. This player ' + 'allows text over video to be rendered.') + part2 = translate('Media.player', 'Audio') + part3 = translate('Media.player', 'Video') + return part1 + '
' + part2 + '
' + str(AUDIO_EXT) + '
' + part3 + \ + '
' + str(VIDEO_EXT) + '
' diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index c2b36551a..4d2ff2ee9 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -399,7 +399,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage :param suffix_list: New Suffix's to be supported """ for suffix in suffix_list: - if not suffix in self.suffixes: + if suffix not in self.suffixes: self.suffixes.append(suffix) def on_new_service_clicked(self, field=None): @@ -629,7 +629,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage for item in self.service_items: self.main_window.increment_progress_bar() service_item = item['service_item'].get_service_repr(self._save_lite) - #TODO: check for file item on save. + # TODO: check for file item on save. service.append({'serviceitem': service_item}) self.main_window.increment_progress_bar() service_content = json.dumps(service) @@ -754,8 +754,9 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage items = json.load(file_to) else: critical_error_message_box(message=translate('OpenLP.ServiceManager', - 'The service file you are trying to open is in an old format.\n ' - 'Please save it using OpenLP 2.0.2 or greater.')) + 'The service file you are trying to open is in an old ' + 'format.\n Please save it using OpenLP 2.0.2 or ' + 'greater.')) return file_to.close() self.new_file() diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 5aba66ef2..a1077e1f4 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -150,5 +150,5 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties): :param function: The function to be called """ - if not function in self.processes: + if function not in self.processes: self.processes.append(function) diff --git a/openlp/core/ui/themelayoutdialog.py b/openlp/core/ui/themelayoutdialog.py index bf6c1069a..023d6259c 100644 --- a/openlp/core/ui/themelayoutdialog.py +++ b/openlp/core/ui/themelayoutdialog.py @@ -44,7 +44,6 @@ class Ui_ThemeLayoutDialog(object): Set up the UI """ themeLayoutDialog.setObjectName('themeLayoutDialogDialog') - #themeLayoutDialog.resize(300, 200) self.preview_layout = QtGui.QVBoxLayout(themeLayoutDialog) self.preview_layout.setObjectName('preview_layout') self.preview_area = QtGui.QWidget(themeLayoutDialog) diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 32ed30303..1f54f984b 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -114,17 +114,19 @@ class ThemesTab(SettingsTab): self.global_group_box.setTitle(translate('OpenLP.ThemesTab', 'Global Theme')) self.level_group_box.setTitle(translate('OpenLP.ThemesTab', 'Theme Level')) self.song_level_radio_button.setText(translate('OpenLP.ThemesTab', 'S&ong Level')) - self.song_level_label.setText(translate('OpenLP.ThemesTab', 'Use the theme from each song ' - 'in the database. If a song doesn\'t have a theme associated with ' - 'it, then use the service\'s theme. If the service doesn\'t have ' - 'a theme, then use the global theme.')) + self.song_level_label.setText( + translate('OpenLP.ThemesTab', 'Use the theme from each song in the database. If a song doesn\'t have a ' + 'theme associated with it, then use the service\'s theme. If the service ' + 'doesn\'t have a theme, then use the global theme.')) self.service_level_radio_button.setText(translate('OpenLP.ThemesTab', '&Service Level')) - self.service_level_label.setText(translate('OpenLP.ThemesTab', 'Use the theme from the service, ' - 'overriding any of the individual songs\' themes. If the ' - 'service doesn\'t have a theme, then use the global theme.')) + self.service_level_label.setText( + translate('OpenLP.ThemesTab', 'Use the theme from the service, overriding any of the individual ' + 'songs\' themes. If the service doesn\'t have a theme, then use the global ' + 'theme.')) self.global_level_radio_button.setText(translate('OpenLP.ThemesTab', '&Global Level')) - self.global_level_label.setText(translate('OpenLP.ThemesTab', 'Use the global theme, overriding ' - 'any themes associated with either the service or the songs.')) + self.global_level_label.setText(translate('OpenLP.ThemesTab', 'Use the global theme, overriding any themes ' + 'associated with either the service or the ' + 'songs.')) def load(self): """ diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 746c50d71..a5b5f356a 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -56,7 +56,7 @@ if sys.platform != 'win32' and sys.platform != 'darwin': from openlp.core.common import translate -log = logging.getLogger(__name__+'.__init__') +log = logging.getLogger(__name__ + '.__init__') APPLICATION_VERSION = {} IMAGES_FILTER = None diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index cf3b7d0ce..76efadf32 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -207,12 +207,12 @@ class AlertsPlugin(Plugin): """ Called to define all translatable texts of the plugin """ - ## Name PluginList ## + # Name PluginList self.text_strings[StringContent.Name] = { 'singular': translate('AlertsPlugin', 'Alert', 'name singular'), 'plural': translate('AlertsPlugin', 'Alerts', 'name plural') } - ## Name for MediaDockManager, SettingsManager ## + # Name for MediaDockManager, SettingsManager self.text_strings[StringContent.VisibleName] = { 'title': translate('AlertsPlugin', 'Alerts', 'container title') } diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 5a51be163..e7f1fdd56 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -88,8 +88,6 @@ class BiblePlugin(Plugin): self.import_bible_item.setVisible(True) action_list = ActionList.get_instance() action_list.add_action(self.import_bible_item, UiStrings().Import) - # Do not add the action to the list yet. - #action_list.add_action(self.export_bible_item, UiStrings().Export) # Set to invisible until we can export bibles self.export_bible_item.setVisible(False) self.tools_upgrade_item.setVisible(bool(self.manager.old_bible_databases)) @@ -104,7 +102,6 @@ class BiblePlugin(Plugin): action_list = ActionList.get_instance() action_list.remove_action(self.import_bible_item, UiStrings().Import) self.import_bible_item.setVisible(False) - #action_list.remove_action(self.export_bible_item, UiStrings().Export) self.export_bible_item.setVisible(False) def app_startup(self): @@ -115,19 +112,27 @@ class BiblePlugin(Plugin): if self.manager.old_bible_databases: if QtGui.QMessageBox.information( self.main_window, translate('OpenLP', 'Information'), - translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your existing Bibles.\n' - 'Should OpenLP upgrade now?'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == \ + translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your ' + 'existing Bibles.\nShould OpenLP upgrade now?'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == \ QtGui.QMessageBox.Yes: self.on_tools_upgrade_Item_triggered() def add_import_menu_item(self, import_menu): + """ + + :param import_menu: + """ self.import_bible_item = create_action(import_menu, 'importBibleItem', text=translate('BiblesPlugin', '&Bible'), visible=False, triggers=self.on_bible_import_click) import_menu.addAction(self.import_bible_item) - def add_export_menu_Item(self, export_menu): + def add_export_menu_item(self, export_menu): + """ + + :param export_menu: + """ self.export_bible_item = create_action(export_menu, 'exportBibleItem', text=translate('BiblesPlugin', '&Bible'), visible=False) export_menu.addAction(self.export_bible_item) @@ -190,12 +195,12 @@ class BiblePlugin(Plugin): """ Called to define all translatable texts of the plugin """ - ## Name PluginList ## + # Name PluginList self.text_strings[StringContent.Name] = { 'singular': translate('BiblesPlugin', 'Bible', 'name singular'), 'plural': translate('BiblesPlugin', 'Bibles', 'name plural') } - ## Name for MediaDockManager, SettingsManager ## + # Name for MediaDockManager, SettingsManager self.text_strings[StringContent.VisibleName] = { 'title': translate('BiblesPlugin', 'Bibles', 'container title') } diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 8011c97c1..c94f6ec8c 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -649,10 +649,10 @@ class BiblesResourcesDB(QtCore.QObject, Manager): 'chapter, verse_count FROM chapters WHERE book_reference_id = ?', (book_ref_id,)) try: return { - 'id': chapters[chapter-1][0], - 'book_reference_id': chapters[chapter-1][1], - 'chapter': chapters[chapter-1][2], - 'verse_count': chapters[chapter-1][3] + 'id': chapters[chapter - 1][0], + 'book_reference_id': chapters[chapter - 1][1], + 'chapter': chapters[chapter - 1][2], + 'verse_count': chapters[chapter - 1][3] } except (IndexError, TypeError): return None @@ -846,13 +846,13 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): file_path = os.path.join( AppLocation.get_directory(AppLocation.DataDir), 'bibles', 'alternative_book_names.sqlite') if not os.path.exists(file_path): - #create new DB, create table alternative_book_names + # create new DB, create table alternative_book_names AlternativeBookNamesDB.conn = sqlite3.connect(file_path) AlternativeBookNamesDB.conn.execute( 'CREATE TABLE alternative_book_names(id INTEGER NOT NULL, ' 'book_reference_id INTEGER, language_id INTEGER, name VARCHAR(50), PRIMARY KEY (id))') else: - #use existing DB + # use existing DB AlternativeBookNamesDB.conn = sqlite3.connect(file_path) AlternativeBookNamesDB.cursor = AlternativeBookNamesDB.conn.cursor() return AlternativeBookNamesDB.cursor diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 340d8ef92..b15e11738 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -552,10 +552,10 @@ class HTTPBible(BibleDB, RegistryProperties): self.application.set_busy_cursor() search_results = self.get_chapter(book, reference[1]) if search_results and search_results.has_verse_list(): - ## We have found a book of the bible lets check to see - ## if it was there. By reusing the returned book name - ## we get a correct book. For example it is possible - ## to request ac and get Acts back. + # We have found a book of the bible lets check to see + # if it was there. By reusing the returned book name + # we get a correct book. For example it is possible + # to request ac and get Acts back. book_name = search_results.book self.application.process_events() # Check to see if book/chapter exists. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 10fef8e31..3b3a0b048 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -480,6 +480,10 @@ class BibleMediaItem(MediaManagerItem): self.reload_bibles() def on_delete_click(self): + """ + When the delete button is pressed + """ + bible = None if self.quickTab.isVisible(): bible = self.quickVersionComboBox.currentText() elif self.advancedTab.isVisible(): @@ -488,8 +492,9 @@ class BibleMediaItem(MediaManagerItem): if QtGui.QMessageBox.question( self, UiStrings().ConfirmDelete, translate('BiblesPlugin.MediaItem', 'Are you sure you want to completely delete "%s" Bible from ' - 'OpenLP?\n\nYou will need to re-import this Bible to use it again.') % bible, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), + 'OpenLP?\n\nYou will need to re-import this Bible to use it ' + 'again.') % bible, + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: return self.plugin.manager.delete_bible(bible) @@ -752,7 +757,7 @@ class BibleMediaItem(MediaManagerItem): log.exception('The second_search_results does not have as many verses as the search_results.') break bible_text = '%s %d%s%d (%s, %s)' % (book, verse.chapter, verse_separator, verse.verse, version, - second_version) + second_version) else: bible_text = '%s %d%s%d (%s)' % (book, verse.chapter, verse_separator, verse.verse, version) bible_verse = QtGui.QListWidgetItem(bible_text) diff --git a/openlp/plugins/bibles/lib/versereferencelist.py b/openlp/plugins/bibles/lib/versereferencelist.py index 1d3877d1d..7cbba68fb 100644 --- a/openlp/plugins/bibles/lib/versereferencelist.py +++ b/openlp/plugins/bibles/lib/versereferencelist.py @@ -94,5 +94,5 @@ class VerseReferenceList(object): result = result + ', ' + version['permission'] result = result.rstrip() if result.endswith(','): - return result[:len(result)-1] + return result[:len(result) - 1] return result diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index eb7de530a..2065717cb 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -43,7 +43,7 @@ log = logging.getLogger(__name__) __default_settings__ = { 'custom/db type': 'sqlite', - 'custom/last search type': CustomSearch.Titles, + 'custom/last search type': CustomSearch.Titles, 'custom/display footer': True, 'custom/add custom from service': True } @@ -97,12 +97,12 @@ class CustomPlugin(Plugin): """ Called to define all translatable texts of the plugin """ - ## Name PluginList ## + # Name PluginList self.text_strings[StringContent.Name] = { 'singular': translate('CustomPlugin', 'Custom Slide', 'name singular'), 'plural': translate('CustomPlugin', 'Custom Slides', 'name plural') } - ## Name for MediaDockManager, SettingsManager ## + # Name for MediaDockManager, SettingsManager self.text_strings[StringContent.VisibleName] = { 'title': translate('CustomPlugin', 'Custom Slides', 'container title') } diff --git a/openlp/plugins/custom/forms/editcustomslideform.py b/openlp/plugins/custom/forms/editcustomslideform.py index afce4887b..e6834dafb 100644 --- a/openlp/plugins/custom/forms/editcustomslideform.py +++ b/openlp/plugins/custom/forms/editcustomslideform.py @@ -1,4 +1,3 @@ -#lint:disable # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 diff --git a/openlp/plugins/custom/lib/customxmlhandler.py b/openlp/plugins/custom/lib/customxmlhandler.py index ca42a705b..3e1880055 100644 --- a/openlp/plugins/custom/lib/customxmlhandler.py +++ b/openlp/plugins/custom/lib/customxmlhandler.py @@ -51,7 +51,7 @@ from lxml import etree, objectify log = logging.getLogger(__name__) -#TODO: These classes need to be refactored into a single class. +# TODO: These classes need to be refactored into a single class. class CustomXMLBuilder(object): """ This class builds the XML used to describe songs. diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 693449530..08c31f53c 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -95,12 +95,12 @@ class ImagePlugin(Plugin): """ Called to define all translatable texts of the plugin. """ - ## Name PluginList ## + # Name PluginList self.text_strings[StringContent.Name] = { 'singular': translate('ImagePlugin', 'Image', 'name singular'), 'plural': translate('ImagePlugin', 'Images', 'name plural') } - ## Name for MediaDockManager, SettingsManager ## + # Name for MediaDockManager, SettingsManager self.text_strings[StringContent.VisibleName] = {'title': translate('ImagePlugin', 'Images', 'container title')} # Middle Header Bar tooltips = { diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 56d3a49f4..a54b37deb 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -95,7 +95,6 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): self.reset_action.setToolTip(UiStrings().ResetLiveBG) self.automatic = UiStrings().Automatic self.display_type_label.setText(translate('MediaPlugin.MediaItem', 'Use Player:')) - #self.rebuild_players() def required_icons(self): """ @@ -141,7 +140,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): if index == 0: set_media_players(player) else: - set_media_players(player, player[index-1]) + set_media_players(player, player[index - 1]) def on_reset_click(self): """ diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 6cf241d1d..d0e082f53 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -73,12 +73,12 @@ class MediaPlugin(Plugin): """ Called to define all translatable texts of the plugin """ - ## Name PluginList ## + # Name PluginList self.text_strings[StringContent.Name] = { 'singular': translate('MediaPlugin', 'Media', 'name singular'), 'plural': translate('MediaPlugin', 'Media', 'name plural') } - ## Name for MediaDockManager, SettingsManager ## + # Name for MediaDockManager, SettingsManager self.text_strings[StringContent.VisibleName] = { 'title': translate('MediaPlugin', 'Media', 'container title') } diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index c55873c5f..584c1401f 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -377,8 +377,6 @@ class ImpressDocument(PresentationDocument): Stop the presentation, remove from screen. """ log.debug('stop presentation OpenOffice') - # deactivate should hide the screen according to docs, but doesn't - #self.control.deactivate() self.presentation.end() self.control = None diff --git a/openlp/plugins/presentations/lib/pdfcontroller.py b/openlp/plugins/presentations/lib/pdfcontroller.py index 597b7d78b..1365e59a9 100644 --- a/openlp/plugins/presentations/lib/pdfcontroller.py +++ b/openlp/plugins/presentations/lib/pdfcontroller.py @@ -74,7 +74,7 @@ class PdfController(PresentationController): runlog = '' log.debug('testing program_path: %s', program_path) try: - runlog = check_output([program_path, '--help'], stderr=STDOUT) + runlog = check_output([program_path, '--help'], stderr=STDOUT) except CalledProcessError as e: runlog = e.output except Exception: @@ -183,7 +183,7 @@ class PdfDocument(PresentationDocument): self.image_files = [] self.num_pages = -1 - def gs_get_resolution(self, size): + def gs_get_resolution(self, size): """ Only used when using ghostscript Ghostscript can't scale automatically while keeping aspect like mupdf, so we need @@ -236,7 +236,7 @@ class PdfDocument(PresentationDocument): if os.path.isfile(os.path.join(self.get_temp_folder(), 'mainslide001.png')): created_files = sorted(os.listdir(self.get_temp_folder())) for fn in created_files: - if os.path.isfile(os.path.join(self.get_temp_folder(), fn)): + if os.path.isfile(os.path.join(self.get_temp_folder(), fn)): self.image_files.append(os.path.join(self.get_temp_folder(), fn)) self.num_pages = len(self.image_files) return True diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index d6447adce..09fdf2fcc 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -247,7 +247,7 @@ class PowerpointDocument(PresentationDocument): Starts a presentation from the beginning. """ log.debug('start_presentation') - #SlideShowWindow measures its size/position by points, not pixels + # SlideShowWindow measures its size/position by points, not pixels try: dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88) except win32ui.error: diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 7d5c81366..590289014 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -175,10 +175,10 @@ class PresentationTab(SettingsTab): if pdf_program == '': enable_pdf_program = 0 if pdf_program != Settings().value(self.settings_section + '/pdf_program'): - Settings().setValue(self.settings_section + '/pdf_program', pdf_program) + Settings().setValue(self.settings_section + '/pdf_program', pdf_program) changed = True if enable_pdf_program != Settings().value(self.settings_section + '/enable_pdf_program'): - Settings().setValue(self.settings_section + '/enable_pdf_program', enable_pdf_program) + Settings().setValue(self.settings_section + '/enable_pdf_program', enable_pdf_program) changed = True if changed: self.settings_form.register_post_process('mediaitem_suffix_reset') diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index de0a0c5a5..5e0d7395d 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -156,12 +156,12 @@ class PresentationPlugin(Plugin): """ Called to define all translatable texts of the plugin. """ - ## Name PluginList ## + # Name PluginList self.text_strings[StringContent.Name] = { 'singular': translate('PresentationPlugin', 'Presentation', 'name singular'), 'plural': translate('PresentationPlugin', 'Presentations', 'name plural') } - ## Name for MediaDockManager, SettingsManager ## + # Name for MediaDockManager, SettingsManager self.text_strings[StringContent.VisibleName] = { 'title': translate('PresentationPlugin', 'Presentations', 'container title') } diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 393f08dd9..d3dc6e58a 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -92,12 +92,12 @@ class RemotesPlugin(Plugin): """ Called to define all translatable texts of the plugin """ - ## Name PluginList ## + # Name PluginList self.text_strings[StringContent.Name] = { 'singular': translate('RemotePlugin', 'Remote', 'name singular'), 'plural': translate('RemotePlugin', 'Remotes', 'name plural') } - ## Name for MediaDockManager, SettingsManager ## + # Name for MediaDockManager, SettingsManager self.text_strings[StringContent.VisibleName] = { 'title': translate('RemotePlugin', 'Remote', 'container title') } diff --git a/openlp/plugins/songs/forms/duplicatesongremovalform.py b/openlp/plugins/songs/forms/duplicatesongremovalform.py index 22299cde5..d85197223 100644 --- a/openlp/plugins/songs/forms/duplicatesongremovalform.py +++ b/openlp/plugins/songs/forms/duplicatesongremovalform.py @@ -114,7 +114,7 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): self.review_layout.addWidget(self.review_scroll_area) self.review_page_id = self.addPage(self.review_page) # Add a dummy page to the end, to prevent the finish button to appear and the next button do disappear on the - #review page. + # review page. self.dummy_page = QtGui.QWizardPage() self.dummy_page_id = self.addPage(self.dummy_page) @@ -217,12 +217,12 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): duplicate_added = False for duplicate_group in self.duplicate_song_list: # Skip the first song in the duplicate lists, since the first one has to be an earlier song. - if search_song in duplicate_group and not duplicate_song in duplicate_group: + if search_song in duplicate_group and duplicate_song not in duplicate_group: duplicate_group.append(duplicate_song) duplicate_group_found = True duplicate_added = True break - elif not search_song in duplicate_group and duplicate_song in duplicate_group: + elif search_song not in duplicate_group and duplicate_song in duplicate_group: duplicate_group.append(search_song) duplicate_group_found = True duplicate_added = True diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index b655c0f73..60c6eae78 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -675,14 +675,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): separator = parts.find(':') if separator >= 0: verse_name = parts[0:separator].strip() - verse_num = parts[separator+1:].strip() + verse_num = parts[separator + 1:].strip() else: verse_name = parts verse_num = '1' verse_index = VerseType.from_loose_input(verse_name) verse_tag = VerseType.tags[verse_index] # Later we need to handle v1a as well. - #regex = re.compile(r'(\d+\w.)') regex = re.compile(r'\D*(\d+)\D*') match = regex.match(verse_num) if match: diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 038cff539..79a69a015 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -75,7 +75,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): text = self.verse_text_edit.toPlainText() position = self.verse_text_edit.textCursor().position() insert_string = '[---]' - if position and text[position-1] != '\n': + if position and text[position - 1] != '\n': insert_string = '\n' + insert_string if position == len(text) or text[position] != '\n': insert_string += '\n' diff --git a/openlp/plugins/songs/forms/mediafilesdialog.py b/openlp/plugins/songs/forms/mediafilesdialog.py index a0392e3db..3a1db39ed 100644 --- a/openlp/plugins/songs/forms/mediafilesdialog.py +++ b/openlp/plugins/songs/forms/mediafilesdialog.py @@ -66,8 +66,10 @@ class Ui_MediaFilesDialog(object): def retranslateUi(self, media_files_dialog): """ Translate the UI on the fly. + + :param media_files_dialog: """ media_files_dialog.setWindowTitle(translate('SongsPlugin.MediaFilesForm', 'Select Media File(s)')) - self.select_label.setText(translate('SongsPlugin.MediaFilesForm', - 'Select one or more audio files from the list below, and click OK to import them ' - 'into this song.')) + self.select_label.setText(translate('SongsPlugin.MediaFilesForm', 'Select one or more audio files from the ' + 'list below, and click OK to import them ' + 'into this song.')) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 4e345b750..589da4d33 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -152,9 +152,9 @@ class SongExportForm(OpenLPWizard): self.setWindowTitle(translate('SongsPlugin.ExportWizardForm', 'Song Export Wizard')) self.title_label.setText(WizardStrings.HeaderStyle % translate('OpenLP.Ui', 'Welcome to the Song Export Wizard')) - self.information_label.setText(translate('SongsPlugin.ExportWizardForm', 'This wizard will help to' - ' export your songs to the open and free OpenLyrics worship ' - 'song format.')) + self.information_label.setText( + translate('SongsPlugin.ExportWizardForm', 'This wizard will help to export your songs to the open and free ' + 'OpenLyrics worship song format.')) self.available_songs_page.setTitle(translate('SongsPlugin.ExportWizardForm', 'Select Songs')) self.available_songs_page.setSubTitle(translate('SongsPlugin.ExportWizardForm', 'Check the songs you want to export.')) diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index 0866a1cc7..5c1fbdcb2 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -270,13 +270,13 @@ class CCLIFileImport(SongImport): verse_text = '' verse_start = False else: - #line_number=0, song title + # line_number=0, song title if line_number == 0: self.title = clean_line line_number += 1 - #line_number=1, verses + # line_number=1, verses elif line_number == 1: - #line_number=1, ccli number, first line after verses + # line_number=1, ccli number, first line after verses if clean_line.startswith('CCLI'): line_number += 1 ccli_parts = clean_line.split(' ') @@ -319,21 +319,21 @@ class CCLIFileImport(SongImport): # last part. Add l so as to keep the CRLF verse_text = verse_text + line else: - #line_number=2, copyright + # line_number=2, copyright if line_number == 2: line_number += 1 if clean_line.startswith('©'): self.copyright = clean_line else: song_author = clean_line - #n=3, authors + # n=3, authors elif line_number == 3: line_number += 1 if song_author: self.copyright = clean_line else: song_author = clean_line - #line_number=4, comments lines before last line + # line_number=4, comments lines before last line elif line_number == 4 and not clean_line.startswith('CCL'): self.comments += clean_line # split on known separators diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index cde0b1692..ca201279a 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -305,7 +305,7 @@ class EasyWorshipSongImport(SongImport): elif field_desc.field_type == FieldType.Logical: return field ^ 0x80 == 1 elif field_desc.field_type == FieldType.Memo or field_desc.field_type == FieldType.Blob: - block_start, blob_size = struct.unpack_from(' Date: Sat, 12 Apr 2014 22:22:31 +0200 Subject: [PATCH 45/45] Fix an import issue --- openlp/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/__init__.py b/openlp/__init__.py index bf7cbc680..98e847979 100644 --- a/openlp/__init__.py +++ b/openlp/__init__.py @@ -30,7 +30,6 @@ The :mod:`openlp` module contains all the project produced OpenLP functionality """ -import core -import plugins +from openlp import core, plugins __all__ = ['core', 'plugins']