mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-06 19:14:57 +11:00
i3/ipc: convert to bindable properties
This commit is contained in:
parent
3b2d84caf0
commit
1a20c39fba
5 changed files with 96 additions and 170 deletions
|
|
@ -1,5 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qproperty.h>
|
||||
#include <qtypes.h>
|
||||
|
||||
#include "connection.hpp"
|
||||
|
||||
namespace qs::i3::ipc {
|
||||
|
|
@ -9,19 +13,19 @@ class I3Workspace: public QObject {
|
|||
Q_OBJECT;
|
||||
|
||||
/// The ID of this workspace, it is unique for i3/Sway launch
|
||||
Q_PROPERTY(qint32 id READ id NOTIFY idChanged);
|
||||
Q_PROPERTY(qint32 id READ default NOTIFY idChanged BINDABLE bindableId);
|
||||
|
||||
/// The name of this workspace
|
||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged);
|
||||
Q_PROPERTY(QString name READ default NOTIFY nameChanged BINDABLE bindableName);
|
||||
|
||||
/// The number of this workspace
|
||||
Q_PROPERTY(qint32 num READ num NOTIFY numChanged);
|
||||
Q_PROPERTY(qint32 num READ default NOTIFY numChanged BINDABLE bindableNum);
|
||||
|
||||
/// If a window in this workspace has an urgent notification
|
||||
Q_PROPERTY(bool urgent READ urgent NOTIFY urgentChanged);
|
||||
Q_PROPERTY(bool urgent READ default NOTIFY urgentChanged BINDABLE bindableUrgent);
|
||||
|
||||
/// If this workspace is the one currently in focus
|
||||
Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged);
|
||||
Q_PROPERTY(bool focused READ default NOTIFY focusedChanged BINDABLE bindableFocused);
|
||||
|
||||
/// The monitor this workspace is being displayed on
|
||||
Q_PROPERTY(qs::i3::ipc::I3Monitor* monitor READ monitor NOTIFY monitorChanged);
|
||||
|
|
@ -37,16 +41,15 @@ class I3Workspace: public QObject {
|
|||
public:
|
||||
I3Workspace(qs::i3::ipc::I3Ipc* ipc): QObject(ipc), ipc(ipc) {}
|
||||
|
||||
[[nodiscard]] qint32 id() const;
|
||||
[[nodiscard]] QString name() const;
|
||||
[[nodiscard]] qint32 num() const;
|
||||
[[nodiscard]] bool urgent() const;
|
||||
[[nodiscard]] bool focused() const;
|
||||
[[nodiscard]] QBindable<qint32> bindableId() { return &this->bId; }
|
||||
[[nodiscard]] QBindable<QString> bindableName() { return &this->bName; }
|
||||
[[nodiscard]] QBindable<qint32> bindableNum() { return &this->bNum; }
|
||||
[[nodiscard]] QBindable<bool> bindableFocused() { return &this->bFocused; }
|
||||
[[nodiscard]] QBindable<bool> bindableUrgent() { return &this->bUrgent; }
|
||||
[[nodiscard]] I3Monitor* monitor() const;
|
||||
[[nodiscard]] QVariantMap lastIpcObject() const;
|
||||
|
||||
void updateFromObject(const QVariantMap& obj);
|
||||
void setFocus(bool focus);
|
||||
|
||||
signals:
|
||||
void idChanged();
|
||||
|
|
@ -60,14 +63,14 @@ signals:
|
|||
private:
|
||||
I3Ipc* ipc;
|
||||
|
||||
qint32 mId = -1;
|
||||
QString mName;
|
||||
qint32 mNum = -1;
|
||||
bool mFocused = false;
|
||||
bool mUrgent = false;
|
||||
|
||||
QVariantMap mLastIpcObject;
|
||||
I3Monitor* mMonitor = nullptr;
|
||||
QString mMonitorName;
|
||||
|
||||
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(I3Workspace, qint32, bId, -1, &I3Workspace::idChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(I3Workspace, QString, bName, &I3Workspace::nameChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(I3Workspace, qint32, bNum, -1, &I3Workspace::numChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(I3Workspace, bool, bFocused, &I3Workspace::focusedChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(I3Workspace, bool, bUrgent, &I3Workspace::urgentChanged);
|
||||
};
|
||||
} // namespace qs::i3::ipc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue