Lite save works

This commit is contained in:
Tim Bentley 2012-10-15 17:20:23 +01:00
parent c29cf8ce70
commit a5824120c3
2 changed files with 20 additions and 8 deletions

View File

@ -257,7 +257,7 @@ class ServiceItem(object):
{u'title': file_name, u'image': image, u'path': path}) {u'title': file_name, u'image': image, u'path': path})
self._new_item() self._new_item()
def get_service_repr(self): def get_service_repr(self, lite_save):
""" """
This method returns some text which can be saved into the service This method returns some text which can be saved into the service
file to represent this item. file to represent this item.
@ -288,6 +288,11 @@ class ServiceItem(object):
if self.service_item_type == ServiceItemType.Text: if self.service_item_type == ServiceItemType.Text:
service_data = [slide for slide in self._raw_frames] service_data = [slide for slide in self._raw_frames]
elif self.service_item_type == ServiceItemType.Image: elif self.service_item_type == ServiceItemType.Image:
if lite_save:
for slide in self._raw_frames:
service_data.append(
{u'title': slide[u'title'], u'path': slide[u'path']})
else:
service_data = [slide[u'title'] for slide in self._raw_frames] service_data = [slide[u'title'] for slide in self._raw_frames]
elif self.service_item_type == ServiceItemType.Command: elif self.service_item_type == ServiceItemType.Command:
for slide in self._raw_frames: for slide in self._raw_frames:
@ -338,9 +343,14 @@ class ServiceItem(object):
for slide in serviceitem[u'serviceitem'][u'data']: for slide in serviceitem[u'serviceitem'][u'data']:
self._raw_frames.append(slide) self._raw_frames.append(slide)
elif self.service_item_type == ServiceItemType.Image: elif self.service_item_type == ServiceItemType.Image:
if path:
for text_image in serviceitem[u'serviceitem'][u'data']: for text_image in serviceitem[u'serviceitem'][u'data']:
filename = os.path.join(path, text_image) filename = os.path.join(path, text_image)
self.add_from_image(filename, text_image) self.add_from_image(filename, text_image)
else:
for text_image in serviceitem[u'serviceitem'][u'data']:
self.add_from_image(text_image[u'path'],
text_image[u'title'])
elif self.service_item_type == ServiceItemType.Command: elif self.service_item_type == ServiceItemType.Command:
for text_image in serviceitem[u'serviceitem'][u'data']: for text_image in serviceitem[u'serviceitem'][u'data']:
if path: if path:

View File

@ -502,7 +502,8 @@ class ServiceManager(QtGui.QWidget):
self.mainwindow.displayProgressBar(len(self.serviceItems) + 1) self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
for item in self.serviceItems: for item in self.serviceItems:
self.mainwindow.incrementProgressBar() self.mainwindow.incrementProgressBar()
service_item = item[u'service_item'].get_service_repr() service_item = item[u'service_item']. \
get_service_repr(self._saveLite)
# Get all the audio files, and ready them for embedding in the # Get all the audio files, and ready them for embedding in the
# service file. # service file.
if service_item[u'header'][u'background_audio']: if service_item[u'header'][u'background_audio']:
@ -634,7 +635,8 @@ class ServiceManager(QtGui.QWidget):
self.mainwindow.displayProgressBar(len(self.serviceItems) + 1) self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
for item in self.serviceItems: for item in self.serviceItems:
self.mainwindow.incrementProgressBar() self.mainwindow.incrementProgressBar()
service_item = item[u'service_item'].get_service_repr() service_item = item[u'service_item']. \
get_service_repr(self._saveLite)
service.append({u'serviceitem': service_item}) service.append({u'serviceitem': service_item})
service_content = cPickle.dumps(service) service_content = cPickle.dumps(service)
# Usual Zip file cannot exceed 2GiB, file with Zip64 cannot be # Usual Zip file cannot exceed 2GiB, file with Zip64 cannot be
@ -713,7 +715,7 @@ class ServiceManager(QtGui.QWidget):
UiStrings().SaveService, path, UiStrings().SaveService, path,
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'OpenLP Service Files (*.osz);;' 'OpenLP Service Files (*.osz);;'
'OpenLP Service Files - light (*.oszl)'))) 'OpenLP Service Files - lite (*.oszl)')))
if not fileName: if not fileName:
return False return False
if os.path.splitext(fileName)[1] == u'': if os.path.splitext(fileName)[1] == u'':