From 767500b4665968178aecfadf94ac0589e9861d50 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 4 Feb 2024 05:17:18 -0800 Subject: [PATCH] refactor: move reload function to QtShellGlobal --- src/cpp/qmlglobal.cpp | 16 ++++++++++++++++ src/cpp/qmlglobal.hpp | 1 + src/cpp/shell.cpp | 17 ----------------- src/cpp/shell.hpp | 4 ---- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/cpp/qmlglobal.cpp b/src/cpp/qmlglobal.cpp index 8b369778..84657506 100644 --- a/src/cpp/qmlglobal.cpp +++ b/src/cpp/qmlglobal.cpp @@ -3,12 +3,16 @@ #include #include #include +#include #include +#include +#include #include #include #include #include "qmlscreen.hpp" +#include "rootwrapper.hpp" QtShellGlobal::QtShellGlobal(QObject* parent): QObject(parent) { auto* app = QCoreApplication::instance(); @@ -42,6 +46,18 @@ QQmlListProperty QtShellGlobal::screens() { ); } +void QtShellGlobal::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 QtShellGlobal::updateScreens() { auto screens = QGuiApplication::screens(); this->mScreens.resize(screens.size()); diff --git a/src/cpp/qmlglobal.hpp b/src/cpp/qmlglobal.hpp index 55ed4d78..e59f179a 100644 --- a/src/cpp/qmlglobal.hpp +++ b/src/cpp/qmlglobal.hpp @@ -24,6 +24,7 @@ signals: void screensChanged(); public slots: + void reload(bool hard); void updateScreens(); private: diff --git a/src/cpp/shell.cpp b/src/cpp/shell.cpp index 2543d36e..fa34193c 100644 --- a/src/cpp/shell.cpp +++ b/src/cpp/shell.cpp @@ -1,26 +1,9 @@ #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); diff --git a/src/cpp/shell.hpp b/src/cpp/shell.hpp index f42d8dc9..4cdd360c 100644 --- a/src/cpp/shell.hpp +++ b/src/cpp/shell.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -24,9 +23,6 @@ public: QQmlListProperty components(); -public slots: - void reload(bool hard = true); - private: static void appendComponent(QQmlListProperty* list, QObject* component);