Load from UI Settings if local zcash.conf is not found
This commit is contained in:
parent
d7f6d2a869
commit
35f7950999
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue