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

#include <KisSplashSourceDialog.h>

+ Inheritance diagram for KisSplashSourceDialog:

Public Member Functions

 KisSplashSourceDialog (const QString &key, QWidget *parent=nullptr)
 
QString selectedKey () const
 

Private Slots

void slotRefreshSources ()
 
void slotSourceSelected ()
 
void slotUpdatePreview ()
 

Private Member Functions

const KisSplashScreen::Source * currentSource () const
 
void initSources (const QString &key)
 

Static Private Member Functions

static QString makePurchaseOption (const QString &key, const QString &text)
 

Private Attributes

QVector< KisSplashScreen::Source > m_sources
 
KisSignalCompressor * m_updatePreviewCompressor
 

Detailed Description

Definition at line 11 of file KisSplashSourceDialog.h.

Constructor & Destructor Documentation

◆ KisSplashSourceDialog()

KisSplashSourceDialog::KisSplashSourceDialog ( const QString & key,
QWidget * parent = nullptr )
explicit

Definition at line 11 of file KisSplashSourceDialog.cpp.

12 : QDialog(parent)
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}
static KisAndroidDonations * instance()
static QVector< Source > getSources()
KisSignalCompressor * m_updatePreviewCompressor
static QString makePurchaseOption(const QString &key, const QString &text)
QVector< KisSplashScreen::Source > m_sources
void initSources(const QString &key)

References initSources(), KisAndroidDonations::instance(), m_updatePreviewCompressor, makePurchaseOption(), KisAndroidDonations::NoSupport, KisAndroidDonations::sigStateChanged(), slotRefreshSources(), slotSourceSelected(), slotUpdatePreview(), KisAndroidDonations::state(), and KisSignalCompressor::timeout().

Member Function Documentation

◆ currentSource()

const KisSplashScreen::Source * KisSplashSourceDialog::currentSource ( ) const
private

Definition at line 120 of file KisSplashSourceDialog.cpp.

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}

References m_sources.

◆ initSources()

void KisSplashSourceDialog::initSources ( const QString & key)
private

Definition at line 105 of file KisSplashSourceDialog.cpp.

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}
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
static bool canChooseSplashScreen()

References KisSplashScreen::canChooseSplashScreen(), KisSplashScreen::getSources(), m_sources, slotSourceSelected(), and source().

◆ makePurchaseOption()

QString KisSplashSourceDialog::makePurchaseOption ( const QString & key,
const QString & text )
staticprivate

Definition at line 130 of file KisSplashSourceDialog.cpp.

131{
132 return QStringLiteral("<li><a href=\"https://krita.org/%1/\">%2</a></li>")
133 .arg(key.toHtmlEscaped(), text.toHtmlEscaped());
134}

◆ selectedKey()

QString KisSplashSourceDialog::selectedKey ( ) const

Definition at line 66 of file KisSplashSourceDialog.cpp.

67{
69 if (source && source->isAvailable) {
70 return source->key;
71 } else {
72 return QString();
73 }
74}
const KisSplashScreen::Source * currentSource() const

References currentSource(), and source().

◆ slotRefreshSources

void KisSplashSourceDialog::slotRefreshSources ( )
privateslot

Definition at line 93 of file KisSplashSourceDialog.cpp.

94{
96}

References initSources(), and selectedKey().

◆ slotSourceSelected

void KisSplashSourceDialog::slotSourceSelected ( )
privateslot

Definition at line 76 of file KisSplashSourceDialog.cpp.

77{
79 m_buttons->button(QDialogButtonBox::Ok)->setEnabled(source && source->isAvailable);
80 m_previewWidget->setPixmap(QPixmap());
82}

References currentSource(), m_updatePreviewCompressor, source(), and KisSignalCompressor::start().

◆ slotUpdatePreview

void KisSplashSourceDialog::slotUpdatePreview ( )
privateslot

Definition at line 84 of file KisSplashSourceDialog.cpp.

85{
87 if (source) {
88 QPixmap img(source->resourcePath);
89 m_previewWidget->setPixmap(img);
90 }
91}

References currentSource(), and source().

Member Data Documentation

◆ m_sources

QVector<KisSplashScreen::Source> KisSplashSourceDialog::m_sources
private

Definition at line 33 of file KisSplashSourceDialog.h.

◆ m_updatePreviewCompressor

KisSignalCompressor* KisSplashSourceDialog::m_updatePreviewCompressor
private

Definition at line 34 of file KisSplashSourceDialog.h.


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