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 bool canChooseSplashScreen ()
 
static Source getAvailableSource (const QString &key)
 
static Source getCurrentSource ()
 
static QVector< Source > getSources ()
 

Private Member Functions

void updateSplashImage (const int height)
 

Static Private Member Functions

static QString defaultSplashResourcePath ()
 

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 20 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 66 of file kis_splash_screen.cpp.

67 : QWidget(parent, f)
68 , m_versionHtml(qApp->applicationVersion().toHtmlEscaped())
69{
70 setWindowTitle(i18n("Krita"));
71#ifndef Q_OS_MACOS
72 setWindowIcon(KisIconUtils::loadIcon("krita-branding"));
73#endif
74
75 setLayout(new QVBoxLayout());
76 layout()->setContentsMargins(QMargins());
77 m_lblSplash = new QLabel();
78 m_lblSplash->setFrameShape(QFrame::NoFrame);
79 layout()->addWidget(m_lblSplash);
80
81 m_loadingTextLabel = new QLabel(m_lblSplash);
82 m_loadingTextLabel->setTextFormat(Qt::RichText);
83 m_loadingTextLabel->setStyleSheet(QStringLiteral("QLabel { color: #fff; background-color: transparent; }"));
84 m_loadingTextLabel->setAlignment(Qt::AlignRight | Qt::AlignTop);
86
87 m_brandingSvg = new QSvgWidget(QStringLiteral(":/krita-branding.svgz"), m_lblSplash);
88 m_bannerSvg = new QSvgWidget(QStringLiteral(":/splash/banner.svg"), m_lblSplash);
90
91 m_artCreditsLabel = new QLabel(m_lblSplash);
92 m_artCreditsLabel->setTextFormat(Qt::PlainText);
93 m_artCreditsLabel->setStyleSheet(QStringLiteral("QLabel { color: #fff; background-color: transparent; font: 10pt; }"));
94 m_artCreditsLabel->setAlignment(Qt::AlignRight | Qt::AlignBottom);
96
97 updateSplashImage(height);
98 setLoadingText(QString()); // the version string is set here too
99
100 connect(&m_timer, SIGNAL(timeout()), SLOT(raise()));
101
102 m_timer.setSingleShot(true);
103 m_timer.start(10);
104}
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

◆ canChooseSplashScreen()

bool KisSplashScreen::canChooseSplashScreen ( )
static

Definition at line 172 of file kis_splash_screen.cpp.

173{
174 // The "professional" splash screen is available on purchased versions of
175 // Krita, since professionals can pay for their tools. On Android, we'll
176 // err on the side of allowing changing the splash screen unless we have
177 // evidence to the contrary, otherwise a bad internet connection could
178 // show the user the wrong splash screen. KisAndroidDonations will reset
179 // the splash screen setting if it sees the user is not a supporter.
180#ifdef Q_OS_ANDROID
182 return !donations || donations->isMaybeSupporter();
183#else
185#endif
186}
static KisAndroidDonations * instance()
static bool isStoreApplication()

References KisAndroidDonations::instance(), KisAndroidDonations::isMaybeSupporter(), and KisApplication::isStoreApplication().

◆ defaultSplashResourcePath()

QString KisSplashScreen::defaultSplashResourcePath ( )
staticprivate

Definition at line 214 of file kis_splash_screen.cpp.

215{
216 // Loading the ginormous 4K PNG splash image increases the startup time on
217 // Android by several seconds and at the same time looks really bad when
218 // scaled down to a dinky size. Instead of overengineering this into an
219 // Enterprise Splash Screen Solution where we choose the image based on
220 // screen size or something, we'll just use a HD JPEG instead. It's fine.
221#ifdef Q_OS_ANDROID
222 return QStringLiteral(":/splash/hd.jpg");
223#else
224 return QStringLiteral(":/splash/0.png");
225#endif
226}

◆ getAvailableSource()

KisSplashScreen::Source KisSplashScreen::getAvailableSource ( const QString & key)
static

Definition at line 161 of file kis_splash_screen.cpp.

162{
163 QVector<Source> sources = getSources();
164 for (const Source &source : sources) {
165 if (source.isAvailable && source.key == key) {
166 return source;
167 }
168 }
169 return sources[0];
170}
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
static QVector< Source > getSources()

References getSources(), and source().

◆ getCurrentSource()

KisSplashScreen::Source KisSplashScreen::getCurrentSource ( )
static

Definition at line 156 of file kis_splash_screen.cpp.

157{
158 return getAvailableSource(KisConfig(true).splashScreenImage());
159}
static Source getAvailableSource(const QString &key)

References getAvailableSource().

◆ getSources()

QVector< KisSplashScreen::Source > KisSplashScreen::getSources ( )
static

Definition at line 188 of file kis_splash_screen.cpp.

189{
190 bool canChoose = canChooseSplashScreen();
191 return {
192 // First entry is used as the default.
193 {
194 QString(),
195 i18nc("Splash screen option showing Kiki", "Mascot"),
197 i18nc("Splash artist name", "Tyson Tan"),
198 true,
199 true,
200 },
201 {
202 QStringLiteral("corpo1"),
203 i18nc("Splash screen option without Kiki", "Plain"),
204 QStringLiteral(":/splash/corpo1.jpg"),
205 // This splash screen was also created by Tyson, but they preferred
206 // to not be credited prominently for something so simple.
207 QString(),
208 canChoose,
209 false,
210 },
211 };
212}
static QString defaultSplashResourcePath()
static bool canChooseSplashScreen()

