diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-24 23:48:47 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-24 23:48:47 +1000 |
| commit | 57e3989185b8209a11d79bac477479019d515180 (patch) | |
| tree | 27e94dcaef9f41bb8f294eab1a91a27ce4da03d0 /plugin/src/Caelestia/Internal/hyprextras.hpp | |
| parent | plugin: sub namespace modules (diff) | |
| download | caelestia-shell-57e3989185b8209a11d79bac477479019d515180.tar.gz caelestia-shell-57e3989185b8209a11d79bac477479019d515180.tar.bz2 caelestia-shell-57e3989185b8209a11d79bac477479019d515180.zip | |
plugin: add hypr extras (#690)
* move machine
* works
* prevent duplicate refreshes
* use instead of hyprctl proc
Diffstat (limited to 'plugin/src/Caelestia/Internal/hyprextras.hpp')
| -rw-r--r-- | plugin/src/Caelestia/Internal/hyprextras.hpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/plugin/src/Caelestia/Internal/hyprextras.hpp b/plugin/src/Caelestia/Internal/hyprextras.hpp new file mode 100644 index 0000000..ca1b2f2 --- /dev/null +++ b/plugin/src/Caelestia/Internal/hyprextras.hpp @@ -0,0 +1,51 @@ +#pragma once + +#include "hyprdevices.hpp" +#include <qlocalsocket.h> +#include <qobject.h> +#include <qqmlintegration.h> + +namespace caelestia::internal::hypr { + +class HyprExtras : public QObject { + Q_OBJECT + QML_ELEMENT + + Q_PROPERTY(QVariantHash options READ options NOTIFY optionsChanged) + Q_PROPERTY(HyprDevices* devices READ devices CONSTANT) + +public: + explicit HyprExtras(QObject* parent = nullptr); + + [[nodiscard]] QVariantHash options() const; + [[nodiscard]] HyprDevices* devices() const; + + Q_INVOKABLE void message(const QString& message); + + Q_INVOKABLE void refreshOptions(); + Q_INVOKABLE void refreshDevices(); + +signals: + void optionsChanged(); + +private: + using SocketPtr = QSharedPointer<QLocalSocket>; + + QString m_requestSocket; + QString m_eventSocket; + QLocalSocket* m_socket; + + QVariantHash m_options; + HyprDevices* const m_devices; + + SocketPtr m_optionsRefresh; + SocketPtr m_devicesRefresh; + + void readEvent(); + void handleEvent(const QString& event); + + SocketPtr makeRequestJson(const QString& request, const std::function<void(bool, QJsonDocument)>& callback); + SocketPtr makeRequest(const QString& request, const std::function<void(bool, QByteArray)>& callback); +}; + +} // namespace caelestia::internal::hypr |