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

View File

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

View File

@ -52,6 +52,7 @@ class ConfigurationGetter(object):
"showSlowdownOSD" : True, "showSlowdownOSD" : True,
"showDifferentRoomOSD" : False, "showDifferentRoomOSD" : False,
"showSameRoomOSD" : True, "showSameRoomOSD" : True,
"showNonControllerOSD" : False,
"showContactInfo" : True, "showContactInfo" : True,
"showDurationNotification" : True "showDurationNotification" : True
} }
@ -87,6 +88,7 @@ class ConfigurationGetter(object):
"showSlowdownOSD", "showSlowdownOSD",
"showDifferentRoomOSD", "showDifferentRoomOSD",
"showSameRoomOSD", "showSameRoomOSD",
"showNonControllerOSD",
"showContactInfo" , "showContactInfo" ,
"showDurationNotification" "showDurationNotification"
] ]
@ -100,7 +102,7 @@ class ConfigurationGetter(object):
self._iniStructure = { self._iniStructure = {
"server_data": ["host", "port", "password"], "server_data": ["host", "port", "password"],
"client_settings": ["name", "room", "playerPath", "slowdownThreshold", "rewindThreshold", "fastforwardThreshold", "slowOnDesync", "rewindOnDesync", "fastforwardOnDesync", "dontSlowDownWithMe", "forceGuiPrompt", "filenamePrivacyMode", "filesizePrivacyMode", "pauseOnLeave"], "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"] "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.showSameRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "chevrons_right.png"))
self.osdSettingsLayout.addWidget(self.showSameRoomOSDCheckbox) 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 = QCheckBox(getMessage("showdifferentroomosd-label"))
self.showDifferentRoomOSDCheckbox.setObjectName("showDifferentRoomOSD") self.showDifferentRoomOSDCheckbox.setObjectName("showDifferentRoomOSD")
self.showDifferentRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "chevrons_right.png")) self.showDifferentRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "chevrons_right.png"))