fetch necessary hyprland options for screenshot tool
This commit is contained in:
+6
-3
@@ -34,8 +34,13 @@ MouseArea {
|
|||||||
property real realRounding: onClient ? (Hypr.options.decoration.rounding ?? 0) : 0
|
property real realRounding: onClient ? (Hypr.options.decoration.rounding ?? 0) : 0
|
||||||
property real rsx: Math.min(sx, ex)
|
property real rsx: Math.min(sx, ex)
|
||||||
property real rsy: Math.min(sy, ey)
|
property real rsy: Math.min(sy, ey)
|
||||||
|
readonly property real scaleRatio: Hypr.monitorFor(screen).scale
|
||||||
required property ShellScreen screen
|
required property ShellScreen screen
|
||||||
property real sh: Math.abs(sy - ey)
|
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 ssx
|
||||||
property real ssy
|
property real ssy
|
||||||
property real sw: Math.abs(sx - ex)
|
property real sw: Math.abs(sx - ex)
|
||||||
@@ -66,9 +71,7 @@ MouseArea {
|
|||||||
|
|
||||||
function save(): void {
|
function save(): void {
|
||||||
const tmpfile = Qt.resolvedUrl(`/tmp/zshell-picker-${Quickshell.processId}-${Date.now()}.png`);
|
const tmpfile = Qt.resolvedUrl(`/tmp/zshell-picker-${Quickshell.processId}-${Date.now()}.png`);
|
||||||
const scale = Hypr.monitorFor(screen).scale;
|
const cmd = Config.screenshot.enable_pp ? ["zshell-img-tools", "--scale", root.scaleRatio, "--shadow-blur-radius", root.shadowRange, "--image"] : ["swappy", "-f"];
|
||||||
console.log(scale);
|
|
||||||
const cmd = Config.screenshot.enable_pp ? ["zshell-img-tools", "--scale", scale, "--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]));
|
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();
|
closeAnim.start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,14 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
|
#include <qcolor.h>
|
||||||
#include <qjsonarray.h>
|
#include <qjsonarray.h>
|
||||||
#include <qjsondocument.h>
|
#include <qjsondocument.h>
|
||||||
#include <qjsonobject.h>
|
#include <qjsonobject.h>
|
||||||
#include <qlocalsocket.h>
|
#include <qlocalsocket.h>
|
||||||
#include <qloggingcategory.h>
|
#include <qloggingcategory.h>
|
||||||
#include <qmetatype.h>
|
#include <qmetatype.h>
|
||||||
|
#include <qobject.h>
|
||||||
#include <qregularexpression.h>
|
#include <qregularexpression.h>
|
||||||
#include <qvariant.h>
|
#include <qvariant.h>
|
||||||
|
|
||||||
@@ -168,13 +170,30 @@ static QString buildHlConfigCall(const QString& key, const QVariant& value) {
|
|||||||
return out;
|
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) {
|
static QVariant parseGetOptionValue(const QJsonObject& obj) {
|
||||||
if (obj.contains(QStringLiteral("bool"))) {
|
if (obj.contains(QStringLiteral("bool"))) {
|
||||||
return obj.value(QStringLiteral("bool")).toBool();
|
return obj.value(QStringLiteral("bool")).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.contains(QStringLiteral("int"))) {
|
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<quint32>(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.contains(QStringLiteral("float"))) {
|
if (obj.contains(QStringLiteral("float"))) {
|
||||||
@@ -193,6 +212,10 @@ static QVariant parseGetOptionValue(const QJsonObject& obj) {
|
|||||||
return obj.value(QStringLiteral("value")).toVariant();
|
return obj.value(QStringLiteral("value")).toVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (obj.contains(QStringLiteral("vec2"))) {
|
||||||
|
return obj.value(QStringLiteral("vec2")).toVariant();
|
||||||
|
}
|
||||||
|
|
||||||
if (obj.contains(QStringLiteral("data"))) {
|
if (obj.contains(QStringLiteral("data"))) {
|
||||||
const auto data = obj.value(QStringLiteral("data"));
|
const auto data = obj.value(QStringLiteral("data"));
|
||||||
if (data.isObject()) {
|
if (data.isObject()) {
|
||||||
@@ -340,6 +363,11 @@ void HyprExtras::refreshOptions() {
|
|||||||
QStringLiteral("general:border_size"),
|
QStringLiteral("general:border_size"),
|
||||||
QStringLiteral("decoration:rounding"),
|
QStringLiteral("decoration:rounding"),
|
||||||
QStringLiteral("animations:enabled"),
|
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<QVariantMap>();
|
auto nextOptions = std::make_shared<QVariantMap>();
|
||||||
|
|||||||
Reference in New Issue
Block a user