1// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
2// SPDX-FileCopyrightText: 2025 Harald Sitter <sitter@kde.org>
3
4#pragma once
5
6#include <QObject>
7#include <QQmlEngine>
8
9#include "kosrelease.h"
10
11// TODO KF7: remove final on KOSRelease class declaration so we can more easily extend it without having to proxy all functions
12
13/*!
14 * \qmltype KOSRelease
15 * \inqmlmodule org.kde.coreaddons
16 * \nativetype KOSRelease
17 * \since 6.11
18 *
19 * \brief Parses /etc/os-release files.
20 *
21 * This is a QML singleton
22 *
23 * \qml
24 * import QtQuick
25 * import org.kde.coreaddons
26 *
27 * Item {
28 * Component.onCompleted: console.log(KOSRelease.name)
29 * }
30 * \endqml
31 */
32class KOSReleaseProxy : public QObject
33{
34 Q_OBJECT
35 QML_NAMED_ELEMENT(KOSRelease)
36 QML_SINGLETON
37
38 /*!
39 * \qmlproperty string KOSRelease::name
40 */
41 Q_PROPERTY(QString name READ name CONSTANT)
42
43 /*!
44 * \qmlproperty string KOSRelease::version
45 */
46 Q_PROPERTY(QString version READ version CONSTANT)
47
48 /*!
49 * \qmlproperty string KOSRelease::id
50 */
51 Q_PROPERTY(QString id READ id CONSTANT)
52
53 /*!
54 * \qmlproperty list<string> KOSRelease::idLike
55 */
56 Q_PROPERTY(QStringList idLike READ idLike CONSTANT)
57
58 /*!
59 * \qmlproperty string KOSRelease::versionCodename
60 */
61 Q_PROPERTY(QString versionCodename READ versionCodename CONSTANT)
62
63 /*!
64 * \qmlproperty string KOSRelease::versionId
65 */
66 Q_PROPERTY(QString versionId READ versionId CONSTANT)
67
68 /*!
69 * \qmlproperty string KOSRelease::prettyName
70 */
71 Q_PROPERTY(QString prettyName READ prettyName CONSTANT)
72
73 /*!
74 * \qmlproperty string KOSRelease::ansiColor
75 */
76 Q_PROPERTY(QString ansiColor READ ansiColor CONSTANT)
77
78 /*!
79 * \qmlproperty string KOSRelease::cpeName
80 */
81 Q_PROPERTY(QString cpeName READ cpeName CONSTANT)
82
83 /*!
84 * \qmlproperty string KOSRelease::homeUrl
85 */
86 Q_PROPERTY(QString homeUrl READ homeUrl CONSTANT)
87
88 /*!
89 * \qmlproperty string KOSRelease::documentationUrl
90 */
91 Q_PROPERTY(QString documentationUrl READ documentationUrl CONSTANT)
92
93 /*!
94 * \qmlproperty string KOSRelease::supportUrl
95 */
96 Q_PROPERTY(QString supportUrl READ supportUrl CONSTANT)
97
98 /*!
99 * \qmlproperty string KOSRelease::bugReportUrl
100 */
101 Q_PROPERTY(QString bugReportUrl READ bugReportUrl CONSTANT)
102
103 /*!
104 * \qmlproperty string KOSRelease::privacyPolicyUrl
105 */
106 Q_PROPERTY(QString privacyPolicyUrl READ privacyPolicyUrl CONSTANT)
107
108 /*!
109 * \qmlproperty string KOSRelease::buildId
110 */
111 Q_PROPERTY(QString buildId READ buildId CONSTANT)
112
113 /*!
114 * \qmlproperty string KOSRelease::variant
115 */
116 Q_PROPERTY(QString variant READ variant CONSTANT)
117
118 /*!
119 * \qmlproperty string KOSRelease::variantId
120 */
121 Q_PROPERTY(QString variantId READ variantId CONSTANT)
122
123 /*!
124 * \qmlproperty string KOSRelease::logo
125 */
126 Q_PROPERTY(QString logo READ logo CONSTANT)
127
128public:
129 using QObject::QObject;
130
131 [[nodiscard]] QString name() const;
132 [[nodiscard]] QString version() const;
133 [[nodiscard]] QString id() const;
134 [[nodiscard]] QStringList idLike() const;
135 [[nodiscard]] QString versionCodename() const;
136 [[nodiscard]] QString versionId() const;
137 [[nodiscard]] QString prettyName() const;
138 [[nodiscard]] QString ansiColor() const;
139 [[nodiscard]] QString cpeName() const;
140 [[nodiscard]] QString homeUrl() const;
141 [[nodiscard]] QString documentationUrl() const;
142 [[nodiscard]] QString supportUrl() const;
143 [[nodiscard]] QString bugReportUrl() const;
144 [[nodiscard]] QString privacyPolicyUrl() const;
145 [[nodiscard]] QString buildId() const;
146 [[nodiscard]] QString variant() const;
147 [[nodiscard]] QString variantId() const;
148 [[nodiscard]] QString logo() const;
149
150 /*!
151 * \qmlmethod list<string> KOSRelease::extraKeys
152 */
153 Q_INVOKABLE [[nodiscard]] QStringList extraKeys() const;
154
155 /*!
156 * \qmlmethod string KOSRelease::extraValue(string key)
157 */
158 Q_INVOKABLE [[nodiscard]] QString extraValue(const QString &key) const;
159
160private:
161 KOSRelease os;
162};
163

source code of kcoreaddons/src/qml/kosreleaseproxy.h