Browse Source

prettify loading dialog

recurring
adityapk00 6 years ago
parent
commit
2b253dd46f
  1. 31
      src/connection.cpp
  2. 2
      src/connection.h
  3. 119
      src/connection.ui
  4. 22
      src/fillediconlabel.cpp
  5. 18
      src/fillediconlabel.h
  6. 2
      src/rpc.cpp
  7. 6
      zec-qt-wallet.pro

31
src/connection.cpp

@ -21,7 +21,7 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) {
int x = (screenGeometry.width() - d->width()) / 2; int x = (screenGeometry.width() - d->width()) / 2;
int y = (screenGeometry.height() - d->height()) / 2; int y = (screenGeometry.height() - d->height()) / 2;
d->move(x, y); d->move(x, y);
connD->buttonBox->setEnabled(false);
} }
ConnectionLoader::~ConnectionLoader() { ConnectionLoader::~ConnectionLoader() {
@ -169,7 +169,7 @@ bool ConnectionLoader::startEmbeddedZcashd() {
}); });
QObject::connect(ezcashd, &QProcess::errorOccurred, [&] (auto error) mutable { 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); ezcashd->start(zcashdProgram);
@ -252,18 +252,9 @@ void ConnectionLoader::refreshZcashdState(Connection* connection) {
QTimer::singleShot(1000, [=]() { this->refreshZcashdState(connection); }); QTimer::singleShot(1000, [=]() { this->refreshZcashdState(connection); });
} else { } else {
// Errored out, show error and exit // 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); 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) { } else if (err == QNetworkReply::NetworkError::AuthenticationRequiredError) {
QString explanation = QString() QString explanation = QString()
% "Authentication failed. The username / password you specified was " % "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()) { } else if (err == QNetworkReply::NetworkError::InternalServerError && !res.is_discarded()) {
// 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.\n\n" % status); showInformation("Your zcashd is starting up. Please wait.", status);
// Refresh after one second // Refresh after one second
QTimer::singleShot(1000, [=]() { this->refreshZcashdState(connection); }); QTimer::singleShot(1000, [=]() { this->refreshZcashdState(connection); });
@ -282,18 +273,18 @@ void ConnectionLoader::refreshZcashdState(Connection* connection) {
); );
} }
void ConnectionLoader::showInformation(QString info) { void ConnectionLoader::showInformation(QString info, QString detail) {
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation);
connD->icon->setPixmap(icon.pixmap(128, 128));
connD->status->setText(info); connD->status->setText(info);
connD->statusDetail->setText(detail);
} }
/**
* Show error will close the loading dialog and show an error.
*/
void ConnectionLoader::showError(QString explanation) { void ConnectionLoader::showError(QString explanation) {
QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical); d->close();
connD->icon->setPixmap(icon.pixmap(128, 128));
connD->status->setText(explanation);
connD->buttonBox->setEnabled(true); QMessageBox::critical(main, "Error", explanation, QMessageBox::Ok);
} }
QString ConnectionLoader::locateZcashConfFile() { QString ConnectionLoader::locateZcashConfFile() {

2
src/connection.h

@ -54,7 +54,7 @@ private:
int getProgressFromStatus(QString status); int getProgressFromStatus(QString status);
void showError(QString explanation); void showError(QString explanation);
void showInformation(QString info); void showInformation(QString info, QString detail = "");
void doRPCSetConnection(Connection* conn); void doRPCSetConnection(Connection* conn);

119
src/connection.ui

@ -16,98 +16,75 @@
<property name="modal"> <property name="modal">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item row="4" column="1"> <property name="leftMargin">
<widget class="QDialogButtonBox" name="buttonBox"> <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>
<widget class="Line" name="line_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="0" rowspan="2"> <item>
<widget class="QLabel" name="icon"> <widget class="QLabel" name="status">
<property name="text"> <property name="text">
<string>TextLabel</string> <string>Connection Status</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="margin"> <property name="wordWrap">
<number>20</number> <bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item>
<spacer name="verticalSpacer"> <widget class="QLabel" name="statusDetail">
<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">
<widget class="QLabel" name="status">
<property name="text"> <property name="text">
<string>Connection Status</string> <string/>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
<property name="wordWrap"> </widget>
<bool>true</bool> </item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>FilledIconLabel</class>
<extends>QLabel</extends>
<header>fillediconlabel.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections> <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>
</ui> </ui>

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

18
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

2
src/rpc.cpp

@ -836,7 +836,7 @@ void RPC::shutdownZcashd() {
d.setWindowTitle("Waiting for zcashd to exit"); d.setWindowTitle("Waiting for zcashd to exit");
d.setText("Please wait for zcashd to exit. Don't click OK!"); d.setText("Please wait for zcashd to exit. Don't click OK!");
d.setStandardButtons(QMessageBox::NoButton); d.setStandardButtons(QMessageBox::NoButton);
d.setWindowFlags(Qt::SplashScreen); //d.setWindowFlags(Qt::SplashScreen);
QTimer waiter(main); QTimer waiter(main);

6
zec-qt-wallet.pro

@ -53,7 +53,8 @@ SOURCES += \
src/turnstile.cpp \ src/turnstile.cpp \
src/utils.cpp \ src/utils.cpp \
src/qrcodelabel.cpp \ src/qrcodelabel.cpp \
src/connection.cpp src/connection.cpp \
src/fillediconlabel.cpp
HEADERS += \ HEADERS += \
src/mainwindow.h \ src/mainwindow.h \
@ -71,7 +72,8 @@ HEADERS += \
src/turnstile.h \ src/turnstile.h \
src/utils.h \ src/utils.h \
src/qrcodelabel.h \ src/qrcodelabel.h \
src/connection.h src/connection.h \
src/fillediconlabel.h
FORMS += \ FORMS += \
src/mainwindow.ui \ src/mainwindow.ui \

Loading…
Cancel
Save