From 558e7e69bfea495795de3d0ca58c624f54aefc8f Mon Sep 17 00:00:00 2001 From: Et0h Date: Sun, 30 Aug 2015 23:34:29 +0100 Subject: [PATCH] Automatically update empty server list if updates are enabled --- syncplay/ui/GuiConfiguration.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/syncplay/ui/GuiConfiguration.py b/syncplay/ui/GuiConfiguration.py index fb7da26..da0b2b1 100644 --- a/syncplay/ui/GuiConfiguration.py +++ b/syncplay/ui/GuiConfiguration.py @@ -208,9 +208,7 @@ class ConfigDialog(QtGui.QDialog): def loadSavedPublicServerList(self): settings = QSettings("Syncplay", "Interface") settings.beginGroup("PublicServerList") - self.publicServers = settings.value("publicServers", constants.FALLBACK_PUBLIC_SYNCPLAY_SERVERS) - if self.publicServers is None: - self.publicServers = constants.FALLBACK_PUBLIC_SYNCPLAY_SERVERS + self.publicServers = settings.value("publicServers", None) def loadMediaBrowseSettings(self): settings = QSettings("Syncplay", "MediaBrowseDialog") @@ -240,7 +238,6 @@ class ConfigDialog(QtGui.QDialog): settings.setValue("ShowMoreSettings", morestate) settings.endGroup() - def updateServerList(self): try: servers = utils.getListOfPublicServers() @@ -910,7 +907,21 @@ class ConfigDialog(QtGui.QDialog): settings = QSettings("Syncplay", "MoreSettings") settings.clear() self.datacleared = True - + + def populateEmptyServerList(self): + if self.publicServers is None: + if self.config["checkForUpdatesAutomatically"] == True: + self.updateServerList() + else: + currentServer = self.hostCombobox.currentText() + self.publicServers = constants.FALLBACK_PUBLIC_SYNCPLAY_SERVERS + i = 0 + for server in self.publicServers: + self.hostCombobox.addItem(server[1]) + self.hostCombobox.setItemData(i, server[0], Qt.ToolTipRole) + i += 1 + self.hostCombobox.setEditText(currentServer) + def __init__(self, config, playerpaths, error, defaultConfig): self.config = config @@ -983,4 +994,5 @@ class ConfigDialog(QtGui.QDialog): if constants.SHOW_TOOLTIPS: self.processWidget(self, lambda w: self.loadTooltips(w)) self.processWidget(self, lambda w: self.loadValues(w)) - self.processWidget(self, lambda w: self.connectChildren(w)) \ No newline at end of file + self.processWidget(self, lambda w: self.connectChildren(w)) + self.populateEmptyServerList() \ No newline at end of file