Krita Source Code Documentation
Loading...
Searching...
No Matches
KisAndroidDonations.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-3.0-or-later
3 */
4#ifndef __KISANDROIDDONATIONS_H_
5#define __KISANDROIDDONATIONS_H_
6
7#include <QObject>
8#include <QVector>
9
10#include "KisSupporterProduct.h"
11#include "kritaui_export.h"
12
13// See DonationHelper.java for notes!
14class KRITAUI_EXPORT KisAndroidDonations : public QObject
15{
16 Q_OBJECT
17 friend class KisApplication;
18
19public:
20 // Keep this in sync with the STATE_ constants in DonationHelper.java!
21 enum class State {
22 // Initial or error state. Assume in-app purchases are unavailable.
23 Unknown = 0,
24 // The billing code is still checking whether any products are available
25 // and if the user owns any of them.
26 Checking = 1,
27 // In-app purchases are unavailable. This may be because of an
28 // unexpected error, but may also be an expected condition, e.g. because
29 // the user is running a debug or nightly build, which have a different
30 // package name and therefore no products assigned to them.
31 Unavailable = 2,
32 // User does not own any support products, but they could purchase one.
33 NoSupport = 3,
34 // User owns at least some kind of supporter product.
35 Supporter = 4,
36 };
37
39
40 State state() const { return m_state; }
41
43 {
44 // Only returns false if we're sure the user is *not* a supporter.
45 // If we're not sure (yet), returns true.
46 switch (m_state) {
47 case State::Unavailable:
48 case State::NoSupport:
49 return false;
50 default:
51 return true;
52 }
53 }
54
55 bool shouldShowSupporterBadge() const;
56
58 {
59 return m_showDonationManagementDialogPending;
60 }
61
62 void setShowDonationManagementDialogPending(bool pending);
63
64 QVector<KisSupporterProduct> getCurrentProducts() const;
65
66 void startBillingFlowFor(const QString &productId, const QString &offerToken);
67
68 static void setLoaded(bool loaded);
69 static void setLoadingText(const QString &text);
70 static void showDonationDialog(bool splash);
71
72public Q_SLOTS:
73 void slotStartDonationFlow();
74 void slotManageSubscriptions();
75 void slotManageSubscription(const QString &productId);
76
77private Q_SLOTS:
78 void slotUpdateState(int state, long long ownedProductFlags);
79
80Q_SIGNALS:
81 void sigStateUpdateReceived(int state, long long ownedProductFlags);
85
86private:
87 explicit KisAndroidDonations(QObject *parent = nullptr);
88
89 bool isProductOwned(const QString &productId) const;
90
91 void syncState();
92
93 static QByteArray makeSplashScreen(QString &outSplashArtist);
94
95 State m_state{State::Unknown};
96 long long m_ownedProductFlags{0L};
97 bool m_showDonationManagementDialogPending{false};
98};
99
100#endif // __KISANDROIDDONATIONS_H
PythonPluginManager * instance
void sigSplashDialogDismissed()
void sigShowDonationManagementDialogRequested()
void sigStateUpdateReceived(int state, long long ownedProductFlags)
bool isShowDonationManagementDialogPending() const
Base class for the Krita app.
@ Unknown
Definition psd.h:44