From a3f38e64147d4794801d5b1fb8a1f9b8c61f6983 Mon Sep 17 00:00:00 2001 From: zach Date: Tue, 26 May 2026 16:46:45 +0200 Subject: [PATCH] fetch necessary hyprland options for screenshot tool --- Helpers/Picker.qml | 9 +++++--- Plugins/ZShell/Internal/hyprextras.cpp | 30 +++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/Helpers/Picker.qml b/Helpers/Picker.qml index e9a150e..85372ec 100644 --- a/Helpers/Picker.qml +++ b/Helpers/Picker.qml @@ -34,8 +34,13 @@ MouseArea { property real realRounding: onClient ? (Hypr.options.decoration.rounding ?? 0) : 0 property real rsx: Math.min(sx, ex) property real rsy: Math.min(sy, ey) + readonly property real scaleRatio: Hypr.monitorFor(screen).scale required property ShellScreen screen property real sh: Math.abs(sy - ey) + readonly property color shadowColor: Hypr.options.decoration.shadow.color + readonly property var shadowOffset: Hypr.options.decoration.shadow.offset + readonly property int shadowRange: Hypr.options.decoration.shadow.range + readonly property int shadowRenderPower: Hypr.options.decoration.shadow.render_power property real ssx property real ssy property real sw: Math.abs(sx - ex) @@ -66,9 +71,7 @@ MouseArea { function save(): void { const tmpfile = Qt.resolvedUrl(`/tmp/zshell-picker-${Quickshell.processId}-${Date.now()}.png`); - const scale = Hypr.monitorFor(screen).scale; - console.log(scale); - const cmd = Config.screenshot.enable_pp ? ["zshell-img-tools", "--scale", scale, "--image"] : ["swappy", "-f"]; + const cmd = Config.screenshot.enable_pp ? ["zshell-img-tools", "--scale", root.scaleRatio, "--shadow-blur-radius", root.shadowRange, "--image"] : ["swappy", "-f"]; ZShellIo.saveItem(screencopy, tmpfile, Qt.rect(Math.ceil(rsx), Math.ceil(rsy), Math.floor(sw), Math.floor(sh)), path => Quickshell.execDetached([...cmd, path])); closeAnim.start(); } diff --git a/Plugins/ZShell/Internal/hyprextras.cpp b/Plugins/ZShell/Internal/hyprextras.cpp index a3056d1..60805d4 100644 --- a/Plugins/ZShell/Internal/hyprextras.cpp +++ b/Plugins/ZShell/Internal/hyprextras.cpp @@ -5,12 +5,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -168,13 +170,30 @@ static QString buildHlConfigCall(const QString& key, const QVariant& value) { return out; } +static QColor colorFromInt(quint32 value) { + const int a = (value >> 24) & 0xFF; + const int r = (value >> 16) & 0xFF; + const int g = (value >> 8) & 0xFF; + const int b = value & 0xFF; + + return QColor(r, g, b, a); +} + static QVariant parseGetOptionValue(const QJsonObject& obj) { if (obj.contains(QStringLiteral("bool"))) { return obj.value(QStringLiteral("bool")).toBool(); } if (obj.contains(QStringLiteral("int"))) { - return obj.value(QStringLiteral("int")).toInt(); + const auto value = obj.value(QStringLiteral("int")).toInt(); + + const auto option = obj.value(QStringLiteral("option")).toString(); + + if (option.contains(QStringLiteral("color")) || option.contains(QStringLiteral("col."))) { + return colorFromInt(static_cast(value)); + } + + return value; } if (obj.contains(QStringLiteral("float"))) { @@ -193,6 +212,10 @@ static QVariant parseGetOptionValue(const QJsonObject& obj) { return obj.value(QStringLiteral("value")).toVariant(); } + if (obj.contains(QStringLiteral("vec2"))) { + return obj.value(QStringLiteral("vec2")).toVariant(); + } + if (obj.contains(QStringLiteral("data"))) { const auto data = obj.value(QStringLiteral("data")); if (data.isObject()) { @@ -340,6 +363,11 @@ void HyprExtras::refreshOptions() { QStringLiteral("general:border_size"), QStringLiteral("decoration:rounding"), QStringLiteral("animations:enabled"), + QStringLiteral("decoration:shadow:enabled"), + QStringLiteral("decoration:shadow:offset"), + QStringLiteral("decoration:shadow:color"), + QStringLiteral("decoration:shadow:range"), + QStringLiteral("decoration:shadow:render_power"), }; auto nextOptions = std::make_shared();