mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2026-04-10 06:11:54 +10:00
io/fileview: convert containers to QVariantList/Map before serialize
QJsonValue::fromVariant doesn't do this automatically for some reason.
This commit is contained in:
parent
b4e71cb2c0
commit
854088c48c
2 changed files with 12 additions and 6 deletions
|
|
@ -69,6 +69,7 @@ set shell id.
|
|||
- Fixed ScreencopyView pixelation when scaled.
|
||||
- Fixed JsonAdapter crashing and providing bad data on read when using JsonObject.
|
||||
- Fixed JsonAdapter sending unnecessary property changes for primitive values.
|
||||
- Fixed JsonAdapter serialization for lists.
|
||||
|
||||
## Packaging Changes
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "jsonadapter.hpp"
|
||||
|
||||
#include <qassociativeiterable.h>
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qjsonarray.h>
|
||||
#include <qjsondocument.h>
|
||||
|
|
@ -14,6 +15,7 @@
|
|||
#include <qqmlengine.h>
|
||||
#include <qqmlinfo.h>
|
||||
#include <qqmllist.h>
|
||||
#include <qsequentialiterable.h>
|
||||
#include <qstringview.h>
|
||||
#include <qvariant.h>
|
||||
|
||||
|
|
@ -131,13 +133,16 @@ QJsonObject JsonAdapter::serializeRec(const QObject* obj, const QMetaObject* bas
|
|||
}
|
||||
|
||||
json.insert(prop.name(), array);
|
||||
} else if (val.canConvert<QJSValue>()) {
|
||||
auto variant = val.value<QJSValue>().toVariant();
|
||||
auto jv = QJsonValue::fromVariant(variant);
|
||||
json.insert(prop.name(), jv);
|
||||
} else {
|
||||
auto jv = QJsonValue::fromVariant(val);
|
||||
json.insert(prop.name(), jv);
|
||||
if (val.canConvert<QJSValue>()) val = val.value<QJSValue>().toVariant();
|
||||
|
||||
if (val.canConvert<QAssociativeIterable>()) {
|
||||
val.convert(QMetaType::fromType<QVariantMap>());
|
||||
} else if (val.canConvert<QSequentialIterable>()) {
|
||||
val.convert(QMetaType::fromType<QVariantList>());
|
||||
}
|
||||
|
||||
json.insert(prop.name(), QJsonValue::fromVariant(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue