diff --git a/src/connection.cpp b/src/connection.cpp index 40d61bf..b9ec551 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -25,21 +25,13 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) { } -ConnectionLoader::~ConnectionLoader() { +ConnectionLoader::~ConnectionLoader() { delete d; delete connD; } -void ConnectionLoader::loadConnection() { - // Load from settings if it is a manual connection. - if (Settings::getInstance()->getIsManualConnection()) { - doManualConnect(); - } else { - doAutoConnect(); - } -} - -void ConnectionLoader::doAutoConnect() { +void ConnectionLoader::loadConnection() { + d->show(); // Priority 1: Try to connect to detect zcash.conf and connect to it. auto config = autoDetectZcashConf(); @@ -48,9 +40,11 @@ void ConnectionLoader::doAutoConnect() { refreshZcashdState(connection); return; - } else { + } else if (!Settings::getInstance()->getIsManualConnection()){ // zcash.conf was not found, so create one createZcashConf(); + } else { + doManualConnect(); } } @@ -109,9 +103,7 @@ void ConnectionLoader::downloadParams(std::function cb) { downloadQueue->enqueue(QUrl("https://z.cash/downloads/sprout-verifying.key")); downloadQueue->enqueue(QUrl("https://z.cash/downloads/sprout-groth16.params")); - doNextDownload(cb); - - d->show(); + doNextDownload(cb); } void ConnectionLoader::doNextDownload(std::function cb) { @@ -242,7 +234,6 @@ void ConnectionLoader::doManualConnect() { auto config = loadFromSettings(); if (config.get() == nullptr) { - d->show(); // Nothing configured, show an error QString explanation = QString() % "A manual connection was requested, but the settings are not configured.\n\n" @@ -299,8 +290,6 @@ void ConnectionLoader::refreshZcashdState(Connection* connection) { this->doRPCSetConnection(connection); }, [=] (auto reply, auto res) { - d->show(); - auto err = reply->error(); // Failed, see what it is. //qDebug() << err << ":" << QString::fromStdString(res.dump()); @@ -323,6 +312,8 @@ void ConnectionLoader::refreshZcashdState(Connection* connection) { this->showError(explanation); } else if (err == QNetworkReply::NetworkError::InternalServerError && !res.is_discarded()) { + d->show(); + // The server is loading, so just poll until it succeeds QString status = QString::fromStdString(res["error"]["message"]); showInformation("Your zcashd is starting up. Please wait.", status); @@ -343,9 +334,8 @@ void ConnectionLoader::showInformation(QString info, QString detail) { * Show error will close the loading dialog and show an error. */ void ConnectionLoader::showError(QString explanation) { - d->close(); - - QMessageBox::critical(main, "Error", explanation, QMessageBox::Ok); + d->hide(); + QMessageBox::critical(main, "Connection Error", explanation, QMessageBox::Ok); } QString ConnectionLoader::locateZcashConfFile() { diff --git a/src/connection.h b/src/connection.h index 384dd5c..6c05ced 100644 --- a/src/connection.h +++ b/src/connection.h @@ -41,7 +41,6 @@ private: Connection* makeConnection(std::shared_ptr config); - void doAutoConnect(); void doManualConnect(); void createZcashConf(); diff --git a/src/connection.ui b/src/connection.ui index 007d877..704f9d9 100644 --- a/src/connection.ui +++ b/src/connection.ui @@ -2,6 +2,9 @@ ConnectionDialog + + Qt::ApplicationModal + 0 diff --git a/src/main.cpp b/src/main.cpp index da40fa6..5eb849b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,7 +22,7 @@ int main(int argc, char *argv[]) Settings::init(); Settings::getInstance()->setExecName(argv[0]); - if (argc >= 2 && QString::fromStdString(argv[1]) == "-manual") { + if (argc >= 2 && QString::fromStdString(argv[1]) == "--no-embedded") { Settings::getInstance()->setManualConnection(true); }