From 3b2bb2726a1573783ceeb8c8755e3d3bf2c9e8ef Mon Sep 17 00:00:00 2001 From: et0h Date: Sun, 7 Nov 2021 16:11:10 +0000 Subject: [PATCH] Allow hiding of empty persistent rooms (#434) --- syncplay/messages_de.py | 1 + syncplay/messages_en.py | 1 + syncplay/messages_es.py | 1 + syncplay/messages_it.py | 1 + syncplay/messages_pt_BR.py | 1 + syncplay/messages_pt_PT.py | 1 + syncplay/messages_ru.py | 1 + syncplay/messages_tr.py | 1 + syncplay/ui/gui.py | 22 ++++++++++++++++++++++ 9 files changed, 30 insertions(+) diff --git a/syncplay/messages_de.py b/syncplay/messages_de.py index 5716501b..d3efe864 100755 --- a/syncplay/messages_de.py +++ b/syncplay/messages_de.py @@ -288,6 +288,7 @@ "autoplay-menu-label": "Auto-Play-Knopf anzeigen", "autoplay-guipushbuttonlabel": "Automatisch abspielen wenn alle bereit sind", "autoplay-minimum-label": "Minimum an Nutzern:", + "hideemptyrooms-menu-label": "Hide empty persistent rooms", # TODO: Translate "sendmessage-label": "Senden", diff --git a/syncplay/messages_en.py b/syncplay/messages_en.py index d1d8569c..8daae25f 100755 --- a/syncplay/messages_en.py +++ b/syncplay/messages_en.py @@ -292,6 +292,7 @@ "autoplay-menu-label": "Show auto-play button", "autoplay-guipushbuttonlabel": "Play when all ready", "autoplay-minimum-label": "Min users:", + "hideemptyrooms-menu-label": "Hide empty persistent rooms", "sendmessage-label": "Send", diff --git a/syncplay/messages_es.py b/syncplay/messages_es.py index b1a29c81..efe8f8cf 100644 --- a/syncplay/messages_es.py +++ b/syncplay/messages_es.py @@ -291,6 +291,7 @@ "autoplay-menu-label": "Mostrar botón de auto-reproducción", "autoplay-guipushbuttonlabel": "Reproducir cuando todos estén listos", "autoplay-minimum-label": "Mín. de usuarios:", + "hideemptyrooms-menu-label": "Hide empty persistent rooms", # TODO: Translate "sendmessage-label": "Enviar", diff --git a/syncplay/messages_it.py b/syncplay/messages_it.py index d3738af8..9a38b5f4 100755 --- a/syncplay/messages_it.py +++ b/syncplay/messages_it.py @@ -291,6 +291,7 @@ "autoplay-menu-label": "Mostra il tasto di riproduzione automatica", "autoplay-guipushbuttonlabel": "Riproduci quando tutti sono pronti", "autoplay-minimum-label": "Minimo utenti pronti:", + "hideemptyrooms-menu-label": "Hide empty persistent rooms", # TODO: Translate "sendmessage-label": "Invia", diff --git a/syncplay/messages_pt_BR.py b/syncplay/messages_pt_BR.py index 24fe2ba3..ec7b8685 100644 --- a/syncplay/messages_pt_BR.py +++ b/syncplay/messages_pt_BR.py @@ -292,6 +292,7 @@ "autoplay-menu-label": "Mostrar botão de reprodução automática", "autoplay-guipushbuttonlabel": "Tocar quando todos estiverem prontos", "autoplay-minimum-label": "Mín. de usuários:", + "hideemptyrooms-menu-label": "Hide empty persistent rooms", # TODO: Translate "sendmessage-label": "Enviar", diff --git a/syncplay/messages_pt_PT.py b/syncplay/messages_pt_PT.py index 3a608b5d..aae0f40d 100644 --- a/syncplay/messages_pt_PT.py +++ b/syncplay/messages_pt_PT.py @@ -290,6 +290,7 @@ "autoplay-menu-label": "Mostrar botão de reprodução automática", "autoplay-guipushbuttonlabel": "Tocar quando todos estiverem prontos", "autoplay-minimum-label": "Mín. de utilizadores:", + "hideemptyrooms-menu-label": "Hide empty persistent rooms", # TODO: Translate "sendmessage-label": "Enviar", diff --git a/syncplay/messages_ru.py b/syncplay/messages_ru.py index 9afeb3e7..76236c35 100755 --- a/syncplay/messages_ru.py +++ b/syncplay/messages_ru.py @@ -291,6 +291,7 @@ "autoplay-menu-label": "Показывать кнопку &автовоспроизведения", "autoplay-guipushbuttonlabel": "Стартовать, когда все будут готовы", "autoplay-minimum-label": "Минимум зрителей:", + "hideemptyrooms-menu-label": "Hide empty persistent rooms", # TODO: Translate "sendmessage-label": "Выслать", "ready-guipushbuttonlabel": "Я готов", diff --git a/syncplay/messages_tr.py b/syncplay/messages_tr.py index e68f4e1a..293fdca2 100644 --- a/syncplay/messages_tr.py +++ b/syncplay/messages_tr.py @@ -292,6 +292,7 @@ "autoplay-menu-label": "Otomatik oynat düğmesini göster", "autoplay-guipushbuttonlabel": "Her şey hazır olduğunda oynat", "autoplay-minimum-label": "Asgari kullanıcı:", + "hideemptyrooms-menu-label": "Hide empty persistent rooms", # TODO: Translate "sendmessage-label": "Gönder", diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index 071f56f3..1b5bf9f7 100755 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -604,6 +604,13 @@ def showUserList(self, currentUser, rooms): self._syncplayClient.fileSwitch.setCurrentDirectory(os.path.dirname(self._syncplayClient.userlist.currentUser.file["path"])) for room in rooms: + if self.hideEmptyRooms: + foundEmptyRooms = False + for user in rooms[room]: + if user.username.strip() == "": + foundEmptyRooms = True + if foundEmptyRooms: + continue self.newWatchlist = [] roomitem = QtGui.QStandardItem(room) font = QtGui.QFont() @@ -624,6 +631,8 @@ def showUserList(self, currentUser, rooms): roomitem.setIcon(QtGui.QPixmap(resourcespath + 'chevrons_right.png')) for user in rooms[room]: + if user.username.strip() == "": + continue useritem = QtGui.QStandardItem(user.username) isController = user.isController() sameRoom = room == currentUser.room @@ -1753,6 +1762,9 @@ def populateMenubar(self, window): window.autoplayAction.setCheckable(True) window.autoplayAction.triggered.connect(self.updateAutoplayVisibility) + window.hideEmptyRoomsAction = window.windowMenu.addAction(getMessage("hideemptyrooms-menu-label")) + window.hideEmptyRoomsAction.setCheckable(True) + window.hideEmptyRoomsAction.triggered.connect(self.updateEmptyRoomVisiblity) # Help menu @@ -1818,6 +1830,11 @@ def updatePlaybackFrameVisibility(self): def updateAutoplayVisibility(self): self.autoplayFrame.setVisible(self.autoplayAction.isChecked()) + def updateEmptyRoomVisiblity(self): + self.hideEmptyRooms = self.hideEmptyRoomsAction.isChecked() + if self._syncplayClient: + self._syncplayClient.getUserList() + def changeReadyState(self): self.updateReadyIcon() if self._syncplayClient: @@ -2017,6 +2034,7 @@ def saveSettings(self): settings.setValue("pos", self.pos()) settings.setValue("showPlaybackButtons", self.playbackAction.isChecked()) settings.setValue("showAutoPlayButton", self.autoplayAction.isChecked()) + settings.setValue("hideEmptyRooms", self.hideEmptyRoomsAction.isChecked()) settings.setValue("autoplayChecked", self.autoplayPushButton.isChecked()) settings.setValue("autoplayMinUsers", self.autoplayThresholdSpinbox.value()) settings.endGroup() @@ -2040,6 +2058,9 @@ def loadSettings(self): if settings.value("showAutoPlayButton", "false") == "true": self.autoplayAction.setChecked(True) self.updateAutoplayVisibility() + if settings.value("hideEmptyRooms", "false") == "true": + self.hideEmptyRooms = True + self.hideEmptyRoomsAction.setChecked(True) if settings.value("autoplayChecked", "false") == "true": self.updateAutoPlayState(True) self.autoplayPushButton.setChecked(True) @@ -2063,6 +2084,7 @@ def __init__(self, passedBar=None): self.lastCheckedForUpdates = None self._syncplayClient = None self.folderSearchEnabled = True + self.hideEmptyRooms = False self.QtGui = QtGui if isMacOS(): self.setWindowFlags(self.windowFlags())