Split shuffle into 'entire' and 'remaining' to address #153 (suggested by xNinjaKittyx)

This commit is contained in:
Etoh 2017-11-05 15:52:34 +00:00
parent 173912914c
commit b1cdceec74
6 changed files with 28 additions and 8 deletions

View File

@ -1,4 +1,4 @@
version = '1.5.0'
milestone = 'Yoitsu'
release_number = '43'
release_number = '44'
projectURL = 'http://syncplay.pl/'

View File

@ -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

View File

@ -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",

View File

@ -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",

View File

@ -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"Добавить ссылку в очередь",

View File

@ -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())