feat: add PersistentProperties

This commit is contained in:
outfoxxed 2024-02-17 04:24:03 -08:00
parent ed62193978
commit 083fff57be
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
5 changed files with 86 additions and 1 deletions

View file

@ -0,0 +1,24 @@
#include "persistentprops.hpp"
#include <qobject.h>
#include <qtmetamacros.h>
void PersistentProperties::onReload(QObject* oldInstance) {
if (qobject_cast<PersistentProperties*>(oldInstance) == nullptr) {
emit this->loaded();
return;
}
const auto* metaObject = this->metaObject();
for (auto i = metaObject->propertyOffset(); i < metaObject->propertyCount(); i++) {
const auto prop = metaObject->property(i);
auto oldProp = oldInstance->property(prop.name());
if (oldProp.isValid()) {
this->setProperty(prop.name(), oldProp);
}
}
emit this->loaded();
emit this->reloaded();
}