mirror of https://github.com/Syncplay/syncplay
Shuffle playlist feature
This commit is contained in:
parent
cf1b2edf4a
commit
bb875fddf9
|
@ -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/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/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/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/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'
|
'resources/world_add.png', 'resources/film_add.png', 'resources/delete.png'
|
||||||
]
|
]
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 683 B |
|
@ -4,6 +4,7 @@ import time
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import ast
|
import ast
|
||||||
|
import random
|
||||||
from twisted.internet.protocol import ClientFactory
|
from twisted.internet.protocol import ClientFactory
|
||||||
from twisted.internet import reactor, task, defer
|
from twisted.internet import reactor, task, defer
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
@ -529,6 +530,16 @@ class SyncplayClient(object):
|
||||||
self.changePlaylist(self._previousPlaylist)
|
self.changePlaylist(self._previousPlaylist)
|
||||||
self._previousPlaylist = undidPlaylist
|
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):
|
def __executePrivacySettings(self, filename, size):
|
||||||
if self._config['filenamePrivacyMode'] == PRIVACY_SENDHASHED_MODE:
|
if self._config['filenamePrivacyMode'] == PRIVACY_SENDHASHED_MODE:
|
||||||
filename = utils.hashFilename(filename)
|
filename = utils.hashFilename(filename)
|
||||||
|
@ -564,7 +575,6 @@ class SyncplayClient(object):
|
||||||
if username and username <> "":
|
if username and username <> "":
|
||||||
self.userlist.currentUser.username = username
|
self.userlist.currentUser.username = username
|
||||||
else:
|
else:
|
||||||
import random
|
|
||||||
random.seed()
|
random.seed()
|
||||||
random_number = random.randrange(1000, 9999)
|
random_number = random.randrange(1000, 9999)
|
||||||
self.userlist.currentUser.username = "Anonymous" + str(random_number) # Not localised as this would give away locale
|
self.userlist.currentUser.username = "Anonymous" + str(random_number) # Not localised as this would give away locale
|
||||||
|
|
|
@ -575,6 +575,10 @@ class MainWindow(QtGui.QMainWindow):
|
||||||
def undoPlaylistChange(self):
|
def undoPlaylistChange(self):
|
||||||
self._syncplayClient.undoPlaylistChange()
|
self._syncplayClient.undoPlaylistChange()
|
||||||
|
|
||||||
|
@needsClient
|
||||||
|
def shufflePlaylist(self):
|
||||||
|
self._syncplayClient.shufflePlaylist()
|
||||||
|
|
||||||
def openPlaylistMenu(self, position):
|
def openPlaylistMenu(self, position):
|
||||||
indexes = self.playlist.selectedIndexes()
|
indexes = self.playlist.selectedIndexes()
|
||||||
if sys.platform.startswith('win'):
|
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 + "film_go.png"), "Open file", lambda: self.openFile(pathFound))
|
||||||
menu.addAction(QtGui.QPixmap(resourcespath + "delete.png"), "Remove from playlist", lambda: self.deleteSelectedPlaylistItems())
|
menu.addAction(QtGui.QPixmap(resourcespath + "delete.png"), "Remove from playlist", lambda: self.deleteSelectedPlaylistItems())
|
||||||
menu.addSeparator()
|
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.addAction(QtGui.QPixmap(resourcespath + "arrow_undo.png"), "Undo last change to playlist", lambda: self.undoPlaylistChange())
|
||||||
menu.exec_(self.playlist.viewport().mapToGlobal(position))
|
menu.exec_(self.playlist.viewport().mapToGlobal(position))
|
||||||
|
|
||||||
|
@ -1335,7 +1340,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||||
if newPlaylist == self.playlistState:
|
if newPlaylist == self.playlistState:
|
||||||
return
|
return
|
||||||
self.updatingPlaylist = True
|
self.updatingPlaylist = True
|
||||||
if len(newPlaylist) > 0:
|
if newPlaylist and len(newPlaylist) > 0:
|
||||||
self.clearedPlaylistNote = True
|
self.clearedPlaylistNote = True
|
||||||
self.playlistState = newPlaylist
|
self.playlistState = newPlaylist
|
||||||
self.playlist.updatePlaylist(newPlaylist)
|
self.playlist.updatePlaylist(newPlaylist)
|
||||||
|
|
Loading…
Reference in New Issue