Skip to content

Commit

Permalink
Allow hiding of empty persistent rooms (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
Et0h committed Nov 7, 2021
1 parent 07499aa commit 3b2bb27
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions syncplay/messages_de.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
1 change: 1 addition & 0 deletions syncplay/messages_en.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
1 change: 1 addition & 0 deletions syncplay/messages_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
1 change: 1 addition & 0 deletions syncplay/messages_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
1 change: 1 addition & 0 deletions syncplay/messages_pt_BR.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
1 change: 1 addition & 0 deletions syncplay/messages_pt_PT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
1 change: 1 addition & 0 deletions syncplay/messages_ru.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "Я готов",
Expand Down
1 change: 1 addition & 0 deletions syncplay/messages_tr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
22 changes: 22 additions & 0 deletions syncplay/ui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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())
Expand Down

0 comments on commit 3b2bb27

Please sign in to comment.