DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dconfigwrapper_p.h
1// SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DCONFIGWRAPPER_H
6#define DCONFIGWRAPPER_H
7
8#include <dtkdeclarative_global.h>
9#include <QQmlParserStatus>
10#include <QtQml/qqml.h>
11
12DCORE_BEGIN_NAMESPACE
13class DConfig;
14DCORE_END_NAMESPACE
15
17class DConfigWrapper : public QObject, public QQmlParserStatus
18{
19 Q_OBJECT
20 Q_INTERFACES(QQmlParserStatus)
21 Q_PROPERTY(QString name READ name WRITE setName)
22 Q_PROPERTY(QString subpath READ subpath WRITE setSubpath)
23#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
24 QML_NAMED_ELEMENT(Config)
25#endif
26public:
27 explicit DConfigWrapper(QObject *parent = nullptr);
28 ~DConfigWrapper() override;
29
30 QString name() const;
31 void setName(const QString &name);
32
33 QString subpath() const;
34 void setSubpath(const QString &subpath);
35
36public Q_SLOTS:
37 QVariant value(const QString &key, const QVariant &fallback = QVariant()) const;
38 void setValue(const QString &key, const QVariant &value);
39 void resetValue(const QString &key);
40 QStringList keyList() const;
41 bool isValid() const;
42
43Q_SIGNALS:
44 void valueChanged(const QString &key);
45
46public:
47 virtual void classBegin() override;
48 virtual void componentComplete() override;
49
50private:
52 DTK_CORE_NAMESPACE::DConfig *impl;
53 QString m_name;
54 QString m_subpath;
55 Q_DISABLE_COPY(DConfigWrapper)
56};
57
58#endif // DCONFIGWRAPPER_H
一个 DTK 配置项中的配置信息类.
Definition dconfigwrapper.cpp:50
Definition dconfigwrapper_p.h:18
bool isValid() const
Definition dconfigwrapper.cpp:157
QStringList keyList() const
Definition dconfigwrapper.cpp:145
QVariant value(const QString &key, const QVariant &fallback=QVariant()) const
Definition dconfigwrapper.cpp:169
void setValue(const QString &key, const QVariant &value)
Definition dconfigwrapper.cpp:181