5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
23#include <QApplication>
26#include <QRadialGradient>
30 : QWidget(nullptr), curAlignment(0) {
32 int paddingRight = 50;
34 int titleVersionVSpace = 17;
35 int titleCopyrightVSpace = 40;
37 float fontFactor = 1.0;
38 float devicePixelRatio = 1.0;
40 static_cast<QGuiApplication *
>(QCoreApplication::instance())
44 QString titleText = PACKAGE_NAME;
47 QString copyrightText = QString::fromUtf8(
52 QString font = QApplication::font().toString();
55 QSize splashSize(634 * devicePixelRatio, 320 * devicePixelRatio);
56 pixmap = QPixmap(splashSize);
59 pixmap.setDevicePixelRatio(devicePixelRatio);
61 QPainter pixPaint(&
pixmap);
62 pixPaint.setPen(QColor(100, 100, 100));
65 QRadialGradient gradient(QPoint(0, 0),
66 splashSize.width() / devicePixelRatio);
67 gradient.setColorAt(0, Qt::white);
68 gradient.setColorAt(1, QColor(247, 247, 247));
69 QRect rGradient(QPoint(0, 0), splashSize);
70 pixPaint.fillRect(rGradient, gradient);
73 QRect rectIcon(QPoint(-10, -100), QSize(430, 430));
75 const QSize requiredSize(1024, 1024);
76 QPixmap icon(networkStyle->
getAppIcon().pixmap(requiredSize));
78 pixPaint.drawPixmap(rectIcon, icon);
81 pixPaint.setFont(QFont(font, 33 * fontFactor));
82 QFontMetrics fm = pixPaint.fontMetrics();
84 if (titleTextWidth > 176) {
85 fontFactor = fontFactor * 176 / titleTextWidth;
88 pixPaint.setFont(QFont(font, 33 * fontFactor));
89 fm = pixPaint.fontMetrics();
91 pixPaint.drawText(
pixmap.width() / devicePixelRatio - titleTextWidth -
93 paddingTop, titleText);
95 pixPaint.setFont(QFont(font, 15 * fontFactor));
98 fm = pixPaint.fontMetrics();
100 if (versionTextWidth > titleTextWidth + paddingRight - 10) {
101 pixPaint.setFont(QFont(font, 10 * fontFactor));
102 titleVersionVSpace -= 5;
104 pixPaint.drawText(
pixmap.width() / devicePixelRatio - titleTextWidth -
106 paddingTop + titleVersionVSpace, versionText);
110 pixPaint.setFont(QFont(font, 10 * fontFactor));
112 pixmap.width() / devicePixelRatio - titleTextWidth - paddingRight;
113 const int y = paddingTop + titleCopyrightVSpace;
114 QRect copyrightRect(x, y,
pixmap.width() - x - paddingRight,
116 pixPaint.drawText(copyrightRect,
117 Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap,
122 if (!titleAddText.isEmpty()) {
123 QFont boldFont = QFont(font, 10 * fontFactor);
124 boldFont.setWeight(QFont::Bold);
125 pixPaint.setFont(boldFont);
126 fm = pixPaint.fontMetrics();
128 pixPaint.drawText(
pixmap.width() / devicePixelRatio -
129 titleAddTextWidth - 10,
136 setWindowTitle(titleText +
" " + titleAddText);
139 QRect r(QPoint(), QSize(
pixmap.size().width() / devicePixelRatio,
140 pixmap.size().height() / devicePixelRatio));
142 setFixedSize(r.size());
143 move(QGuiApplication::primaryScreen()->geometry().center() - r.center());
145 installEventFilter(
this);
173 if (ev->type() == QEvent::KeyPress) {
174 QKeyEvent *keyEvent =
static_cast<QKeyEvent *
>(ev);
175 if (keyEvent->key() == Qt::Key_Q) {
179 return QObject::eventFilter(obj, ev);
194 bool invoked = QMetaObject::invokeMethod(
195 splash,
"showMessage", Qt::QueuedConnection,
196 Q_ARG(QString, QString::fromStdString(message)),
197 Q_ARG(
int, Qt::AlignBottom | Qt::AlignHCenter),
198 Q_ARG(QColor, QColor(55, 55, 55)));
203 int nProgress,
bool resume_possible) {
206 title + std::string(
"\n") +
208 ?
_(
"(press q to shutdown and continue later)").translated
209 :
_(
"press q to shutdown").translated) +
216 std::bind(
InitMessage,
this, std::placeholders::_1));
219 std::placeholders::_2, std::placeholders::_3));
228 [
this](std::unique_ptr<interfaces::Wallet>
wallet) {
231 std::placeholders::_2,
false)));
249 const QColor &color) {
257 QPainter painter(
this);
258 painter.drawPixmap(0, 0,
pixmap);
259 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.
void finish()
Hide the splash screen window and schedule the splash screen object for deletion.
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 WalletClient & walletClient()=0
Get wallet client.
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)(Config &config, 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)
bilingual_str _(const char *psz)
Translation function.