forked from quickshell/quickshell
feat: abstract out scavenger scopes
This commit is contained in:
parent
82aa7d45d3
commit
d6ed717c39
4 changed files with 74 additions and 56 deletions
|
@ -2,9 +2,7 @@
|
|||
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qlist.h>
|
||||
#include <qobject.h>
|
||||
#include <qqmlengine.h>
|
||||
#include <qqmllist.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
#include "scavenge.hpp"
|
||||
|
@ -18,35 +16,22 @@ public:
|
|||
};
|
||||
|
||||
///! Root config element
|
||||
class ShellRoot: public Scavenger, virtual public Scavengeable {
|
||||
class ShellRoot: public ScavengeableScope {
|
||||
Q_OBJECT;
|
||||
/// If `config.watchFiles` is true the configuration will be reloaded whenever it changes.
|
||||
/// Defaults to true.
|
||||
Q_PROPERTY(ShellConfig config READ config WRITE setConfig);
|
||||
Q_PROPERTY(QQmlListProperty<QObject> components READ components);
|
||||
Q_CLASSINFO("DefaultProperty", "components");
|
||||
QML_ELEMENT;
|
||||
|
||||
public:
|
||||
explicit ShellRoot(QObject* parent = nullptr): Scavenger(parent) {}
|
||||
|
||||
void earlyInit(QObject* old) override;
|
||||
QObject* scavengeTargetFor(QObject* child) override;
|
||||
explicit ShellRoot(QObject* parent = nullptr): ScavengeableScope(parent) {}
|
||||
|
||||
void setConfig(ShellConfig config);
|
||||
[[nodiscard]] ShellConfig config() const;
|
||||
|
||||
QQmlListProperty<QObject> components();
|
||||
|
||||
signals:
|
||||
void configChanged();
|
||||
|
||||
private:
|
||||
static void appendComponent(QQmlListProperty<QObject>* list, QObject* component);
|
||||
|
||||
ShellConfig mConfig;
|
||||
|
||||
// track only the children assigned to `components` in order
|
||||
QList<QObject*> children;
|
||||
QList<QObject*> scavengeableChildren;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue