all: use UntypedObjectModel instead of ObjectModel in Q_PROPERTY

Fixes qmllint/qmlls type deduction for ObjectModels
This commit is contained in:
outfoxxed 2024-11-01 03:12:07 -07:00
parent 746b0e70d7
commit 98cdb87181
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
9 changed files with 33 additions and 11 deletions

View file

@ -9,6 +9,7 @@
#include <qqmlintegration.h> #include <qqmlintegration.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include "doc.hpp"
#include "model.hpp" #include "model.hpp"
class DesktopAction; class DesktopAction;
@ -139,7 +140,8 @@ private:
class DesktopEntries: public QObject { class DesktopEntries: public QObject {
Q_OBJECT; Q_OBJECT;
/// All desktop entries of type Application that are not Hidden or NoDisplay. /// All desktop entries of type Application that are not Hidden or NoDisplay.
Q_PROPERTY(ObjectModel<DesktopEntry>* applications READ applications CONSTANT); QSDOC_TYPE_OVERRIDE(ObjectModel<DesktopEntry>*);
Q_PROPERTY(UntypedObjectModel* applications READ applications CONSTANT);
QML_ELEMENT; QML_ELEMENT;
QML_SINGLETON; QML_SINGLETON;

View file

@ -18,3 +18,6 @@
// overridden properties // overridden properties
#define QSDOC_PROPERTY_OVERRIDE(...) #define QSDOC_PROPERTY_OVERRIDE(...)
// override types of properties for docs
#define QSDOC_TYPE_OVERRIDE(type)

View file

@ -10,6 +10,7 @@
#include <qqmllist.h> #include <qqmllist.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include "../../core/doc.hpp"
#include "../../core/model.hpp" #include "../../core/model.hpp"
#include "player.hpp" #include "player.hpp"
@ -46,7 +47,8 @@ class MprisQml: public QObject {
QML_NAMED_ELEMENT(Mpris); QML_NAMED_ELEMENT(Mpris);
QML_SINGLETON; QML_SINGLETON;
/// All connected MPRIS players. /// All connected MPRIS players.
Q_PROPERTY(ObjectModel<qs::service::mpris::MprisPlayer>* players READ players CONSTANT); QSDOC_TYPE_OVERRIDE(ObjectModel<qs::service::mpris::MprisPlayer>*);
Q_PROPERTY(UntypedObjectModel* players READ players CONSTANT);
public: public:
explicit MprisQml(QObject* parent = nullptr): QObject(parent) {}; explicit MprisQml(QObject* parent = nullptr): QObject(parent) {};

View file

@ -6,6 +6,7 @@
#include <qqmlintegration.h> #include <qqmlintegration.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include "../../core/doc.hpp"
#include "../../core/model.hpp" #include "../../core/model.hpp"
#include "../../core/reload.hpp" #include "../../core/reload.hpp"
#include "notification.hpp" #include "notification.hpp"
@ -67,7 +68,8 @@ class NotificationServerQml
/// If the notification server should advertise that it supports images. Defaults to false. /// If the notification server should advertise that it supports images. Defaults to false.
Q_PROPERTY(bool imageSupported READ imageSupported WRITE setImageSupported NOTIFY imageSupportedChanged); Q_PROPERTY(bool imageSupported READ imageSupported WRITE setImageSupported NOTIFY imageSupportedChanged);
/// All notifications currently tracked by the server. /// All notifications currently tracked by the server.
Q_PROPERTY(ObjectModel<qs::service::notifications::Notification>* trackedNotifications READ trackedNotifications NOTIFY trackedNotificationsChanged); QSDOC_TYPE_OVERRIDE(ObjectModel<qs::service::notifications::Notification>*);
Q_PROPERTY(UntypedObjectModel* trackedNotifications READ trackedNotifications NOTIFY trackedNotificationsChanged);
/// Extra hints to expose to notification clients. /// Extra hints to expose to notification clients.
Q_PROPERTY(QVector<QString> extraHints READ extraHints WRITE setExtraHints NOTIFY extraHintsChanged); Q_PROPERTY(QVector<QString> extraHints READ extraHints WRITE setExtraHints NOTIFY extraHintsChanged);
// clang-format on // clang-format on

View file

@ -8,6 +8,7 @@
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <qtypes.h> #include <qtypes.h>
#include "../../core/doc.hpp"
#include "../../core/model.hpp" #include "../../core/model.hpp"
#include "link.hpp" #include "link.hpp"
#include "node.hpp" #include "node.hpp"
@ -59,7 +60,8 @@ class Pipewire: public QObject {
/// - @@PwNode.isStream - if the node is an application or hardware device. /// - @@PwNode.isStream - if the node is an application or hardware device.
/// - @@PwNode.isSink - if the node is a sink or source. /// - @@PwNode.isSink - if the node is a sink or source.
/// - @@PwNode.audio - if non null the node is an audio node. /// - @@PwNode.audio - if non null the node is an audio node.
Q_PROPERTY(ObjectModel<qs::service::pipewire::PwNodeIface>* nodes READ nodes CONSTANT); QSDOC_TYPE_OVERRIDE(ObjectModel<qs::service::pipewire::PwNodeIface>*);
Q_PROPERTY(UntypedObjectModel* nodes READ nodes CONSTANT);
/// All links present in pipewire. /// All links present in pipewire.
/// ///
/// Links connect pipewire nodes to each other, and can be used to determine /// 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 /// > [!INFO] Multiple links may exist between the same nodes. See @@linkGroups
/// > for a deduplicated list containing only one entry per link between nodes. /// > for a deduplicated list containing only one entry per link between nodes.
Q_PROPERTY(ObjectModel<qs::service::pipewire::PwLinkIface>* links READ links CONSTANT); QSDOC_TYPE_OVERRIDE(ObjectModel<qs::service::pipewire::PwLinkIface>*);
Q_PROPERTY(UntypedObjectModel* links READ links CONSTANT);
/// All link groups present in pipewire. /// All link groups present in pipewire.
/// ///
/// The same as @@links but deduplicated. /// The same as @@links but deduplicated.
/// ///
/// If you already have a node you want to check for connections to, /// If you already have a node you want to check for connections to,
/// use @@PwNodeLinkTracker instead of filtering this list. /// use @@PwNodeLinkTracker instead of filtering this list.
Q_PROPERTY(ObjectModel<qs::service::pipewire::PwLinkGroupIface>* linkGroups READ linkGroups CONSTANT); QSDOC_TYPE_OVERRIDE(ObjectModel<qs::service::pipewire::PwLinkGroupIface>*);
Q_PROPERTY(UntypedObjectModel* linkGroups READ linkGroups CONSTANT);
/// The default audio sink (output) or `null`. /// The default audio sink (output) or `null`.
/// ///
/// This is the default sink currently in use by pipewire, and the one applications /// This is the default sink currently in use by pipewire, and the one applications

View file

@ -5,6 +5,7 @@
#include <qtclasshelpermacros.h> #include <qtclasshelpermacros.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include "../../core/doc.hpp"
#include "../../core/model.hpp" #include "../../core/model.hpp"
#include "item.hpp" #include "item.hpp"
@ -125,7 +126,8 @@ signals:
class SystemTray: public QObject { class SystemTray: public QObject {
Q_OBJECT; Q_OBJECT;
/// List of all system tray icons. /// List of all system tray icons.
Q_PROPERTY(ObjectModel<SystemTrayItem>* items READ items CONSTANT); QSDOC_TYPE_OVERRIDE(ObjectModel<SystemTrayItem>*);
Q_PROPERTY(UntypedObjectModel* items READ items CONSTANT);
QML_ELEMENT; QML_ELEMENT;
QML_SINGLETON; QML_SINGLETON;

View file

@ -7,6 +7,7 @@
#include <qqmllist.h> #include <qqmllist.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include "../../core/doc.hpp"
#include "../../core/model.hpp" #include "../../core/model.hpp"
#include "../../dbus/properties.hpp" #include "../../dbus/properties.hpp"
#include "dbus_service.h" #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. /// 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); Q_PROPERTY(qs::service::upower::UPowerDevice* displayDevice READ displayDevice NOTIFY displayDeviceChanged);
/// All connected UPower devices. /// All connected UPower devices.
Q_PROPERTY(ObjectModel<qs::service::upower::UPowerDevice>* devices READ devices CONSTANT); QSDOC_TYPE_OVERRIDE(ObjectModel<qs::service::upower::UPowerDevice>*);
Q_PROPERTY(UntypedObjectModel* devices READ devices CONSTANT);
/// If the system is currently running on battery power, or discharging. /// If the system is currently running on battery power, or discharging.
Q_PROPERTY(bool onBattery READ onBattery NOTIFY onBatteryChanged); Q_PROPERTY(bool onBattery READ onBattery NOTIFY onBatteryChanged);
// clang-format on // clang-format on

View file

@ -5,6 +5,7 @@
#include <qqmlintegration.h> #include <qqmlintegration.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include "../../../core/doc.hpp"
#include "../../../core/model.hpp" #include "../../../core/model.hpp"
#include "../../../core/qmlscreen.hpp" #include "../../../core/qmlscreen.hpp"
#include "connection.hpp" #include "connection.hpp"
@ -22,9 +23,11 @@ class HyprlandIpcQml: public QObject {
/// The currently focused hyprland monitor. May be null. /// The currently focused hyprland monitor. May be null.
Q_PROPERTY(qs::hyprland::ipc::HyprlandMonitor* focusedMonitor READ focusedMonitor NOTIFY focusedMonitorChanged); Q_PROPERTY(qs::hyprland::ipc::HyprlandMonitor* focusedMonitor READ focusedMonitor NOTIFY focusedMonitorChanged);
/// All hyprland monitors. /// All hyprland monitors.
Q_PROPERTY(ObjectModel<qs::hyprland::ipc::HyprlandMonitor>* monitors READ monitors CONSTANT); QSDOC_TYPE_OVERRIDE(ObjectModel<qs::hyprland::ipc::HyprlandMonitor>*);
Q_PROPERTY(UntypedObjectModel* monitors READ monitors CONSTANT);
/// All hyprland workspaces. /// All hyprland workspaces.
Q_PROPERTY(ObjectModel<qs::hyprland::ipc::HyprlandWorkspace>* workspaces READ workspaces CONSTANT); QSDOC_TYPE_OVERRIDE(ObjectModel<qs::hyprland::ipc::HyprlandWorkspace>*);
Q_PROPERTY(UntypedObjectModel* workspaces READ workspaces CONSTANT);
// clang-format on // clang-format on
QML_NAMED_ELEMENT(Hyprland); QML_NAMED_ELEMENT(Hyprland);
QML_SINGLETON; QML_SINGLETON;

View file

@ -4,6 +4,7 @@
#include <qqmlintegration.h> #include <qqmlintegration.h>
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include "../../core/doc.hpp"
#include "../../core/model.hpp" #include "../../core/model.hpp"
#include "../../core/qmlscreen.hpp" #include "../../core/qmlscreen.hpp"
#include "../../core/util.hpp" #include "../../core/util.hpp"
@ -143,7 +144,8 @@ class ToplevelManagerQml: public QObject {
Q_OBJECT; Q_OBJECT;
// clang-format off // clang-format off
/// All toplevel windows exposed by the compositor. /// All toplevel windows exposed by the compositor.
Q_PROPERTY(ObjectModel<qs::wayland::toplevel_management::Toplevel>* toplevels READ toplevels CONSTANT); QSDOC_TYPE_OVERRIDE(ObjectModel<qs::wayland::toplevel_management::Toplevel>*);
Q_PROPERTY(UntypedObjectModel* toplevels READ toplevels CONSTANT);
/// Active toplevel or null. /// Active toplevel or null.
/// ///
/// > [!INFO] If multiple are active, this will be the most recently activated one. /// > [!INFO] If multiple are active, this will be the most recently activated one.