CuteLogger
Fast and simple logging solution for Qt based applications
qmlextension.h
1/*
2 * Copyright (c) 2025-2026 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef QMLEXTENSION_H
19#define QMLEXTENSION_H
20
21#include <QDir>
22#include <QObject>
23#include <QQmlListProperty>
24#include <QString>
25
26class QmlExtensionFile : public QObject
27{
28 Q_OBJECT
29 Q_PROPERTY(QString name MEMBER m_name NOTIFY changed)
30 Q_PROPERTY(QString description MEMBER m_description NOTIFY changed)
31 Q_PROPERTY(QString file MEMBER m_file NOTIFY changed)
32 Q_PROPERTY(QString url MEMBER m_url NOTIFY changed)
33 Q_PROPERTY(QString sha256 MEMBER m_sha256 NOTIFY changed)
34 Q_PROPERTY(QString size MEMBER m_size NOTIFY changed)
35 Q_PROPERTY(bool standard MEMBER m_standard NOTIFY changed)
36
37public:
38 explicit QmlExtensionFile(QObject *parent = 0);
39
40 QString name() const { return m_name; }
41 QString description() const { return m_description; }
42 QString file() const { return m_file; }
43 QString url() const { return m_url; }
44 QString sha256() const { return m_sha256; }
45 QString size() const { return m_size; }
46 bool standard() const { return m_standard; }
47
48signals:
49 void changed();
50
51private:
52 QString m_name;
53 QString m_description;
54 QString m_file;
55 QString m_url;
56 QString m_sha256;
57 QString m_size;
58 bool m_standard;
59};
60
61class QmlExtension : public QObject
62{
63 Q_OBJECT
64 Q_PROPERTY(QString id READ id WRITE setId NOTIFY changed)
65 Q_PROPERTY(QString name READ name WRITE setName NOTIFY changed)
66 Q_PROPERTY(QString version READ version WRITE setVersion NOTIFY changed)
67 Q_PROPERTY(QQmlListProperty<QmlExtensionFile> files READ files NOTIFY changed)
68
69public:
70 static QmlExtension *load(const QString &id);
71 static QString extensionFileName(const QString &id);
72 static QDir installDir(const QString &id);
73 static QDir appDir(const QString &id);
74 static const QString WHISPER_ID;
75
76 explicit QmlExtension(QObject *parent = 0);
77
78 QString id() const { return m_id; }
79 void setId(const QString &);
80 QString name() const { return m_name; }
81 void setName(const QString &);
82 QString version() const { return m_version; }
83 void setVersion(const QString &);
84 QQmlListProperty<QmlExtensionFile> files()
85 {
86 return QQmlListProperty<QmlExtensionFile>(this, &m_files);
87 }
88 int fileCount() const { return m_files.count(); }
89 QmlExtensionFile *file(int index) const { return m_files[index]; }
90 QString localPath(int index);
91 bool downloaded(int index);
92
93signals:
94 void changed();
95
96private:
97 QString m_id;
98 QString m_name;
99 QString m_version;
100 QList<QmlExtensionFile *> m_files;
101};
102
103#endif // QMLEXTENSION_H