diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-25 00:40:55 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-25 00:40:55 +1000 |
| commit | f0ca30692ddb70fc32e8545c07e02ed5539dc92a (patch) | |
| tree | e3771a3beb5cabc05513a3d587041b4b71fc95e4 /plugin/src/Caelestia/Internal | |
| parent | plugin: add hypr extras (#690) (diff) | |
| download | caelestia-shell-f0ca30692ddb70fc32e8545c07e02ed5539dc92a.tar.gz caelestia-shell-f0ca30692ddb70fc32e8545c07e02ed5539dc92a.tar.bz2 caelestia-shell-f0ca30692ddb70fc32e8545c07e02ed5539dc92a.zip | |
plugin/hypr: add more helpers
Also refresh options on dynamic option application
Diffstat (limited to 'plugin/src/Caelestia/Internal')
| -rw-r--r-- | plugin/src/Caelestia/Internal/hyprextras.cpp | 30 | ||||
| -rw-r--r-- | plugin/src/Caelestia/Internal/hyprextras.hpp | 2 |
2 files changed, 32 insertions, 0 deletions
diff --git a/plugin/src/Caelestia/Internal/hyprextras.cpp b/plugin/src/Caelestia/Internal/hyprextras.cpp index 23495b2..0504d70 100644 --- a/plugin/src/Caelestia/Internal/hyprextras.cpp +++ b/plugin/src/Caelestia/Internal/hyprextras.cpp @@ -51,10 +51,40 @@ HyprDevices* HyprExtras::devices() const { } void HyprExtras::message(const QString& message) { + if (message.isEmpty()) { + return; + } + makeRequest(message, [](bool, const QByteArray&) { }); } +void HyprExtras::batchMessage(const QStringList& messages) { + if (messages.isEmpty()) { + return; + } + + makeRequest("[[BATCH]]" + messages.join(";"), [](bool, const QByteArray&) { + }); +} + +void HyprExtras::applyOptions(const QVariantHash& options) { + if (options.isEmpty()) { + return; + } + + QString request = "[[BATCH]]"; + for (auto it = options.constBegin(); it != options.constEnd(); ++it) { + request += QString("keyword %1 %2;").arg(it.key(), it.value().toString()); + } + + makeRequest(request, [this](bool success, const QByteArray&) { + if (success) { + refreshOptions(); + } + }); +} + void HyprExtras::refreshOptions() { if (!m_optionsRefresh.isNull()) { m_optionsRefresh->close(); diff --git a/plugin/src/Caelestia/Internal/hyprextras.hpp b/plugin/src/Caelestia/Internal/hyprextras.hpp index ca1b2f2..f1863ed 100644 --- a/plugin/src/Caelestia/Internal/hyprextras.hpp +++ b/plugin/src/Caelestia/Internal/hyprextras.hpp @@ -21,6 +21,8 @@ public: [[nodiscard]] HyprDevices* devices() const; Q_INVOKABLE void message(const QString& message); + Q_INVOKABLE void batchMessage(const QStringList& messages); + Q_INVOKABLE void applyOptions(const QVariantHash& options); Q_INVOKABLE void refreshOptions(); Q_INVOKABLE void refreshDevices(); |