forked from openlp/openlp
Add missing file check to Presentations and Media
bzr-revno: 2103
This commit is contained in:
commit
8a70f5fba7
|
@ -47,6 +47,7 @@ CLAPPERBOARD = u':/media/slidecontroller_multimedia.png'
|
||||||
VIDEO = QtGui.QImage(u':/media/media_video.png')
|
VIDEO = QtGui.QImage(u':/media/media_video.png')
|
||||||
AUDIO = QtGui.QImage(u':/media/media_audio.png')
|
AUDIO = QtGui.QImage(u':/media/media_audio.png')
|
||||||
DVD_ICON = QtGui.QImage(u':/media/media_video.png')
|
DVD_ICON = QtGui.QImage(u':/media/media_video.png')
|
||||||
|
ERROR = QtGui.QImage(u':/general/general_delete.png')
|
||||||
|
|
||||||
class MediaMediaItem(MediaManagerItem):
|
class MediaMediaItem(MediaManagerItem):
|
||||||
"""
|
"""
|
||||||
|
@ -292,7 +293,12 @@ class MediaMediaItem(MediaManagerItem):
|
||||||
key=lambda filename: os.path.split(unicode(filename))[1])
|
key=lambda filename: os.path.split(unicode(filename))[1])
|
||||||
for track in media:
|
for track in media:
|
||||||
track_info = QtCore.QFileInfo(track)
|
track_info = QtCore.QFileInfo(track)
|
||||||
if track_info.isFile():
|
if not os.path.exists(track):
|
||||||
|
filename = os.path.split(unicode(track))[1]
|
||||||
|
item_name = QtGui.QListWidgetItem(filename)
|
||||||
|
item_name.setIcon(build_icon(ERROR))
|
||||||
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(track))
|
||||||
|
elif track_info.isFile():
|
||||||
filename = os.path.split(unicode(track))[1]
|
filename = os.path.split(unicode(track))[1]
|
||||||
item_name = QtGui.QListWidgetItem(filename)
|
item_name = QtGui.QListWidgetItem(filename)
|
||||||
item_name.setIcon(build_icon(VIDEO))
|
item_name.setIcon(build_icon(VIDEO))
|
||||||
|
|
|
@ -43,6 +43,8 @@ from openlp.plugins.presentations.lib import MessageListener
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
ERROR = QtGui.QImage(u':/general/general_delete.png')
|
||||||
|
|
||||||
class PresentationMediaItem(MediaManagerItem):
|
class PresentationMediaItem(MediaManagerItem):
|
||||||
"""
|
"""
|
||||||
This is the Presentation media manager item for Presentation Items.
|
This is the Presentation media manager item for Presentation Items.
|
||||||
|
@ -180,44 +182,53 @@ class PresentationMediaItem(MediaManagerItem):
|
||||||
if currlist.count(file) > 0:
|
if currlist.count(file) > 0:
|
||||||
continue
|
continue
|
||||||
filename = os.path.split(unicode(file))[1]
|
filename = os.path.split(unicode(file))[1]
|
||||||
if titles.count(filename) > 0:
|
if not os.path.exists(file):
|
||||||
if not initialLoad:
|
item_name = QtGui.QListWidgetItem(filename)
|
||||||
critical_error_message_box(
|
item_name.setIcon(build_icon(ERROR))
|
||||||
translate('PresentationPlugin.MediaItem',
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
||||||
'File Exists'),
|
item_name.setToolTip(file)
|
||||||
translate('PresentationPlugin.MediaItem',
|
self.listView.addItem(item_name)
|
||||||
'A presentation with that filename already exists.'))
|
|
||||||
continue
|
|
||||||
controller_name = self.findControllerByType(filename)
|
|
||||||
if controller_name:
|
|
||||||
controller = self.controllers[controller_name]
|
|
||||||
doc = controller.add_document(unicode(file))
|
|
||||||
thumb = os.path.join(doc.get_thumbnail_folder(), u'icon.png')
|
|
||||||
preview = doc.get_thumbnail_path(1, True)
|
|
||||||
if not preview and not initialLoad:
|
|
||||||
doc.load_presentation()
|
|
||||||
preview = doc.get_thumbnail_path(1, True)
|
|
||||||
doc.close_presentation()
|
|
||||||
if not (preview and os.path.exists(preview)):
|
|
||||||
icon = build_icon(u':/general/general_delete.png')
|
|
||||||
else:
|
|
||||||
if validate_thumb(preview, thumb):
|
|
||||||
icon = build_icon(thumb)
|
|
||||||
else:
|
|
||||||
icon = create_thumb(preview, thumb)
|
|
||||||
else:
|
else:
|
||||||
if initialLoad:
|
if titles.count(filename) > 0:
|
||||||
icon = build_icon(u':/general/general_delete.png')
|
if not initialLoad:
|
||||||
else:
|
critical_error_message_box(
|
||||||
critical_error_message_box(UiStrings().UnsupportedFile,
|
translate('PresentationPlugin.MediaItem',
|
||||||
translate('PresentationPlugin.MediaItem',
|
'File Exists'),
|
||||||
'This type of presentation is not supported.'))
|
translate('PresentationPlugin.MediaItem',
|
||||||
|
'A presentation with that filename already exists.')
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
item_name = QtGui.QListWidgetItem(filename)
|
controller_name = self.findControllerByType(filename)
|
||||||
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
if controller_name:
|
||||||
item_name.setIcon(icon)
|
controller = self.controllers[controller_name]
|
||||||
item_name.setToolTip(file)
|
doc = controller.add_document(unicode(file))
|
||||||
self.listView.addItem(item_name)
|
thumb = os.path.join(doc.get_thumbnail_folder(),
|
||||||
|
u'icon.png')
|
||||||
|
preview = doc.get_thumbnail_path(1, True)
|
||||||
|
if not preview and not initialLoad:
|
||||||
|
doc.load_presentation()
|
||||||
|
preview = doc.get_thumbnail_path(1, True)
|
||||||
|
doc.close_presentation()
|
||||||
|
if not (preview and os.path.exists(preview)):
|
||||||
|
icon = build_icon(u':/general/general_delete.png')
|
||||||
|
else:
|
||||||
|
if validate_thumb(preview, thumb):
|
||||||
|
icon = build_icon(thumb)
|
||||||
|
else:
|
||||||
|
icon = create_thumb(preview, thumb)
|
||||||
|
else:
|
||||||
|
if initialLoad:
|
||||||
|
icon = build_icon(u':/general/general_delete.png')
|
||||||
|
else:
|
||||||
|
critical_error_message_box(UiStrings().UnsupportedFile,
|
||||||
|
translate('PresentationPlugin.MediaItem',
|
||||||
|
'This type of presentation is not supported.'))
|
||||||
|
continue
|
||||||
|
item_name = QtGui.QListWidgetItem(filename)
|
||||||
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
||||||
|
item_name.setIcon(icon)
|
||||||
|
item_name.setToolTip(file)
|
||||||
|
self.listView.addItem(item_name)
|
||||||
Receiver.send_message(u'cursor_normal')
|
Receiver.send_message(u'cursor_normal')
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
self.plugin.formParent.finishedProgressBar()
|
self.plugin.formParent.finishedProgressBar()
|
||||||
|
|
Loading…
Reference in New Issue