References canChooseSplashScreen(), and defaultSplashResourcePath().

◆ repaint()

void KisSplashScreen::repaint ( )

Definition at line 228 of file kis_splash_screen.cpp.

229{
230 QWidget::repaint();
231 qApp->sendPostedEvents();
232}

◆ setLoadingText()

void KisSplashScreen::setLoadingText ( QString text)

Definition at line 147 of file kis_splash_screen.cpp.

148{
149 int larger = 12;
150 int notAsLarge = larger - 1;
151 QString htmlText = QStringLiteral("<span style='font: %3pt;'><span style='font: bold %4pt;'>%1</span><br><i>%2</i></span>")
152 .arg(m_versionHtml, text.toHtmlEscaped(), QString::number(notAsLarge), QString::number(larger));
153 m_loadingTextLabel->setText(htmlText);
154}

References m_loadingTextLabel, and m_versionHtml.

◆ show()

void KisSplashScreen::show ( )

Definition at line 234 of file kis_splash_screen.cpp.

235{
236 if (!this->parentWidget()) {
237 this->winId(); // Force creation of native window
238 QWindow *windowHandle = this->windowHandle();
239 QScreen *screen = windowHandle ? windowHandle->screen() : nullptr;
240 if (windowHandle && !screen) {
241 // At least on Windows, the window may be created on a non-primary
242 // screen with a different scale factor. If we don't explicitly
243 // move it to the primary screen, the position will be scaled with
244 // the wrong factor and the splash will be offset.
245 // XXX: In theory this branch should be unreachable, but leaving
246 // this here just in case.
247 windowHandle->setScreen(QApplication::primaryScreen());
248 }
249 if (!screen) {
250 screen = QApplication::primaryScreen();
251 }
252 QRect r(QPoint(), size());
253 move(screen->availableGeometry().center() - r.center());
254 }
255 if (isVisible()) {
256 repaint();
257 }
258 m_timer.setSingleShot(true);
259 m_timer.start(1);
260 QWidget::show();
261}
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 106 of file kis_splash_screen.cpp.

107{
108 const int bannerHeight = height * 0.16875;
109 const int marginTop = height * 0.05;
110 const int marginRight = height * 0.1;
111
113 QPixmap img(source.resourcePath);
114
115 if (img.isNull() || img.height() == 0) return;
116
117 // Preserve aspect ratio of splash.
118 const int width = height * img.width() / img.height();
119
120 setFixedSize(width, height);
121 m_lblSplash->setFixedSize(width, height);
122
123 // Let scaledContents downscale to the fixedSize
124 m_lblSplash->setScaledContents(true);
125 m_lblSplash->setPixmap(img);
126
127 // Align banner to top-left with margin.
128 m_bannerSvg->setFixedHeight(bannerHeight);
129 m_bannerSvg->setFixedWidth(bannerHeight * m_bannerSvg->sizeHint().width() / m_bannerSvg->sizeHint().height());
130 m_bannerSvg->move(width - m_bannerSvg->width() - marginRight, marginTop);
131
132 // Place logo to the left of banner.
133 m_brandingSvg->setFixedSize(bannerHeight, bannerHeight);
134 m_brandingSvg->move(m_bannerSvg->x() - m_brandingSvg->width(), marginTop);
135
136 // Place loading text immediately below.
137 m_loadingTextLabel->move(marginRight, m_brandingSvg->geometry().bottom());
138 m_loadingTextLabel->setFixedWidth(m_bannerSvg->geometry().right() - marginRight);
139
140 // Place credits text on bottom right with similar margins.
141 m_artCreditsLabel->setText(source.artistCredit());
142 m_artCreditsLabel->setFixedWidth(m_loadingTextLabel->width());
143 m_artCreditsLabel->setFixedHeight(20);
144 m_artCreditsLabel->move(m_loadingTextLabel->x(), height - marginTop - m_artCreditsLabel->height());
145}
static Source getCurrentSource()

References getCurrentSource(), 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 61 of file kis_splash_screen.h.

◆ m_bannerSvg

QSvgWidget* KisSplashScreen::m_bannerSvg
private

Definition at line 59 of file kis_splash_screen.h.

◆ m_brandingSvg

QSvgWidget* KisSplashScreen::m_brandingSvg
private

Definition at line 58 of file kis_splash_screen.h.

◆ m_displayLinks

bool KisSplashScreen::m_displayLinks { false }
private

Definition at line 56 of file kis_splash_screen.h.

56{ false };

◆ m_lblSplash

QLabel* KisSplashScreen::m_lblSplash
private

Definition at line 57 of file kis_splash_screen.h.

◆ m_loadingTextLabel

QLabel* KisSplashScreen::m_loadingTextLabel
private

Definition at line 60 of file kis_splash_screen.h.

◆ m_timer

QTimer KisSplashScreen::m_timer
private

Definition at line 55 of file kis_splash_screen.h.

◆ m_versionHtml

QString KisSplashScreen::m_versionHtml
private

Definition at line 62 of file kis_splash_screen.h.


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