Add message popup and guard Images and Media as well

This commit is contained in:
Tim Bentley 2010-12-29 09:27:13 +00:00
parent 87c1074cfe
commit ad346d8e05
3 changed files with 36 additions and 13 deletions

View File

@ -172,9 +172,18 @@ class ImageMediaItem(MediaManagerItem):
for item in items:
bitem = self.listView.item(item.row())
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
(path, name) = os.path.split(filename)
service_item.add_from_image(filename, name)
return True
if os.path.exists(filename):
(path, name) = os.path.split(filename)
service_item.add_from_image(filename, name)
return True
else:
# File is no longer present
QtGui.QMessageBox.critical(
self, translate('ImagePlugin.MediaItem',
'Missing Image'),
unicode(translate('ImagePlugin.MediaItem',
'The Image %s no longer exists.')) % filename)
return False
else:
return False

View File

@ -122,15 +122,24 @@ class MediaMediaItem(MediaManagerItem):
if item is None:
return False
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
service_item.title = unicode(
translate('MediaPlugin.MediaItem', 'Media'))
service_item.add_capability(ItemCapabilities.RequiresMedia)
# force a nonexistent theme
service_item.theme = -1
frame = u':/media/image_clapperboard.png'
(path, name) = os.path.split(filename)
service_item.add_from_command(path, name, frame)
return True
if os.path.exists(filename):
service_item.title = unicode(
translate('MediaPlugin.MediaItem', 'Media'))
service_item.add_capability(ItemCapabilities.RequiresMedia)
# force a nonexistent theme
service_item.theme = -1
frame = u':/media/image_clapperboard.png'
(path, name) = os.path.split(filename)
service_item.add_from_command(path, name, frame)
return True
else:
# File is no longer present
QtGui.QMessageBox.critical(
self, translate('MediaPlugin.MediaItem',
'Missing Media File'),
unicode(translate('MediaPlugin.MediaItem',
'The file %s no longer exists.')) % filename)
return False
def initialise(self):
self.listView.setSelectionMode(

View File

@ -272,10 +272,15 @@ class PresentationMediaItem(MediaManagerItem):
i = i + 1
img = doc.get_thumbnail_path(i, True)
doc.close_presentation()
return True
else:
# File is no longer present
QtGui.QMessageBox.critical(
self, translate('PresentationPlugin.MediaItem',
'Missing Presentation'),
unicode(translate('PresentationPlugin.MediaItem',
'The Presentation %s no longer exists.')) % filename)
return False
return True
else:
return False