From 39edc2c9e9e0a3d0f4726944c3d8fad1e4938244 Mon Sep 17 00:00:00 2001 From: Etoh Date: Sun, 15 Oct 2017 14:08:06 +0100 Subject: [PATCH] Don't prompt for password on known public servers --- syncplay/ui/GuiConfiguration.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/syncplay/ui/GuiConfiguration.py b/syncplay/ui/GuiConfiguration.py index 6bd7535..d3a1c8d 100644 --- a/syncplay/ui/GuiConfiguration.py +++ b/syncplay/ui/GuiConfiguration.py @@ -527,8 +527,12 @@ class ConfigDialog(QtGui.QDialog): if self.publicServers: i = 0 for publicServer in self.publicServers: - self.hostCombobox.addItem(publicServer[1]) - self.hostCombobox.setItemData(i, publicServer[0], Qt.ToolTipRole) + serverTitle = publicServer[0] + serverAddressPort = publicServer[1] + self.hostCombobox.addItem(serverAddressPort) + self.hostCombobox.setItemData(i, serverTitle, Qt.ToolTipRole) + if not serverAddressPort in self.publicServerAddresses: + self.publicServerAddresses.append(serverAddressPort) i += 1 self.hostCombobox.setEditable(True) self.hostCombobox.setEditText(host) @@ -552,6 +556,8 @@ class ConfigDialog(QtGui.QDialog): self.usernameTextbox.setObjectName("name") self.serverpassLabel.setObjectName("password") self.serverpassTextbox.setObjectName("password") + self.hostCombobox.editTextChanged.connect(self.updatePasswordVisibilty) + self.hostCombobox.currentIndexChanged.connect(self.updatePasswordVisibilty) self.defaultroomLabel.setObjectName("room") self.defaultroomTextbox.setObjectName("room") @@ -583,7 +589,6 @@ class ConfigDialog(QtGui.QDialog): self.executablepathCombobox.setEditable(True) self.executablepathCombobox.currentIndexChanged.connect(self.updateExecutableIcon) self.executablepathCombobox.setEditText(self._tryToFillPlayerPath(config['playerPath'], playerpaths)) - #bob self.executablepathCombobox.setFixedWidth(250) self.executablepathCombobox.editTextChanged.connect(self.updateExecutableIcon) @@ -1038,8 +1043,25 @@ class ConfigDialog(QtGui.QDialog): for server in self.publicServers: self.hostCombobox.addItem(server[1]) self.hostCombobox.setItemData(i, server[0], Qt.ToolTipRole) + if not server[1] in self.publicServerAddresses: + self.publicServerAddresses.append(server[1]) i += 1 self.hostCombobox.setEditText(currentServer) + + def updatePasswordVisibilty(self): + if (self.hostCombobox.currentText() == "" and self.serverpassTextbox.text() == "") or unicode(self.hostCombobox.currentText()) in self.publicServerAddresses: + self.serverpassLabel.hide() + self.serverpassTextbox.hide() + self.serverpassTextbox.setText("") + else: + self.serverpassLabel.show() + self.serverpassTextbox.show() + newHeight = self.connectionSettingsGroup.minimumSizeHint().height()+self.mediaplayerSettingsGroup.minimumSizeHint().height()+self.bottomButtonFrame.minimumSizeHint().height()+3 + if self.error: + newHeight += self.errorLabel.height()+3 + self.stackedFrame.setFixedHeight(newHeight) + self.adjustSize() + self.setFixedSize(self.sizeHint()) def __init__(self, config, playerpaths, error, defaultConfig): self.config = config @@ -1049,6 +1071,7 @@ class ConfigDialog(QtGui.QDialog): self.config['resetConfig'] = False self.subitems = {} self.publicServers = None + self.publicServerAddresses = [] self._playerProbeThread = GetPlayerIconThread() self._playerProbeThread.done.connect(self._updateExecutableIcon) @@ -1129,3 +1152,4 @@ class ConfigDialog(QtGui.QDialog): self.processWidget(self, lambda w: self.loadValues(w)) self.processWidget(self, lambda w: self.connectChildren(w)) self.populateEmptyServerList() + self.updatePasswordVisibilty() \ No newline at end of file