feat: add filesystem watcher and rename QtShell object

This commit is contained in:
outfoxxed 2024-02-04 23:00:59 -08:00
parent cab5ffc65e
commit c0d6e63f6c
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
9 changed files with 142 additions and 42 deletions

View file

@ -9,24 +9,40 @@
#include "scavenge.hpp"
class QtShell: public Scavenger, virtual public Scavengeable {
class ShellConfig {
Q_GADGET;
Q_PROPERTY(bool watchFiles MEMBER mWatchFiles);
public:
bool mWatchFiles = true;
};
class ShellRoot: public Scavenger, virtual public Scavengeable {
Q_OBJECT;
Q_PROPERTY(ShellConfig config READ config WRITE setConfig);
Q_PROPERTY(QQmlListProperty<QObject> components READ components FINAL);
Q_CLASSINFO("DefaultProperty", "components");
QML_ELEMENT;
public:
explicit QtShell(QObject* parent = nullptr): Scavenger(parent) {}
explicit ShellRoot(QObject* parent = nullptr): Scavenger(parent) {}
void earlyInit(QObject* old) override;
QObject* scavengeTargetFor(QObject* child) override;
void setConfig(ShellConfig config);
[[nodiscard]] ShellConfig config() const;
QQmlListProperty<QObject> components();
signals:
void configChanged();
private:
static void appendComponent(QQmlListProperty<QObject>* list, QObject* component);
public:
ShellConfig mConfig;
// track only the children assigned to `components` in order
QList<QObject*> children;
QList<QObject*> scavengeableChildren;