From f2a5d0242efcd41ee32baf4a70c611def8abd6b6 Mon Sep 17 00:00:00 2001 From: Et0h Date: Sun, 30 Nov 2014 10:45:22 +0000 Subject: [PATCH] Add default option to exclude events from non-controllers in controlled rooms --- syncplay/client.py | 65 ++++++++++++++++++------------ syncplay/constants.py | 1 + syncplay/messages.py | 2 + syncplay/ui/ConfigurationGetter.py | 4 +- syncplay/ui/GuiConfiguration.py | 5 +++ 5 files changed, 51 insertions(+), 26 deletions(-) diff --git a/syncplay/client.py b/syncplay/client.py index 5e59412..329b774 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -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 diff --git a/syncplay/constants.py b/syncplay/constants.py index 491fbdd..caddbaa 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -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 diff --git a/syncplay/messages.py b/syncplay/messages.py index 2d4126d..82e244b 100755 --- a/syncplay/messages.py +++ b/syncplay/messages.py @@ -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.", diff --git a/syncplay/ui/ConfigurationGetter.py b/syncplay/ui/ConfigurationGetter.py index e85b245..37d18f4 100755 --- a/syncplay/ui/ConfigurationGetter.py +++ b/syncplay/ui/ConfigurationGetter.py @@ -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"] } diff --git a/syncplay/ui/GuiConfiguration.py b/syncplay/ui/GuiConfiguration.py index 45a79a2..c947183 100644 --- a/syncplay/ui/GuiConfiguration.py +++ b/syncplay/ui/GuiConfiguration.py @@ -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"))