From dc616923aa7baf8dcce2f6ab804153f5e13f92e4 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sat, 17 Feb 2024 05:14:15 -0800 Subject: [PATCH] refactor: rename ProxyShell/FloatingWindow to Shell/FloatingWindow also make ProxyWindowBase visible in docs --- src/cpp/layershell.hpp | 8 ++++---- src/cpp/proxywindow.hpp | 20 +++++++++++++------- src/cpp/qmlglobal.hpp | 2 +- src/cpp/qmlscreen.hpp | 4 ++-- src/cpp/reload.hpp | 10 ++++++---- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/cpp/layershell.hpp b/src/cpp/layershell.hpp index 597e75d2..8aeeaee1 100644 --- a/src/cpp/layershell.hpp +++ b/src/cpp/layershell.hpp @@ -75,9 +75,9 @@ Q_ENUM_NS(Enum); } // namespace Layer -/// Type of keyboard focus that will be accepted by a [ProxyShellWindow] +/// Type of keyboard focus that will be accepted by a [ShellWindow] /// -/// [ProxyShellWindow]: ../proxyshellwindow +/// [ShellWindow]: ../shellwindow namespace KeyboardFocus { // NOLINT Q_NAMESPACE; QML_ELEMENT; @@ -117,7 +117,7 @@ Q_ENUM_NS(Enum); /// The following snippet creates a white bar attached to the bottom of [TODO] screen. /// /// ```qml -/// ProxyShellWindow { +/// ShellWindow { /// anchors { /// left: true /// bottom: true @@ -162,7 +162,7 @@ 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); - QML_ELEMENT; + QML_NAMED_ELEMENT(ShellWindow); // clang-format on public: diff --git a/src/cpp/proxywindow.hpp b/src/cpp/proxywindow.hpp index 568d1bae..d0c82098 100644 --- a/src/cpp/proxywindow.hpp +++ b/src/cpp/proxywindow.hpp @@ -17,10 +17,12 @@ // Proxy to an actual window exposing a limited property set with the ability to // transfer it to a new window. -// Detaching a window and touching any property is a use after free. -// -// NOTE: setting an `id` in qml will point to the proxy window and not the real window so things -// like anchors must use `item`. + +///! Base class for reloadable windows +/// Base class for reloadable windows. See [ShellWindow] and [FloatingWindow] +/// +/// [ShellWindow]: ../shellwindow +/// [FloatingWindow]: ../floatingwindow class ProxyWindowBase: public Reloadable { Q_OBJECT; /// The QtQuick window backing this window. @@ -58,7 +60,7 @@ class ProxyWindowBase: public Reloadable { /// If non null then the clickable areas of the window will be determined by the provided region. /// /// ```qml - /// ProxyShellWindow { + /// ShellWindow { /// // The mask region is set to `rect`, meaning only `rect` is clickable. /// // All other clicks pass through the window to ones behind it. /// mask: Region { item: rect } @@ -80,7 +82,7 @@ class ProxyWindowBase: public Reloadable { /// the mask region not clickable and pass through clicks inside it through the window. /// /// ```qml - /// ProxyShellWindow { + /// ShellWindow { /// // The mask region is set to `rect`, but the intersection mode is set to `Xor`. /// // This inverts the mask causing all clicks inside `rect` to be passed to the window /// // behind this one. @@ -98,6 +100,8 @@ class ProxyWindowBase: public Reloadable { Q_PROPERTY(PendingRegion* mask READ mask WRITE setMask NOTIFY maskChanged); Q_PROPERTY(QQmlListProperty data READ data); Q_CLASSINFO("DefaultProperty", "data"); + QML_ELEMENT; + QML_UNCREATABLE("use ShellWindow or FloatingWindow"); public: explicit ProxyWindowBase(QObject* parent = nullptr); @@ -162,9 +166,11 @@ private: // qt attempts to resize the window but fails because wayland // and only resizes the graphics context which looks terrible. + +///! Standard floating window. class ProxyFloatingWindow: public ProxyWindowBase { Q_OBJECT; - QML_ELEMENT; + QML_NAMED_ELEMENT(FloatingWindow); public: // Setting geometry while the window is visible makes the content item shrink but not the window diff --git a/src/cpp/qmlglobal.hpp b/src/cpp/qmlglobal.hpp index f0e964a2..88fcbdf4 100644 --- a/src/cpp/qmlglobal.hpp +++ b/src/cpp/qmlglobal.hpp @@ -19,7 +19,7 @@ class QuickShellGlobal: public QObject { /// ```qml /// ShellRoot { /// Variants { - /// ProxyShellWindow { + /// ShellWindow { /// // ... /// } /// diff --git a/src/cpp/qmlscreen.hpp b/src/cpp/qmlscreen.hpp index 1fbfd2c7..fed24e31 100644 --- a/src/cpp/qmlscreen.hpp +++ b/src/cpp/qmlscreen.hpp @@ -9,7 +9,7 @@ // unfortunately QQuickScreenInfo is private. -/// Monitor object useful for setting the monitor for a [ProxyShellWindow] +/// Monitor object useful for setting the monitor for a [ShellWindow] /// or querying information about the monitor. /// /// > [!WARNING] If the monitor is disconnected than any stored copies of its ShellMonitor will @@ -18,7 +18,7 @@ /// /// Due to some technical limitations, it was not possible to reuse the native qml [Screen] type. /// -/// [ProxyShellWindow]: ../proxyshellwindow +/// [ShellWindow]: ../shellwindow /// [Screen]: https://doc.qt.io/qt-6/qml-qtquick-screen.html class QuickShellScreenInfo: public QObject { Q_OBJECT; diff --git a/src/cpp/reload.hpp b/src/cpp/reload.hpp index 1261afc6..85333093 100644 --- a/src/cpp/reload.hpp +++ b/src/cpp/reload.hpp @@ -9,8 +9,10 @@ ///! The base class of all types that can be reloaded. /// Reloadables will attempt to take specific state from previous config revisions if possible. -/// Some examples are `ProxyShellWindow` and `ProxyFloatingWindow` which will attempt to find the -/// windows assigned to them in the previous configuration. +/// Some examples are [ProxyWindowBase] and [PersistentProperties] +/// +/// [ProxyWindowBase]: ../proxywindowbase +/// [PersistentProperties]: ../persistentproperties class Reloadable: public QObject, public QQmlParserStatus { Q_OBJECT; Q_INTERFACES(QQmlParserStatus); @@ -32,8 +34,8 @@ class Reloadable: public QObject, public QQmlParserStatus { /// /// // any non `Reloadable` object /// QtObject { - /// ProxyFloatingWindow { - /// // this ProxyFloatingWindow will now be matched to the same one in the previous + /// FloatingWindow { + /// // this FloatingWindow will now be matched to the same one in the previous /// // widget tree for its variant. "myFloatingWindow" refers to both the variant in /// // `foo: 1` and `foo: 2` for each tree. /// reloadableId: "myFloatingWindow"