Popup splash screen properly
This commit is contained in:
@@ -31,15 +31,7 @@ ConnectionLoader::~ConnectionLoader() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,8 +104,6 @@ void ConnectionLoader::downloadParams(std::function<void(void)> cb) {
|
|||||||
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() {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user