5 #if defined(HAVE_CONFIG_H) 23 #include <QApplication> 24 #include <QCloseEvent> 25 #include <QDesktopWidget> 27 #include <QRadialGradient> 30 QWidget(0, f), curAlignment(0)
33 int versionTextHeight = 30;
34 int statusHeight = 30;
35 int titleAddTextHeight = 20;
37 float fontFactor = 1.0;
38 float devicePixelRatio = 1.0;
39 #if QT_VERSION > 0x050100 40 devicePixelRatio = ((QGuiApplication*)QCoreApplication::instance())->devicePixelRatio();
45 QString versionText = QString(
"Version %1").arg(QString::fromStdString(
FormatFullVersion()));
49 QString font = QApplication::font().toString();
52 QSize splashSize(480,320);
53 pixmap = QPixmap(480*devicePixelRatio,320*devicePixelRatio);
55 #if QT_VERSION > 0x050100 57 pixmap.setDevicePixelRatio(devicePixelRatio);
60 QPainter pixPaint(&
pixmap);
61 pixPaint.setPen(QColor(
"#ffffff"));
63 QRect mainRect(QPoint(0,0), splashSize);
64 pixPaint.fillRect(mainRect, QColor(
"#030509"));
67 QRect rectBg(QPoint(-50, -50), QSize(splashSize.width() + 50, splashSize.height() + 50));
68 QPixmap bg(
":/styles/app-icons/splash_bg");
69 pixPaint.drawPixmap(rectBg, bg);
71 pixPaint.setFont(QFont(font, 32*fontFactor, QFont::Bold));
72 QRect rectTitle(QPoint(0,0), QSize(splashSize.width(), (splashSize.height() / 2)));
73 pixPaint.drawText(rectTitle, Qt::AlignHCenter | Qt::AlignBottom, titleText);
75 QPoint versionPoint(rectTitle.bottomLeft());
78 if(!titleAddText.isEmpty())
80 QRect titleAddRect(rectTitle.bottomLeft(), QSize(rectTitle.width(), titleAddTextHeight));
81 versionPoint = titleAddRect.bottomLeft();
82 pixPaint.setFont(QFont(font, 8*fontFactor, QFont::Bold));
83 pixPaint.drawText(titleAddRect, Qt::AlignHCenter | Qt::AlignVCenter, titleAddText);
86 pixPaint.setFont(QFont(font, 11*fontFactor));
87 QRect versionRect(versionPoint, QSize(rectTitle.width(), versionTextHeight));
88 pixPaint.drawText(versionRect, Qt::AlignHCenter | Qt::AlignTop, versionText);
91 QFont statusFont = QApplication::font();
92 statusFont.setPointSizeF(statusFont.pointSizeF() * 0.9);
93 pixPaint.setFont(statusFont);
94 QRect statusRect(mainRect.left(), mainRect.height() - statusHeight, mainRect.width(), statusHeight);
95 QColor statusColor(255, 255, 255);
96 statusColor.setAlphaF(0.1);
97 pixPaint.fillRect(statusRect, statusColor);
98 pixPaint.drawText(statusRect.adjusted(10, 0, -10, 0), Qt::AlignLeft | Qt::AlignVCenter, copyrightText);
103 setWindowTitle(titleText +
" " + titleAddText);
106 QRect r(QPoint(), QSize(
pixmap.size().width()/devicePixelRatio,
pixmap.size().height()/devicePixelRatio));
108 setFixedSize(r.size());
109 move(QApplication::desktop()->screenGeometry().center() - r.center());
112 installEventFilter(
this);
121 if (ev->type() == QEvent::KeyPress) {
122 QKeyEvent *keyEvent =
static_cast<QKeyEvent *
>(ev);
123 if(keyEvent->text()[0] ==
'q' &&
breakAction !=
nullptr) {
127 return QObject::eventFilter(obj, ev);
142 static void InitMessage(
SplashScreen *splash,
const std::string &message)
144 QMetaObject::invokeMethod(splash,
"showMessage",
145 Qt::QueuedConnection,
146 Q_ARG(QString, QString::fromStdString(message)),
147 Q_ARG(
int, Qt::AlignBottom|Qt::AlignRight),
148 Q_ARG(QColor, QColor(
"#ffffff")));
151 static void ShowProgress(
SplashScreen *splash,
const std::string &title,
int nProgress)
153 InitMessage(splash, title +
strprintf(
"%d", nProgress) +
"%");
163 QMetaObject::invokeMethod(splash,
"setBreakAction",
164 Qt::QueuedConnection,
171 wallet->
ShowProgress.connect(boost::bind(ShowProgress,
this, _1, _2));
194 pwallet->ShowProgress.disconnect(boost::bind(ShowProgress,
this, _1, _2));
209 QPainter painter(
this);
210 painter.drawPixmap(0, 0,
pixmap);
211 QRect r = rect().adjusted(10, 10, -10, -10);
213 QFont font = QApplication::font();
214 font.setPointSizeF(font.pointSizeF() * 0.9);
215 painter.setFont(font);
bool eventFilter(QObject *obj, QEvent *ev)
void unsubscribeFromCoreSignals()
Disconnect core signals to splash screen.
#define function(a, b, c, d, k, s)
void closeEvent(QCloseEvent *event)
void ConnectWallet(CWallet *)
Connect wallet signals to splash screen.
Class for the splashscreen with information of the running client.
SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
void subscribeToCoreSignals()
Connect core signals to splash screen.
boost::signals2::signal< void(CWallet *wallet)> LoadWallet
A wallet has been loaded.
QList< CWallet * > connectedWallets
void paintEvent(QPaintEvent *event)
void showMessage(const QString &message, int alignment, const QColor &color)
Show message and progress.
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
std::string FormatFullVersion()
std::string CopyrightHolders(const std::string &strPrefix)
std::function< void(void)> breakAction
void slotFinish(QWidget *mainWin)
Slot to call finish() method as it's not defined as slot.
boost::signals2::signal< void(std::function< void(void)> action)> SetProgressBreakAction
Set progress break action (possible "cancel button" triggers that action)
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
void setBreakAction(const std::function< void(void)> &action)
Sets the break action.
const char * titleAddText
CClientUIInterface uiInterface
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
const QString & getTitleAddText() const