fix: icon font config
This commit is contained in:
parent
8f49fdb405
commit
38a737b4d8
3 changed files with 18 additions and 8 deletions
|
|
@ -22,7 +22,7 @@ void ConfigObject::loadFromJson(const QJsonObject& obj) {
|
|||
qCDebug(lcConfig) << "Loading JSON into" << meta->className() << "with" << obj.keys().size()
|
||||
<< "keys:" << obj.keys();
|
||||
|
||||
for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
for (int i = basePropertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
auto prop = meta->property(i);
|
||||
const auto key = QString::fromUtf8(prop.name());
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ QJsonObject ConfigObject::toJsonObject() const {
|
|||
QJsonObject obj;
|
||||
const auto* meta = metaObject();
|
||||
|
||||
for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
for (int i = basePropertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
const auto prop = meta->property(i);
|
||||
|
||||
if (!prop.isReadable())
|
||||
|
|
@ -127,7 +127,7 @@ void ConfigObject::clearLoadedKeys() {
|
|||
m_loadedKeys.clear();
|
||||
|
||||
const auto* meta = metaObject();
|
||||
for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
for (int i = basePropertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
auto prop = meta->property(i);
|
||||
if (isGlobalOnly(QString::fromUtf8(prop.name())))
|
||||
continue;
|
||||
|
|
@ -148,7 +148,7 @@ void ConfigObject::syncFromGlobal(ConfigObject* global) {
|
|||
connect(global, &ConfigObject::propertiesChanged, this, &ConfigObject::onGlobalPropertiesChanged);
|
||||
|
||||
// Initial sync: copy all non-loaded property values from global
|
||||
for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
for (int i = basePropertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
auto prop = meta->property(i);
|
||||
const auto key = QString::fromUtf8(prop.name());
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ void ConfigObject::resyncFromGlobal() {
|
|||
return;
|
||||
|
||||
const auto* meta = metaObject();
|
||||
for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
for (int i = basePropertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
auto prop = meta->property(i);
|
||||
const auto key = QString::fromUtf8(prop.name());
|
||||
|
||||
|
|
@ -210,6 +210,10 @@ void ConfigObject::resyncFromGlobal() {
|
|||
}
|
||||
}
|
||||
|
||||
int ConfigObject::basePropertyOffset() {
|
||||
return ConfigObject::staticMetaObject.propertyCount();
|
||||
}
|
||||
|
||||
QString ConfigObject::propertyPath(const QString& name) const {
|
||||
QStringList parts;
|
||||
parts.append(name);
|
||||
|
|
@ -223,7 +227,7 @@ QString ConfigObject::propertyPath(const QString& name) const {
|
|||
// Find which property name this child is on the parent
|
||||
const auto* meta = parentConfig->metaObject();
|
||||
bool found = false;
|
||||
for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
for (int i = basePropertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
auto prop = meta->property(i);
|
||||
auto val = prop.read(parentObj);
|
||||
if (val.value<QObject*>() == obj) {
|
||||
|
|
|
|||
|
|
@ -102,6 +102,12 @@ public:
|
|||
|
||||
[[nodiscard]] bool isPropertyLoaded(const QString& name) const;
|
||||
[[nodiscard]] QString propertyPath(const QString& name) const;
|
||||
|
||||
// First property index past QObject's own (objectName). ConfigObject declares no
|
||||
// properties, so this is where every subclass's config properties begin — including
|
||||
// ones inherited from an intermediate config class (e.g. IconFontStyleConfig). Use
|
||||
// this instead of metaObject()->propertyOffset(), which excludes inherited properties.
|
||||
[[nodiscard]] static int basePropertyOffset();
|
||||
[[nodiscard]] bool isOverlay() const;
|
||||
// Returns true only on overlays — global singleton always returns false.
|
||||
[[nodiscard]] bool isGlobalOnly(const QString& name) const;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ QStringList RootConfig::collectUnknownKeys(const ConfigObject* obj, const QJsonO
|
|||
const auto* meta = obj->metaObject();
|
||||
|
||||
QSet<QString> known;
|
||||
for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i)
|
||||
for (int i = ConfigObject::basePropertyOffset(); i < meta->propertyCount(); ++i)
|
||||
known.insert(QString::fromUtf8(meta->property(i).name()));
|
||||
|
||||
for (auto it = json.begin(); it != json.end(); ++it) {
|
||||
|
|
@ -126,7 +126,7 @@ void RootConfig::connectAutoSave(ConfigObject* obj) {
|
|||
|
||||
// Recurse into sub-objects
|
||||
const auto* meta = obj->metaObject();
|
||||
for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
for (int i = ConfigObject::basePropertyOffset(); i < meta->propertyCount(); ++i) {
|
||||
auto prop = meta->property(i);
|
||||
auto value = prop.read(obj);
|
||||
auto* subObj = value.value<ConfigObject*>();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue