Make public readiness neutral if no file is open

This commit is contained in:
Et0h 2015-02-02 02:17:13 +00:00
parent a8275032a2
commit 92b016ea16
2 changed files with 24 additions and 10 deletions

View File

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

View File

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