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
provides the facility to display images from OpenLP.
"""
"""

View File

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

View File

@ -24,4 +24,4 @@
# 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)
# force a nonexistent theme
service_item.theme = -1
existing_images = []
missing_images = []
text = u''
for item in items:
bitem = self.listView.item(item.row())
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
if os.path.exists(filename):
(path, name) = os.path.split(filename)
service_item.add_from_image(filename, name)
# We have only one image, which is no longer present.
elif len(items) == 1:
QtGui.QMessageBox.critical(
self, translate('ImagePlugin.MediaItem',
'Missing Image'),
existing_images.append(filename)
else:
missing_images.append(filename)
text += u'\n' + filename
# We cannot continue, as all images are missing.
if len(missing_images) == len(items):
if len(missing_images) == 1:
QtGui.QMessageBox.critical(self,
translate('ImagePlugin.MediaItem', 'Missing Image'),
unicode(translate('ImagePlugin.MediaItem',
'The image %s no longer exists.')) % filename)
return False
# We have more than one item, but a file is missing.
elif QtGui.QMessageBox.question(self,
translate('ImagePlugin.MediaItem', 'Missing Image'),
'The image %s no longer exists.')) % text)
else:
QtGui.QMessageBox.critical(self,
translate('ImagePlugin.MediaItem', 'Missing Images'),
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 '
'no longer exists. Do you want to add the other images '
'anyway?')) % filename,
'anyway?')) % text,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
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
else:
return False