Load from UI Settings if local zcash.conf is not found
This commit is contained in:
@@ -16,6 +16,7 @@ int main(int argc, char *argv[])
|
|||||||
qApp->setFont(QFont("Ubuntu", 11, QFont::Normal, false));
|
qApp->setFont(QFont("Ubuntu", 11, QFont::Normal, false));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QCoreApplication::setOrganizationName("zcash-qt-wallet-org");
|
||||||
QCoreApplication::setApplicationName("zcash-qt-wallet");
|
QCoreApplication::setApplicationName("zcash-qt-wallet");
|
||||||
|
|
||||||
Settings::init();
|
Settings::init();
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ void MainWindow::setupSettingsModal() {
|
|||||||
settings.rpcpassword->setEnabled(false);
|
settings.rpcpassword->setEnabled(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
settings.confMsg->setText("No local zcash.conf found. Please configure manually.");
|
||||||
settings.hostname->setEnabled(true);
|
settings.hostname->setEnabled(true);
|
||||||
settings.port->setEnabled(true);
|
settings.port->setEnabled(true);
|
||||||
settings.rpcuser->setEnabled(true);
|
settings.rpcuser->setEnabled(true);
|
||||||
@@ -147,13 +148,11 @@ void MainWindow::setupSettingsModal() {
|
|||||||
if (settingsDialog.exec() == QDialog::Accepted) {
|
if (settingsDialog.exec() == QDialog::Accepted) {
|
||||||
if (zcashConfLocation.isEmpty()) {
|
if (zcashConfLocation.isEmpty()) {
|
||||||
// Save settings
|
// Save settings
|
||||||
QSettings s;
|
Settings::getInstance()->saveSettings(
|
||||||
s.setValue("connection/host", settings.hostname->text());
|
settings.hostname->text(),
|
||||||
s.setValue("connection/port", settings.port->text());
|
settings.port->text(),
|
||||||
s.setValue("connection/rpcuser", settings.rpcuser->text());
|
settings.rpcuser->text(),
|
||||||
s.setValue("connection/rpcpassword", settings.rpcpassword->text());
|
settings.rpcpassword->text());
|
||||||
|
|
||||||
s.sync();
|
|
||||||
|
|
||||||
// Then refresh everything.
|
// Then refresh everything.
|
||||||
this->rpc->reloadConnectionInfo();
|
this->rpc->reloadConnectionInfo();
|
||||||
|
|||||||
@@ -12,9 +12,8 @@ Settings::~Settings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Settings* Settings::init() {
|
Settings* Settings::init() {
|
||||||
if (instance != nullptr) return instance;
|
if (instance == nullptr)
|
||||||
|
instance = new Settings();
|
||||||
instance = new Settings();
|
|
||||||
|
|
||||||
// There are 3 possible configurations
|
// There are 3 possible configurations
|
||||||
// 1. The defaults
|
// 1. The defaults
|
||||||
@@ -74,13 +73,27 @@ bool Settings::loadFromSettings() {
|
|||||||
return !username.isEmpty();
|
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() {
|
bool Settings::loadFromFile() {
|
||||||
delete zcashconf;
|
delete zcashconf;
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
confLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, ".zcash/zcash.conf");
|
confLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, ".zcash/zcash.conf");
|
||||||
#else
|
#else
|
||||||
confLocation = QStandardPaths::locate(QStandardPaths::AppDataLocation, "../Zcash/zcash.conf");
|
confLocation = QStandardPaths::locate(QStandardPaths::AppDataLocation, "../../Zcash/zcash.conf");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
confLocation = QDir::cleanPath(confLocation);
|
confLocation = QDir::cleanPath(confLocation);
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public:
|
|||||||
bool loadFromSettings();
|
bool loadFromSettings();
|
||||||
bool loadFromFile();
|
bool loadFromFile();
|
||||||
|
|
||||||
|
void saveSettings(const QString& host, const QString& port, const QString& username, const QString& password);
|
||||||
|
|
||||||
bool isTestnet();
|
bool isTestnet();
|
||||||
void setTestnet(bool isTestnet);
|
void setTestnet(bool isTestnet);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user