6 #if defined(HAVE_CONFIG_H) 24 #include <QApplication> 25 #include <QCloseEvent> 26 #include <QDesktopWidget> 28 #include <QRadialGradient> 31 QWidget(0, f), curAlignment(0)
34 int paddingRight = 50;
36 int titleVersionVSpace = 17;
37 int titleCopyrightVSpace = 40;
39 float fontFactor = 1.0;
40 float devicePixelRatio = 1.0;
41 #if QT_VERSION > 0x050100 42 devicePixelRatio = ((QGuiApplication*)QCoreApplication::instance())->devicePixelRatio();
47 QString versionText = QString(
"Version %1").arg(QString::fromStdString(
FormatFullVersion()));
51 QString font = QApplication::font().toString();
54 QSize splashSize(480*devicePixelRatio,320*devicePixelRatio);
55 pixmap = QPixmap(splashSize);
57 #if QT_VERSION > 0x050100 59 pixmap.setDevicePixelRatio(devicePixelRatio);
62 QPainter pixPaint(&
pixmap);
63 pixPaint.setPen(QColor(100,100,100));
66 QRadialGradient gradient(QPoint(0,0), 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(-40,0), QSize(310,310));
75 const QSize requiredSize(1024,1024);
76 QPixmap icon(networkStyle->
getSplashIcon().pixmap(requiredSize));
78 pixPaint.drawPixmap(rectIcon, icon);
81 pixPaint.setFont(QFont(font, 33*fontFactor));
82 QFontMetrics fm = pixPaint.fontMetrics();
83 int titleTextWidth = fm.width(titleText);
84 if (titleTextWidth > 176) {
85 fontFactor = fontFactor * 176 / titleTextWidth;
88 pixPaint.setFont(QFont(font, 33*fontFactor));
89 fm = pixPaint.fontMetrics();
90 titleTextWidth = fm.width(titleText);
91 pixPaint.drawText(
pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop,titleText);
93 pixPaint.setFont(QFont(font, 15*fontFactor));
96 fm = pixPaint.fontMetrics();
97 int versionTextWidth = fm.width(versionText);
98 if(versionTextWidth > titleTextWidth+paddingRight-10) {
99 pixPaint.setFont(QFont(font, 10*fontFactor));
100 titleVersionVSpace -= 5;
102 pixPaint.drawText(
pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);
106 pixPaint.setFont(QFont(font, 10*fontFactor));
107 const int x =
pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight;
108 const int y = paddingTop+titleCopyrightVSpace;
109 QRect copyrightRect(x, y,
pixmap.width() - x - paddingRight,
pixmap.height() - y);
110 pixPaint.drawText(copyrightRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, copyrightText);
114 if(!titleAddText.isEmpty()) {
115 QFont boldFont = QFont(font, 10*fontFactor);
116 boldFont.setWeight(QFont::Bold);
117 pixPaint.setFont(boldFont);
118 fm = pixPaint.fontMetrics();
119 int titleAddTextWidth = fm.width(titleAddText);
120 pixPaint.drawText(
pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,
titleAddText);
126 setWindowTitle(titleText +
" " + titleAddText);
129 QRect r(QPoint(), QSize(
pixmap.size().width()/devicePixelRatio,
pixmap.size().height()/devicePixelRatio));
131 setFixedSize(r.size());
132 move(QApplication::desktop()->screenGeometry().center() - r.center());
135 installEventFilter(
this);
144 if (ev->type() == QEvent::KeyPress) {
145 QKeyEvent *keyEvent =
static_cast<QKeyEvent *
>(ev);
146 if(keyEvent->text()[0] ==
'q') {
150 return QObject::eventFilter(obj, ev);
165 static void InitMessage(
SplashScreen *splash,
const std::string &message)
167 QMetaObject::invokeMethod(splash,
"showMessage",
168 Qt::QueuedConnection,
169 Q_ARG(QString, QString::fromStdString(message)),
170 Q_ARG(
int, Qt::AlignBottom|Qt::AlignHCenter),
171 Q_ARG(QColor, QColor(55,55,55)));
174 static void ShowProgress(
SplashScreen *splash,
const std::string &title,
int nProgress,
bool resume_possible)
176 InitMessage(splash, title + std::string(
"\n") +
177 (resume_possible ?
_(
"(press q to shutdown and continue later)")
178 :
_(
"press q to shutdown")) +
185 wallet->
ShowProgress.connect(boost::bind(ShowProgress,
this, _1, _2,
false));
207 pwallet->ShowProgress.disconnect(boost::bind(ShowProgress,
this, _1, _2,
false));
222 QPainter painter(
this);
223 painter.drawPixmap(0, 0,
pixmap);
224 QRect r = rect().adjusted(5, 5, -5, -5);
bool eventFilter(QObject *obj, QEvent *ev)
void unsubscribeFromCoreSignals()
Disconnect core signals to splash screen.
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
const QString & getTitleAddText() const
void paintEvent(QPaintEvent *event)
void showMessage(const QString &message, int alignment, const QColor &color)
Show message and progress.
const QIcon & getSplashIcon() const
std::string FormatFullVersion()
std::string CopyrightHolders(const std::string &strPrefix)
void slotFinish(QWidget *mainWin)
Slot to call finish() method as it's not defined as slot.
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.
const char * titleAddText
CClientUIInterface uiInterface
boost::signals2::signal< void(const std::string &title, int nProgress, bool resume_possible)> ShowProgress
Show progress e.g.
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.