#include "shell.hpp" #include #include #include #include #include #include #include "rootwrapper.hpp" void QtShell::reload(bool hard) { auto* rootobj = QQmlEngine::contextForObject(this)->engine()->parent(); auto* root = qobject_cast(rootobj); if (root == nullptr) { qWarning() << "cannot find RootWrapper for reload, ignoring request"; return; } root->reloadGraph(hard); } void QtShell::earlyInit(QObject* old) { auto* oldshell = qobject_cast(old); if (oldshell != nullptr) { this->scavengeableChildren = std::move(oldshell->children); } } QObject* QtShell::scavengeTargetFor(QObject* /* child */) { if (this->scavengeableChildren.length() > this->children.length()) { return this->scavengeableChildren[this->children.length()]; } return nullptr; } QQmlListProperty QtShell::components() { return QQmlListProperty( this, nullptr, &QtShell::appendComponent, nullptr, nullptr, nullptr, nullptr, nullptr ); } void QtShell::appendComponent(QQmlListProperty* list, QObject* component) { auto* shell = static_cast(list->object); // NOLINT component->setParent(shell); shell->children.append(component); }