hyprland/ipc: make monitor bindable + fix property errors

This commit is contained in:
outfoxxed 2025-03-26 14:19:50 -07:00
parent 62ccab5d30
commit 8f11d60999
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
3 changed files with 35 additions and 35 deletions

View file

@ -12,8 +12,11 @@
namespace qs::hyprland::ipc {
class HyprlandMonitor;
class HyprlandWorkspace: public QObject {
Q_OBJECT;
// clang-format off
Q_PROPERTY(qint32 id READ default NOTIFY idChanged BINDABLE bindableId);
Q_PROPERTY(QString name READ default NOTIFY nameChanged BINDABLE bindableName);
/// If this workspace is currently active on its monitor. See also @@focused.
@ -27,12 +30,13 @@ class HyprlandWorkspace: public QObject {
/// > Hyprland. If you need a value that is subject to change and does not have a dedicated
/// > property, run @@Hyprland.refreshWorkspaces() and wait for this property to update.
Q_PROPERTY(QVariantMap lastIpcObject READ lastIpcObject NOTIFY lastIpcObjectChanged);
Q_PROPERTY(HyprlandMonitor* monitor READ monitor NOTIFY monitorChanged);
Q_PROPERTY(qs::hyprland::ipc::HyprlandMonitor* monitor READ default NOTIFY monitorChanged BINDABLE bindableMonitor);
// clang-format on
QML_ELEMENT;
QML_UNCREATABLE("HyprlandWorkspaces must be retrieved from the HyprlandIpc object.");
public:
explicit HyprlandWorkspace(HyprlandIpc* ipc): QObject(ipc), ipc(ipc) {}
explicit HyprlandWorkspace(HyprlandIpc* ipc);
void updateInitial(qint32 id, const QString& name);
void updateFromObject(QVariantMap object);
@ -49,10 +53,10 @@ public:
[[nodiscard]] QBindable<QString> bindableName() { return &this->bName; }
[[nodiscard]] QBindable<bool> bindableActive() { return &this->bActive; }
[[nodiscard]] QBindable<bool> bindableFocused() { return &this->bFocused; }
[[nodiscard]] QBindable<HyprlandMonitor*> bindableMonitor() { return &this->bMonitor; }
[[nodiscard]] QVariantMap lastIpcObject() const;
[[nodiscard]] HyprlandMonitor* monitor() const;
void setMonitor(HyprlandMonitor* monitor);
signals:
@ -70,13 +74,13 @@ private:
HyprlandIpc* ipc;
QVariantMap mLastIpcObject;
HyprlandMonitor* mMonitor = nullptr;
// clang-format off
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(HyprlandWorkspace, qint32, bId, -1, &HyprlandWorkspace::idChanged);
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, QString, bName, &HyprlandWorkspace::nameChanged);
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bActive, &HyprlandWorkspace::activeChanged);
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, bool, bFocused, &HyprlandWorkspace::focusedChanged);
Q_OBJECT_BINDABLE_PROPERTY(HyprlandWorkspace, HyprlandMonitor*, bMonitor, &HyprlandWorkspace::monitorChanged);
// clang-format on
};