-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppInfo.h
86 lines (63 loc) · 1.96 KB
/
AppInfo.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef APPINFO_H
#define APPINFO_H
#include <QObject>
#include <QDate>
#include <QJsonObject>
#include <QJsonArray>
class AppInfo : public QObject {
Q_OBJECT
public:
explicit AppInfo(QObject *parent = nullptr);
enum BuildType {
Release,
Beta,
Alpha,
Unofficial
};
class AppVersion;
static AppVersion *currentVersion();
static BuildType currentBuildType();
static int versionCount();
static AppVersion *olderVersion(const int &index);
static AppVersion *version(const QString &name);
static bool fileFormatChangesSinceVersion(AppVersion *);
static const inline QRegularExpression VersionNameRegex = QRegularExpression("^(?<major>[0-9]+)\\.(?<minor>[0-9]+)\\.(?<patch>[0-9]+)-(?<type>.+)$");
private:
static inline QList<AppVersion *> _versions;
signals:
};
class AppInfo::AppVersion : public QObject {
Q_OBJECT
public:
explicit AppVersion(QObject *parent = nullptr);
explicit AppVersion(QObject *parent = nullptr, const QJsonObject & = {});
bool operator>(const AppInfo::AppVersion &other);
QString name() const;
QDate releaseDate() const;
QJsonArray changelogCompact() const;
QJsonObject changelogDetailed() const;
QString changelogCompactHtml() const;
QString changelogDetailedHtml(const int &headlineLevel) const;
bool changedFileFormat() const;
int majorRelease() const;
int minorRelease() const;
int patchLevel() const;
QString buildID() const;
BuildType buildType() const;
bool isCurrentVersion() const;
protected:
void fromJson(const QJsonObject &);
QString changeLogToHtml(const QJsonArray &) const;
QString changeLogItemToHtml(const QJsonObject &) const;
private:
QString _name;
QDate _releaseDate;
QJsonArray _changelogCompact;
QJsonObject _changelogDetailed;
bool _changedFileFormat;
int _versionNumber[3];
BuildType _buildType;
QString _buildID;
signals:
};
#endif // APPINFO_H