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: for item in items:
bitem = self.listView.item(item.row()) bitem = self.listView.item(item.row())
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
(path, name) = os.path.split(filename) if os.path.exists(filename):
service_item.add_from_image(filename, name) (path, name) = os.path.split(filename)
return True 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: else:
return False return False

View File

@ -122,15 +122,24 @@ class MediaMediaItem(MediaManagerItem):
if item is None: if item is None:
return False return False
filename = unicode(item.data(QtCore.Qt.UserRole).toString()) filename = unicode(item.data(QtCore.Qt.UserRole).toString())
service_item.title = unicode( if os.path.exists(filename):
translate('MediaPlugin.MediaItem', 'Media')) service_item.title = unicode(
service_item.add_capability(ItemCapabilities.RequiresMedia) translate('MediaPlugin.MediaItem', 'Media'))
# force a nonexistent theme service_item.add_capability(ItemCapabilities.RequiresMedia)
service_item.theme = -1 # force a nonexistent theme
frame = u':/media/image_clapperboard.png' service_item.theme = -1
(path, name) = os.path.split(filename) frame = u':/media/image_clapperboard.png'
service_item.add_from_command(path, name, frame) (path, name) = os.path.split(filename)
return True 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): def initialise(self):
self.listView.setSelectionMode( self.listView.setSelectionMode(

View File

@ -272,10 +272,15 @@ class PresentationMediaItem(MediaManagerItem):
i = i + 1 i = i + 1
img = doc.get_thumbnail_path(i, True) img = doc.get_thumbnail_path(i, True)
doc.close_presentation() doc.close_presentation()
return True
else: else:
# File is no longer present # 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 False
return True
else: else:
return False return False