From 8ec9eea45dd3f26e6b18313d4741a07d0ba55c3b Mon Sep 17 00:00:00 2001 From: Et0h Date: Sun, 17 Jan 2016 12:51:24 +0000 Subject: [PATCH] Don't prompt users to add duplicate files to playlist --- syncplay/ui/gui.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index 4b882f1..ea5eb41 100644 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -646,7 +646,7 @@ class MainWindow(QtGui.QMainWindow): if roomToJoin <> self._syncplayClient.getRoom(): menu.addAction(u"Join room {}".format(roomToJoin), lambda: self.joinRoom(roomToJoin)) elif username and filename and filename <> getMessage("nofile-note"): - if self.config['sharedPlaylistEnabled']: + if self.config['sharedPlaylistEnabled'] and not self.isItemInPlaylist(filename): if isURL(filename): menu.addAction(QtGui.QPixmap(resourcespath + "world_add.png"), u"Add {} stream to playlist".format(shortUsername), lambda: self.addStreamToPlaylist(filename)) else: @@ -1447,11 +1447,17 @@ class MainWindow(QtGui.QMainWindow): self._syncplayClient._player.openFile(filePath, resetPosition) def noPlaylistDuplicates(self, filename): + if self.isItemInPlaylist(filename): + self.showErrorMessage(u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.".format(filename)) + return False + else: + return True + + def isItemInPlaylist(self, filename): for playlistindex in xrange(self.playlist.count()): if self.playlist.item(playlistindex).text() == filename: - self.showErrorMessage(u"Could not add second entry for '{}' to the playlist as no duplicates are allowed.".format(filename)) - return False - return True + return True + return False def addStreamToPlaylist(self, streamURI): self.removePlaylistNote()