forked from openlp/openlp
Prevent duplicate images
bzr-revno: 1509 Fixes: https://launchpad.net/bugs/772080
This commit is contained in:
commit
da996844b7
@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui
|
|||||||
from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \
|
from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \
|
||||||
StringContent, build_icon, translate, Receiver, ListWidgetWithDnD
|
StringContent, build_icon, translate, Receiver, ListWidgetWithDnD
|
||||||
from openlp.core.lib.ui import UiStrings, context_menu_action, \
|
from openlp.core.lib.ui import UiStrings, context_menu_action, \
|
||||||
context_menu_separator
|
context_menu_separator, critical_error_message_box
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -333,7 +333,21 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
log.info(u'New files(s) %s', unicode(files))
|
log.info(u'New files(s) %s', unicode(files))
|
||||||
if files:
|
if files:
|
||||||
Receiver.send_message(u'cursor_busy')
|
Receiver.send_message(u'cursor_busy')
|
||||||
self.loadList(files)
|
names = []
|
||||||
|
for count in range(0, self.listView.count()):
|
||||||
|
names.append(self.listView.item(count).text())
|
||||||
|
newFiles = []
|
||||||
|
for file in files:
|
||||||
|
filename = os.path.split(unicode(file))[1]
|
||||||
|
if filename in names:
|
||||||
|
critical_error_message_box(
|
||||||
|
UiStrings().Duplicate,
|
||||||
|
unicode(translate('OpenLP.MediaManagerItem',
|
||||||
|
'Duplicate file name %s.\nFilename already exists in '
|
||||||
|
'list')) % filename)
|
||||||
|
else:
|
||||||
|
newFiles.append(file)
|
||||||
|
self.loadList(newFiles)
|
||||||
lastDir = os.path.split(unicode(files[0]))[0]
|
lastDir = os.path.split(unicode(files[0]))[0]
|
||||||
SettingsManager.set_last_dir(self.settingsSection, lastDir)
|
SettingsManager.set_last_dir(self.settingsSection, lastDir)
|
||||||
SettingsManager.set_list(self.settingsSection,
|
SettingsManager.set_list(self.settingsSection,
|
||||||
|
@ -67,6 +67,7 @@ class UiStrings(object):
|
|||||||
self.Default = unicode(translate('OpenLP.Ui', 'Default'))
|
self.Default = unicode(translate('OpenLP.Ui', 'Default'))
|
||||||
self.Delete = translate('OpenLP.Ui', '&Delete')
|
self.Delete = translate('OpenLP.Ui', '&Delete')
|
||||||
self.DisplayStyle = translate('OpenLP.Ui', 'Display style:')
|
self.DisplayStyle = translate('OpenLP.Ui', 'Display style:')
|
||||||
|
self.Duplicate = translate('OpenLP.Ui', 'Duplicate Error')
|
||||||
self.Edit = translate('OpenLP.Ui', '&Edit')
|
self.Edit = translate('OpenLP.Ui', '&Edit')
|
||||||
self.EmptyField = translate('OpenLP.Ui', 'Empty Field')
|
self.EmptyField = translate('OpenLP.Ui', 'Empty Field')
|
||||||
self.Error = translate('OpenLP.Ui', 'Error')
|
self.Error = translate('OpenLP.Ui', 'Error')
|
||||||
@ -124,6 +125,7 @@ class UiStrings(object):
|
|||||||
self.Themes = translate('OpenLP.Ui', 'Themes', 'Plural')
|
self.Themes = translate('OpenLP.Ui', 'Themes', 'Plural')
|
||||||
self.Tools = translate('OpenLP.Ui', 'Tools')
|
self.Tools = translate('OpenLP.Ui', 'Tools')
|
||||||
self.Top = translate('OpenLP.Ui', 'Top')
|
self.Top = translate('OpenLP.Ui', 'Top')
|
||||||
|
self.UnsupportedFile = translate('OpenLP.Ui', 'Unsupported File')
|
||||||
self.VersePerSlide = translate('OpenLP.Ui', 'Verse Per Slide')
|
self.VersePerSlide = translate('OpenLP.Ui', 'Verse Per Slide')
|
||||||
self.VersePerLine = translate('OpenLP.Ui', 'Verse Per Line')
|
self.VersePerLine = translate('OpenLP.Ui', 'Verse Per Line')
|
||||||
self.Version = translate('OpenLP.Ui', 'Version')
|
self.Version = translate('OpenLP.Ui', 'Version')
|
||||||
|
@ -108,7 +108,6 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
self.settingsSection, self.getFileList())
|
self.settingsSection, self.getFileList())
|
||||||
|
|
||||||
def loadList(self, list, initialLoad=False):
|
def loadList(self, list, initialLoad=False):
|
||||||
Receiver.send_message(u'cursor_busy')
|
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
self.parent.formparent.displayProgressBar(len(list))
|
self.parent.formparent.displayProgressBar(len(list))
|
||||||
for imageFile in list:
|
for imageFile in list:
|
||||||
@ -127,7 +126,6 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
item_name.setIcon(icon)
|
item_name.setIcon(icon)
|
||||||
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile))
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile))
|
||||||
self.listView.addItem(item_name)
|
self.listView.addItem(item_name)
|
||||||
Receiver.send_message(u'cursor_normal')
|
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
self.parent.formparent.finishedProgressBar()
|
self.parent.formparent.finishedProgressBar()
|
||||||
|
|
||||||
|
@ -138,10 +138,8 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
if not self.mediaStateWait(Phonon.StoppedState):
|
if not self.mediaStateWait(Phonon.StoppedState):
|
||||||
# Due to string freeze, borrow a message from presentations
|
# Due to string freeze, borrow a message from presentations
|
||||||
# This will be corrected in 1.9.6
|
# This will be corrected in 1.9.6
|
||||||
critical_error_message_box(
|
critical_error_message_box(UiStrings().UnsupportedFile,
|
||||||
translate('PresentationPlugin.MediaItem', 'Unsupported File'),
|
UiStrings().UnsupportedFile)
|
||||||
unicode(translate('PresentationPlugin.MediaItem',
|
|
||||||
'Unsupported File')))
|
|
||||||
return False
|
return False
|
||||||
# File too big for processing
|
# File too big for processing
|
||||||
if os.path.getsize(filename) <= 52428800: # 50MiB
|
if os.path.getsize(filename) <= 52428800: # 50MiB
|
||||||
@ -152,15 +150,11 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
# Due to string freeze, borrow a message from presentations
|
# Due to string freeze, borrow a message from presentations
|
||||||
# This will be corrected in 1.9.6
|
# This will be corrected in 1.9.6
|
||||||
self.mediaObject.stop()
|
self.mediaObject.stop()
|
||||||
critical_error_message_box(
|
critical_error_message_box(UiStrings().UnsupportedFile,
|
||||||
translate('PresentationPlugin.MediaItem',
|
UiStrings().UnsupportedFile)
|
||||||
'Unsupported File'),
|
|
||||||
unicode(translate('PresentationPlugin.MediaItem',
|
|
||||||
'Unsupported File')))
|
|
||||||
return False
|
return False
|
||||||
self.mediaLength = self.mediaObject.totalTime() / 1000
|
|
||||||
self.mediaObject.stop()
|
self.mediaObject.stop()
|
||||||
service_item.media_length = self.mediaLength
|
service_item.media_length = self.mediaObject.totalTime() / 1000
|
||||||
service_item.add_capability(
|
service_item.add_capability(
|
||||||
ItemCapabilities.AllowsVariableStartTime)
|
ItemCapabilities.AllowsVariableStartTime)
|
||||||
service_item.title = unicode(self.plugin.nameStrings[u'singular'])
|
service_item.title = unicode(self.plugin.nameStrings[u'singular'])
|
||||||
|
@ -193,9 +193,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
if initialLoad:
|
if initialLoad:
|
||||||
icon = build_icon(u':/general/general_delete.png')
|
icon = build_icon(u':/general/general_delete.png')
|
||||||
else:
|
else:
|
||||||
critical_error_message_box(
|
critical_error_message_box(UiStrings().UnsupportedFile,
|
||||||
translate('PresentationPlugin.MediaItem',
|
|
||||||
'Unsupported File'),
|
|
||||||
translate('PresentationPlugin.MediaItem',
|
translate('PresentationPlugin.MediaItem',
|
||||||
'This type of presentation is not supported.'))
|
'This type of presentation is not supported.'))
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user