diff --git a/buildPy2exe.py b/buildPy2exe.py index 5b108d0..6e4269d 100644 --- a/buildPy2exe.py +++ b/buildPy2exe.py @@ -653,7 +653,7 @@ guiIcons = ['resources/accept.png', 'resources/arrow_undo.png', 'resources/clock 'resources/eye.png', 'resources/comments.png', 'resources/cog_delete.png', 'resources/chevrons_right.png', 'resources/user_key.png', 'resources/lock.png', 'resources/key_go.png', 'resources/page_white_key.png', 'resources/tick.png', 'resources/lock_open.png', 'resources/empty_checkbox.png', 'resources/tick_checkbox.png', - 'resources/world_explore.png', 'resources/application_get.png', 'resources/cog.png', + 'resources/world_explore.png', 'resources/application_get.png', 'resources/cog.png', 'resources/arrow_switch.png', 'resources/film_go.png', 'resources/world_go.png', 'resources/arrow_refresh.png', 'resources/bullet_right_grey.png', 'resources/world_add.png', 'resources/film_add.png', 'resources/delete.png' ] diff --git a/resources/arrow_switch.png b/resources/arrow_switch.png new file mode 100644 index 0000000..258c16c Binary files /dev/null and b/resources/arrow_switch.png differ diff --git a/syncplay/client.py b/syncplay/client.py index 3eb91d0..5898e70 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -4,6 +4,7 @@ import time import re import sys import ast +import random from twisted.internet.protocol import ClientFactory from twisted.internet import reactor, task, defer from functools import wraps @@ -529,6 +530,16 @@ class SyncplayClient(object): self.changePlaylist(self._previousPlaylist) self._previousPlaylist = undidPlaylist + def shufflePlaylist(self): + if self._playlist and len(self._playlist) > 0: + oldPlaylist = self._playlist + random.seed() + shuffledPlaylist = deepcopy(self._playlist) + random.shuffle(shuffledPlaylist) + self.ui.setPlaylist(shuffledPlaylist) + self.changePlaylist(shuffledPlaylist) + self._previousPlaylist = oldPlaylist + def __executePrivacySettings(self, filename, size): if self._config['filenamePrivacyMode'] == PRIVACY_SENDHASHED_MODE: filename = utils.hashFilename(filename) @@ -564,7 +575,6 @@ class SyncplayClient(object): if username and username <> "": self.userlist.currentUser.username = username else: - import random random.seed() random_number = random.randrange(1000, 9999) self.userlist.currentUser.username = "Anonymous" + str(random_number) # Not localised as this would give away locale diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index e664a83..d2e7c48 100644 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -575,6 +575,10 @@ class MainWindow(QtGui.QMainWindow): def undoPlaylistChange(self): self._syncplayClient.undoPlaylistChange() + @needsClient + def shufflePlaylist(self): + self._syncplayClient.shufflePlaylist() + def openPlaylistMenu(self, position): indexes = self.playlist.selectedIndexes() if sys.platform.startswith('win'): @@ -598,6 +602,7 @@ class MainWindow(QtGui.QMainWindow): menu.addAction(QtGui.QPixmap(resourcespath + "film_go.png"), "Open file", lambda: self.openFile(pathFound)) menu.addAction(QtGui.QPixmap(resourcespath + "delete.png"), "Remove from playlist", lambda: self.deleteSelectedPlaylistItems()) menu.addSeparator() + menu.addAction(QtGui.QPixmap(resourcespath + "arrow_switch.png"), "Shuffle playlist", lambda: self.shufflePlaylist()) menu.addAction(QtGui.QPixmap(resourcespath + "arrow_undo.png"), "Undo last change to playlist", lambda: self.undoPlaylistChange()) menu.exec_(self.playlist.viewport().mapToGlobal(position)) @@ -1335,7 +1340,7 @@ class MainWindow(QtGui.QMainWindow): if newPlaylist == self.playlistState: return self.updatingPlaylist = True - if len(newPlaylist) > 0: + if newPlaylist and len(newPlaylist) > 0: self.clearedPlaylistNote = True self.playlistState = newPlaylist self.playlist.updatePlaylist(newPlaylist)