-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobalsettings.h
63 lines (59 loc) · 1.9 KB
/
globalsettings.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef GLOBALSETTINGS_H
#define GLOBALSETTINGS_H
#include <QObject>
#include <QVariant>
struct settingDbResult {
bool found;
QVariant value;
settingDbResult(bool found,QVariant value) :
found(found),
value(value)
{}
};
class GlobalSettings : public QObject
{
Q_OBJECT
Q_PROPERTY(bool cloudinaryConfigured MEMBER m_cloudinaryProperlyConfigured NOTIFY settingsChanged)
Q_PROPERTY(QString cloudinaryCloudName MEMBER m_cloudinaryCloudName NOTIFY settingsChanged)
Q_PROPERTY(bool optedOutTracking MEMBER m_optedOutTracking NOTIFY settingsChanged)
Q_PROPERTY(bool userDebugLogOn MEMBER m_userDebugLogOn NOTIFY settingsChanged)
public:
explicit GlobalSettings(QObject *parent = nullptr);
static GlobalSettings *getInstance();
static QString TABLE_NAME;
bool validateCloudinarySettings();
signals:
void settingsChanged();
void internetConnectionChanged();
public slots:
bool updateInBulk(QString cloudinaryCloudName, QString cloudinaryApiKey, QString cloudinaryApiSecret);
void loadFromStorage();
void saveToStorage();
QString getCloudinaryCloudName(){
return m_cloudinaryCloudName;
}
QString getCloudinaryApiKey(){
return m_cloudinaryApiKey;
}
QString getCloudinaryApiSecret(){
return m_cloudinaryApiSecret;
}
bool getUserDebugLogOn() {
return m_userDebugLogOn;
}
void emitSettingsChanged(){
emit settingsChanged();
}
private:
static GlobalSettings *m_instance;
bool m_cloudinaryProperlyConfigured = false;
QString m_cloudinaryCloudName;
QString m_cloudinaryApiKey;
QString m_cloudinaryApiSecret;
bool m_hasInternet = false;
settingDbResult getSettingFromDb(QString settingKey);
bool saveSettingToDb(QString settingKey, QVariant settingVal);
bool m_userDebugLogOn = false;
bool m_optedOutTracking = false;
};
#endif // GLOBALSETTINGS_H