prettify loading dialog
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -16,98 +16,75 @@
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="4" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="FilledIconLabel" name="topIcon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="icon">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<item>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<item>
|
||||
<widget class="QLabel" name="status">
|
||||
<property name="text">
|
||||
<string>Connection Status</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="statusDetail">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>FilledIconLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>fillediconlabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ConnectionDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ConnectionDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
22
src/fillediconlabel.cpp
Normal file
22
src/fillediconlabel.cpp
Normal file
@@ -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);
|
||||
}
|
||||
18
src/fillediconlabel.h
Normal file
18
src/fillediconlabel.h
Normal file
@@ -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
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user