diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 8b63963a0..e5e8ed3b1 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \ StringContent, build_icon, translate, Receiver, ListWidgetWithDnD from openlp.core.lib.ui import UiStrings, context_menu_action, \ - context_menu_separator + context_menu_separator, critical_error_message_box log = logging.getLogger(__name__) @@ -333,7 +333,21 @@ class MediaManagerItem(QtGui.QWidget): log.info(u'New files(s) %s', unicode(files)) if files: 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] SettingsManager.set_last_dir(self.settingsSection, lastDir) SettingsManager.set_list(self.settingsSection, diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index b544efab9..47776a64b 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -67,6 +67,7 @@ class UiStrings(object): self.Default = unicode(translate('OpenLP.Ui', 'Default')) self.Delete = translate('OpenLP.Ui', '&Delete') self.DisplayStyle = translate('OpenLP.Ui', 'Display style:') + self.Duplicate = translate('OpenLP.Ui', 'Duplicate Error') self.Edit = translate('OpenLP.Ui', '&Edit') self.EmptyField = translate('OpenLP.Ui', 'Empty Field') self.Error = translate('OpenLP.Ui', 'Error') @@ -124,6 +125,7 @@ class UiStrings(object): self.Themes = translate('OpenLP.Ui', 'Themes', 'Plural') self.Tools = translate('OpenLP.Ui', 'Tools') self.Top = translate('OpenLP.Ui', 'Top') + self.UnsupportedFile = translate('OpenLP.Ui', 'Unsupported File') self.VersePerSlide = translate('OpenLP.Ui', 'Verse Per Slide') self.VersePerLine = translate('OpenLP.Ui', 'Verse Per Line') self.Version = translate('OpenLP.Ui', 'Version') diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 68da7fbe1..21b81128d 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -108,7 +108,6 @@ class ImageMediaItem(MediaManagerItem): self.settingsSection, self.getFileList()) def loadList(self, list, initialLoad=False): - Receiver.send_message(u'cursor_busy') if not initialLoad: self.parent.formparent.displayProgressBar(len(list)) for imageFile in list: @@ -127,7 +126,6 @@ class ImageMediaItem(MediaManagerItem): item_name.setIcon(icon) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile)) self.listView.addItem(item_name) - Receiver.send_message(u'cursor_normal') if not initialLoad: self.parent.formparent.finishedProgressBar() diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index e494b9e5e..aa574d029 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -138,10 +138,8 @@ class MediaMediaItem(MediaManagerItem): if not self.mediaStateWait(Phonon.StoppedState): # Due to string freeze, borrow a message from presentations # This will be corrected in 1.9.6 - critical_error_message_box( - translate('PresentationPlugin.MediaItem', 'Unsupported File'), - unicode(translate('PresentationPlugin.MediaItem', - 'Unsupported File'))) + critical_error_message_box(UiStrings().UnsupportedFile, + UiStrings().UnsupportedFile) return False # File too big for processing if os.path.getsize(filename) <= 52428800: # 50MiB @@ -152,15 +150,11 @@ class MediaMediaItem(MediaManagerItem): # Due to string freeze, borrow a message from presentations # This will be corrected in 1.9.6 self.mediaObject.stop() - critical_error_message_box( - translate('PresentationPlugin.MediaItem', - 'Unsupported File'), - unicode(translate('PresentationPlugin.MediaItem', - 'Unsupported File'))) + critical_error_message_box(UiStrings().UnsupportedFile, + UiStrings().UnsupportedFile) return False - self.mediaLength = self.mediaObject.totalTime() / 1000 self.mediaObject.stop() - service_item.media_length = self.mediaLength + service_item.media_length = self.mediaObject.totalTime() / 1000 service_item.add_capability( ItemCapabilities.AllowsVariableStartTime) service_item.title = unicode(self.plugin.nameStrings[u'singular']) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index c3a62e32a..65b85454d 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -193,9 +193,7 @@ class PresentationMediaItem(MediaManagerItem): if initialLoad: icon = build_icon(u':/general/general_delete.png') else: - critical_error_message_box( - translate('PresentationPlugin.MediaItem', - 'Unsupported File'), + critical_error_message_box(UiStrings().UnsupportedFile, translate('PresentationPlugin.MediaItem', 'This type of presentation is not supported.')) continue