Browse Source

Popup splash screen properly

recurring
Aditya Kulkarni 6 years ago
parent
commit
2b9cc055bf
  1. 32
      src/connection.cpp
  2. 1
      src/connection.h
  3. 3
      src/connection.ui
  4. 2
      src/main.cpp

32
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<void(void)> 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<void(void)> 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() {

1
src/connection.h

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

3
src/connection.ui

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

2
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);
}

Loading…
Cancel
Save