openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #20659
[Merge] lp:~trb143/openlp/title into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/title into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~trb143/openlp/title/+merge/165730
Fix Presentation plugin so it works
Correct abuse of the service item title field
Add migration code and test to prove it.
--
https://code.launchpad.net/~trb143/openlp/title/+merge/165730
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/title into lp:openlp.
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py 2013-04-08 16:53:11 +0000
+++ openlp/core/lib/serviceitem.py 2013-05-25 05:56:28 +0000
@@ -58,8 +58,7 @@
Provides an enumeration of a service item's capabilities
``CanPreview``
- The capability to allow the ServiceManager to add to the preview
- tab when making the previous item live.
+ The capability to allow the ServiceManager to add to the preview tab when making the previous item live.
``CanEdit``
The capability to allow the ServiceManager to allow the item to be edited
@@ -71,8 +70,7 @@
Determines is the service_item needs a Media Player
``CanLoop``
- The capability to allow the SlideController to allow the loop
- processing.
+ The capability to allow the SlideController to allow the loop processing.
``CanAppend``
The capability to allow the ServiceManager to add leaves to the
@@ -82,22 +80,19 @@
The capability to remove lines breaks in the renderer
``OnLoadUpdate``
- The capability to update MediaManager when a service Item is
- loaded.
+ The capability to update MediaManager when a service Item is loaded.
``AddIfNewItem``
Not Used
``ProvidesOwnDisplay``
- The capability to tell the SlideController the service Item has a
- different display.
+ The capability to tell the SlideController the service Item has a different display.
``HasDetailedTitleDisplay``
- ServiceItem provides a title
+ Being Removed and decommissioned.
``HasVariableStartTime``
- The capability to tell the ServiceManager that a change to start
- time is possible.
+ The capability to tell the ServiceManager that a change to start time is possible.
``CanSoftBreak``
The capability to tell the renderer that Soft Break is allowed
@@ -149,7 +144,7 @@
if plugin:
self.name = plugin.name
self.title = u''
- self.shortname = u''
+ self.processor = None
self.audit = u''
self.items = []
self.iconic_representation = None
@@ -353,7 +348,8 @@
u'media_length': self.media_length,
u'background_audio': self.background_audio,
u'theme_overwritten': self.theme_overwritten,
- u'will_auto_start': self.will_auto_start
+ u'will_auto_start': self.will_auto_start,
+ u'processor': self.processor
}
service_data = []
if self.service_item_type == ServiceItemType.Text:
@@ -387,7 +383,6 @@
self.title = header[u'title']
self.name = header[u'name']
self.service_item_type = header[u'type']
- self.shortname = header[u'plugin']
self.theme = header[u'theme']
self.add_icon(header[u'icon'])
self.raw_footer = header[u'footer']
@@ -406,7 +401,13 @@
self.auto_play_slides_loop = header.get(u'auto_play_slides_loop', False)
self.timed_slide_interval = header.get(u'timed_slide_interval', 0)
self.will_auto_start = header.get(u'will_auto_start', False)
+ self.processor = header.get(u'processor', None)
self.has_original_files = True
+ #TODO Remove me in 2,3 build phase
+ if self.is_capable(ItemCapabilities.HasDetailedTitleDisplay):
+ self.capabilities.remove(ItemCapabilities.HasDetailedTitleDisplay)
+ self.processor = self.title
+ self.title = None
if u'background_audio' in header:
self.background_audio = []
for filename in header[u'background_audio']:
@@ -429,6 +430,8 @@
self.add_from_image(text_image[u'path'], text_image[u'title'], background)
elif self.service_item_type == ServiceItemType.Command:
for text_image in serviceitem[u'serviceitem'][u'data']:
+ if not self.title:
+ self.title = text_image[u'title']
if path:
self.has_original_files = False
self.add_from_command(path, text_image[u'title'], text_image[u'image'])
@@ -443,9 +446,7 @@
if self.is_text():
return self.title
else:
- if ItemCapabilities.HasDetailedTitleDisplay in self.capabilities:
- return self._raw_frames[0][u'title']
- elif len(self._raw_frames) > 1:
+ if len(self._raw_frames) > 1:
return self.title
else:
return self._raw_frames[0][u'title']
=== modified file 'openlp/core/ui/media/mediacontroller.py'
--- openlp/core/ui/media/mediacontroller.py 2013-03-26 11:35:29 +0000
+++ openlp/core/ui/media/mediacontroller.py 2013-05-25 05:56:28 +0000
@@ -466,8 +466,8 @@
The ServiceItem containing the details to be played.
"""
used_players = get_media_players()[0]
- if service_item.title != UiStrings().Automatic:
- used_players = [service_item.title.lower()]
+ if service_item.processor != UiStrings().Automatic:
+ used_players = [service_item.processor.lower()]
if controller.media_info.file_info.isFile():
suffix = u'*.%s' % controller.media_info.file_info.suffix().lower()
for title in used_players:
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py 2013-04-28 17:17:45 +0000
+++ openlp/plugins/media/lib/mediaitem.py 2013-05-25 05:56:28 +0000
@@ -155,7 +155,7 @@
if os.path.exists(filename):
service_item = ServiceItem()
service_item.title = u'webkit'
- service_item.shortname = service_item.title
+ service_item.processor = u'webkit'
(path, name) = os.path.split(filename)
service_item.add_from_command(path, name,CLAPPERBOARD)
if self.media_controller.video(DisplayControllerType.Live, service_item, video_behind_text=True):
@@ -185,9 +185,9 @@
translate('MediaPlugin.MediaItem', 'Missing Media File'),
translate('MediaPlugin.MediaItem', 'The file %s no longer exists.') % filename)
return False
- service_item.title = self.display_type_combo_box.currentText()
- service_item.shortname = service_item.title
(path, name) = os.path.split(filename)
+ service_item.title = name
+ service_item.processor = self.display_type_combo_box.currentText()
service_item.add_from_command(path, name, CLAPPERBOARD)
# Only get start and end times if going to a service
if context == ServiceItemContext.Service:
@@ -196,7 +196,6 @@
return False
service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
service_item.add_capability(ItemCapabilities.RequiresMedia)
- service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay)
if Settings().value(self.settings_section + u'/media auto start') == QtCore.Qt.Checked:
service_item.will_auto_start = True
# force a non-existent theme
@@ -260,8 +259,7 @@
Settings().setValue(self.settings_section + u'/media files', self.get_file_list())
def load_list(self, media, target_group=None):
- # Sort the media by its filename considering language specific
- # characters.
+ # Sort the media by its filename considering language specific characters.
media.sort(key=lambda filename: get_locale_key(os.path.split(unicode(filename))[1]))
for track in media:
track_info = QtCore.QFileInfo(track)
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2013-04-19 19:15:12 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2013-05-25 05:56:28 +0000
@@ -244,22 +244,20 @@
items = self.list_view.selectedItems()
if len(items) > 1:
return False
- service_item.title = self.display_type_combo_box.currentText()
- service_item.shortname = self.display_type_combo_box.currentText()
+ service_item.processor = self.display_type_combo_box.currentText()
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
- service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay)
- shortname = service_item.shortname
- if not shortname:
+ if not self.display_type_combo_box.currentText():
return False
for bitem in items:
filename = bitem.data(QtCore.Qt.UserRole)
+ (path, name) = os.path.split(filename)
+ service_item.title = name
if os.path.exists(filename):
- if shortname == self.Automatic:
- service_item.shortname = self.findControllerByType(filename)
- if not service_item.shortname:
+ if service_item.processor == self.Automatic:
+ service_item.processor = self.findControllerByType(filename)
+ if not service_item.processor:
return False
- controller = self.controllers[service_item.shortname]
- (path, name) = os.path.split(filename)
+ controller = self.controllers[service_item.processor]
doc = controller.add_document(filename)
if doc.get_thumbnail_path(1, True) is None:
doc.load_presentation()
=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py 2013-04-19 18:52:39 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py 2013-05-25 05:56:28 +0000
@@ -36,6 +36,7 @@
log = logging.getLogger(__name__)
+
class Controller(object):
"""
This is the Presentation listener who acts on events from the slide controller and passes the messages on the the
@@ -314,7 +315,7 @@
item = message[0]
hide_mode = message[2]
file = item.get_frame_path()
- self.handler = item.title
+ self.handler = item.processor
if self.handler == self.media_item.Automatic:
self.handler = self.media_item.findControllerByType(file)
if not self.handler:
=== modified file 'openlp/plugins/presentations/lib/presentationcontroller.py'
--- openlp/plugins/presentations/lib/presentationcontroller.py 2013-04-19 18:52:39 +0000
+++ openlp/plugins/presentations/lib/presentationcontroller.py 2013-05-25 05:56:28 +0000
@@ -38,6 +38,7 @@
log = logging.getLogger(__name__)
+
class PresentationDocument(object):
"""
Base class for presentation documents to inherit from. Loads and closes the presentation as well as triggering the
@@ -322,7 +323,7 @@
``supports``
The primary native file types this application supports.
- ``alsosupports``
+ ``also_supports``
Other file types the application can import, although not necessarily the first choice due to potential
incompatibilities.
@@ -358,7 +359,7 @@
Name of the application, to appear in the application
"""
self.supports = []
- self.alsosupports = []
+ self.also_supports = []
self.docs = []
self.plugin = plugin
self.name = name
=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py 2013-04-20 09:06:26 +0000
+++ openlp/plugins/presentations/presentationplugin.py 2013-05-25 05:56:28 +0000
@@ -49,7 +49,7 @@
u'presentations/Powerpoint': QtCore.Qt.Checked,
u'presentations/Powerpoint Viewer': QtCore.Qt.Checked,
u'presentations/presentations files': []
- }
+}
class PresentationPlugin(Plugin):
=== modified file 'tests/functional/openlp_core_lib/test_serviceitem.py'
--- tests/functional/openlp_core_lib/test_serviceitem.py 2013-04-20 18:39:10 +0000
+++ tests/functional/openlp_core_lib/test_serviceitem.py 2013-05-25 05:56:28 +0000
@@ -210,7 +210,6 @@
# THEN: We should get back a valid service item
assert service_item.is_valid is True, u'The new service item should be valid'
- print service_item.get_rendered_frame(0)
assert service_item.get_rendered_frame(0) == test_file, u'The first frame should match the path to the image'
assert service_item.get_frames()[0] == frame_array, u'The return should match frame array1'
assert service_item.get_frame_path(0) == test_file, u'The frame path should match the full path to the image'
@@ -268,6 +267,26 @@
assert service_item.is_capable(ItemCapabilities.CanAppend) is True, \
u'This service item should be able to have new items added to it'
+ def serviceitem_migrate_test_20_22(self):
+ """
+ Test the Service Item - migrating a media only service item from 2.0 to 2.2 format
+ """
+ # GIVEN: A new service item and a mocked add icon function
+ service_item = ServiceItem(None)
+ service_item.add_icon = MagicMock()
+
+ # WHEN: adding an media from a saved Service and mocked exists
+ line = self.convert_file_service_item(u'migrate_video_20_22.osd')
+ with patch('os.path.exists'):
+ service_item.set_from_service(line, TEST_PATH)
+
+ # THEN: We should get back a converted service item
+ assert service_item.is_valid is True, u'The new service item should be valid'
+ assert service_item.processor is None, u'The Processor should have been set'
+ assert service_item.title is None, u'The title should be set to a value'
+ assert service_item.is_capable(ItemCapabilities.HasDetailedTitleDisplay) is False, \
+ u'The Capability should have been removed'
+
def convert_file_service_item(self, name):
service_file = os.path.join(TEST_PATH, name)
try:
=== added file 'tests/resources/migrate_video_20_22.osd'
--- tests/resources/migrate_video_20_22.osd 1970-01-01 00:00:00 +0000
+++ tests/resources/migrate_video_20_22.osd 2013-05-25 05:56:28 +0000
@@ -0,0 +1,98 @@
+(lp1
+(dp2
+Vserviceitem
+p3
+(dp4
+Vheader
+p5
+(dp6
+Vxml_version
+p7
+NsVauto_play_slides_loop
+p8
+I00
+sVauto_play_slides_once
+p9
+I00
+sVwill_auto_start
+p10
+I01
+sVtitle
+p11
+VVLC
+p12
+sVcapabilities
+p13
+(lp14
+I12
+aI16
+aI4
+aI11
+asVtheme
+p15
+I-1
+sVbackground_audio
+p16
+(lp17
+sVicon
+p18
+V:/plugins/plugin_media.png
+p19
+sVtype
+p20
+I3
+sVstart_time
+p21
+I0
+sVfrom_plugin
+p22
+I00
+sVmedia_length
+p23
+I144
+sVdata
+p24
+V
+sVtimed_slide_interval
+p25
+I0
+sVaudit
+p26
+V
+sVsearch
+p27
+V
+sVname
+p28
+Vmedia
+p29
+sVfooter
+p30
+(lp31
+sVnotes
+p32
+V
+sVplugin
+p33
+g29
+sVtheme_overwritten
+p34
+I00
+sVend_time
+p35
+I0
+ssg24
+(lp36
+(dp37
+Vpath
+p38
+V/home/tim/Videos/puppets
+p39
+sVimage
+p40
+V:/media/slidecontroller_multimedia.png
+p41
+sg11
+VMVI_3405.MOV
+p42
+sassa.
\ No newline at end of file
Follow ups