forked from openlp/openlp
head
This commit is contained in:
commit
b312342475
@ -452,14 +452,27 @@ class ServiceItem(object):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
return u''
|
return u''
|
||||||
|
|
||||||
def get_frame_path(self, row=0):
|
def get_frame_path(self, row=0, frame=None):
|
||||||
"""
|
"""
|
||||||
Returns the path of the raw frame
|
Returns the path of the raw frame
|
||||||
"""
|
"""
|
||||||
|
if not frame:
|
||||||
try:
|
try:
|
||||||
return self._raw_frames[row][u'path']
|
frame = self._raw_frames[row]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return u''
|
return u''
|
||||||
|
if self.is_image():
|
||||||
|
path_from = frame[u'path']
|
||||||
|
else:
|
||||||
|
path_from = os.path.join(frame[u'path'], frame[u'title'])
|
||||||
|
return path_from
|
||||||
|
|
||||||
|
def remove_frame(self, frame):
|
||||||
|
"""
|
||||||
|
Remove the soecified frame from the item
|
||||||
|
"""
|
||||||
|
if frame in self._raw_frames:
|
||||||
|
self._raw_frames.remove(frame)
|
||||||
|
|
||||||
def get_media_time(self):
|
def get_media_time(self):
|
||||||
"""
|
"""
|
||||||
@ -496,3 +509,17 @@ class ServiceItem(object):
|
|||||||
self._new_item()
|
self._new_item()
|
||||||
self.render()
|
self.render()
|
||||||
|
|
||||||
|
def remove_invalid_frames(self, invalid_paths=None):
|
||||||
|
"""
|
||||||
|
Remove invalid frames, such as ones where the file no longer exists.
|
||||||
|
"""
|
||||||
|
if self.uses_file():
|
||||||
|
for frame in self.get_frames():
|
||||||
|
if self.get_frame_path(frame=frame) in invalid_paths:
|
||||||
|
self.remove_frame(frame)
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
"""
|
||||||
|
Validates this service item
|
||||||
|
"""
|
||||||
|
return bool(self._raw_frames)
|
||||||
|
@ -484,58 +484,61 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
path)
|
path)
|
||||||
service = []
|
service = []
|
||||||
write_list = []
|
write_list = []
|
||||||
|
missing_list = []
|
||||||
audio_files = []
|
audio_files = []
|
||||||
total_size = 0
|
total_size = 0
|
||||||
Receiver.send_message(u'cursor_busy')
|
Receiver.send_message(u'cursor_busy')
|
||||||
# Number of items + 1 to zip it
|
# Number of items + 1 to zip it
|
||||||
self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
|
self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
|
||||||
|
# Get list of missing files, and list of files to write
|
||||||
for item in self.serviceItems:
|
for item in self.serviceItems:
|
||||||
self.mainwindow.incrementProgressBar()
|
|
||||||
service_item = item[u'service_item'].get_service_repr()
|
|
||||||
# Get all the audio files, and ready them for embedding in the
|
|
||||||
# service file.
|
|
||||||
if service_item[u'header'][u'background_audio']:
|
|
||||||
for i, filename in \
|
|
||||||
enumerate(service_item[u'header'][u'background_audio']):
|
|
||||||
new_file = os.path.join(u'audio',
|
|
||||||
item[u'service_item']._uuid, filename)
|
|
||||||
audio_files.append((filename, new_file))
|
|
||||||
service_item[u'header'][u'background_audio'][i] = new_file
|
|
||||||
# Add the service item to the service.
|
|
||||||
service.append({u'serviceitem': service_item})
|
|
||||||
if not item[u'service_item'].uses_file():
|
if not item[u'service_item'].uses_file():
|
||||||
continue
|
continue
|
||||||
skipMissing = False
|
|
||||||
for frame in item[u'service_item'].get_frames():
|
for frame in item[u'service_item'].get_frames():
|
||||||
if item[u'service_item'].is_image():
|
path_from = item[u'service_item'].get_frame_path(frame=frame)
|
||||||
path_from = frame[u'path']
|
if path_from in write_list or path_from in missing_list:
|
||||||
else:
|
|
||||||
path_from = os.path.join(frame[u'path'], frame[u'title'])
|
|
||||||
# Only write a file once
|
|
||||||
if path_from in write_list:
|
|
||||||
continue
|
continue
|
||||||
if not os.path.exists(path_from):
|
if not os.path.exists(path_from):
|
||||||
if not skipMissing:
|
missing_list.append(path_from)
|
||||||
|
else:
|
||||||
|
write_list.append(path_from)
|
||||||
|
if missing_list:
|
||||||
Receiver.send_message(u'cursor_normal')
|
Receiver.send_message(u'cursor_normal')
|
||||||
title = unicode(translate('OpenLP.ServiceManager',
|
title = unicode(translate('OpenLP.ServiceManager',
|
||||||
'Service File Missing'))
|
'Service File(s) Missing'))
|
||||||
message = unicode(translate('OpenLP.ServiceManager',
|
message = unicode(translate('OpenLP.ServiceManager',
|
||||||
'File missing from service\n\n %s \n\n'
|
'The following file(s) in the service are missing:\n\t%s\n\n'
|
||||||
'Continue saving?')) % path_from
|
'These files will be removed if you continue to save.')
|
||||||
|
) % "\n\t".join(missing_list)
|
||||||
answer = QtGui.QMessageBox.critical(self, title,
|
answer = QtGui.QMessageBox.critical(self, title,
|
||||||
message,
|
message,
|
||||||
QtGui.QMessageBox.StandardButtons(
|
QtGui.QMessageBox.StandardButtons(
|
||||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
|
QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel))
|
||||||
QtGui.QMessageBox.YesToAll))
|
if answer == QtGui.QMessageBox.Cancel:
|
||||||
if answer == QtGui.QMessageBox.No:
|
|
||||||
self.mainwindow.finishedProgressBar()
|
self.mainwindow.finishedProgressBar()
|
||||||
return False
|
return False
|
||||||
if answer == QtGui.QMessageBox.YesToAll:
|
|
||||||
skipMissing = True
|
|
||||||
Receiver.send_message(u'cursor_busy')
|
Receiver.send_message(u'cursor_busy')
|
||||||
|
# Check if item contains a missing file.
|
||||||
|
for item in list(self.serviceItems):
|
||||||
|
self.mainwindow.incrementProgressBar()
|
||||||
|
item[u'service_item'].remove_invalid_frames(missing_list)
|
||||||
|
if not item[u'service_item'].validate():
|
||||||
|
self.serviceItems.remove(item)
|
||||||
else:
|
else:
|
||||||
file_size = os.path.getsize(path_from)
|
service_item = item[u'service_item'].get_service_repr()
|
||||||
write_list.append(path_from)
|
if service_item[u'header'][u'background_audio']:
|
||||||
|
for i, filename in enumerate(
|
||||||
|
service_item[u'header'][u'background_audio']):
|
||||||
|
new_file = os.path.join(u'audio',
|
||||||
|
item[u'service_item']._uuid, filename)
|
||||||
|
audio_files.append((filename, new_file))
|
||||||
|
service_item[u'header'][u'background_audio'][i] = \
|
||||||
|
new_file
|
||||||
|
# Add the service item to the service.
|
||||||
|
service.append({u'serviceitem': service_item})
|
||||||
|
self.repaintServiceList(-1, -1)
|
||||||
|
for file in write_list:
|
||||||
|
file_size = os.path.getsize(file)
|
||||||
total_size += file_size
|
total_size += file_size
|
||||||
log.debug(u'ServiceManager.saveFile - ZIP contents size is %i bytes' %
|
log.debug(u'ServiceManager.saveFile - ZIP contents size is %i bytes' %
|
||||||
total_size)
|
total_size)
|
||||||
|
@ -1351,7 +1351,7 @@ class SlideController(Controller):
|
|||||||
Respond to the arrival of a media service item
|
Respond to the arrival of a media service item
|
||||||
"""
|
"""
|
||||||
log.debug(u'SlideController onMediaStart')
|
log.debug(u'SlideController onMediaStart')
|
||||||
file = os.path.join(item.get_frame_path(), item.get_frame_title())
|
file = item.get_frame_path()
|
||||||
self.mediaController.video(self, file, False, False, self.hideMode())
|
self.mediaController.video(self, file, False, False, self.hideMode())
|
||||||
if not self.isLive or self.mediaController.withLivePreview:
|
if not self.isLive or self.mediaController.withLivePreview:
|
||||||
self.previewDisplay.show()
|
self.previewDisplay.show()
|
||||||
|
@ -330,7 +330,7 @@ class MessageListener(object):
|
|||||||
item = message[0]
|
item = message[0]
|
||||||
log.debug(u'Startup called with message %s' % message)
|
log.debug(u'Startup called with message %s' % message)
|
||||||
hide_mode = message[2]
|
hide_mode = message[2]
|
||||||
file = os.path.join(item.get_frame_path(), item.get_frame_title())
|
file = item.get_frame_path()
|
||||||
self.handler = item.title
|
self.handler = item.title
|
||||||
if self.handler == self.mediaitem.Automatic:
|
if self.handler == self.mediaitem.Automatic:
|
||||||
self.handler = self.mediaitem.findControllerByType(file)
|
self.handler = self.mediaitem.findControllerByType(file)
|
||||||
|
Loading…
Reference in New Issue
Block a user