2013-11-04 16:20:43 +01:00
|
|
|
// Copyright (c) 2011-2013 The Bitcoin developers
|
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2013-04-14 11:35:37 +02:00
|
|
|
#include "splashscreen.h"
|
2013-04-13 07:13:08 +02:00
|
|
|
|
|
|
|
#include "chainparams.h"
|
2013-04-14 11:35:37 +02:00
|
|
|
#include "clientversion.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
#include <QApplication>
|
2013-07-23 08:52:24 +02:00
|
|
|
#include <QPainter>
|
2013-04-14 11:35:37 +02:00
|
|
|
|
|
|
|
SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) :
|
|
|
|
QSplashScreen(pixmap, f)
|
|
|
|
{
|
|
|
|
// set reference point, paddings
|
|
|
|
int paddingRight = 50;
|
|
|
|
int paddingTop = 50;
|
|
|
|
int titleVersionVSpace = 17;
|
|
|
|
int titleCopyrightVSpace = 40;
|
|
|
|
|
|
|
|
float fontFactor = 1.0;
|
|
|
|
|
|
|
|
// define text to place
|
2013-12-13 07:39:56 +01:00
|
|
|
QString titleText = tr("Bitcoin Core");
|
2013-04-14 11:35:37 +02:00
|
|
|
QString versionText = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
|
2013-12-13 07:39:56 +01:00
|
|
|
QString copyrightText = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers"));
|
2013-04-14 11:35:37 +02:00
|
|
|
QString testnetAddText = QString(tr("[testnet]")); // define text to place as single text object
|
|
|
|
|
|
|
|
QString font = "Arial";
|
|
|
|
|
|
|
|
// load the bitmap for writing some text over it
|
|
|
|
QPixmap newPixmap;
|
2013-06-23 18:04:44 +02:00
|
|
|
if(TestNet()) {
|
2013-04-14 11:35:37 +02:00
|
|
|
newPixmap = QPixmap(":/images/splash_testnet");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newPixmap = QPixmap(":/images/splash");
|
|
|
|
}
|
|
|
|
|
|
|
|
QPainter pixPaint(&newPixmap);
|
|
|
|
pixPaint.setPen(QColor(100,100,100));
|
|
|
|
|
|
|
|
// check font size and drawing with
|
|
|
|
pixPaint.setFont(QFont(font, 33*fontFactor));
|
|
|
|
QFontMetrics fm = pixPaint.fontMetrics();
|
|
|
|
int titleTextWidth = fm.width(titleText);
|
|
|
|
if(titleTextWidth > 160) {
|
|
|
|
// strange font rendering, Arial probably not found
|
|
|
|
fontFactor = 0.75;
|
|
|
|
}
|
|
|
|
|
|
|
|
pixPaint.setFont(QFont(font, 33*fontFactor));
|
|
|
|
fm = pixPaint.fontMetrics();
|
|
|
|
titleTextWidth = fm.width(titleText);
|
|
|
|
pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop,titleText);
|
|
|
|
|
|
|
|
pixPaint.setFont(QFont(font, 15*fontFactor));
|
|
|
|
|
|
|
|
// if the version string is to long, reduce size
|
|
|
|
fm = pixPaint.fontMetrics();
|
|
|
|
int versionTextWidth = fm.width(versionText);
|
|
|
|
if(versionTextWidth > titleTextWidth+paddingRight-10) {
|
|
|
|
pixPaint.setFont(QFont(font, 10*fontFactor));
|
|
|
|
titleVersionVSpace -= 5;
|
|
|
|
}
|
|
|
|
pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);
|
|
|
|
|
|
|
|
// draw copyright stuff
|
|
|
|
pixPaint.setFont(QFont(font, 10*fontFactor));
|
|
|
|
pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);
|
|
|
|
|
2013-10-22 09:03:50 +02:00
|
|
|
// draw testnet string if testnet is on
|
|
|
|
if(TestNet()) {
|
2013-04-14 11:35:37 +02:00
|
|
|
QFont boldFont = QFont(font, 10*fontFactor);
|
|
|
|
boldFont.setWeight(QFont::Bold);
|
|
|
|
pixPaint.setFont(boldFont);
|
|
|
|
fm = pixPaint.fontMetrics();
|
|
|
|
int testnetAddTextWidth = fm.width(testnetAddText);
|
|
|
|
pixPaint.drawText(newPixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
|
|
|
|
}
|
|
|
|
|
|
|
|
pixPaint.end();
|
|
|
|
|
|
|
|
this->setPixmap(newPixmap);
|
|
|
|
}
|