This commit is contained in:
Andreas Preikschat 2011-01-02 08:57:05 +01:00
parent def66c204a
commit 8a0eeb54bb
4 changed files with 38 additions and 16 deletions

View File

@ -26,4 +26,4 @@
""" """
The :mod:`images` module provides the Images plugin. The Images plugin The :mod:`images` module provides the Images plugin. The Images plugin
provides the facility to display images from OpenLP. provides the facility to display images from OpenLP.
""" """

View File

@ -41,7 +41,7 @@ class ImagePlugin(Plugin):
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
def getMediaManagerItem(self): def getMediaManagerItem(self):
# Create the MediaManagerItem object # Create the MediaManagerItem object.
return ImageMediaItem(self, self, self.icon) return ImageMediaItem(self, self, self.icon)
def about(self): def about(self):

View File

@ -24,4 +24,4 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from mediaitem import ImageMediaItem from mediaitem import ImageMediaItem

View File

@ -166,29 +166,51 @@ class ImageMediaItem(MediaManagerItem):
service_item.add_capability(ItemCapabilities.AllowsAdditions) service_item.add_capability(ItemCapabilities.AllowsAdditions)
# force a nonexistent theme # force a nonexistent theme
service_item.theme = -1 service_item.theme = -1
existing_images = []
missing_images = []
text = u''
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())
if os.path.exists(filename): if os.path.exists(filename):
(path, name) = os.path.split(filename) existing_images.append(filename)
service_item.add_from_image(filename, name) else:
# We have only one image, which is no longer present. missing_images.append(filename)
elif len(items) == 1: text += u'\n' + filename
QtGui.QMessageBox.critical( # We cannot continue, as all images are missing.
self, translate('ImagePlugin.MediaItem', if len(missing_images) == len(items):
'Missing Image'), if len(missing_images) == 1:
QtGui.QMessageBox.critical(self,
translate('ImagePlugin.MediaItem', 'Missing Image'),
unicode(translate('ImagePlugin.MediaItem', unicode(translate('ImagePlugin.MediaItem',
'The image %s no longer exists.')) % filename) 'The image %s no longer exists.')) % text)
return False else:
# We have more than one item, but a file is missing. QtGui.QMessageBox.critical(self,
elif QtGui.QMessageBox.question(self, translate('ImagePlugin.MediaItem', 'Missing Images'),
translate('ImagePlugin.MediaItem', 'Missing Image'), unicode(translate('ImagePlugin.MediaItem',
'The following images no longer exist: %s')) % text)
return False
# We still have present images. Ask what to do.
elif missing_images:
if len(missing_images) == 1 and QtGui.QMessageBox.question(
self, translate('ImagePlugin.MediaItem', 'Missing Image'),
unicode(translate('ImagePlugin.MediaItem', 'The image %s ' unicode(translate('ImagePlugin.MediaItem', 'The image %s '
'no longer exists. Do you want to add the other images ' 'no longer exists. Do you want to add the other images '
'anyway?')) % filename, 'anyway?')) % text,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
return False return False
elif len(missing_images) > 1 and QtGui.QMessageBox.question(
self, translate('ImagePlugin.MediaItem', 'Missing Images'),
unicode(translate('ImagePlugin.MediaItem', 'The following '
'images no longer exist: %s\nDo you want to add the other '
'images anyway?')) % text,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
return False
for filename in existing_images:
(path, name) = os.path.split(filename)
service_item.add_from_image(filename, name)
return True return True
else: else:
return False return False