#include "kzqproperty.h" #include "kzqsettings.h" namespace KaZoe { class KzQPropertyPrivate { Q_DISABLE_COPY(KzQPropertyPrivate) Q_DECLARE_PUBLIC(KaZoe::KzQProperty) KaZoe::KzQProperty * const q_ptr; QString m_key; QVariant m_value; KaZoe::KzQSettings m_settings; KzQPropertyPrivate(KaZoe::KzQProperty* systemprop): q_ptr(systemprop){} }; }; KaZoe::KzQProperty::KzQProperty(QObject *parent) : QObject{parent} , d_ptr(new KaZoe::KzQPropertyPrivate(this)) { Q_D(KzQProperty); QObject::connect(&d->m_settings, &KaZoe::KzQSettings::valueChanged, [this](QString id, QVariant value){ Q_D(KzQProperty); if(id == d->m_key) { setValue(value); } }); } KaZoe::KzQProperty::~KzQProperty() = default; QString KaZoe::KzQProperty::key() const { Q_D(const KzQProperty); return d->m_key; } void KaZoe::KzQProperty::setKey(const QString &newKey) { Q_D(KzQProperty); if (d->m_key == newKey) return; d->m_key = newKey; setValue(d->m_settings.get(d->m_key)); emit keyChanged(); } QVariant KaZoe::KzQProperty::value() const { Q_D(const KzQProperty); return d->m_value; } void KaZoe::KzQProperty::setValue(const QVariant &newValue) { Q_D(KzQProperty); if (d->m_value == newValue) return; d->m_value = newValue; emit valueChanged(); }