forked from quickshell/quickshell
feat: completely redesign hot reloader
The hot reloader previously attempted to figure out which parent a component would attach to as it loaded. This was fairly error prone as it was heuristic based and didn't work as soon as you split definitions into multiple QML files. The new hot reloader functions by first completely building the widget tree, then applying the old tree to the first tree and pulling out usable values. Proxy windows now wait to appear until being reloaded. Additionally added support for `reloadableId` to help match a Reloadable to its value in the previous widget tree.
This commit is contained in:
parent
d6ed717c39
commit
1da43be6c0
17 changed files with 518 additions and 442 deletions
|
@ -7,8 +7,9 @@
|
|||
#include <qobject.h>
|
||||
#include <qqmlcomponent.h>
|
||||
#include <qqmlparserstatus.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
#include "scavenge.hpp"
|
||||
#include "reload.hpp"
|
||||
|
||||
// extremely inefficient map
|
||||
template <typename K, typename V>
|
||||
|
@ -28,7 +29,7 @@ public:
|
|||
/// screen.
|
||||
///
|
||||
/// [QuickShell.screens]: ../quickshell#prop.screens
|
||||
class Variants: public Scavenger, virtual public Scavengeable {
|
||||
class Variants: public Reloadable {
|
||||
Q_OBJECT;
|
||||
/// The component to create instances of
|
||||
Q_PROPERTY(QQmlComponent* component MEMBER mComponent);
|
||||
|
@ -39,10 +40,9 @@ class Variants: public Scavenger, virtual public Scavengeable {
|
|||
QML_ELEMENT;
|
||||
|
||||
public:
|
||||
explicit Variants(QObject* parent = nullptr): Scavenger(parent) {}
|
||||
explicit Variants(QObject* parent = nullptr): Reloadable(parent) {}
|
||||
|
||||
void earlyInit(QObject* old) override;
|
||||
QObject* scavengeTargetFor(QObject* child) override;
|
||||
void onReload(QObject* oldInstance) override;
|
||||
|
||||
void componentComplete() override;
|
||||
|
||||
|
@ -53,8 +53,4 @@ private:
|
|||
QQmlComponent* mComponent = nullptr;
|
||||
QVariantList mVariants;
|
||||
AwfulMap<QVariantMap, QObject*> instances;
|
||||
|
||||
// pointers may die post componentComplete.
|
||||
AwfulMap<QVariantMap, QObject*> scavengeableInstances;
|
||||
QVariantMap* activeScavengeVariant = nullptr;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue