feat: add hard reload signal and wrap root object

This commit is contained in:
outfoxxed committed 2024-01-31 18:02:20 -08:00
1 parent d14258df8e
commit 9a5ad44aa9
6 files changed
+116 -22

No files matched your search

+13 -6
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);
}