Skip to content

Commit

Permalink
Allow multiple servers in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapk00 committed Nov 17, 2019
1 parent 6520a09 commit 1a762b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
6 changes: 3 additions & 3 deletions lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,13 @@ void MainWindow::setupSettingsModal() {
// Fetch prices
settings.chkFetchPrices->setChecked(Settings::getInstance()->getAllowFetchPrices());

// List of default servers
settings.cmbServer->addItem("https://lightd-main.zecwallet.co:443");
settings.cmbServer->addItem("https://lightd-main.zcashfr.io:443");

// Load current values into the dialog
auto conf = Settings::getInstance()->getSettings();
settings.txtServer->setText(conf.server);
settings.cmbServer->setCurrentText(conf.server);

// Connection tab by default
settings.tabWidget->setCurrentIndex(0);
Expand All @@ -429,11 +433,15 @@ void MainWindow::setupSettingsModal() {
Settings::getInstance()->setAllowFetchPrices(settings.chkFetchPrices->isChecked());

// Save the server
Settings::getInstance()->saveSettings(settings.txtServer->text().trimmed());
bool reloadConnection = false;
if (conf.server != settings.cmbServer->currentText().trimmed()) {
reloadConnection = true;
}
Settings::getInstance()->saveSettings(settings.cmbServer->currentText().trimmed());

if (false /* connection needs reloading?*/) {
if (reloadConnection) {
// Save settings
Settings::getInstance()->saveSettings(settings.txtServer->text());
Settings::getInstance()->saveSettings(settings.cmbServer->currentText());

auto cl = new ConnectionLoader(this, rpc);
cl->loadConnection();
Expand Down
23 changes: 9 additions & 14 deletions src/settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
<height>539</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>540</width>
<height>500</height>
</size>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
Expand Down Expand Up @@ -57,14 +51,15 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtServer">
<property name="placeholderText">
<string/>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2"/>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="cmbServer">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
Expand Down

0 comments on commit 1a762b0

Please sign in to comment.