Update playlist UI on external change and show message

This commit is contained in:
Et0h 2015-10-02 00:23:56 +01:00
parent 03bb31eefa
commit d742b04fed
3 changed files with 18 additions and 4 deletions

View File

@ -445,9 +445,8 @@ class SyncplayClient(object):
if username is None and self._protocol and self._protocol.logged:
self._protocol.setPlaylist(files)
elif username != self.getUsername():
pass
# TODO: Display info about playlist change
# TODO: Update UI with new playlist
self.ui.setPlaylist(self._playlist)
self.ui.showMessage(u"{} updated the playlist".format(username))
def __executePrivacySettings(self, filename, size):
if self._config['filenamePrivacyMode'] == PRIVACY_SENDHASHED_MODE:
@ -1197,6 +1196,9 @@ class UiManager(object):
self.lastSecondaryOSDEndTime = None
self.lastError = ""
def setPlaylist(self, newPlaylist):
self.__ui.setPlaylist(newPlaylist)
def showDebugMessage(self, message):
if constants.DEBUG_MODE and message.rstrip():
sys.stderr.write("{}{}\n".format(time.strftime(constants.UI_TIME_FORMAT, time.localtime()),message.rstrip()))

View File

@ -22,6 +22,9 @@ class ConsoleUI(threading.Thread):
def drop(self):
pass
def setPlaylist(self, newPlaylist):
pass
def run(self):
try:

View File

@ -87,6 +87,7 @@ class UserlistItemDelegate(QtGui.QStyledItemDelegate):
class MainWindow(QtGui.QMainWindow):
insertPosition = None
playlistState = []
blockPlaylistUpdateNotifications = False
def setPlaylistInsertPosition(self, newPosition):
if MainWindow.insertPosition <> newPosition:
@ -802,7 +803,7 @@ class MainWindow(QtGui.QMainWindow):
def playlistUpdated(self):
newPlaylist = self.getPlaylistState()
if newPlaylist <> self.playlistState and self._syncplayClient:
if newPlaylist <> self.playlistState and self._syncplayClient and not self.blockPlaylistUpdateNotifications:
self.playlistState = newPlaylist
self._syncplayClient.changePlaylist(newPlaylist)
@ -1207,6 +1208,14 @@ class MainWindow(QtGui.QMainWindow):
self._syncplayClient._player.openFile(dropfilepath, resetPosition=True)
self._syncplayClient.setPosition(0)
def setPlaylist(self, newPlaylist):
if newPlaylist == [] and not self.clearedPlaylistNote:
return
self.blockPlaylistUpdateNotifications = True
self.playlist.clear()
self.playlist.insertItems(0, newPlaylist)
self.blockPlaylistUpdateNotifications = False
def addFileToPlaylist(self, filePath, index = -1):
if os.path.isfile(filePath):
self.removePlaylistNote()