From 01eeb59af6c981b87d43e2b6508e127f79e767bb Mon Sep 17 00:00:00 2001 From: Spencer Lievens Date: Tue, 28 Feb 2017 09:59:27 +0100 Subject: [PATCH] Splashscreen now displays correctly (Fully) (#1367) * Splashscreen now displays correctly on retina devices * Remove devicePixelRatio instances --- src/qt/splashscreen.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index e02c5b06b..85de3fa5b 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -5,15 +5,14 @@ #include "splashscreen.h" +#include "guiutil.h" #include "networkstyle.h" #include "clientversion.h" -#include "guiutil.h" #include "init.h" #include "util.h" #include "ui_interface.h" #include "version.h" - #ifdef ENABLE_WALLET #include "wallet/wallet.h" #endif @@ -26,6 +25,14 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) : QWidget(0, f), curAlignment(0) { + + // transparent background + setAttribute(Qt::WA_TranslucentBackground); + setStyleSheet("background:transparent;"); + + // no window decorations + setWindowFlags(Qt::FramelessWindowHint); + // set reference point, paddings int paddingLeft = 14; int paddingTop = 470; @@ -33,10 +40,6 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) int titleCopyrightVSpace = 32; 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("Dash Core"); @@ -44,9 +47,6 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) QString copyrightTextBtc = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers")); QString copyrightTextDash = QChar(0xA9)+QString(" 2014-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Dash Core developers")); QString titleAddText = networkStyle->getTitleAddText(); - - QString font = QApplication::font().toString(); - // networkstyle.cpp can't (yet) read themes, so we do it here to get the correct Splash-screen QString splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash"; if(GetBoolArg("-regtest", false)) @@ -54,6 +54,8 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) if(GetBoolArg("-testnet", false)) splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_testnet"; + QString font = QApplication::font().toString(); + // load the bitmap for writing some text over it pixmap = QPixmap(splashScreenPath); @@ -94,11 +96,8 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) pixPaint.end(); - // Set window title - setWindowTitle(titleText + " " + titleAddText); - // Resize window and move to center of desktop, disallow resizing - QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height()/devicePixelRatio)); + QRect r(QPoint(), pixmap.size()); resize(r.size()); setFixedSize(r.size()); move(QApplication::desktop()->screenGeometry().center() - r.center());