mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-04 19:04:56 +11:00
A signal is now used over the previous tree-searching method as some QML components such as Repeater fail to reparent created children to themselves, which breaks the tree.
32 lines
632 B
C++
32 lines
632 B
C++
#pragma once
|
|
|
|
#include <qhash.h>
|
|
#include <qobject.h>
|
|
#include <qqmlengine.h>
|
|
#include <qqmlintegration.h>
|
|
#include <qtmetamacros.h>
|
|
#include <qtypes.h>
|
|
#include <qurl.h>
|
|
|
|
#include "reload.hpp"
|
|
|
|
///! The root component for reloadable singletons.
|
|
/// All singletons should inherit from this type.
|
|
class Singleton: public ReloadPropagator {
|
|
Q_OBJECT;
|
|
QML_ELEMENT;
|
|
|
|
public:
|
|
void componentComplete() override;
|
|
};
|
|
|
|
class SingletonRegistry {
|
|
public:
|
|
SingletonRegistry() = default;
|
|
|
|
void registerSingleton(const QUrl& url, Singleton* singleton);
|
|
void onReload(SingletonRegistry* old);
|
|
|
|
private:
|
|
QHash<QUrl, Singleton*> registry;
|
|
};
|