Add default option to exclude events from non-controllers in controlled rooms

This commit is contained in:
Et0h 2014-11-30 10:45:22 +00:00
parent b103363e41
commit f2a5d0242e
5 changed files with 51 additions and 26 deletions

View File

@ -596,6 +596,10 @@ class SyncplayUser(object):
def isController(self):
return self._controller
def canControl(self):
if self.isController() or not utils.RoomPasswordProvider.isControlledRoom(self.room):
return True
class SyncplayUserlist(object):
def __init__(self, ui, client):
self.currentUser = SyncplayUser()
@ -616,31 +620,33 @@ class SyncplayUserlist(object):
showOnOSD = constants.SHOW_OSD_WARNINGS
else:
showOnOSD = constants.SHOW_DIFFERENT_ROOM_OSD
if constants.SHOW_NONCONTROLLER_OSD == False and self.canControl(username) == False:
showOnOSD = False
hideFromOSD = not showOnOSD
if room and not file_:
message = getMessage("room-join-notification").format(username, room)
self.ui.showMessage(message, hideFromOSD)
elif room and file_:
duration = utils.formatTime(file_['duration'])
message = getMessage("playing-notification").format(username, file_['name'], duration)
if self.currentUser.room <> room or self.currentUser.username == username:
message += getMessage("playing-notification/room-addendum").format(room)
self.ui.showMessage(message, hideFromOSD)
if self.currentUser.file and not self.currentUser.isFileSame(file_) and self.currentUser.room == room:
message = getMessage("file-different-notification").format(username)
self.ui.showMessage(message, not constants.SHOW_OSD_WARNINGS)
differences = []
differentName = not utils.sameFilename(self.currentUser.file['name'], file_['name'])
differentSize = not utils.sameFilesize(self.currentUser.file['size'], file_['size'])
differentDuration = not utils.sameFileduration(self.currentUser.file['duration'], file_['duration'])
if differentName:
differences.append("filename")
if differentSize:
differences.append("size")
if differentDuration:
differences.append("duration")
message = getMessage("file-differences-notification") + ", ".join(differences)
self.ui.showMessage(message, not constants.SHOW_OSD_WARNINGS)
if not file_:
message = getMessage("room-join-notification").format(username, room)
self.ui.showMessage(message, hideFromOSD)
else:
duration = utils.formatTime(file_['duration'])
message = getMessage("playing-notification").format(username, file_['name'], duration)
if self.currentUser.room <> room or self.currentUser.username == username:
message += getMessage("playing-notification/room-addendum").format(room)
self.ui.showMessage(message, hideFromOSD)
if self.currentUser.file and not self.currentUser.isFileSame(file_) and self.currentUser.room == room:
message = getMessage("file-different-notification").format(username)
self.ui.showMessage(message, hideFromOSD)
differences = []
differentName = not utils.sameFilename(self.currentUser.file['name'], file_['name'])
differentSize = not utils.sameFilesize(self.currentUser.file['size'], file_['size'])
differentDuration = not utils.sameFileduration(self.currentUser.file['duration'], file_['duration'])
if differentName:
differences.append("filename")
if differentSize:
differences.append("size")
if differentDuration:
differences.append("duration")
message = getMessage("file-differences-notification") + ", ".join(differences)
self.ui.showMessage(message, hideFromOSD)
def addUser(self, username, room, file_, noMessage=False, isController=None):
if username == self.currentUser.username:
@ -702,7 +708,7 @@ class SyncplayUserlist(object):
def areAllFilesInRoomSame(self):
for user in self._users.itervalues():
if user.room == self.currentUser.room and user.file and not self.currentUser.isFileSame(user.file):
if user.isController() or not utils.RoomPasswordProvider.isControlledRoom(user.room):
if user.canControl():
return False
return True
@ -718,6 +724,15 @@ class SyncplayUserlist(object):
return True
return False
def canControl(self, username):
if self.currentUser.username == username and self.currentUser.canControl():
return True
for user in self._users.itervalues():
if user.username == username and user.canControl():
return True
return False
def userListChange(self, room = None):
if room is not None and self.isRoomSame(room):
self._roomUsersChanged = True

View File

