From 92b016ea16d3cad58ef653df2c79e8029bb4c284 Mon Sep 17 00:00:00 2001 From: Et0h Date: Mon, 2 Feb 2015 02:17:13 +0000 Subject: [PATCH] Make public readiness neutral if no file is open --- syncplay/client.py | 26 ++++++++++++++++++++------ syncplay/ui/gui.py | 8 ++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/syncplay/client.py b/syncplay/client.py index 3e329c9..d6d0b8c 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -747,6 +747,11 @@ class SyncplayUser(object): else: return False + def isReadyWithFile(self): + if self.file is None: + return None + return self.ready + def isReady(self): return self.ready @@ -897,13 +902,13 @@ class SyncplayUserlist(object): if not self.currentUser.isReady(): return False for user in self._users.itervalues(): - if user.room == self.currentUser.room and user.isReady() == False: + if user.room == self.currentUser.room and user.isReadyWithFile() == False: return False return True def areAllOtherUsersInRoomReady(self): for user in self._users.itervalues(): - if user.room == self.currentUser.room and user.isReady() == False: + if user.room == self.currentUser.room and user.isReadyWithFile() == False: return False return True @@ -912,14 +917,14 @@ class SyncplayUserlist(object): if self.currentUser.isReady(): readyCount += 1 for user in self._users.itervalues(): - if user.room == self.currentUser.room and user.isReady(): + if user.room == self.currentUser.room and user.isReadyWithFile(): readyCount += 1 return readyCount def usersInRoomCount(self): userCount = 1 for user in self._users.itervalues(): - if user.room == self.currentUser.room and user.isReady(): + if user.room == self.currentUser.room and user.isReadyWithFile(): userCount += 1 return userCount @@ -928,7 +933,7 @@ class SyncplayUserlist(object): if not self.currentUser.isReady(): notReady.append(self.currentUser.username) for user in self._users.itervalues(): - if user.room == self.currentUser.room and user.isReady() == False: + if user.room == self.currentUser.room and user.isReadyWithFile() == False: notReady.append(user.username) return ", ".join(notReady) @@ -948,7 +953,7 @@ class SyncplayUserlist(object): def onlyUserInRoomWhoSupportsReadiness(self): for user in self._users.itervalues(): - if user.room == self.currentUser.room and user.isReady() is not None: + if user.room == self.currentUser.room and user.isReadyWithFile() is not None: return False return True @@ -967,6 +972,15 @@ class SyncplayUserlist(object): return True return False + def isReadyWithFile(self, username): + if self.currentUser.username == username: + return self.currentUser.isReadyWithFile() + + for user in self._users.itervalues(): + if user.username == username: + return user.isReadyWithFile() + return None + def isReady(self, username): if self.currentUser.username == username: return self.currentUser.isReady() diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index f0acfef..bbdb38c 100644 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -148,11 +148,11 @@ class MainWindow(QtGui.QMainWindow): isController = user.isController() sameRoom = room == currentUser.room if sameRoom: - isReady = user.isReady() + isReadyWithFile = user.isReadyWithFile() else: - isReady = None + isReadyWithFile = None useritem.setData(isController, Qt.UserRole + constants.USERITEM_CONTROLLER_ROLE) - useritem.setData(isReady, Qt.UserRole + constants.USERITEM_READY_ROLE) + useritem.setData(isReadyWithFile, Qt.UserRole + constants.USERITEM_READY_ROLE) if user.file: filesizeitem = QtGui.QStandardItem(formatSize(user.file['size'])) filedurationitem = QtGui.QStandardItem("({})".format(formatTime(user.file['duration']))) @@ -184,7 +184,7 @@ class MainWindow(QtGui.QMainWindow): font = QtGui.QFont() if currentUser.username == user.username: font.setWeight(QtGui.QFont.Bold) - self.updateReadyState(currentUser.isReady()) + self.updateReadyState(currentUser.isReadyWithFile()) if isControlledRoom and not isController: useritem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_NOTCONTROLLER_COLOR))) useritem.setFont(font)