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:
outfoxxed 2024-02-16 06:38:20 -08:00
parent d6ed717c39
commit 1da43be6c0
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
17 changed files with 518 additions and 442 deletions

View file

@ -162,27 +162,18 @@ class ProxyShellWindow: public ProxyWindowBase {
/// The degree of keyboard focus taken. Defaults to `KeyboardFocus.None`.
Q_PROPERTY(KeyboardFocus::Enum keyboardFocus READ keyboardFocus WRITE setKeyboardFocus NOTIFY keyboardFocusChanged);
Q_PROPERTY(ScreenConfiguration::Enum screenConfiguration READ screenConfiguration WRITE setScreenConfiguration);
Q_PROPERTY(bool closeOnDismissed READ closeOnDismissed WRITE setCloseOnDismissed);
QML_ELEMENT;
// clang-format on
protected:
void earlyInit(QObject* old) override;
public:
void componentComplete() override;
void setupWindow() override;
QQuickWindow* disownWindow() override;
QQmlListProperty<QObject> data();
void setVisible(bool visible) override;
bool isVisible() override;
void setWidth(qint32 width) override;
qint32 width() override;
void setHeight(qint32 height) override;
qint32 height() override;
void setScreen(QuickShellScreenInfo* screen);
[[nodiscard]] QuickShellScreenInfo* screen() const;
@ -211,9 +202,6 @@ public:
void setScreenConfiguration(ScreenConfiguration::Enum configuration);
[[nodiscard]] ScreenConfiguration::Enum screenConfiguration() const;
void setCloseOnDismissed(bool close);
[[nodiscard]] bool closeOnDismissed() const;
signals:
void screenChanged();
void anchorsChanged();
@ -225,20 +213,19 @@ signals:
private slots:
void updateExclusionZone();
void onScreenDestroyed();
private:
LayerShellQt::Window* shellWindow = nullptr;
bool anchorsInitialized = false;
QScreen* mScreen = nullptr;
ExclusionMode::Enum mExclusionMode = ExclusionMode::Normal;
qint32 requestedExclusionZone = 0;
qint32 mExclusionZone = 0;
Anchors mAnchors;
Margins mMargins;
Layer::Enum mLayer = Layer::Top;
QString mScope;
KeyboardFocus::Enum mKeyboardFocus = KeyboardFocus::None;
ScreenConfiguration::Enum mScreenConfiguration = ScreenConfiguration::Window;
// needed to ensure size dosent fuck up when changing layershell attachments
// along with setWidth and setHeight overrides
qint32 requestedWidth = 100;
qint32 requestedHeight = 100;
// width/height must be set before anchors, so we have to track anchors and apply them late
bool complete = false;
bool stagingVisible = false;
Anchors stagingAnchors;
bool connected = false;
};