feat: add hard reload signal and wrap root object

This commit is contained in:
outfoxxed 2024-01-31 17:43:18 -08:00
parent d14258df8e
commit 9a5ad44aa9
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
6 changed files with 116 additions and 22 deletions

View file

@ -11,18 +11,25 @@
#include <qqmllist.h>
#include <qtmetamacros.h>
#include "rootwrapper.hpp"
QString CONFIG_PATH; // NOLINT
QtShell::QtShell(): QObject(nullptr), path(CONFIG_PATH), dir(QFileInfo(this->path).dir()) {
CONFIG_PATH = "";
}
QtShell::QtShell(): QObject(nullptr), path(CONFIG_PATH), dir(QFileInfo(this->path).dir()) {}
void QtShell::componentComplete() {
if (this->path.isEmpty()) {
qWarning() << "Multiple QtShell objects were created. You should not do this.";
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";
return;
}
root->reloadGraph();
}
void QtShell::componentComplete() {
for (auto* component: this->mComponents) {
component->prepare(this->dir);
}