forked from openlp/openlp
- Fixed traceback on adding multiple image groups to the service in one go
- Cleaned up obsolete line in imagetab
This commit is contained in:
parent
df1faa2a8d
commit
44547769c6
@ -464,7 +464,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
translate('OpenLP.MediaManagerItem', 'You must select one or more items to preview.'))
|
translate('OpenLP.MediaManagerItem', 'You must select one or more items to preview.'))
|
||||||
else:
|
else:
|
||||||
log.debug(u'%s Preview requested', self.plugin.name)
|
log.debug(u'%s Preview requested', self.plugin.name)
|
||||||
service_item = self.build_service_item()
|
service_item = self.build_service_item(context=ServiceItemContext.Preview)
|
||||||
if service_item:
|
if service_item:
|
||||||
service_item.from_plugin = True
|
service_item.from_plugin = True
|
||||||
self.preview_controller.add_service_item(service_item)
|
self.preview_controller.add_service_item(service_item)
|
||||||
|
@ -32,7 +32,6 @@ from PyQt4 import QtGui
|
|||||||
from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate
|
from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ImageTab(SettingsTab):
|
class ImageTab(SettingsTab):
|
||||||
"""
|
"""
|
||||||
ImageTab is the images settings tab in the settings dialog.
|
ImageTab is the images settings tab in the settings dialog.
|
||||||
|
@ -32,7 +32,7 @@ import os
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, ServiceItemContext, Settings, \
|
from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, ServiceItem, ServiceItemContext, Settings, \
|
||||||
StringContent, TreeWidgetWithDnD, UiStrings, build_icon, check_directory_exists, check_item_selected, \
|
StringContent, TreeWidgetWithDnD, UiStrings, build_icon, check_directory_exists, check_item_selected, \
|
||||||
create_thumb, translate, validate_thumb
|
create_thumb, translate, validate_thumb
|
||||||
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
|
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
|
||||||
@ -538,44 +538,46 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
"""
|
"""
|
||||||
background = QtGui.QColor(Settings().value(self.settings_section + u'/background color'))
|
background = QtGui.QColor(Settings().value(self.settings_section + u'/background color'))
|
||||||
if item:
|
if item:
|
||||||
items = [item]
|
new_items = [item]
|
||||||
else:
|
else:
|
||||||
items = self.list_view.selectedItems()
|
new_items = self.list_view.selectedItems()
|
||||||
if not items:
|
if not new_items:
|
||||||
return False
|
return False
|
||||||
|
for bitem in new_items:
|
||||||
|
new_service_item = ServiceItem(self.plugin)
|
||||||
|
new_service_item.add_icon(self.plugin.icon_path)
|
||||||
# Determine service item title
|
# Determine service item title
|
||||||
if isinstance(items[0].data(0, QtCore.Qt.UserRole), ImageGroups):
|
if isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageGroups):
|
||||||
service_item.title = items[0].text(0)
|
new_service_item.title = bitem.text(0)
|
||||||
else:
|
else:
|
||||||
service_item.title = unicode(self.plugin.name_strings[u'plural'])
|
new_service_item.title = unicode(self.plugin.name_strings[u'plural'])
|
||||||
service_item.add_capability(ItemCapabilities.CanMaintain)
|
new_service_item.add_capability(ItemCapabilities.CanMaintain)
|
||||||
service_item.add_capability(ItemCapabilities.CanPreview)
|
new_service_item.add_capability(ItemCapabilities.CanPreview)
|
||||||
service_item.add_capability(ItemCapabilities.CanLoop)
|
new_service_item.add_capability(ItemCapabilities.CanLoop)
|
||||||
service_item.add_capability(ItemCapabilities.CanAppend)
|
new_service_item.add_capability(ItemCapabilities.CanAppend)
|
||||||
# force a nonexistent theme
|
# force a nonexistent theme
|
||||||
service_item.theme = -1
|
new_service_item.theme = -1
|
||||||
|
sub_images = []
|
||||||
missing_items = []
|
missing_items = []
|
||||||
missing_items_filenames = []
|
missing_items_filenames = []
|
||||||
# Expand groups to images
|
# Expand groups to images
|
||||||
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):
|
||||||
items.append(bitem.child(index))
|
sub_images.append(bitem.child(index))
|
||||||
items.remove(bitem)
|
|
||||||
# Don't try to display empty groups
|
# Don't try to display empty groups
|
||||||
if not items:
|
if not sub_images:
|
||||||
return False
|
return False
|
||||||
# Find missing files
|
# Find missing files
|
||||||
for bitem in items:
|
for bitem in sub_images:
|
||||||
filename = bitem.data(0, QtCore.Qt.UserRole).filename
|
filename = bitem.data(0, QtCore.Qt.UserRole).filename
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
missing_items.append(bitem)
|
missing_items.append(bitem)
|
||||||
missing_items_filenames.append(filename)
|
missing_items_filenames.append(filename)
|
||||||
for item in missing_items:
|
for item in missing_items:
|
||||||
items.remove(item)
|
sub_images.remove(item)
|
||||||
# We cannot continue, as all images do not exist.
|
# We cannot continue, as all images do not exist.
|
||||||
if not items:
|
if not sub_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)'),
|
||||||
@ -587,14 +589,23 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
|
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
|
||||||
translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s\n'
|
translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s\n'
|
||||||
'Do you want to add the other images anyway?') % u'\n'.join(missing_items_filenames),
|
'Do 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:
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == \
|
||||||
|
QtGui.QMessageBox.No:
|
||||||
return False
|
return False
|
||||||
# Continue with the existing images.
|
# Continue with the existing images.
|
||||||
for bitem in items:
|
for sub_image in sub_images:
|
||||||
filename = bitem.data(0, QtCore.Qt.UserRole).filename
|
filename = sub_image.data(0, QtCore.Qt.UserRole).filename
|
||||||
name = os.path.split(filename)[1]
|
name = os.path.split(filename)[1]
|
||||||
service_item.add_from_image(filename, name, background)
|
new_service_item.add_from_image(filename, name, background)
|
||||||
return True
|
# Add the service item to the correct controller
|
||||||
|
if context == ServiceItemContext.Service:
|
||||||
|
self.service_manager.add_service_item(new_service_item)
|
||||||
|
elif context == ServiceItemContext.Preview:
|
||||||
|
self.preview_controller.add_service_item(new_service_item)
|
||||||
|
elif context == ServiceItemContext.Live:
|
||||||
|
self.live_controller.add_service_item(new_service_item)
|
||||||
|
# Return False because we added the service item ourselves
|
||||||
|
return False
|
||||||
|
|
||||||
def check_group_exists(self, new_group):
|
def check_group_exists(self, new_group):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user