From 98cdb8718101577068dedc95459df4c2adce57d3 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 1 Nov 2024 03:12:07 -0700 Subject: [PATCH] all: use UntypedObjectModel instead of ObjectModel in Q_PROPERTY Fixes qmllint/qmlls type deduction for ObjectModels --- src/core/desktopentry.hpp | 4 +++- src/core/doc.hpp | 3 +++ src/services/mpris/watcher.hpp | 4 +++- src/services/notifications/qml.hpp | 4 +++- src/services/pipewire/qml.hpp | 10 +++++++--- src/services/status_notifier/qml.hpp | 4 +++- src/services/upower/core.hpp | 4 +++- src/wayland/hyprland/ipc/qml.hpp | 7 +++++-- src/wayland/toplevel_management/qml.hpp | 4 +++- 9 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/core/desktopentry.hpp b/src/core/desktopentry.hpp index 57bc3bc7..3871181b 100644 --- a/src/core/desktopentry.hpp +++ b/src/core/desktopentry.hpp @@ -9,6 +9,7 @@ #include #include +#include "doc.hpp" #include "model.hpp" class DesktopAction; @@ -139,7 +140,8 @@ private: class DesktopEntries: public QObject { Q_OBJECT; /// All desktop entries of type Application that are not Hidden or NoDisplay. - Q_PROPERTY(ObjectModel* applications READ applications CONSTANT); + QSDOC_TYPE_OVERRIDE(ObjectModel*); + Q_PROPERTY(UntypedObjectModel* applications READ applications CONSTANT); QML_ELEMENT; QML_SINGLETON; diff --git a/src/core/doc.hpp b/src/core/doc.hpp index f7db7ac4..fbb21400 100644 --- a/src/core/doc.hpp +++ b/src/core/doc.hpp @@ -18,3 +18,6 @@ // overridden properties #define QSDOC_PROPERTY_OVERRIDE(...) + +// override types of properties for docs +#define QSDOC_TYPE_OVERRIDE(type) diff --git a/src/services/mpris/watcher.hpp b/src/services/mpris/watcher.hpp index f3a5b9b7..bd922cd3 100644 --- a/src/services/mpris/watcher.hpp +++ b/src/services/mpris/watcher.hpp @@ -10,6 +10,7 @@ #include #include +#include "../../core/doc.hpp" #include "../../core/model.hpp" #include "player.hpp" @@ -46,7 +47,8 @@ class MprisQml: public QObject { QML_NAMED_ELEMENT(Mpris); QML_SINGLETON; /// All connected MPRIS players. - Q_PROPERTY(ObjectModel* players READ players CONSTANT); + QSDOC_TYPE_OVERRIDE(ObjectModel*); + Q_PROPERTY(UntypedObjectModel* players READ players CONSTANT); public: explicit MprisQml(QObject* parent = nullptr): QObject(parent) {}; diff --git a/src/services/notifications/qml.hpp b/src/services/notifications/qml.hpp index bedbcbef..3f5f34c0 100644 --- a/src/services/notifications/qml.hpp +++ b/src/services/notifications/qml.hpp @@ -6,6 +6,7 @@ #include #include +#include "../../core/doc.hpp" #include "../../core/model.hpp" #include "../../core/reload.hpp" #include "notification.hpp" @@ -67,7 +68,8 @@ class NotificationServerQml /// If the notification server should advertise that it supports images. Defaults to false. Q_PROPERTY(bool imageSupported READ imageSupported WRITE setImageSupported NOTIFY imageSupportedChanged); /// All notifications currently tracked by the server. - Q_PROPERTY(ObjectModel* trackedNotifications READ trackedNotifications NOTIFY trackedNotificationsChanged); + QSDOC_TYPE_OVERRIDE(ObjectModel*); + Q_PROPERTY(UntypedObjectModel* trackedNotifications READ trackedNotifications NOTIFY trackedNotificationsChanged); /// Extra hints to expose to notification clients. Q_PROPERTY(QVector extraHints READ extraHints WRITE setExtraHints NOTIFY extraHintsChanged); // clang-format on diff --git a/src/services/pipewire/qml.hpp b/src/services/pipewire/qml.hpp index 44b3fbad..675b923b 100644 --- a/src/services/pipewire/qml.hpp +++ b/src/services/pipewire/qml.hpp @@ -8,6 +8,7 @@ #include #include +#include "../../core/doc.hpp" #include "../../core/model.hpp" #include "link.hpp" #include "node.hpp" @@ -59,7 +60,8 @@ class Pipewire: public QObject { /// - @@PwNode.isStream - if the node is an application or hardware device. /// - @@PwNode.isSink - if the node is a sink or source. /// - @@PwNode.audio - if non null the node is an audio node. - Q_PROPERTY(ObjectModel* nodes READ nodes CONSTANT); + QSDOC_TYPE_OVERRIDE(ObjectModel*); + Q_PROPERTY(UntypedObjectModel* nodes READ nodes CONSTANT); /// All links present in pipewire. /// /// Links connect pipewire nodes to each other, and can be used to determine @@ -70,14 +72,16 @@ class Pipewire: public QObject { /// /// > [!INFO] Multiple links may exist between the same nodes. See @@linkGroups /// > for a deduplicated list containing only one entry per link between nodes. - Q_PROPERTY(ObjectModel* links READ links CONSTANT); + QSDOC_TYPE_OVERRIDE(ObjectModel*); + Q_PROPERTY(UntypedObjectModel* links READ links CONSTANT); /// All link groups present in pipewire. /// /// The same as @@links but deduplicated. /// /// If you already have a node you want to check for connections to, /// use @@PwNodeLinkTracker instead of filtering this list. - Q_PROPERTY(ObjectModel* linkGroups READ linkGroups CONSTANT); + QSDOC_TYPE_OVERRIDE(ObjectModel*); + Q_PROPERTY(UntypedObjectModel* linkGroups READ linkGroups CONSTANT); /// The default audio sink (output) or `null`. /// /// This is the default sink currently in use by pipewire, and the one applications diff --git a/src/services/status_notifier/qml.hpp b/src/services/status_notifier/qml.hpp index 797f364d..98a647fa 100644 --- a/src/services/status_notifier/qml.hpp +++ b/src/services/status_notifier/qml.hpp @@ -5,6 +5,7 @@ #include #include +#include "../../core/doc.hpp" #include "../../core/model.hpp" #include "item.hpp" @@ -125,7 +126,8 @@ signals: class SystemTray: public QObject { Q_OBJECT; /// List of all system tray icons. - Q_PROPERTY(ObjectModel* items READ items CONSTANT); + QSDOC_TYPE_OVERRIDE(ObjectModel*); + Q_PROPERTY(UntypedObjectModel* items READ items CONSTANT); QML_ELEMENT; QML_SINGLETON; diff --git a/src/services/upower/core.hpp b/src/services/upower/core.hpp index 3446d66c..302311ea 100644 --- a/src/services/upower/core.hpp +++ b/src/services/upower/core.hpp @@ -7,6 +7,7 @@ #include #include +#include "../../core/doc.hpp" #include "../../core/model.hpp" #include "../../dbus/properties.hpp" #include "dbus_service.h" @@ -60,7 +61,8 @@ class UPowerQml: public QObject { /// It is typically the device that is used for displaying information in desktop environments. Q_PROPERTY(qs::service::upower::UPowerDevice* displayDevice READ displayDevice NOTIFY displayDeviceChanged); /// All connected UPower devices. - Q_PROPERTY(ObjectModel* devices READ devices CONSTANT); + QSDOC_TYPE_OVERRIDE(ObjectModel*); + Q_PROPERTY(UntypedObjectModel* devices READ devices CONSTANT); /// If the system is currently running on battery power, or discharging. Q_PROPERTY(bool onBattery READ onBattery NOTIFY onBatteryChanged); // clang-format on diff --git a/src/wayland/hyprland/ipc/qml.hpp b/src/wayland/hyprland/ipc/qml.hpp index e39855a2..72bb4e14 100644 --- a/src/wayland/hyprland/ipc/qml.hpp +++ b/src/wayland/hyprland/ipc/qml.hpp @@ -5,6 +5,7 @@ #include #include +#include "../../../core/doc.hpp" #include "../../../core/model.hpp" #include "../../../core/qmlscreen.hpp" #include "connection.hpp" @@ -22,9 +23,11 @@ class HyprlandIpcQml: public QObject { /// The currently focused hyprland monitor. May be null. Q_PROPERTY(qs::hyprland::ipc::HyprlandMonitor* focusedMonitor READ focusedMonitor NOTIFY focusedMonitorChanged); /// All hyprland monitors. - Q_PROPERTY(ObjectModel* monitors READ monitors CONSTANT); + QSDOC_TYPE_OVERRIDE(ObjectModel*); + Q_PROPERTY(UntypedObjectModel* monitors READ monitors CONSTANT); /// All hyprland workspaces. - Q_PROPERTY(ObjectModel* workspaces READ workspaces CONSTANT); + QSDOC_TYPE_OVERRIDE(ObjectModel*); + Q_PROPERTY(UntypedObjectModel* workspaces READ workspaces CONSTANT); // clang-format on QML_NAMED_ELEMENT(Hyprland); QML_SINGLETON; diff --git a/src/wayland/toplevel_management/qml.hpp b/src/wayland/toplevel_management/qml.hpp index e08fcfa6..127b4c8f 100644 --- a/src/wayland/toplevel_management/qml.hpp +++ b/src/wayland/toplevel_management/qml.hpp @@ -4,6 +4,7 @@ #include #include +#include "../../core/doc.hpp" #include "../../core/model.hpp" #include "../../core/qmlscreen.hpp" #include "../../core/util.hpp" @@ -143,7 +144,8 @@ class ToplevelManagerQml: public QObject { Q_OBJECT; // clang-format off /// All toplevel windows exposed by the compositor. - Q_PROPERTY(ObjectModel* toplevels READ toplevels CONSTANT); + QSDOC_TYPE_OVERRIDE(ObjectModel*); + Q_PROPERTY(UntypedObjectModel* toplevels READ toplevels CONSTANT); /// Active toplevel or null. /// /// > [!INFO] If multiple are active, this will be the most recently activated one.