Skip to content

Commit 9fdc841

Browse files
committed
new splash screen connected.
1 parent 85478f4 commit 9fdc841

File tree

5 files changed

+306
-9
lines changed

5 files changed

+306
-9
lines changed

src/qt/pivx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "net.h"
1818
#include "networkstyle.h"
1919
#include "optionsmodel.h"
20-
#include "splashscreen.h"
20+
#include "qt/pivx/splash.h"
2121
#include "utilitydialog.h"
2222
#include "winshutdownmonitor.h"
2323

@@ -359,7 +359,7 @@ void BitcoinApplication::createWindow(const NetworkStyle* networkStyle)
359359

360360
void BitcoinApplication::createSplashScreen(const NetworkStyle* networkStyle)
361361
{
362-
SplashScreen* splash = new SplashScreen(0, networkStyle);
362+
Splash* splash = new Splash(0);
363363
// We don't hold a direct pointer to the splash screen after creation, so use
364364
// Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
365365
splash->setAttribute(Qt::WA_DeleteOnClose);

src/qt/pivx/forms/splash.ui

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>Splash</class>
4+
<widget class="QWidget" name="Splash">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>1200</width>
10+
<height>750</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Form</string>
15+
</property>
16+
<layout class="QVBoxLayout" name="verticalLayout_2">
17+
<property name="spacing">
18+
<number>0</number>
19+
</property>
20+
<property name="leftMargin">
21+
<number>0</number>
22+
</property>
23+
<property name="topMargin">
24+
<number>0</number>
25+
</property>
26+
<property name="rightMargin">
27+
<number>0</number>
28+
</property>
29+
<property name="bottomMargin">
30+
<number>0</number>
31+
</property>
32+
<item>
33+
<widget class="QFrame" name="frame">
34+
<property name="minimumSize">
35+
<size>
36+
<width>750</width>
37+
<height>520</height>
38+
</size>
39+
</property>
40+
<property name="styleSheet">
41+
<string notr="true"/>
42+
</property>
43+
<property name="frameShape">
44+
<enum>QFrame::StyledPanel</enum>
45+
</property>
46+
<property name="frameShadow">
47+
<enum>QFrame::Raised</enum>
48+
</property>
49+
<layout class="QVBoxLayout" name="verticalLayout">
50+
<property name="spacing">
51+
<number>0</number>
52+
</property>
53+
<property name="leftMargin">
54+
<number>0</number>
55+
</property>
56+
<property name="topMargin">
57+
<number>0</number>
58+
</property>
59+
<property name="rightMargin">
60+
<number>0</number>
61+
</property>
62+
<property name="bottomMargin">
63+
<number>0</number>
64+
</property>
65+
<item>
66+
<spacer name="verticalSpacer_2">
67+
<property name="orientation">
68+
<enum>Qt::Vertical</enum>
69+
</property>
70+
<property name="sizeHint" stdset="0">
71+
<size>
72+
<width>20</width>
73+
<height>40</height>
74+
</size>
75+
</property>
76+
</spacer>
77+
</item>
78+
<item alignment="Qt::AlignHCenter">
79+
<widget class="QLabel" name="label">
80+
<property name="minimumSize">
81+
<size>
82+
<width>300</width>
83+
<height>100</height>
84+
</size>
85+
</property>
86+
<property name="styleSheet">
87+
<string notr="true">border:none;</string>
88+
</property>
89+
<property name="text">
90+
<string/>
91+
</property>
92+
<property name="pixmap">
93+
<pixmap>://img-logo-pivx</pixmap>
94+
</property>
95+
</widget>
96+
</item>
97+
<item>
98+
<spacer name="verticalSpacer">
99+
<property name="orientation">
100+
<enum>Qt::Vertical</enum>
101+
</property>
102+
<property name="sizeHint" stdset="0">
103+
<size>
104+
<width>20</width>
105+
<height>40</height>
106+
</size>
107+
</property>
108+
</spacer>
109+
</item>
110+
<item alignment="Qt::AlignHCenter">
111+
<widget class="QLabel" name="lblMessage">
112+
<property name="minimumSize">
113+
<size>
114+
<width>0</width>
115+
<height>30</height>
116+
</size>
117+
</property>
118+
<property name="styleSheet">
119+
<string notr="true">color:white;</string>
120+
</property>
121+
<property name="text">
122+
<string>Loading…</string>
123+
</property>
124+
<property name="alignment">
125+
<set>Qt::AlignHCenter|Qt::AlignTop</set>
126+
</property>
127+
</widget>
128+
</item>
129+
<item>
130+
<widget class="QWidget" name="layoutProgress" native="true">
131+
<property name="minimumSize">
132+
<size>
133+
<width>0</width>
134+
<height>12</height>
135+
</size>
136+
</property>
137+
<layout class="QHBoxLayout" name="horizontalLayout">
138+
<property name="spacing">
139+
<number>0</number>
140+
</property>
141+
<property name="leftMargin">
142+
<number>0</number>
143+
</property>
144+
<property name="topMargin">
145+
<number>4</number>
146+
</property>
147+
<property name="rightMargin">
148+
<number>0</number>
149+
</property>
150+
<property name="bottomMargin">
151+
<number>0</number>
152+
</property>
153+
<item>
154+
<widget class="QProgressBar" name="progressBar">
155+
<property name="value">
156+
<number>24</number>
157+
</property>
158+
</widget>
159+
</item>
160+
</layout>
161+
</widget>
162+
</item>
163+
</layout>
164+
</widget>
165+
</item>
166+
</layout>
167+
</widget>
168+
<resources/>
169+
<connections/>
170+
</ui>

src/qt/pivx/res/css/style_light.css

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,35 +2115,35 @@ QPushButton[cssClass="ic-step-confirm-welcome"] {
21152115
}
21162116

21172117
*[cssClass="container-welcome-step1"] {
2118-
background-image: url(://img-welcome-step1.png);
2118+
background-image: url("://img-welcome-step1");
21192119
background-position:left bottom;
21202120
background-repeat:no-repeat;
21212121
background-color: transparent;
21222122
}
21232123

21242124
*[cssClass="container-welcome-step2"] {
2125-
background-image: url(://img-welcome-step2.png);
2125+
background-image: url("://img-welcome-step2");
21262126
background-position:left bottom;
21272127
background-repeat:no-repeat;
21282128
background-color: transparent;
21292129
}
21302130

21312131
*[cssClass="container-welcome-step3"] {
2132-
background-image: url(://img-welcome-step3.png);
2132+
background-image: url("://img-welcome-step3");
21332133
background-position:left bottom;
21342134
background-repeat:no-repeat;
21352135
background-color: transparent;
21362136
}
21372137

21382138
*[cssClass="container-welcome-step4"] {
2139-
background-image: url(://img-welcome-step4.png);
2139+
background-image: url("://img-welcome-step4");
21402140
background-position:left bottom;
21412141
background-repeat:no-repeat;
21422142
background-color: transparent;
21432143
}
21442144

21452145
QComboBox[cssClass="btn-combo-welcome"] {
2146-
background-image: url(://ic-arrow-purple-down);
2146+
background-image: url("://ic-arrow-purple-down");
21472147
background-position:right center;
21482148
background-repeat:no-repeat;
21492149
background-color:#171022;
@@ -2154,7 +2154,7 @@ QComboBox[cssClass="btn-combo-welcome"] {
21542154
}
21552155

21562156
QPushButton[cssClass="btn-welcome-back"] {
2157-
background: url(://ic-arrow-right);
2157+
background: url("://ic-arrow-right");
21582158
background-repeat:no-repeat;
21592159
background-position:center;
21602160
border: 0;
@@ -2163,7 +2163,7 @@ QPushButton[cssClass="btn-welcome-back"] {
21632163
}
21642164

21652165
QPushButton[cssClass="btn-welcome-next"] {
2166-
background: url(://ic-arrow-right);
2166+
background: url("://ic-arrow-right");
21672167
background-repeat:no-repeat;
21682168
background-position:center;
21692169
border: 0;

src/qt/pivx/splash.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#include "qt/pivx/splash.h"
2+
#include "qt/pivx/forms/ui_splash.h"
3+
#include "QFile"
4+
5+
#include "init.h"
6+
#include "ui_interface.h"
7+
#include "networkstyle.h"
8+
#include "util.h"
9+
#include "version.h"
10+
#include "guiutil.h"
11+
12+
#ifdef ENABLE_WALLET
13+
#include "wallet.h"
14+
#endif
15+
16+
#include <QCloseEvent>
17+
18+
#include <iostream>
19+
20+
Splash::Splash(QWidget *parent) :
21+
QWidget(parent),
22+
ui(new Ui::Splash)
23+
{
24+
ui->setupUi(this);
25+
setWindowTitle("PIVX Wallet");
26+
27+
this->setStyleSheet(GUIUtil::loadStyleSheet());
28+
29+
ui->progressBar->setTextVisible(false);
30+
ui->frame->setProperty("cssClass", "container-welcome");
31+
ui->layoutProgress->setProperty("cssClass", "bg-progress");
32+
33+
subscribeToCoreSignals();
34+
}
35+
36+
Splash::~Splash(){
37+
unsubscribeFromCoreSignals();
38+
delete ui;
39+
}
40+
41+
void Splash::slotFinish(QWidget* mainWin){
42+
Q_UNUSED(mainWin);
43+
hide();
44+
}
45+
46+
static void InitMessage(Splash* splash, const std::string& message){
47+
QMetaObject::invokeMethod(splash, "showMessage",
48+
Qt::QueuedConnection,
49+
Q_ARG(QString, QString::fromStdString(message)),
50+
Q_ARG(int, Qt::AlignBottom | Qt::AlignHCenter),
51+
Q_ARG(QColor, QColor(100, 100, 100)));
52+
}
53+
54+
static void ShowProgress(Splash* splash, const std::string& title, int nProgress){
55+
InitMessage(splash, title + strprintf("%d", nProgress) + "%");
56+
}
57+
58+
#ifdef ENABLE_WALLET
59+
static void ConnectWallet(Splash* splash, CWallet* wallet){
60+
wallet->ShowProgress.connect(boost::bind(ShowProgress, splash, _1, _2));
61+
}
62+
#endif
63+
64+
void Splash::subscribeToCoreSignals(){
65+
// Connect signals to client
66+
uiInterface.InitMessage.connect(boost::bind(InitMessage, this, _1));
67+
uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
68+
#ifdef ENABLE_WALLET
69+
uiInterface.LoadWallet.connect(boost::bind(ConnectWallet, this, _1));
70+
#endif
71+
}
72+
73+
void Splash::unsubscribeFromCoreSignals(){
74+
// Disconnect signals from client
75+
uiInterface.InitMessage.disconnect(boost::bind(InitMessage, this, _1));
76+
uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
77+
#ifdef ENABLE_WALLET
78+
if (pwalletMain)
79+
pwalletMain->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
80+
#endif
81+
}
82+
83+
void Splash::showMessage(const QString& message, int alignment, const QColor& color){
84+
ui->lblMessage->setText(message);
85+
}
86+
87+
void Splash::closeEvent(QCloseEvent* event){
88+
StartShutdown(); // allows an "emergency" shutdown during startup
89+
event->ignore();
90+
}

src/qt/pivx/splash.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef SPLASH_H
2+
#define SPLASH_H
3+
4+
#include <QWidget>
5+
6+
namespace Ui {
7+
class Splash;
8+
}
9+
10+
class Splash : public QWidget
11+
{
12+
Q_OBJECT
13+
14+
public:
15+
explicit Splash(QWidget *parent = nullptr);
16+
~Splash();
17+
18+
public slots:
19+
/** Slot to call finish() method as it's not defined as slot */
20+
void slotFinish(QWidget* mainWin);
21+
22+
/** Show message and progress */
23+
void showMessage(const QString& message, int alignment, const QColor& color);
24+
25+
protected:
26+
void closeEvent(QCloseEvent* event);
27+
28+
private:
29+
Ui::Splash *ui;
30+
31+
/** Connect core signals to splash screen */
32+
void subscribeToCoreSignals();
33+
/** Disconnect core signals to splash screen */
34+
void unsubscribeFromCoreSignals();
35+
};
36+
37+
#endif // SPLASH_H

0 commit comments

Comments
 (0)