Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSplashSourceDialog.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
3#include <QPixmap>
4#include <QPushButton>
5#include <QSignalBlocker>
7#ifdef Q_OS_ANDROID
9#endif
10
11KisSplashSourceDialog::KisSplashSourceDialog(const QString &key, QWidget *parent)
12 : QDialog(parent)
13 , m_sources(KisSplashScreen::getSources())
14 , m_updatePreviewCompressor(
15 new KisSignalCompressor(100, KisSignalCompressor::POSTPONE, KisSignalCompressor::ADDITIVE_INTERVAL, this))
16{
17 setupUi(this);
18
19#ifdef Q_OS_ANDROID
21 if (androidDonations && androidDonations->state() == KisAndroidDonations::State::NoSupport) {
22 m_explanationLabel->setText(
23 QStringLiteral("%1 <a href=\"#\">%2</a>")
24 .arg(i18n("Become a supporter to change the splash screen.").toHtmlEscaped(), i18n("Support Krita")));
25
26 connect(m_explanationLabel, &QLabel::linkActivated, this, &KisSplashSourceDialog::slotShowDonationDialog);
27
28 connect(androidDonations,
30 this,
32 } else {
33 m_explanationLabel->setText(
34 i18n("Changing the splash screen is only available for supporters through the Play Store."));
35 }
36#else
37 QString explanationText = i18n("Purchase Krita to change the splash screen and receive automatic updates.");
38
39 QStringList purchaseOptions = {
40 makePurchaseOption(QStringLiteral("steam"), i18n("Get Krita on Steam")),
41#ifdef Q_OS_WINDOWS
42 makePurchaseOption(QStringLiteral("epicgamesstore"), i18n("Get Krita on the Epic Games Store")),
43 makePurchaseOption(QStringLiteral("microsoftstore"), i18n("Get Krita on the Microsoft Store")),
44#endif
45#ifdef Q_OS_MACOS
46 makePurchaseOption(QStringLiteral("appleappstore"), i18n("Get Krita on the App Store")),
47#endif
48 };
49
50 m_explanationLabel->setOpenExternalLinks(true);
51 m_explanationLabel->setText(
52 QStringLiteral("%1<ul>%2</ul>").arg(explanationText.toHtmlEscaped(), purchaseOptions.join(QString())));
53#endif
54
55 connect(m_sourceCombo,
56 QOverload<int>::of(&QComboBox::currentIndexChanged),
57 this,
60 connect(m_buttons, &QDialogButtonBox::accepted, this, &KisSplashSourceDialog::accept);
61 connect(m_buttons, &QDialogButtonBox::rejected, this, &KisSplashSourceDialog::reject);
62
63 initSources(key);
64}
65
67{
69 if (source && source->isAvailable) {
70 return source->key;
71 } else {
72 return QString();
73 }
74}
75
77{
79 m_buttons->button(QDialogButtonBox::Ok)->setEnabled(source && source->isAvailable);
80 m_previewWidget->setPixmap(QPixmap());
82}
83
85{
87 if (source) {
88 QPixmap img(source->resourcePath);
89 m_previewWidget->setPixmap(img);
90 }
91}
92
97
98#ifdef Q_OS_ANDROID
99void KisSplashSourceDialog::slotShowDonationDialog()
100{
102}
103#endif
104
106{
107 QSignalBlocker blocker(m_sourceCombo);
108 m_explanationLabel->setVisible(!KisSplashScreen::canChooseSplashScreen());
110 m_sourceCombo->clear();
112 m_sourceCombo->addItem(source.description());
113 if (key == source.key) {
114 m_sourceCombo->setCurrentIndex(m_sourceCombo->count() - 1);
115 }
116 }
118}
119
121{
122 int index = m_sourceCombo->currentIndex();
123 if (index >= 0 && index < m_sources.size()) {
124 return &m_sources[index];
125 } else {
126 return nullptr;
127 }
128}
129
130QString KisSplashSourceDialog::makePurchaseOption(const QString &key, const QString &text)
131{
132 return QStringLiteral("<li><a href=\"https://krita.org/%1/\">%2</a></li>")
133 .arg(key.toHtmlEscaped(), text.toHtmlEscaped());
134}
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
static void showDonationDialog(bool splash)
static KisAndroidDonations * instance()
static QVector< Source > getSources()
static bool canChooseSplashScreen()
KisSignalCompressor * m_updatePreviewCompressor
static QString makePurchaseOption(const QString &key, const QString &text)
QVector< KisSplashScreen::Source > m_sources
KisSplashSourceDialog(const QString &key, QWidget *parent=nullptr)
const KisSplashScreen::Source * currentSource() const
void initSources(const QString &key)