]> Git Repo - VerusCoin.git/blame - src/qt/splashscreen.cpp
Copyright header updates s/2013/2014 on files whose last git commit was done in 2014.
[VerusCoin.git] / src / qt / splashscreen.cpp
CommitLineData
57702541 1// Copyright (c) 2011-2014 The Bitcoin developers
e592d43f
WL
2// Distributed under the MIT/X11 software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
f9124587 5#include "splashscreen.h"
51ed9ec9 6
f9124587 7#include "clientversion.h"
35ecf854 8#include "ui_interface.h"
4bee715b 9#include "util.h"
f9124587 10
f9124587 11#include <QApplication>
84ef729a 12#include <QPainter>
f9124587 13
2ea980a7 14SplashScreen::SplashScreen(const QPixmap &pixmap, Qt::WindowFlags f, bool isTestNet) :
f9124587
JS
15 QSplashScreen(pixmap, f)
16{
202d853b
WL
17 setAutoFillBackground(true);
18
f9124587
JS
19 // set reference point, paddings
20 int paddingRight = 50;
21 int paddingTop = 50;
22 int titleVersionVSpace = 17;
23 int titleCopyrightVSpace = 40;
24
25 float fontFactor = 1.0;
26
27 // define text to place
22f0135d 28 QString titleText = tr("Bitcoin Core");
f9124587 29 QString versionText = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
22f0135d 30 QString copyrightText = QChar(0xA9)+QString(" 2009-%1 ").arg(COPYRIGHT_YEAR) + QString(tr("The Bitcoin Core developers"));
f9124587
JS
31 QString testnetAddText = QString(tr("[testnet]")); // define text to place as single text object
32
33 QString font = "Arial";
34
35 // load the bitmap for writing some text over it
36 QPixmap newPixmap;
2ea980a7 37 if(isTestNet) {
f9124587
JS
38 newPixmap = QPixmap(":/images/splash_testnet");
39 }
40 else {
41 newPixmap = QPixmap(":/images/splash");
42 }
43
44 QPainter pixPaint(&newPixmap);
45 pixPaint.setPen(QColor(100,100,100));
46
47 // check font size and drawing with
48 pixPaint.setFont(QFont(font, 33*fontFactor));
49 QFontMetrics fm = pixPaint.fontMetrics();
50 int titleTextWidth = fm.width(titleText);
51 if(titleTextWidth > 160) {
52 // strange font rendering, Arial probably not found
53 fontFactor = 0.75;
54 }
55
56 pixPaint.setFont(QFont(font, 33*fontFactor));
57 fm = pixPaint.fontMetrics();
58 titleTextWidth = fm.width(titleText);
59 pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop,titleText);
60
61 pixPaint.setFont(QFont(font, 15*fontFactor));
62
63 // if the version string is to long, reduce size
64 fm = pixPaint.fontMetrics();
65 int versionTextWidth = fm.width(versionText);
66 if(versionTextWidth > titleTextWidth+paddingRight-10) {
67 pixPaint.setFont(QFont(font, 10*fontFactor));
68 titleVersionVSpace -= 5;
69 }
70 pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight+2,paddingTop+titleVersionVSpace,versionText);
71
72 // draw copyright stuff
73 pixPaint.setFont(QFont(font, 10*fontFactor));
74 pixPaint.drawText(newPixmap.width()-titleTextWidth-paddingRight,paddingTop+titleCopyrightVSpace,copyrightText);
75
81bdc9a5 76 // draw testnet string if testnet is on
2ea980a7 77 if(isTestNet) {
f9124587
JS
78 QFont boldFont = QFont(font, 10*fontFactor);
79 boldFont.setWeight(QFont::Bold);
80 pixPaint.setFont(boldFont);
81 fm = pixPaint.fontMetrics();
82 int testnetAddTextWidth = fm.width(testnetAddText);
83 pixPaint.drawText(newPixmap.width()-testnetAddTextWidth-10,15,testnetAddText);
84 }
85
86 pixPaint.end();
87
88 this->setPixmap(newPixmap);
35ecf854
WL
89
90 subscribeToCoreSignals();
91}
92
93SplashScreen::~SplashScreen()
94{
95 unsubscribeFromCoreSignals();
96}
97
98void SplashScreen::slotFinish(QWidget *mainWin)
99{
100 finish(mainWin);
101}
102
103static void InitMessage(SplashScreen *splash, const std::string &message)
104{
105 QMetaObject::invokeMethod(splash, "showMessage",
106 Qt::QueuedConnection,
107 Q_ARG(QString, QString::fromStdString(message)),
108 Q_ARG(int, Qt::AlignBottom|Qt::AlignHCenter),
109 Q_ARG(QColor, QColor(55,55,55)));
110}
111
112void SplashScreen::subscribeToCoreSignals()
113{
114 // Connect signals to client
115 uiInterface.InitMessage.connect(boost::bind(InitMessage, this, _1));
116}
117
118void SplashScreen::unsubscribeFromCoreSignals()
119{
120 // Disconnect signals from client
121 uiInterface.InitMessage.disconnect(boost::bind(InitMessage, this, _1));
f9124587 122}
This page took 0.1007 seconds and 4 git commands to generate.