forked from quickshell/quickshell
refactor: move reload function to QtShellGlobal
This commit is contained in:
parent
7a18ce8a55
commit
767500b466
|
@ -3,12 +3,16 @@
|
||||||
#include <qcontainerfwd.h>
|
#include <qcontainerfwd.h>
|
||||||
#include <qcoreapplication.h>
|
#include <qcoreapplication.h>
|
||||||
#include <qguiapplication.h>
|
#include <qguiapplication.h>
|
||||||
|
#include <qlogging.h>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
|
#include <qqmlcontext.h>
|
||||||
|
#include <qqmlengine.h>
|
||||||
#include <qqmllist.h>
|
#include <qqmllist.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
#include <qtypes.h>
|
#include <qtypes.h>
|
||||||
|
|
||||||
#include "qmlscreen.hpp"
|
#include "qmlscreen.hpp"
|
||||||
|
#include "rootwrapper.hpp"
|
||||||
|
|
||||||
QtShellGlobal::QtShellGlobal(QObject* parent): QObject(parent) {
|
QtShellGlobal::QtShellGlobal(QObject* parent): QObject(parent) {
|
||||||
auto* app = QCoreApplication::instance();
|
auto* app = QCoreApplication::instance();
|
||||||
|
@ -42,6 +46,18 @@ QQmlListProperty<QtShellScreenInfo> QtShellGlobal::screens() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtShellGlobal::reload(bool hard) {
|
||||||
|
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(hard);
|
||||||
|
}
|
||||||
|
|
||||||
void QtShellGlobal::updateScreens() {
|
void QtShellGlobal::updateScreens() {
|
||||||
auto screens = QGuiApplication::screens();
|
auto screens = QGuiApplication::screens();
|
||||||
this->mScreens.resize(screens.size());
|
this->mScreens.resize(screens.size());
|
||||||
|
|
|
@ -24,6 +24,7 @@ signals:
|
||||||
void screensChanged();
|
void screensChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void reload(bool hard);
|
||||||
void updateScreens();
|
void updateScreens();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,26 +1,9 @@
|
||||||
#include "shell.hpp"
|
#include "shell.hpp"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <qlogging.h>
|
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qqmlcontext.h>
|
|
||||||
#include <qqmlengine.h>
|
|
||||||
#include <qqmllist.h>
|
#include <qqmllist.h>
|
||||||
|
|
||||||
#include "rootwrapper.hpp"
|
|
||||||
|
|
||||||
void QtShell::reload(bool hard) {
|
|
||||||
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(hard);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtShell::earlyInit(QObject* old) {
|
void QtShell::earlyInit(QObject* old) {
|
||||||
auto* oldshell = qobject_cast<QtShell*>(old);
|
auto* oldshell = qobject_cast<QtShell*>(old);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <qcontainerfwd.h>
|
#include <qcontainerfwd.h>
|
||||||
#include <qlist.h>
|
#include <qlist.h>
|
||||||
#include <qlogging.h>
|
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qqmlengine.h>
|
#include <qqmlengine.h>
|
||||||
#include <qqmllist.h>
|
#include <qqmllist.h>
|
||||||
|
@ -24,9 +23,6 @@ public:
|
||||||
|
|
||||||
QQmlListProperty<QObject> components();
|
QQmlListProperty<QObject> components();
|
||||||
|
|
||||||
public slots:
|
|
||||||
void reload(bool hard = true);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void appendComponent(QQmlListProperty<QObject>* list, QObject* component);
|
static void appendComponent(QQmlListProperty<QObject>* list, QObject* component);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue