forked from openlp/openlp
Fixes thumbnails in stage view
This commit is contained in:
parent
0cc2ae5998
commit
3fcccd70e4
@ -314,6 +314,16 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
return True
|
return True
|
||||||
return return_value
|
return return_value
|
||||||
|
|
||||||
|
def generate_thumbnail_path(self, image):
|
||||||
|
"""
|
||||||
|
Generate a path to the thumbnail
|
||||||
|
|
||||||
|
:param imageFile: An instance of fImageFileNames
|
||||||
|
:return: A path to the thumbnail of type str
|
||||||
|
"""
|
||||||
|
ext = os.path.splitext(image.filename)[1].lower()
|
||||||
|
return os.path.join(self.service_path, '{}{}'.format(str(image.id), ext))
|
||||||
|
|
||||||
def load_full_list(self, images, initial_load=False, open_group=None):
|
def load_full_list(self, images, initial_load=False, open_group=None):
|
||||||
"""
|
"""
|
||||||
Replace the list of images and groups in the interface.
|
Replace the list of images and groups in the interface.
|
||||||
@ -338,8 +348,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
for imageFile in images:
|
for imageFile in images:
|
||||||
log.debug('Loading image: %s', imageFile.filename)
|
log.debug('Loading image: %s', imageFile.filename)
|
||||||
filename = os.path.split(imageFile.filename)[1]
|
filename = os.path.split(imageFile.filename)[1]
|
||||||
ext = os.path.splitext(imageFile.filename)[1].lower()
|
thumb = self.generate_thumbnail_path(imageFile)
|
||||||
thumb = os.path.join(self.service_path, "%s%s" % (str(imageFile.id), ext))
|
|
||||||
if not os.path.exists(imageFile.filename):
|
if not os.path.exists(imageFile.filename):
|
||||||
icon = build_icon(':/general/general_delete.png')
|
icon = build_icon(':/general/general_delete.png')
|
||||||
else:
|
else:
|
||||||
@ -549,24 +558,24 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
# force a nonexistent theme
|
# force a nonexistent theme
|
||||||
service_item.theme = -1
|
service_item.theme = -1
|
||||||
missing_items_file_names = []
|
missing_items_file_names = []
|
||||||
images_file_names = []
|
images = []
|
||||||
# Expand groups to images
|
# Expand groups to images
|
||||||
for bitem in items:
|
for bitem in items:
|
||||||
if isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageGroups) or bitem.data(0, QtCore.Qt.UserRole) is None:
|
if isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageGroups) or bitem.data(0, QtCore.Qt.UserRole) is None:
|
||||||
for index in range(0, bitem.childCount()):
|
for index in range(0, bitem.childCount()):
|
||||||
if isinstance(bitem.child(index).data(0, QtCore.Qt.UserRole), ImageFilenames):
|
if isinstance(bitem.child(index).data(0, QtCore.Qt.UserRole), ImageFilenames):
|
||||||
images_file_names.append(bitem.child(index).data(0, QtCore.Qt.UserRole).filename)
|
images.append(bitem.child(index).data(0, QtCore.Qt.UserRole))
|
||||||
elif isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageFilenames):
|
elif isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageFilenames):
|
||||||
images_file_names.append(bitem.data(0, QtCore.Qt.UserRole).filename)
|
images.append(bitem.data(0, QtCore.Qt.UserRole))
|
||||||
# Don't try to display empty groups
|
# Don't try to display empty groups
|
||||||
if not images_file_names:
|
if not images:
|
||||||
return False
|
return False
|
||||||
# Find missing files
|
# Find missing files
|
||||||
for filename in images_file_names:
|
for image in images:
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(image.filename):
|
||||||
missing_items_file_names.append(filename)
|
missing_items_file_names.append(image.filename)
|
||||||
# We cannot continue, as all images do not exist.
|
# We cannot continue, as all images do not exist.
|
||||||
if not images_file_names:
|
if not images:
|
||||||
if not remote:
|
if not remote:
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
|
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
|
||||||
@ -582,9 +591,10 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
QtGui.QMessageBox.No:
|
QtGui.QMessageBox.No:
|
||||||
return False
|
return False
|
||||||
# Continue with the existing images.
|
# Continue with the existing images.
|
||||||
for filename in images_file_names:
|
for image in images:
|
||||||
name = os.path.split(filename)[1]
|
name = os.path.split(image.filename)[1]
|
||||||
service_item.add_from_image(filename, name, background, os.path.join(self.service_path, name))
|
thumbnail = self.generate_thumbnail_path(image)
|
||||||
|
service_item.add_from_image(image.filename, name, background, thumbnail)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_group_exists(self, new_group):
|
def check_group_exists(self, new_group):
|
||||||
|
Loading…
Reference in New Issue
Block a user