@ -21,6 +21,7 @@ SHOW_OSD = True # Sends Syncplay messages to media player OSD
SHOW_OSD_WARNINGS = True # Show warnings if playing different file, alone in room
SHOW_SLOWDOWN_OSD = True # Show notifications of slowing down / reverting on time difference
SHOW_SAME_ROOM_OSD = True # Show OSD notifications for events relating to room user is in
SHOW_NONCONTROLLER_OSD = False # Show OSD notifications for non-controllers in controlled rooms
SHOW_DIFFERENT_ROOM_OSD = False # Show OSD notifications for events relating to room user is not in
SHOW_DURATION_NOTIFICATION = True
DEBUG_MODE = False

View File

@ -154,6 +154,7 @@ en = {
"showosdwarnings-label" : "Include warnings (e.g. when files are different)",
"showsameroomosd-label" : "Include events in your room",
"shownoncontrollerosd-label" : "Include events from non-controllers in controlled rooms",
"showdifferentroomosd-label" : "Include events in other rooms",
"showslowdownosd-label" :"Include slowing down / reverting notification",
"showcontactinfo-label" : "Show contact info box",
@ -249,6 +250,7 @@ en = {
"showosd-tooltip" : "Sends Syncplay messages to media player OSD.",
"showosdwarnings-tooltip" : "Show warnings if playing different file, alone in room.",
"showsameroomosd-tooltip" : "Show OSD notifications for events relating to room user is in.",
"shownoncontrollerosd-tooltip" : "Show OSD notifications for events relating to non-controllers who are in controllerd rooms.",
"showdifferentroomosd-tooltip" : "Show OSD notifications for events relating to room user is not in.",
"showslowdownosd-tooltip" :"Show notifications of slowing down / reverting on time difference.",
"showcontactinfo-tooltip" : "Show information box about contacting Syncplay developers in main Syncplay window.",

View File

@ -52,6 +52,7 @@ class ConfigurationGetter(object):
"showSlowdownOSD" : True,
"showDifferentRoomOSD" : False,
"showSameRoomOSD" : True,
"showNonControllerOSD" : False,
"showContactInfo" : True,
"showDurationNotification" : True
}
@ -87,6 +88,7 @@ class ConfigurationGetter(object):
"showSlowdownOSD",
"showDifferentRoomOSD",
"showSameRoomOSD",
"showNonControllerOSD",
"showContactInfo" ,
"showDurationNotification"
]
@ -100,7 +102,7 @@ class ConfigurationGetter(object):
self._iniStructure = {
"server_data": ["host", "port", "password"],
"client_settings": ["name", "room", "playerPath", "slowdownThreshold", "rewindThreshold", "fastforwardThreshold", "slowOnDesync", "rewindOnDesync", "fastforwardOnDesync", "dontSlowDownWithMe", "forceGuiPrompt", "filenamePrivacyMode", "filesizePrivacyMode", "pauseOnLeave"],
"gui": ["showOSD", "showOSDWarnings", "showSlowdownOSD", "showDifferentRoomOSD", "showSameRoomOSD", "showContactInfo" , "showDurationNotification"],
"gui": ["showOSD", "showOSDWarnings", "showSlowdownOSD", "showDifferentRoomOSD", "showSameRoomOSD", "showNonControllerOSD", "showContactInfo" , "showDurationNotification"],
"general": ["language"]
}

View File

@ -551,6 +551,11 @@ class ConfigDialog(QtGui.QDialog):
self.showSameRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "chevrons_right.png"))
self.osdSettingsLayout.addWidget(self.showSameRoomOSDCheckbox)
self.showNonControllerOSDCheckbox = QCheckBox(getMessage("shownoncontrollerosd-label"))
self.showNonControllerOSDCheckbox.setObjectName("showNonControllerOSD")
self.showNonControllerOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "chevrons_right.png"))
self.osdSettingsLayout.addWidget(self.showNonControllerOSDCheckbox)
self.showDifferentRoomOSDCheckbox = QCheckBox(getMessage("showdifferentroomosd-label"))
self.showDifferentRoomOSDCheckbox.setObjectName("showDifferentRoomOSD")
self.showDifferentRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "chevrons_right.png"))