forked from openlp/openlp
Add guard for missing filename
This commit is contained in:
parent
8b231fbeb2
commit
87c1074cfe
@ -381,7 +381,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
if os.path.exists(thumb):
|
||||
filedate = os.stat(file).st_mtime
|
||||
thumbdate = os.stat(thumb).st_mtime
|
||||
#if file updated rebuild icon
|
||||
# if file updated rebuild icon
|
||||
if filedate > thumbdate:
|
||||
self.iconFromFile(file, thumb)
|
||||
else:
|
||||
@ -544,4 +544,4 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
Method to add processing when a service has been loaded and
|
||||
individual service items need to be processed by the plugins
|
||||
"""
|
||||
pass
|
||||
pass
|
||||
|
@ -132,7 +132,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
os.remove(os.path.join(self.servicePath,
|
||||
unicode(text.text())))
|
||||
except OSError:
|
||||
#if not present do not worry
|
||||
# if not present do not worry
|
||||
pass
|
||||
self.listView.takeItem(row)
|
||||
SettingsManager.set_list(self.settingsSection,
|
||||
@ -195,4 +195,4 @@ class ImageMediaItem(MediaManagerItem):
|
||||
self.resetButton.setVisible(True)
|
||||
|
||||
def onPreviewClick(self):
|
||||
MediaManagerItem.onPreviewClick(self)
|
||||
MediaManagerItem.onPreviewClick(self)
|
||||
|
@ -89,7 +89,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.ImageWidget.sizePolicy().hasHeightForWidth())
|
||||
self.ImageWidget.setSizePolicy(sizePolicy)
|
||||
self.ImageWidget.setObjectName(u'ImageWidget')
|
||||
#Replace backgrounds do not work at present so remove functionality.
|
||||
# Replace backgrounds do not work at present so remove functionality.
|
||||
self.blankButton = self.toolbar.addToolbarButton(
|
||||
translate('MediaPlugin.MediaItem', 'Replace Background'),
|
||||
u':/slides/slide_blank.png',
|
||||
@ -159,4 +159,4 @@ class MediaMediaItem(MediaManagerItem):
|
||||
img = QtGui.QPixmap(u':/media/media_video.png').toImage()
|
||||
item_name.setIcon(build_icon(img))
|
||||
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
||||
self.listView.addItem(item_name)
|
||||
self.listView.addItem(item_name)
|
||||
|
@ -255,8 +255,9 @@ class ImpressDocument(PresentationDocument):
|
||||
self.document = desktop.loadComponentFromURL(url, u'_blank',
|
||||
0, properties)
|
||||
except:
|
||||
log.exception(u'Failed to load presentation')
|
||||
log.exception(u'Failed to load presentation %s' % url)
|
||||
return False
|
||||
|
||||
self.presentation = self.document.getPresentation()
|
||||
self.presentation.Display = \
|
||||
self.controller.plugin.renderManager.screens.current_display + 1
|
||||
@ -478,4 +479,4 @@ class ImpressDocument(PresentationDocument):
|
||||
shape = notes.getByIndex(idx)
|
||||
if shape.supportsService("com.sun.star.drawing.Text"):
|
||||
text += shape.getString() + '\n'
|
||||
return text
|
||||
return text
|
||||
|
@ -153,7 +153,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
"""
|
||||
self.DisplayTypeComboBox.clear()
|
||||
for item in self.controllers:
|
||||
#load the drop down selection
|
||||
# load the drop down selection
|
||||
if self.controllers[item].enabled():
|
||||
self.DisplayTypeComboBox.addItem(item)
|
||||
if self.DisplayTypeComboBox.count() > 1:
|
||||
@ -197,7 +197,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
doc.load_presentation()
|
||||
preview = doc.get_thumbnail_path(1, True)
|
||||
doc.close_presentation()
|
||||
if preview and self.validate(preview, thumb):
|
||||
if preview and self.validate(preview, file):
|
||||
icon = build_icon(thumb)
|
||||
else:
|
||||
icon = build_icon(u':/general/general_delete.png')
|
||||
@ -254,22 +254,27 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
for item in items:
|
||||
bitem = self.listView.item(item.row())
|
||||
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
||||
if shortname == self.Automatic:
|
||||
service_item.shortname = self.findControllerByType(filename)
|
||||
if not service_item.shortname:
|
||||
return False
|
||||
controller = self.controllers[service_item.shortname]
|
||||
(path, name) = os.path.split(filename)
|
||||
doc = controller.add_doc(filename)
|
||||
if doc.get_thumbnail_path(1, True) is None:
|
||||
doc.load_presentation()
|
||||
i = 1
|
||||
img = doc.get_thumbnail_path(i, True)
|
||||
while img:
|
||||
service_item.add_from_command(path, name, img)
|
||||
i = i + 1
|
||||
if os.path.exists(filename):
|
||||
if shortname == self.Automatic:
|
||||
service_item.shortname = \
|
||||
self.findControllerByType(filename)
|
||||
if not service_item.shortname:
|
||||
return False
|
||||
controller = self.controllers[service_item.shortname]
|
||||
(path, name) = os.path.split(filename)
|
||||
doc = controller.add_doc(filename)
|
||||
if doc.get_thumbnail_path(1, True) is None:
|
||||
doc.load_presentation()
|
||||
i = 1
|
||||
img = doc.get_thumbnail_path(i, True)
|
||||
doc.close_presentation()
|
||||
while img:
|
||||
service_item.add_from_command(path, name, img)
|
||||
i = i + 1
|
||||
img = doc.get_thumbnail_path(i, True)
|
||||
doc.close_presentation()
|
||||
else:
|
||||
# File is no longer present
|
||||
return False
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -280,7 +285,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
file type. This is used if "Automatic" is set as the preferred
|
||||
controller. Find the first (alphabetic) enabled controller which
|
||||
"supports" the extension. If none found, then look for a controller
|
||||
which "alsosupports" it instead.
|
||||
which "also supports" it instead.
|
||||
"""
|
||||
filetype = filename.split(u'.')[1]
|
||||
if not filetype:
|
||||
@ -293,4 +298,4 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
if self.controllers[controller].enabled():
|
||||
if filetype in self.controllers[controller].alsosupports:
|
||||
return controller
|
||||
return None
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user