| 1 |
// SPDX-FileCopyrightText: 2016 - 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include <QVariant> |
| 8 |
#include <QObject> |
| 9 |
#include <QPointer> |
| 10 |
|
| 11 |
#include "dtkcore_global.h" |
| 12 |
|
| 13 |
DCORE_BEGIN_NAMESPACE |
| 14 |
|
| 15 |
class DSettingsGroup; |
| 16 |
class DSettingsOptionPrivate; |
| 17 |
class LIBDTKCORESHARED_EXPORT DSettingsOption : public QObject |
| 18 |
{ |
| 19 |
Q_OBJECT |
| 20 |
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) |
| 21 |
|
| 22 |
public: |
| 23 |
explicit DSettingsOption(QObject *parent = Q_NULLPTR); |
| 24 |
~DSettingsOption(); |
| 25 |
|
| 26 |
QPointer<DSettingsGroup> parentGroup() const; |
| 27 |
void setParentGroup(QPointer<DSettingsGroup> parentGroup); |
| 28 |
|
| 29 |
QString key() const; |
| 30 |
QString name() const; |
| 31 |
bool canReset() const; |
| 32 |
QVariant defaultValue() const; |
| 33 |
QVariant value() const; |
| 34 |
QVariant data(const QString &dataType) const; |
| 35 |
|
| 36 |
QString viewType() const; |
| 37 |
bool isHidden() const; |
| 38 |
|
| 39 |
static QPointer<DSettingsOption> fromJson(const QString &prefixKey, const QJsonObject &json); |
| 40 |
Q_SIGNALS: |
| 41 |
void valueChanged(QVariant value); |
| 42 |
void dataChanged(const QString &dataType, QVariant value); |
| 43 |
|
| 44 |
public Q_SLOTS: |
| 45 |
void setValue(QVariant value); |
| 46 |
void setData(const QString &dataType, QVariant value); |
| 47 |
|
| 48 |
private: |
| 49 |
void parseJson(const QString &prefixKey, const QJsonObject &option); |
| 50 |
|
| 51 |
QScopedPointer<DSettingsOptionPrivate> dd_ptr; |
| 52 |
Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), DSettingsOption) |
| 53 |
}; |
| 54 |
|
| 55 |
typedef QPointer<DSettingsOption> OptionPtr; |
| 56 |
|
| 57 |
DCORE_END_NAMESPACE |