|
|
|
@ -19,6 +19,7 @@
@@ -19,6 +19,7 @@
|
|
|
|
|
#include <QCloseEvent> |
|
|
|
|
#include <QDesktopWidget> |
|
|
|
|
#include <QPainter> |
|
|
|
|
#include <QRadialGradient> |
|
|
|
|
|
|
|
|
|
SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) : |
|
|
|
|
QWidget(0, f), curAlignment(0) |
|
|
|
@ -30,6 +31,10 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
@@ -30,6 +31,10 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
|
|
|
|
|
int titleCopyrightVSpace = 40; |
|
|
|
|
|
|
|
|
|
float fontFactor = 1.0; |
|
|
|
|
float devicePixelRatio = 1.0; |
|
|
|
|
#if QT_VERSION > 0x050100 |
|
|
|
|
devicePixelRatio = ((QGuiApplication*)QCoreApplication::instance())->devicePixelRatio(); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// define text to place
|
|
|
|
|
QString titleText = tr("Bitcoin Core"); |
|
|
|
@ -39,12 +44,34 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
@@ -39,12 +44,34 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
|
|
|
|
|
|
|
|
|
|
QString font = "Arial"; |
|
|
|
|
|
|
|
|
|
// load the bitmap for writing some text over it
|
|
|
|
|
pixmap = networkStyle->getSplashImage(); |
|
|
|
|
// create a bitmap according to device pixelratio
|
|
|
|
|
QSize splashSize(480*devicePixelRatio,320*devicePixelRatio); |
|
|
|
|
pixmap = QPixmap(splashSize); |
|
|
|
|
|
|
|
|
|
#if QT_VERSION > 0x050100 |
|
|
|
|
// change to HiDPI if it makes sense
|
|
|
|
|
pixmap.setDevicePixelRatio(devicePixelRatio); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
QPainter pixPaint(&pixmap); |
|
|
|
|
pixPaint.setPen(QColor(100,100,100)); |
|
|
|
|
|
|
|
|
|
// draw a slighly radial gradient
|
|
|
|
|
QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio); |
|
|
|
|
gradient.setColorAt(0, Qt::white); |
|
|
|
|
gradient.setColorAt(1, QColor(247,247,247)); |
|
|
|
|
QRect rGradient(QPoint(0,0), splashSize); |
|
|
|
|
pixPaint.fillRect(rGradient, gradient); |
|
|
|
|
|
|
|
|
|
// draw the bitcoin icon, expected size of PNG: 1024x1024
|
|
|
|
|
QRect rectIcon(QPoint(-150,-122), QSize(430,430)); |
|
|
|
|
|
|
|
|
|
const QSize requiredSize(1024,1024); |
|
|
|
|
QIcon appIcon = networkStyle->getAppIcon(requiredSize); |
|
|
|
|
QPixmap icon(appIcon.pixmap(requiredSize)); |
|
|
|
|
|
|
|
|
|
pixPaint.drawPixmap(rectIcon, icon); |
|
|
|
|
|
|
|
|
|
// check font size and drawing with
|
|
|
|
|
pixPaint.setFont(QFont(font, 33*fontFactor)); |
|
|
|
|
QFontMetrics fm = pixPaint.fontMetrics(); |
|
|
|
@ -57,7 +84,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
@@ -57,7 +84,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
|
|
|
|
|
pixPaint.setFont(QFont(font, 33*fontFactor)); |
|
|
|
|
fm = pixPaint.fontMetrics(); |
|
|
|
|
titleTextWidth = fm.width(titleText); |
|
|
|
|
pixPaint.drawText(pixmap.width()-titleTextWidth-paddingRight,paddingTop,titleText); |
|
|
|
|
pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop,titleText); |
|
|
|
|
|
|
|
|
|
pixPaint.setFont(QFont(font, 15*fontFactor)); |
|
|
|
|
|
|
|
|
@ -68,11 +95,11 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
@@ -68,11 +95,11 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
|
|
|
|
|
pixPaint.setFont(QFont(font, 10*fontFactor)); |
|
|
|
|
titleVersionVSpace -= 5; |
|
|
|
|
} |
|
|
|
|
pixPaint.drawText(pixmap.width()-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText); |
|
|
|
|
pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText); |
|
|
|
|
|
|
|
|
|
// draw copyright stuff
|
|
|
|
|
pixPaint.setFont(QFont(font, 10*fontFactor)); |
|
|
|
|
pixPaint.drawText(pixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText); |
|
|
|
|
pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText); |
|
|
|
|
|
|
|
|
|
// draw additional text if special network
|
|
|
|
|
if(!titleAddText.isEmpty()) { |
|
|
|
@ -81,7 +108,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
@@ -81,7 +108,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
|
|
|
|
|
pixPaint.setFont(boldFont); |
|
|
|
|
fm = pixPaint.fontMetrics(); |
|
|
|
|
int titleAddTextWidth = fm.width(titleAddText); |
|
|
|
|
pixPaint.drawText(pixmap.width()-titleAddTextWidth-10,15,titleAddText); |
|
|
|
|
pixPaint.drawText(pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleAddText); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pixPaint.end(); |
|
|
|
@ -90,7 +117,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
@@ -90,7 +117,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
|
|
|
|
|
setWindowTitle(titleText + " " + titleAddText); |
|
|
|
|
|
|
|
|
|
// Resize window and move to center of desktop, disallow resizing
|
|
|
|
|
QRect r(QPoint(), pixmap.size()); |
|
|
|
|
QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height()/devicePixelRatio)); |
|
|
|
|
resize(r.size()); |
|
|
|
|
setFixedSize(r.size()); |
|
|
|
|
move(QApplication::desktop()->screenGeometry().center() - r.center()); |
|
|
|
|