Make public readiness neutral if no file is open
This commit is contained in:
parent
a8275032a2
commit
92b016ea16
@ -747,6 +747,11 @@ class SyncplayUser(object):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def isReadyWithFile(self):
|
||||||
|
if self.file is None:
|
||||||
|
return None
|
||||||
|
return self.ready
|
||||||
|
|
||||||
def isReady(self):
|
def isReady(self):
|
||||||
return self.ready
|
return self.ready
|
||||||
|
|
||||||
@ -897,13 +902,13 @@ class SyncplayUserlist(object):
|
|||||||
if not self.currentUser.isReady():
|
if not self.currentUser.isReady():
|
||||||
return False
|
return False
|
||||||
for user in self._users.itervalues():
|
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 False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def areAllOtherUsersInRoomReady(self):
|
def areAllOtherUsersInRoomReady(self):
|
||||||
for user in self._users.itervalues():
|
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 False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -912,14 +917,14 @@ class SyncplayUserlist(object):
|
|||||||
if self.currentUser.isReady():
|
if self.currentUser.isReady():
|
||||||
readyCount += 1
|
readyCount += 1
|
||||||
for user in self._users.itervalues():
|
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
|
readyCount += 1
|
||||||
return readyCount
|
return readyCount
|
||||||
|
|
||||||
def usersInRoomCount(self):
|
def usersInRoomCount(self):
|
||||||
userCount = 1
|
userCount = 1
|
||||||
for user in self._users.itervalues():
|
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
|
userCount += 1
|
||||||
return userCount
|
return userCount
|
||||||
|
|
||||||
@ -928,7 +933,7 @@ class SyncplayUserlist(object):
|
|||||||
if not self.currentUser.isReady():
|
if not self.currentUser.isReady():
|
||||||
notReady.append(self.currentUser.username)
|
notReady.append(self.currentUser.username)
|
||||||
for user in self._users.itervalues():
|
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)
|
notReady.append(user.username)
|
||||||
return ", ".join(notReady)
|
return ", ".join(notReady)
|
||||||
|
|
||||||
@ -948,7 +953,7 @@ class SyncplayUserlist(object):
|
|||||||
|
|
||||||
def onlyUserInRoomWhoSupportsReadiness(self):
|
def onlyUserInRoomWhoSupportsReadiness(self):
|
||||||
for user in self._users.itervalues():
|
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 False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -967,6 +972,15 @@ class SyncplayUserlist(object):
|
|||||||
return True
|
return True
|
||||||
return False
|
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):
|
def isReady(self, username):
|
||||||
if self.currentUser.username == username:
|
if self.currentUser.username == username:
|
||||||
return self.currentUser.isReady()
|
return self.currentUser.isReady()
|
||||||
|
|||||||
@ -148,11 +148,11 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
isController = user.isController()
|
isController = user.isController()
|
||||||
sameRoom = room == currentUser.room
|
sameRoom = room == currentUser.room
|
||||||
if sameRoom:
|
if sameRoom:
|
||||||
isReady = user.isReady()
|
isReadyWithFile = user.isReadyWithFile()
|
||||||
else:
|
else:
|
||||||
isReady = None
|
isReadyWithFile = None
|
||||||
useritem.setData(isController, Qt.UserRole + constants.USERITEM_CONTROLLER_ROLE)
|
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:
|
if user.file:
|
||||||
filesizeitem = QtGui.QStandardItem(formatSize(user.file['size']))
|
filesizeitem = QtGui.QStandardItem(formatSize(user.file['size']))
|
||||||
filedurationitem = QtGui.QStandardItem("({})".format(formatTime(user.file['duration'])))
|
filedurationitem = QtGui.QStandardItem("({})".format(formatTime(user.file['duration'])))
|
||||||
@ -184,7 +184,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
font = QtGui.QFont()
|
font = QtGui.QFont()
|
||||||
if currentUser.username == user.username:
|
if currentUser.username == user.username:
|
||||||
font.setWeight(QtGui.QFont.Bold)
|
font.setWeight(QtGui.QFont.Bold)
|
||||||
self.updateReadyState(currentUser.isReady())
|
self.updateReadyState(currentUser.isReadyWithFile())
|
||||||
if isControlledRoom and not isController:
|
if isControlledRoom and not isController:
|
||||||
useritem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_NOTCONTROLLER_COLOR)))
|
useritem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_NOTCONTROLLER_COLOR)))
|
||||||
useritem.setFont(font)
|
useritem.setFont(font)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user