2024-01-25 12:33:02 +00:00
|
|
|
#include "shell.hpp"
|
|
|
|
|
|
|
|
#include <qlogging.h>
|
|
|
|
#include <qobject.h>
|
|
|
|
#include <qqmlcontext.h>
|
|
|
|
#include <qqmlengine.h>
|
|
|
|
#include <qqmllist.h>
|
|
|
|
|
2024-02-01 01:43:18 +00:00
|
|
|
#include "rootwrapper.hpp"
|
|
|
|
|
|
|
|
void QtShell::reload() {
|
|
|
|
auto* rootobj = QQmlEngine::contextForObject(this)->engine()->parent();
|
|
|
|
auto* root = qobject_cast<RootWrapper*>(rootobj);
|
|
|
|
|
|
|
|
if (root == nullptr) {
|
|
|
|
qWarning() << "cannot find RootWrapper for reload, ignoring request";
|
2024-01-25 12:33:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-02-01 01:43:18 +00:00
|
|
|
root->reloadGraph();
|
|
|
|
}
|
|
|
|
|
2024-02-01 02:35:51 +00:00
|
|
|
QQmlListProperty<QObject> QtShell::components() {
|
|
|
|
return QQmlListProperty<QObject>(
|
2024-01-25 12:33:02 +00:00
|
|
|
this,
|
|
|
|
nullptr,
|
|
|
|
&QtShell::appendComponent,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-02-01 02:35:51 +00:00
|
|
|
void QtShell::appendComponent(QQmlListProperty<QObject>* list, QObject* component) {
|
|
|
|
auto* shell = static_cast<QtShell*>(list->object); // NOLINT
|
|
|
|
component->setParent(shell);
|
2024-01-25 12:33:02 +00:00
|
|
|
}
|