Browse Source

Allow multiple servers in settings

pull/25/head^2
Aditya Kulkarni 5 years ago
parent
commit
1a762b01c8
  1. 6
      lib/Cargo.lock
  2. 16
      src/mainwindow.cpp
  3. 23
      src/settings.ui

6
lib/Cargo.lock

@ -1051,7 +1051,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=61dc063fe155d1510e9a074e5a3577a0621f8c3a)", "zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=96997c5a467b710286bc9c6fea818b9d7d76f254)",
] ]
[[package]] [[package]]
@ -2266,7 +2266,7 @@ dependencies = [
[[package]] [[package]]
name = "zecwalletlitelib" name = "zecwalletlitelib"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/adityapk00/zecwallet-light-cli?rev=61dc063fe155d1510e9a074e5a3577a0621f8c3a#61dc063fe155d1510e9a074e5a3577a0621f8c3a" source = "git+https://github.com/adityapk00/zecwallet-light-cli?rev=96997c5a467b710286bc9c6fea818b9d7d76f254#96997c5a467b710286bc9c6fea818b9d7d76f254"
dependencies = [ dependencies = [
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bellman 0.1.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)", "bellman 0.1.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)",
@ -2562,4 +2562,4 @@ dependencies = [
"checksum zcash_client_backend 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>" "checksum zcash_client_backend 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
"checksum zcash_primitives 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>" "checksum zcash_primitives 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
"checksum zcash_proofs 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>" "checksum zcash_proofs 0.0.0 (git+https://github.com/adityapk00/librustzcash.git?rev=188537ea025fcb7fbdfc11266f307a084a5451e4)" = "<none>"
"checksum zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=61dc063fe155d1510e9a074e5a3577a0621f8c3a)" = "<none>" "checksum zecwalletlitelib 0.1.0 (git+https://github.com/adityapk00/zecwallet-light-cli?rev=96997c5a467b710286bc9c6fea818b9d7d76f254)" = "<none>"

16
src/mainwindow.cpp

@ -408,9 +408,13 @@ void MainWindow::setupSettingsModal() {
// Fetch prices // Fetch prices
settings.chkFetchPrices->setChecked(Settings::getInstance()->getAllowFetchPrices()); 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 // Load current values into the dialog
auto conf = Settings::getInstance()->getSettings(); auto conf = Settings::getInstance()->getSettings();
settings.txtServer->setText(conf.server); settings.cmbServer->setCurrentText(conf.server);
// Connection tab by default // Connection tab by default
settings.tabWidget->setCurrentIndex(0); settings.tabWidget->setCurrentIndex(0);
@ -429,11 +433,15 @@ void MainWindow::setupSettingsModal() {
Settings::getInstance()->setAllowFetchPrices(settings.chkFetchPrices->isChecked()); Settings::getInstance()->setAllowFetchPrices(settings.chkFetchPrices->isChecked());
// Save the server // 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 // Save settings
Settings::getInstance()->saveSettings(settings.txtServer->text()); Settings::getInstance()->saveSettings(settings.cmbServer->currentText());
auto cl = new ConnectionLoader(this, rpc); auto cl = new ConnectionLoader(this, rpc);
cl->loadConnection(); cl->loadConnection();

23
src/settings.ui

@ -10,12 +10,6 @@
<height>539</height> <height>539</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>540</width>
<height>500</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Settings</string> <string>Settings</string>
</property> </property>
@ -57,14 +51,15 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="txtServer"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="placeholderText"> <item>
<string/> <widget class="QComboBox" name="cmbServer">
</property> <property name="editable">
</widget> <bool>true</bool>
</item> </property>
<item> </widget>
<layout class="QVBoxLayout" name="verticalLayout_2"/> </item>
</layout>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">

Loading…
Cancel
Save