Skip to content

Commit

Permalink
Automatically update empty server list if updates are enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Et0h committed Aug 30, 2015
1 parent 2983dbc commit 558e7e6
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions syncplay/ui/GuiConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ def loadLastUpdateCheckDate(self):
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")
Expand Down Expand Up @@ -240,7 +238,6 @@ def saveMoreState(self, morestate):
settings.setValue("ShowMoreSettings", morestate)
settings.endGroup()


def updateServerList(self):
try:
servers = utils.getListOfPublicServers()
Expand Down Expand Up @@ -910,7 +907,21 @@ def clearGUIData(self, leaveMore=False):
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
Expand Down Expand Up @@ -983,4 +994,5 @@ def __init__(self, config, playerpaths, error, defaultConfig):
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))
self.processWidget(self, lambda w: self.connectChildren(w))
self.populateEmptyServerList()

0 comments on commit 558e7e6

Please sign in to comment.