Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSplashScreen Class Reference

#include <kis_splash_screen.h>

+ Inheritance diagram for KisSplashScreen:

Classes

struct  Source
 

Public Member Functions

 KisSplashScreen (int height, QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags(Qt::SplashScreen|Qt::FramelessWindowHint))
 
void repaint ()
 
void setLoadingText (QString text)
 
void show ()
 

Static Public Member Functions

static Source getImageSource ()
 

Private Member Functions

void updateSplashImage (const int height)
 

Private Attributes

QLabel * m_artCreditsLabel
 
QSvgWidget * m_bannerSvg
 
QSvgWidget * m_brandingSvg
 
bool m_displayLinks { false }
 
QLabel * m_lblSplash
 
QLabel * m_loadingTextLabel
 
QTimer m_timer
 
QString m_versionHtml
 

Detailed Description

Definition at line 19 of file kis_splash_screen.h.

Constructor & Destructor Documentation

◆ KisSplashScreen()

KisSplashScreen::KisSplashScreen ( int height,
QWidget * parent = 0,
Qt::WindowFlags f = Qt::WindowFlags(Qt::SplashScreen | Qt::FramelessWindowHint) )
explicit

Definition at line 42 of file kis_splash_screen.cpp.

43 : QWidget(parent, f)
44 , m_versionHtml(qApp->applicationVersion().toHtmlEscaped())
45{
46 setWindowTitle(i18n("Krita"));
47#ifndef Q_OS_MACOS
48 setWindowIcon(KisIconUtils::loadIcon("krita-branding"));
49#endif
50
51 setLayout(new QVBoxLayout());
52 layout()->setContentsMargins(QMargins());
53 m_lblSplash = new QLabel();
54 m_lblSplash->setFrameShape(QFrame::NoFrame);
55 layout()->addWidget(m_lblSplash);
56
57 m_loadingTextLabel = new QLabel(m_lblSplash);
58 m_loadingTextLabel->setTextFormat(Qt::RichText);
59 m_loadingTextLabel->setStyleSheet(QStringLiteral("QLabel { color: #fff; background-color: transparent; }"));
60 m_loadingTextLabel->setAlignment(Qt::AlignRight | Qt::AlignTop);
62
63 m_brandingSvg = new QSvgWidget(QStringLiteral(":/krita-branding.svgz"), m_lblSplash);
64 m_bannerSvg = new QSvgWidget(QStringLiteral(":/splash/banner.svg"), m_lblSplash);
66
67 m_artCreditsLabel = new QLabel(m_lblSplash);
68 m_artCreditsLabel->setTextFormat(Qt::PlainText);
69 m_artCreditsLabel->setStyleSheet(QStringLiteral("QLabel { color: #fff; background-color: transparent; font: 10pt; }"));
70 m_artCreditsLabel->setAlignment(Qt::AlignRight | Qt::AlignBottom);
72
73 updateSplashImage(height);
74 setLoadingText(QString()); // the version string is set here too
75
76 connect(&m_timer, SIGNAL(timeout()), SLOT(raise()));
77
78 m_timer.setSingleShot(true);
79 m_timer.start(10);
80}
void updateSplashImage(const int height)
void setLoadingText(QString text)
QLabel * m_loadingTextLabel
QSvgWidget * m_brandingSvg
QSvgWidget * m_bannerSvg
static void addDropShadow(QWidget *widget)
QIcon loadIcon(const QString &name)

References addDropShadow(), KisIconUtils::loadIcon(), m_artCreditsLabel, m_bannerSvg, m_brandingSvg, m_lblSplash, m_loadingTextLabel, m_timer, setLoadingText(), and updateSplashImage().

Member Function Documentation

◆ getImageSource()

KisSplashScreen::Source KisSplashScreen::getImageSource ( )
static

Definition at line 132 of file kis_splash_screen.cpp.

133{
134 QString artistCredit = i18nc("Normal splash artist name", "Tyson Tan");
135 // Loading the ginormous 4K PNG splash image increases the startup time on
136 // Android by several seconds and at the same time looks really bad when
137 // scaled down to a dinky size. Instead of overengineering this into an
138 // Enterprise Splash Screen Solution where we choose the image based on
139 // screen size or something, we'll just use a HD JPEG instead. It's fine.
140#ifdef Q_OS_ANDROID
141 QString resourcePath = QStringLiteral(":/splash/hd.jpg");
142#else
143 QString resourcePath = QStringLiteral(":/splash/0.png");
144 // TODO: Re-add the holiday splash...
145#if 0
146 QDate currentDate = QDate::currentDate();
147 if (currentDate > QDate(currentDate.year(), 12, 4) ||
148 currentDate < QDate(currentDate.year(), 1, 9)) {
149 resourcePath = QStringLiteral(":/splash/1.png");
150 artistCredit = QStringLiteral("???")};
151 }
152#endif
153#endif
154 if (!artistCredit.isEmpty()) {
155 artistCredit = i18nc("splash image credit", "Artwork by: %1", artistCredit);
156 }
157 return Source{resourcePath, artistCredit};
158}

◆ repaint()

void KisSplashScreen::repaint ( )

Definition at line 160 of file kis_splash_screen.cpp.

161{
162 QWidget::repaint();
163 qApp->sendPostedEvents();
164}

