Minor cleanup & set RR default for new clients (#3591)

* Minor cleanup & set RR default for new clients

* Handle case of no entries

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>

* Use RR as default on rebuilds

Signed-off-by: Zach Halpern <ZaHalpern+github@gmail.com>
This commit is contained in:
Zach H 2019-02-28 00:10:10 -05:00 committed by GitHub
parent 45b16ba78d
commit e77e439c4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 27 deletions

View file

@ -161,21 +161,6 @@ DlgConnect::DlgConnect(QWidget *parent) : QDialog(parent)
DlgConnect::~DlgConnect() = default;
void DlgConnect::actSaveConfig()
{
bool updateSuccess = settingsCache->servers().updateExistingServer(
saveEdit->text().trimmed(), hostEdit->text().trimmed(), portEdit->text().trimmed(),
playernameEdit->text().trimmed(), passwordEdit->text(), savePasswordCheckBox->isChecked());
if (!updateSuccess) {
settingsCache->servers().addNewServer(saveEdit->text().trimmed(), hostEdit->text().trimmed(),
portEdit->text().trimmed(), playernameEdit->text().trimmed(),
passwordEdit->text(), savePasswordCheckBox->isChecked());
}
preRebuildComboBoxList();
}
void DlgConnect::downloadThePublicServers()
{
btnRefreshServers->setDisabled(true);
@ -205,21 +190,19 @@ void DlgConnect::rebuildComboBoxList(int failure)
UserConnection_Information uci;
savedHostList = uci.getServerInfo();
int i = 0;
for (auto pair : savedHostList) {
for (const auto &pair : savedHostList) {
auto tmp = pair.second;
QString saveName = tmp.getSaveName();
if (saveName.size()) {
previousHosts->addItem(saveName);
if (settingsCache->servers().getPrevioushostName() == saveName) {
previousHosts->setCurrentIndex(i);
}
i++;
}
}
// On rebuild, set to RR
if (previousHosts->count() >= 2) {
previousHosts->setCurrentIndex(1);
}
btnRefreshServers->setDisabled(false);
}

View file

@ -52,7 +52,7 @@ public slots:
private slots:
void actOk();
void actSaveConfig();
void passwordSaved(int state);
void previousHostSelected(bool state);
void newHostSelected(bool state);
@ -62,9 +62,9 @@ private slots:
void rebuildComboBoxList(int failure = -1);
private:
QGridLayout *newHostLayout, *connectionLayout, *loginLayout, *serverInfoLayout, *grid;
QGridLayout *connectionLayout, *loginLayout, *serverInfoLayout, *grid;
QHBoxLayout *newHolderLayout;
QGroupBox *loginGroupBox, *serverInfoGroupBox, *btnGroupBox, *restrictionsGroupBox;
QGroupBox *loginGroupBox, *serverInfoGroupBox, *restrictionsGroupBox;
QVBoxLayout *mainLayout;
QLabel *hostLabel, *portLabel, *playernameLabel, *passwordLabel, *saveLabel, *serverIssuesLabel,
*serverContactLabel, *serverContactLink;

View file

@ -87,7 +87,7 @@ void HandlePublicServers::updateServerINISettings(QMap<QString, QVariant> jsonMa
if (serverFound) {
settingsCache->servers().updateExistingServerWithoutLoss(serverName, serverAddress, serverPort, serverSite);
} else {
settingsCache->servers().addNewServer(serverName, serverAddress, serverPort, "", "", false);
settingsCache->servers().addNewServer(serverName, serverAddress, serverPort, "", "", false, serverSite);
}
}