5#include <bitcoin-build-config.h>
21#include <QApplication>
24#include <QRadialGradient>
32 int paddingRight = 50;
34 int titleVersionVSpace = 17;
35 int titleCopyrightVSpace = 40;
37 float fontFactor = 1.0;
38 float devicePixelRatio = 1.0;
39 devicePixelRatio =
static_cast<QGuiApplication*
>(QCoreApplication::instance())->devicePixelRatio();
42 QString titleText = CLIENT_NAME;
43 QString versionText = QString(
"Version %1").arg(QString::fromStdString(
FormatFullVersion()));
47 QString font = QApplication::font().toString();
50 QSize splashSize(480*devicePixelRatio,320*devicePixelRatio);
51 pixmap = QPixmap(splashSize);
54 pixmap.setDevicePixelRatio(devicePixelRatio);
56 QPainter pixPaint(&
pixmap);
57 pixPaint.setPen(QColor(100,100,100));
60 QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio);
61 gradient.setColorAt(0, Qt::white);
62 gradient.setColorAt(1, QColor(247,247,247));
63 QRect rGradient(QPoint(0,0), splashSize);
64 pixPaint.fillRect(rGradient, gradient);
67 QRect rectIcon(QPoint(-150,-122), QSize(430,430));
69 const QSize requiredSize(1024,1024);
70 QPixmap icon(networkStyle->
getAppIcon().pixmap(requiredSize));
72 pixPaint.drawPixmap(rectIcon, icon);
75 pixPaint.setFont(QFont(font, 33*fontFactor));
76 QFontMetrics fm = pixPaint.fontMetrics();
78 if (titleTextWidth > 176) {
79 fontFactor = fontFactor * 176 / titleTextWidth;
82 pixPaint.setFont(QFont(font, 33*fontFactor));
83 fm = pixPaint.fontMetrics();
85 pixPaint.drawText(
pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop,titleText);
87 pixPaint.setFont(QFont(font, 15*fontFactor));
90 fm = pixPaint.fontMetrics();
92 if(versionTextWidth > titleTextWidth+paddingRight-10) {
93 pixPaint.setFont(QFont(font, 10*fontFactor));
94 titleVersionVSpace -= 5;
96 pixPaint.drawText(
pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);
100 pixPaint.setFont(QFont(font, 10*fontFactor));
101 const int x =
pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight;
102 const int y = paddingTop+titleCopyrightVSpace;
103 QRect copyrightRect(x, y,
pixmap.width() - x - paddingRight,
pixmap.height() - y);
104 pixPaint.drawText(copyrightRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, copyrightText);
108 if(!titleAddText.isEmpty()) {
109 QFont boldFont = QFont(font, 10*fontFactor);
110 boldFont.setWeight(QFont::Bold);
111 pixPaint.setFont(boldFont);
112 fm = pixPaint.fontMetrics();
114 pixPaint.drawText(
pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleAddText);
120 setWindowTitle(titleText +
" " + titleAddText);
123 QRect r(QPoint(), QSize(
pixmap.size().width()/devicePixelRatio,
pixmap.size().height()/devicePixelRatio));
125 setFixedSize(r.size());
126 move(QGuiApplication::primaryScreen()->geometry().center() - r.center());
128 installEventFilter(
this);
153 if (ev->type() == QEvent::KeyPress) {
154 QKeyEvent *keyEvent =
static_cast<QKeyEvent *
>(ev);
155 if (keyEvent->key() == Qt::Key_Q) {
159 return QObject::eventFilter(obj, ev);
164 bool invoked = QMetaObject::invokeMethod(splash,
"showMessage",
165 Qt::QueuedConnection,
166 Q_ARG(QString, QString::fromStdString(message)),
167 Q_ARG(
int, Qt::AlignBottom|Qt::AlignHCenter),
168 Q_ARG(QColor, QColor(55,55,55)));
175 (resume_possible ? SplashScreen::tr(
"(press q to shutdown and continue later)").toStdString()
176 : SplashScreen::tr(
"press q to shutdown").toStdString()) +
221 QPainter painter(
this);
222 painter.drawPixmap(0, 0,
pixmap);
223 QRect r = rect().adjusted(5, 5, -5, -5);
const QIcon & getAppIcon() const
const QString & getTitleAddText() const
Class for the splashscreen with information of the running client.
void shutdown()
Initiate shutdown.
std::unique_ptr< interfaces::Handler > m_handler_show_progress
void showMessage(const QString &message, int alignment, const QColor &color)
Show message and progress.
void unsubscribeFromCoreSignals()
Disconnect core signals to splash screen.
std::list< std::unique_ptr< interfaces::Wallet > > m_connected_wallets
void subscribeToCoreSignals()
Connect core signals to splash screen.
std::unique_ptr< interfaces::Handler > m_handler_init_wallet
std::list< std::unique_ptr< interfaces::Handler > > m_connected_wallet_handlers
std::unique_ptr< interfaces::Handler > m_handler_init_message
void paintEvent(QPaintEvent *event) override
void closeEvent(QCloseEvent *event) override
void handleLoadWallet()
Handle wallet load notifications.
void setNode(interfaces::Node &node)
bool eventFilter(QObject *obj, QEvent *ev) override
SplashScreen(const NetworkStyle *networkStyle)
std::unique_ptr< interfaces::Handler > m_handler_load_wallet
interfaces::Node * m_node
static bool isWalletEnabled()
Top-level interface for a bitcoin node (bitcoind process).
virtual std::unique_ptr< Handler > handleInitMessage(InitMessageFn fn)=0
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
virtual void startShutdown()=0
Start shutdown.
virtual std::unique_ptr< Handler > handleInitWallet(InitWalletFn fn)=0
virtual WalletLoader & walletLoader()=0
Get wallet loader.
virtual std::unique_ptr< Handler > handleLoadWallet(LoadWalletFn fn)=0
std::string CopyrightHolders(const std::string &strPrefix)
std::string FormatFullVersion()
void handleCloseWindowShortcut(QWidget *w)
int TextWidth(const QFontMetrics &fm, const QString &text)
Returns the distance in pixels appropriate for drawing a subsequent character after text.
bool(* handler)(const std::any &context, HTTPRequest *req, const std::string &strReq)
static void ShowProgress(SplashScreen *splash, const std::string &title, int nProgress, bool resume_possible)
static void InitMessage(SplashScreen *splash, const std::string &message)