aboutsummaryrefslogtreecommitdiff
path: root/src/qt/splashscreen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/splashscreen.cpp')
-rw-r--r--src/qt/splashscreen.cpp61
1 files changed, 40 insertions, 21 deletions
diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp
index 74512e62aa..378d79c1e1 100644
--- a/src/qt/splashscreen.cpp
+++ b/src/qt/splashscreen.cpp
@@ -6,6 +6,7 @@
#include "clientversion.h"
#include "init.h"
+#include "networkstyle.h"
#include "ui_interface.h"
#include "util.h"
#include "version.h"
@@ -18,8 +19,9 @@
#include <QCloseEvent>
#include <QDesktopWidget>
#include <QPainter>
+#include <QRadialGradient>
-SplashScreen::SplashScreen(Qt::WindowFlags f, bool isTestNet) :
+SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) :
QWidget(0, f), curAlignment(0)
{
// set reference point, paddings
@@ -29,26 +31,46 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, bool isTestNet) :
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");
QString versionText = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
QString copyrightText = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers"));
- QString testnetAddText = QString(tr("[testnet]")); // define text to place as single text object
+ QString titleAddText = networkStyle->getTitleAddText();
QString font = "Arial";
- // load the bitmap for writing some text over it
- if(isTestNet) {
- pixmap = QPixmap(":/images/splash_testnet");
- }
- else {
- pixmap = QPixmap(":/images/splash");
- }
+ // 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);
+ QPixmap icon(networkStyle->getAppIcon().pixmap(requiredSize));
+
+ pixPaint.drawPixmap(rectIcon, icon);
+
// check font size and drawing with
pixPaint.setFont(QFont(font, 33*fontFactor));
QFontMetrics fm = pixPaint.fontMetrics();
@@ -61,7 +83,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, bool isTestNet) :
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));
@@ -72,32 +94,29 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, bool isTestNet) :
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 testnet string if testnet is on
- if(isTestNet) {
+ // draw additional text if special network
+ if(!titleAddText.isEmpty()) {
QFont boldFont = QFont(font, 10*fontFactor);
boldFont.setWeight(QFont::Bold);
pixPaint.setFont(boldFont);
fm = pixPaint.fontMetrics();
- int testnetAddTextWidth = fm.width(testnetAddText);
- pixPaint.drawText(pixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
+ int titleAddTextWidth = fm.width(titleAddText);
+ pixPaint.drawText(pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleAddText);
}
pixPaint.end();
// Set window title
- if(isTestNet)
- setWindowTitle(titleText + " " + testnetAddText);
- else
- setWindowTitle(titleText);
+ 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());