diff --git a/src/main.cpp b/src/main.cpp index 5580475..1c8edfe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,6 +16,7 @@ int main(int argc, char *argv[]) qApp->setFont(QFont("Ubuntu", 11, QFont::Normal, false)); #endif + QCoreApplication::setOrganizationName("zcash-qt-wallet-org"); QCoreApplication::setApplicationName("zcash-qt-wallet"); Settings::init(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0ee6d00..ea2a763 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -138,6 +138,7 @@ void MainWindow::setupSettingsModal() { settings.rpcpassword->setEnabled(false); } else { + settings.confMsg->setText("No local zcash.conf found. Please configure manually."); settings.hostname->setEnabled(true); settings.port->setEnabled(true); settings.rpcuser->setEnabled(true); @@ -147,13 +148,11 @@ void MainWindow::setupSettingsModal() { if (settingsDialog.exec() == QDialog::Accepted) { if (zcashConfLocation.isEmpty()) { // Save settings - QSettings s; - s.setValue("connection/host", settings.hostname->text()); - s.setValue("connection/port", settings.port->text()); - s.setValue("connection/rpcuser", settings.rpcuser->text()); - s.setValue("connection/rpcpassword", settings.rpcpassword->text()); - - s.sync(); + Settings::getInstance()->saveSettings( + settings.hostname->text(), + settings.port->text(), + settings.rpcuser->text(), + settings.rpcpassword->text()); // Then refresh everything. this->rpc->reloadConnectionInfo(); diff --git a/src/settings.cpp b/src/settings.cpp index 1501b96..149213e 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -12,9 +12,8 @@ Settings::~Settings() { } Settings* Settings::init() { - if (instance != nullptr) return instance; - - instance = new Settings(); + if (instance == nullptr) + instance = new Settings(); // There are 3 possible configurations // 1. The defaults @@ -74,13 +73,27 @@ bool Settings::loadFromSettings() { return !username.isEmpty(); } +void Settings::saveSettings(const QString& host, const QString& port, const QString& username, const QString& password) { + QSettings s; + + s.setValue("connection/host", host); + s.setValue("connection/port", port); + s.setValue("connection/rpcuser", username); + s.setValue("connection/rpcpassword", password); + + s.sync(); + + // re-init to load correct settings + init(); +} + bool Settings::loadFromFile() { delete zcashconf; #ifdef Q_OS_LINUX confLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, ".zcash/zcash.conf"); #else - confLocation = QStandardPaths::locate(QStandardPaths::AppDataLocation, "../Zcash/zcash.conf"); + confLocation = QStandardPaths::locate(QStandardPaths::AppDataLocation, "../../Zcash/zcash.conf"); #endif confLocation = QDir::cleanPath(confLocation); diff --git a/src/settings.h b/src/settings.h index 7c9cd10..8f3ea80 100644 --- a/src/settings.h +++ b/src/settings.h @@ -23,6 +23,8 @@ public: bool loadFromSettings(); bool loadFromFile(); + void saveSettings(const QString& host, const QString& port, const QString& username, const QString& password); + bool isTestnet(); void setTestnet(bool isTestnet);