← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/images into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/images into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/images/+merge/45007

Hello!

- fixed adding/appending more images to the Service Manager
- possibility to add/append images to the Service Manager if an image is missing
- prevent that "Replace Live Background" can use a non existing image and prevent replacing the background with more images (as this makes no sense)
-- 
https://code.launchpad.net/~googol-hush/openlp/images/+merge/45007
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/images into lp:openlp.
=== modified file 'openlp/plugins/images/imageplugin.py'
--- openlp/plugins/images/imageplugin.py	2010-12-31 02:17:41 +0000
+++ openlp/plugins/images/imageplugin.py	2011-01-02 21:39:54 +0000
@@ -41,7 +41,7 @@
         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):

=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py	2011-01-01 12:49:38 +0000
+++ openlp/plugins/images/lib/mediaitem.py	2011-01-02 21:39:54 +0000
@@ -31,7 +31,7 @@
 
 from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
     context_menu_action, ItemCapabilities, SettingsManager, translate, \
-    check_item_selected, Receiver
+    check_item_selected
 from openlp.core.utils import AppLocation, get_images_filter
 
 log = logging.getLogger(__name__)
@@ -43,6 +43,7 @@
         self.PluginName = u'Images'
         BaseListWithDnD.__init__(self, parent)
 
+
 class ImageMediaItem(MediaManagerItem):
     """
     This is the custom media manager item for images.
@@ -51,8 +52,8 @@
 
     def __init__(self, parent, plugin, icon):
         self.IconPath = u'images/image'
-        # this next is a class, not an instance of a class - it will
-        # be instanced by the base MediaManagerItem
+        # This next is a class, not an instance of a class - it will
+        # be instanced by the base MediaManagerItem.
         self.ListViewWithDnD_class = ImageListView
         MediaManagerItem.__init__(self, parent, self, icon)
 
@@ -113,7 +114,7 @@
             u':/system/system_close.png',
             translate('ImagePlugin.MediaItem', 'Reset Live Background'),
             self.onResetClick, False)
-        # Add the song widget to the page layout
+        # Add the song widget to the page layout.
         self.pageLayout.addWidget(self.ImageWidget)
         self.resetButton.setVisible(False)
 
@@ -165,21 +166,40 @@
             service_item.add_capability(ItemCapabilities.AllowsAdditions)
             # force a nonexistent theme
             service_item.theme = -1
-            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)
-                    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
+            missing_items = []
+            missing_items_filenames = []
+            for item in items:
+                bitem = self.listView.item(item.row())
+                filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
+                if not os.path.exists(filename):
+                    missing_items.append(item)
+                    missing_items_filenames.append(filename)
+            for item in missing_items:
+                items.remove(item)
+            # We cannot continue, as all images do not exist.
+            if not items:
+                QtGui.QMessageBox.critical(self,
+                    translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
+                    unicode(translate('ImagePlugin.MediaItem',
+                    'The following image(s) no longer exist: %s')) %
+                    u'\n'.join(missing_items_filenames))
+                return False
+            # We have missing as well as existing images. We ask what to do.
+            elif missing_items and QtGui.QMessageBox.question(self,
+                translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
+                unicode(translate('ImagePlugin.MediaItem', 'The following '
+                'image(s) no longer exist: %s\nDo you want to add the other '
+                'images anyway?')) % u'\n'.join(missing_items_filenames),
+                QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
+                QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
+                return False
+            # Continue with the existing images.
+            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
         else:
             return False
 
@@ -191,12 +211,18 @@
         if check_item_selected(self.listView,
             translate('ImagePlugin.MediaItem',
             'You must select an image to replace the background with.')):
-            items = self.listView.selectedIndexes()
-            for item in items:
-                bitem = self.listView.item(item.row())
-                filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
+            item = self.listView.selectedIndexes()[0]
+            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)
                 self.parent.liveController.display.directImage(name, filename)
+            else:
+                QtGui.QMessageBox.critical(self,
+                    translate('ImagePlugin.MediaItem', 'Live Background Could '
+                    'Not Be Replaced'),
+                    unicode(translate('ImagePlugin.MediaItem',
+                    'The image %s no longer exists.')) % filename)
         self.resetButton.setVisible(True)
 
     def onPreviewClick(self):


Follow ups