Popup splash screen properly

This commit is contained in:
Aditya Kulkarni
2018-11-07 14:54:31 -08:00
parent 02e1a2de36
commit 2b9cc055bf
4 changed files with 15 additions and 23 deletions

View File

@@ -25,21 +25,13 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) {
} }
ConnectionLoader::~ConnectionLoader() { ConnectionLoader::~ConnectionLoader() {
delete d; delete d;
delete connD; delete connD;
} }
void ConnectionLoader::loadConnection() { void ConnectionLoader::loadConnection() {
// Load from settings if it is a manual connection. d->show();
if (Settings::getInstance()->getIsManualConnection()) {
doManualConnect();
} else {
doAutoConnect();
}
}
void ConnectionLoader::doAutoConnect() {
// Priority 1: Try to connect to detect zcash.conf and connect to it. // Priority 1: Try to connect to detect zcash.conf and connect to it.
auto config = autoDetectZcashConf(); auto config = autoDetectZcashConf();
@@ -48,9 +40,11 @@ void ConnectionLoader::doAutoConnect() {
refreshZcashdState(connection); refreshZcashdState(connection);
return; return;
} else { } else if (!Settings::getInstance()->getIsManualConnection()){
// zcash.conf was not found, so create one // zcash.conf was not found, so create one
createZcashConf(); createZcashConf();
} else {
doManualConnect();
} }
} }
@@ -109,9 +103,7 @@ void ConnectionLoader::downloadParams(std::function<void(void)> cb) {
downloadQueue->enqueue(QUrl("https://z.cash/downloads/sprout-verifying.key")); downloadQueue->enqueue(QUrl("https://z.cash/downloads/sprout-verifying.key"));
downloadQueue->enqueue(QUrl("https://z.cash/downloads/sprout-groth16.params")); downloadQueue->enqueue(QUrl("https://z.cash/downloads/sprout-groth16.params"));
doNextDownload(cb); doNextDownload(cb);
d->show();
} }
void ConnectionLoader::doNextDownload(std::function<void(void)> cb) { void ConnectionLoader::doNextDownload(std::function<void(void)> cb) {
@@ -242,7 +234,6 @@ void ConnectionLoader::doManualConnect() {
auto config = loadFromSettings(); auto config = loadFromSettings();
if (config.get() == nullptr) { if (config.get() == nullptr) {
d->show();
// Nothing configured, show an error // Nothing configured, show an error
QString explanation = QString() QString explanation = QString()
% "A manual connection was requested, but the settings are not configured.\n\n" % "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); this->doRPCSetConnection(connection);
}, },
[=] (auto reply, auto res) { [=] (auto reply, auto res) {
d->show();
auto err = reply->error(); auto err = reply->error();
// Failed, see what it is. // Failed, see what it is.
//qDebug() << err << ":" << QString::fromStdString(res.dump()); //qDebug() << err << ":" << QString::fromStdString(res.dump());
@@ -323,6 +312,8 @@ void ConnectionLoader::refreshZcashdState(Connection* connection) {
this->showError(explanation); this->showError(explanation);
} else if (err == QNetworkReply::NetworkError::InternalServerError && !res.is_discarded()) { } else if (err == QNetworkReply::NetworkError::InternalServerError && !res.is_discarded()) {
d->show();
// The server is loading, so just poll until it succeeds // The server is loading, so just poll until it succeeds
QString status = QString::fromStdString(res["error"]["message"]); QString status = QString::fromStdString(res["error"]["message"]);
showInformation("Your zcashd is starting up. Please wait.", status); 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. * Show error will close the loading dialog and show an error.
*/ */
void ConnectionLoader::showError(QString explanation) { void ConnectionLoader::showError(QString explanation) {
d->close(); d->hide();
QMessageBox::critical(main, "Connection Error", explanation, QMessageBox::Ok);
QMessageBox::critical(main, "Error", explanation, QMessageBox::Ok);
} }
QString ConnectionLoader::locateZcashConfFile() { QString ConnectionLoader::locateZcashConfFile() {

View File

@@ -41,7 +41,6 @@ private:
Connection* makeConnection(std::shared_ptr<ConnectionConfig> config); Connection* makeConnection(std::shared_ptr<ConnectionConfig> config);
void doAutoConnect();
void doManualConnect(); void doManualConnect();
void createZcashConf(); void createZcashConf();

View File

@@ -2,6 +2,9 @@
<ui version="4.0"> <ui version="4.0">
<class>ConnectionDialog</class> <class>ConnectionDialog</class>
<widget class="QDialog" name="ConnectionDialog"> <widget class="QDialog" name="ConnectionDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>

View File

@@ -22,7 +22,7 @@ int main(int argc, char *argv[])
Settings::init(); Settings::init();
Settings::getInstance()->setExecName(argv[0]); 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); Settings::getInstance()->setManualConnection(true);
} }