From fa9bdca241c52b975e061da24c84ebcf9ab400cc Mon Sep 17 00:00:00 2001 From: Zacharias-Brohn Date: Wed, 4 Feb 2026 19:08:55 +0100 Subject: [PATCH] toggle dnd shortcut --- Components/CustomSwitch.qml | 85 ------------------- Modules/Notifications/Sidebar/Notif.qml | 2 +- .../Sidebar/Utils/Cards/Toggles.qml | 11 +++ 3 files changed, 12 insertions(+), 86 deletions(-) diff --git a/Components/CustomSwitch.qml b/Components/CustomSwitch.qml index 46aa299..83de2dd 100644 --- a/Components/CustomSwitch.qml +++ b/Components/CustomSwitch.qml @@ -42,91 +42,6 @@ Switch { } } - Shape { - id: icon - - property point start1: { - if (root.pressed) - return Qt.point(width * 0.2, height / 2); - if (root.checked) - return Qt.point(width * 0.15, height / 2); - return Qt.point(width * 0.15, height * 0.15); - } - property point end1: { - if (root.pressed) { - if (root.checked) - return Qt.point(width * 0.4, height / 2); - return Qt.point(width * 0.8, height / 2); - } - if (root.checked) - return Qt.point(width * 0.4, height * 0.7); - return Qt.point(width * 0.85, height * 0.85); - } - property point start2: { - if (root.pressed) { - if (root.checked) - return Qt.point(width * 0.4, height / 2); - return Qt.point(width * 0.2, height / 2); - } - if (root.checked) - return Qt.point(width * 0.4, height * 0.7); - return Qt.point(width * 0.15, height * 0.85); - } - property point end2: { - if (root.pressed) - return Qt.point(width * 0.8, height / 2); - if (root.checked) - return Qt.point(width * 0.85, height * 0.2); - return Qt.point(width * 0.85, height * 0.15); - } - - anchors.centerIn: parent - width: height - height: parent.implicitHeight - 10 * 2 - preferredRendererType: Shape.CurveRenderer - asynchronous: true - - ShapePath { - strokeWidth: 20 * 0.15 - strokeColor: root.checked ? DynamicColors.palette.m3primary : DynamicColors.palette.m3surfaceContainerHighest - fillColor: "transparent" - capStyle: 1 === 0 ? ShapePath.SquareCap : ShapePath.RoundCap - - startX: icon.start1.x - startY: icon.start1.y - - PathLine { - x: icon.end1.x - y: icon.end1.y - } - PathMove { - x: icon.start2.x - y: icon.start2.y - } - PathLine { - x: icon.end2.x - y: icon.end2.y - } - - Behavior on strokeColor { - CAnim {} - } - } - - Behavior on start1 { - PropAnim {} - } - Behavior on end1 { - PropAnim {} - } - Behavior on start2 { - PropAnim {} - } - Behavior on end2 { - PropAnim {} - } - } - Behavior on x { Anim {} } diff --git a/Modules/Notifications/Sidebar/Notif.qml b/Modules/Notifications/Sidebar/Notif.qml index c85c728..6033e3c 100644 --- a/Modules/Notifications/Sidebar/Notif.qml +++ b/Modules/Notifications/Sidebar/Notif.qml @@ -130,7 +130,7 @@ CustomRect { Layout.fillWidth: true textFormat: Text.MarkdownText text: root.modelData.body.replace(/(.)\n(?!\n)/g, "$1\n\n") || qsTr("No body here! :/") - color: root.modelData.urgency === "critical" ? DynamicColors.palette.m3secondary : DynamicColors.palette.m3outline + color: root.modelData.urgency === "critical" ? DynamicColors.palette.m3secondary : DynamicColors.palette.m3onSurface wrapMode: Text.WordWrap onLinkActivated: link => { diff --git a/Modules/Notifications/Sidebar/Utils/Cards/Toggles.qml b/Modules/Notifications/Sidebar/Utils/Cards/Toggles.qml index 221fbbf..3e7e983 100644 --- a/Modules/Notifications/Sidebar/Utils/Cards/Toggles.qml +++ b/Modules/Notifications/Sidebar/Utils/Cards/Toggles.qml @@ -4,6 +4,7 @@ import qs.Modules import qs.Daemons import Quickshell import Quickshell.Bluetooth +import Quickshell.Hyprland import QtQuick import QtQuick.Layouts @@ -31,6 +32,7 @@ CustomRect { spacing: 7 Toggle { + id: toggle icon: "notifications_off" checked: NotifServer.dnd onClicked: NotifServer.dnd = !NotifServer.dnd @@ -38,6 +40,15 @@ CustomRect { } } + GlobalShortcut { + name: "toggle-dnd" + appid: "zshell-nc" + + onPressed: { + toggle.clicked(); + } + } + component Toggle: IconButton { Layout.fillWidth: true Layout.preferredWidth: implicitWidth + (stateLayer.pressed ? 18 : internalChecked ? 7 : 0)