diff --git a/src/connection.cpp b/src/connection.cpp index ffca84c..15463eb 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -21,7 +21,7 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) { int x = (screenGeometry.width() - d->width()) / 2; int y = (screenGeometry.height() - d->height()) / 2; d->move(x, y); - connD->buttonBox->setEnabled(false); + } ConnectionLoader::~ConnectionLoader() { @@ -169,7 +169,7 @@ bool ConnectionLoader::startEmbeddedZcashd() { }); QObject::connect(ezcashd, &QProcess::errorOccurred, [&] (auto error) mutable { - qDebug() << "Couldn't start zcashd: " << error << ezcashd->errorString(); + qDebug() << "Couldn't start zcashd: " << error; }); ezcashd->start(zcashdProgram); @@ -252,18 +252,9 @@ void ConnectionLoader::refreshZcashdState(Connection* connection) { QTimer::singleShot(1000, [=]() { this->refreshZcashdState(connection); }); } else { // Errored out, show error and exit - QString explanation = "Couldn't start zcashd"; + QString explanation = "Couldn't start the embedded zcashd. The process returned:\n\n" % ezcashd->errorString(); this->showError(explanation); } - - // auto isZcashConfFound = connection->config.get()->usingZcashConf; - // QString explanation = QString() - // % (isZcashConfFound ? "A zcash.conf file was found, but a" : "A") - // % " connection to zcashd could not be established.\n\n" - // % "If you are connecting to a remote/non-standard node " - // % "please set the host/port and user/password in the File->Settings menu"; - - // this->showError(explanation); } else if (err == QNetworkReply::NetworkError::AuthenticationRequiredError) { QString explanation = QString() % "Authentication failed. The username / password you specified was " @@ -273,7 +264,7 @@ void ConnectionLoader::refreshZcashdState(Connection* connection) { } else if (err == QNetworkReply::NetworkError::InternalServerError && !res.is_discarded()) { // 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.\n\n" % status); + showInformation("Your zcashd is starting up. Please wait.", status); // Refresh after one second QTimer::singleShot(1000, [=]() { this->refreshZcashdState(connection); }); @@ -282,18 +273,18 @@ void ConnectionLoader::refreshZcashdState(Connection* connection) { ); } -void ConnectionLoader::showInformation(QString info) { - QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation); - connD->icon->setPixmap(icon.pixmap(128, 128)); +void ConnectionLoader::showInformation(QString info, QString detail) { connD->status->setText(info); + connD->statusDetail->setText(detail); } +/** + * Show error will close the loading dialog and show an error. +*/ void ConnectionLoader::showError(QString explanation) { - QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical); - connD->icon->setPixmap(icon.pixmap(128, 128)); - connD->status->setText(explanation); + d->close(); - connD->buttonBox->setEnabled(true); + QMessageBox::critical(main, "Error", explanation, QMessageBox::Ok); } QString ConnectionLoader::locateZcashConfFile() { diff --git a/src/connection.h b/src/connection.h index ccdd163..582b3aa 100644 --- a/src/connection.h +++ b/src/connection.h @@ -54,7 +54,7 @@ private: int getProgressFromStatus(QString status); void showError(QString explanation); - void showInformation(QString info); + void showInformation(QString info, QString detail = ""); void doRPCSetConnection(Connection* conn); diff --git a/src/connection.ui b/src/connection.ui index a4d98af..007d877 100644 --- a/src/connection.ui +++ b/src/connection.ui @@ -16,98 +16,75 @@ true - - - + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + + Qt::Horizontal - - QDialogButtonBox::Close - - - + + - TextLabel + Connection Status Qt::AlignCenter - - 20 - - - - - - - Qt::Horizontal + + true - - - - Qt::Vertical - - - - 20 - 40 - - - - - - + + - Connection Status + - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Qt::AlignCenter - - true + + + + + + Qt::Horizontal + + + FilledIconLabel + QLabel +
fillediconlabel.h
+
+
- - - buttonBox - accepted() - ConnectionDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - ConnectionDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/src/fillediconlabel.cpp b/src/fillediconlabel.cpp new file mode 100644 index 0000000..a04447a --- /dev/null +++ b/src/fillediconlabel.cpp @@ -0,0 +1,22 @@ +#include "fillediconlabel.h" + +FilledIconLabel::FilledIconLabel(QWidget* parent) : + QLabel(parent) { + this->setMinimumSize(1, 1); + setScaledContents(false); +} + + +void FilledIconLabel::resizeEvent(QResizeEvent*) { + // Top pixmap + QIcon icon(":/icons/res/icon.ico"); + QSize sz = size(); + qDebug() << sz; + QPixmap p(sz); + p.fill(Qt::white); + QPainter painter(&p); + painter.drawPixmap((sz.width() - sz.height()) / 2, 0, + icon.pixmap(sz.height(), sz.height())); + + QLabel::setPixmap(p); +} \ No newline at end of file diff --git a/src/fillediconlabel.h b/src/fillediconlabel.h new file mode 100644 index 0000000..a910796 --- /dev/null +++ b/src/fillediconlabel.h @@ -0,0 +1,18 @@ +#ifndef FILLEDICONLABEL_H +#define FILLEDICONLABEL_H + +#include "precompiled.h" + +class FilledIconLabel : public QLabel +{ + Q_OBJECT +public: + explicit FilledIconLabel(QWidget *parent = 0); + +public slots: + void resizeEvent(QResizeEvent *); + +}; + + +#endif // FILLEDICONLABEL_H \ No newline at end of file diff --git a/src/rpc.cpp b/src/rpc.cpp index de422ac..6ef88d5 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -836,7 +836,7 @@ void RPC::shutdownZcashd() { d.setWindowTitle("Waiting for zcashd to exit"); d.setText("Please wait for zcashd to exit. Don't click OK!"); d.setStandardButtons(QMessageBox::NoButton); - d.setWindowFlags(Qt::SplashScreen); + //d.setWindowFlags(Qt::SplashScreen); QTimer waiter(main); diff --git a/zec-qt-wallet.pro b/zec-qt-wallet.pro index 2ece2d0..e7c011e 100644 --- a/zec-qt-wallet.pro +++ b/zec-qt-wallet.pro @@ -53,7 +53,8 @@ SOURCES += \ src/turnstile.cpp \ src/utils.cpp \ src/qrcodelabel.cpp \ - src/connection.cpp + src/connection.cpp \ + src/fillediconlabel.cpp HEADERS += \ src/mainwindow.h \ @@ -71,7 +72,8 @@ HEADERS += \ src/turnstile.h \ src/utils.h \ src/qrcodelabel.h \ - src/connection.h + src/connection.h \ + src/fillediconlabel.h FORMS += \ src/mainwindow.ui \