From b1cdceec748c184c9b6f42addbf5c1c00210b201 Mon Sep 17 00:00:00 2001 From: Etoh Date: Sun, 5 Nov 2017 15:52:34 +0000 Subject: [PATCH] Split shuffle into 'entire' and 'remaining' to address #153 (suggested by xNinjaKittyx) --- syncplay/__init__.py | 2 +- syncplay/client.py | 14 +++++++++++++- syncplay/messages_de.py | 3 ++- syncplay/messages_en.py | 3 ++- syncplay/messages_ru.py | 3 ++- syncplay/ui/gui.py | 11 ++++++++--- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/syncplay/__init__.py b/syncplay/__init__.py index c36fc87..514ae90 100644 --- a/syncplay/__init__.py +++ b/syncplay/__init__.py @@ -1,4 +1,4 @@ version = '1.5.0' milestone = 'Yoitsu' -release_number = '43' +release_number = '44' projectURL = 'http://syncplay.pl/' diff --git a/syncplay/client.py b/syncplay/client.py index 0cbbedf..fa73d9e 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -1584,11 +1584,23 @@ class SyncplayPlaylist(): self.changePlaylist(newPlaylist, username=None) @needsSharedPlaylistsEnabled - def shufflePlaylist(self): + def shuffleRemainingPlaylist(self): + if self._playlist and len(self._playlist) > 0: + shuffledPlaylist = deepcopy(self._playlist) + shufflePoint = self._playlistIndex + 1 + partToKeep = shuffledPlaylist[:shufflePoint] + partToShuffle = shuffledPlaylist[shufflePoint:] + random.shuffle(partToShuffle) + shuffledPlaylist = partToKeep + partToShuffle + self.changePlaylist(shuffledPlaylist, username=None, resetIndex=False) + + @needsSharedPlaylistsEnabled + def shuffleEntirePlaylist(self): if self._playlist and len(self._playlist) > 0: shuffledPlaylist = deepcopy(self._playlist) random.shuffle(shuffledPlaylist) self.changePlaylist(shuffledPlaylist, username=None, resetIndex=True) + self.switchToNewPlaylistIndex(0, resetPosition=True) def canUndoPlaylist(self, currentPlaylist): return self._previousPlaylist is not None and currentPlaylist <> self._previousPlaylist diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index fb4bd50..f9887e9 100644 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -412,7 +412,8 @@ de = { "cannot-add-unsafe-path-error" : u"Could not automatically load {} because it is not on a trusted domain. You can switch to the URL manually by double clicking it in the playlist, and add trusted domains via File->Advanced->Set Trusted Domains. If you right click on a URL then you can add its domain as a trusted domain via the context menu.", # Filename "sharedplaylistenabled-label" : u"Enable shared playlists", "removefromplaylist-menu-label" : u"Remove from playlist", - "shuffleplaylist-menuu-label" : u"Shuffle playlist", + "shuffleremainingplaylist-menu-label" : u"Shuffle remaining playlist", + "shuffleentireplaylist-menuu-label" : u"Shuffle entire playlist", "undoplaylist-menu-label" : u"Undo last change to playlist", "addfilestoplaylist-menu-label" : u"Add file(s) to bottom of playlist", "addurlstoplaylist-menu-label" : u"Add URL(s) to bottom of playlist", diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index 105bebf..7140d9c 100644 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -411,7 +411,8 @@ en = { "cannot-add-unsafe-path-error" : u"Could not automatically load {} because it is not on a trusted domain. You can switch to the URL manually by double clicking it in the playlist, and add trusted domains via File->Advanced->Set Trusted Domains. If you right click on a URL then you can add its domain as a trusted domain via the context menu.", # Filename "sharedplaylistenabled-label" : u"Enable shared playlists", "removefromplaylist-menu-label" : u"Remove from playlist", - "shuffleplaylist-menuu-label" : u"Shuffle playlist", + "shuffleremainingplaylist-menu-label" : u"Shuffle remaining playlist", + "shuffleentireplaylist-menuu-label" : u"Shuffle entire playlist", "undoplaylist-menu-label" : u"Undo last change to playlist", "addfilestoplaylist-menu-label" : u"Add file(s) to bottom of playlist", "addurlstoplaylist-menu-label" : u"Add URL(s) to bottom of playlist", diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index 31cef89..c00e07d 100644 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -411,7 +411,8 @@ ru = { "cannot-add-unsafe-path-error" : u"Не удалось автоматически переключиться на {}, потому что ссылка не соответствует доверенным сайтам. Её можно включить вручную, дважны кливнув по ссылке в списке воспроизведения. Добавить доверенный сайт можно в выпадающем меню 'Дополнительно' или просто кликнув по ссылке правой кнопкой мыши.", # Filename "sharedplaylistenabled-label" : u"Включить общий список воспроизведения", "removefromplaylist-menu-label" : u"Удалить", - "shuffleplaylist-menuu-label" : u"Перемешать список", + "shufflepremaininglaylist-menuu-label" : u"Shuffle remaining playlist", # Was: Перемешать список # TODO: Translate + "shuffleentireplaylist-menuu-label" : u"Shuffle entire playlist", # TODO: Translate "undoplaylist-menu-label" : u"Отменить последнее действие", "addfilestoplaylist-menu-label" : u"Добавить файлы в очередь", "addurlstoplaylist-menu-label" : u"Добавить ссылку в очередь", diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index 8b6c506..583e340 100755 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -554,8 +554,12 @@ class MainWindow(QtGui.QMainWindow): self._syncplayClient.playlist.undoPlaylistChange() @needsClient - def shufflePlaylist(self): - self._syncplayClient.playlist.shufflePlaylist() + def shuffleRemainingPlaylist(self): + self._syncplayClient.playlist.shuffleRemainingPlaylist() + + @needsClient + def shuffleEntirePlaylist(self): + self._syncplayClient.playlist.shuffleEntirePlaylist() @needsClient def openPlaylistMenu(self, position): @@ -587,7 +591,8 @@ class MainWindow(QtGui.QMainWindow): menu.addAction(QtGui.QPixmap(resourcespath + u"shield_add.png"),getMessage("addtrusteddomain-menu-label").format(domain), lambda: self.addTrustedDomain(domain)) menu.addAction(QtGui.QPixmap(resourcespath + u"delete.png"), getMessage("removefromplaylist-menu-label"), lambda: self.deleteSelectedPlaylistItems()) menu.addSeparator() - menu.addAction(QtGui.QPixmap(resourcespath + u"arrow_switch.png"), getMessage("shuffleplaylist-menuu-label"), lambda: self.shufflePlaylist()) + menu.addAction(QtGui.QPixmap(resourcespath + u"arrow_switch.png"), getMessage("shuffleremainingplaylist-menu-label"), lambda: self.shuffleRemainingPlaylist()) + menu.addAction(QtGui.QPixmap(resourcespath + u"arrow_switch.png"), getMessage("shuffleentireplaylist-menuu-label"), lambda: self.shuffleEntirePlaylist()) menu.addAction(QtGui.QPixmap(resourcespath + u"arrow_undo.png"), getMessage("undoplaylist-menu-label"), lambda: self.undoPlaylistChange()) menu.addAction(QtGui.QPixmap(resourcespath + u"film_edit.png"), getMessage("editplaylist-menu-label"), lambda: self.openEditPlaylistDialog()) menu.addAction(QtGui.QPixmap(resourcespath + u"film_add.png"),getMessage("addfilestoplaylist-menu-label"), lambda: self.OpenAddFilesToPlaylistDialog())