◆ setLoadingText()

void KisSplashScreen::setLoadingText ( QString text)

Definition at line 123 of file kis_splash_screen.cpp.

124{
125 int larger = 12;
126 int notAsLarge = larger - 1;
127 QString htmlText = QStringLiteral("<span style='font: %3pt;'><span style='font: bold %4pt;'>%1</span><br><i>%2</i></span>")
128 .arg(m_versionHtml, text.toHtmlEscaped(), QString::number(notAsLarge), QString::number(larger));
129 m_loadingTextLabel->setText(htmlText);
130}

References m_loadingTextLabel, and m_versionHtml.

◆ show()

void KisSplashScreen::show ( )

Definition at line 166 of file kis_splash_screen.cpp.

167{
168 if (!this->parentWidget()) {
169 this->winId(); // Force creation of native window
170 QWindow *windowHandle = this->windowHandle();
171 QScreen *screen = windowHandle ? windowHandle->screen() : nullptr;
172 if (windowHandle && !screen) {
173 // At least on Windows, the window may be created on a non-primary
174 // screen with a different scale factor. If we don't explicitly
175 // move it to the primary screen, the position will be scaled with
176 // the wrong factor and the splash will be offset.
177 // XXX: In theory this branch should be unreachable, but leaving
178 // this here just in case.
179 windowHandle->setScreen(QApplication::primaryScreen());
180 }
181 if (!screen) {
182 screen = QApplication::primaryScreen();
183 }
184 QRect r(QPoint(), size());
185 move(screen->availableGeometry().center() - r.center());
186 }
187 if (isVisible()) {
188 repaint();
189 }
190 m_timer.setSingleShot(true);
191 m_timer.start(1);
192 QWidget::show();
193}
int size(const Forest< T > &forest)
Definition KisForest.h:1232

References m_timer, and repaint().

◆ updateSplashImage()

void KisSplashScreen::updateSplashImage ( const int height)
private

Definition at line 82 of file kis_splash_screen.cpp.

83{
84 const int bannerHeight = height * 0.16875;
85 const int marginTop = height * 0.05;
86 const int marginRight = height * 0.1;
87
89 QPixmap img(source.resourcePath);
90
91 if (img.isNull() || img.height() == 0) return;
92
93 // Preserve aspect ratio of splash.
94 const int width = height * img.width() / img.height();
95
96 setFixedSize(width, height);
97 m_lblSplash->setFixedSize(width, height);
98
99 // Let scaledContents downscale to the fixedSize
100 m_lblSplash->setScaledContents(true);
101 m_lblSplash->setPixmap(img);
102
103 // Align banner to top-left with margin.
104 m_bannerSvg->setFixedHeight(bannerHeight);
105 m_bannerSvg->setFixedWidth(bannerHeight * m_bannerSvg->sizeHint().width() / m_bannerSvg->sizeHint().height());
106 m_bannerSvg->move(width - m_bannerSvg->width() - marginRight, marginTop);
107
108 // Place logo to the left of banner.
109 m_brandingSvg->setFixedSize(bannerHeight, bannerHeight);
110 m_brandingSvg->move(m_bannerSvg->x() - m_brandingSvg->width(), marginTop);
111
112 // Place loading text immediately below.
113 m_loadingTextLabel->move(marginRight, m_brandingSvg->geometry().bottom());
114 m_loadingTextLabel->setFixedWidth(m_bannerSvg->geometry().right() - marginRight);
115
116 // Place credits text on bottom right with similar margins.
117 m_artCreditsLabel->setText(source.artistCredit);
118 m_artCreditsLabel->setFixedWidth(m_loadingTextLabel->width());
119 m_artCreditsLabel->setFixedHeight(20);
120 m_artCreditsLabel->move(m_loadingTextLabel->x(), height - marginTop - m_artCreditsLabel->height());
121}
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
static Source getImageSource()

References getImageSource(), m_artCreditsLabel, m_bannerSvg, m_brandingSvg, m_lblSplash, m_loadingTextLabel, and source().

Member Data Documentation

◆ m_artCreditsLabel

QLabel* KisSplashScreen::m_artCreditsLabel
private

Definition at line 50 of file kis_splash_screen.h.

◆ m_bannerSvg

QSvgWidget* KisSplashScreen::m_bannerSvg
private

Definition at line 48 of file kis_splash_screen.h.

◆ m_brandingSvg

QSvgWidget* KisSplashScreen::m_brandingSvg
private

Definition at line 47 of file kis_splash_screen.h.

◆ m_displayLinks

bool KisSplashScreen::m_displayLinks { false }
private

Definition at line 45 of file kis_splash_screen.h.

45{ false };

◆ m_lblSplash

QLabel* KisSplashScreen::m_lblSplash
private

Definition at line 46 of file kis_splash_screen.h.

◆ m_loadingTextLabel

QLabel* KisSplashScreen::m_loadingTextLabel
private

Definition at line 49 of file kis_splash_screen.h.

◆ m_timer

QTimer KisSplashScreen::m_timer
private

Definition at line 44 of file kis_splash_screen.h.

◆ m_versionHtml

QString KisSplashScreen::m_versionHtml
private

Definition at line 51 of file kis_splash_screen.h.


The documentation for this class was generated from the following files: