From 9f4aa3f7e151a1274fec4b4f6854ac264feb4021 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Tue, 26 Aug 2025 14:38:37 +0700 Subject: [PATCH] add corner scrolling for brightness/volume --- .config/quickshell/ii/modules/bar/Bar.qml | 2 - .../quickshell/ii/modules/common/Config.qml | 6 +- .../common/widgets/FocusedScrollMouseArea.qml | 3 +- .../ii/modules/common/widgets/RoundCorner.qml | 12 ++-- .../modules/screenCorners/ScreenCorners.qml | 60 +++++++++++++++---- .../ii/modules/settings/InterfaceConfig.qml | 27 ++++++++- .../ii/modules/verticalBar/VerticalBar.qml | 2 - 7 files changed, 89 insertions(+), 23 deletions(-) diff --git a/.config/quickshell/ii/modules/bar/Bar.qml b/.config/quickshell/ii/modules/bar/Bar.qml index 120f8bc7e..01d794f4f 100644 --- a/.config/quickshell/ii/modules/bar/Bar.qml +++ b/.config/quickshell/ii/modules/bar/Bar.qml @@ -14,8 +14,6 @@ import qs.modules.common.functions Scope { id: bar - - readonly property int osdHideMouseMoveThreshold: 20 property bool showBarBackground: Config.options.bar.showBackground Variants { diff --git a/.config/quickshell/ii/modules/common/Config.qml b/.config/quickshell/ii/modules/common/Config.qml index 18968ce23..d70199550 100644 --- a/.config/quickshell/ii/modules/common/Config.qml +++ b/.config/quickshell/ii/modules/common/Config.qml @@ -295,8 +295,10 @@ Singleton { } property JsonObject cornerOpen: JsonObject { property bool enable: true - property bool clickless: true - property real cornerRegionWidth: 30 + property bool bottom: false + property bool valueScroll: true + property bool clickless: false + property real cornerRegionWidth: 60 property real cornerRegionHeight: 2 property bool visualize: false } diff --git a/.config/quickshell/ii/modules/common/widgets/FocusedScrollMouseArea.qml b/.config/quickshell/ii/modules/common/widgets/FocusedScrollMouseArea.qml index b4bc3780c..9b48d1997 100644 --- a/.config/quickshell/ii/modules/common/widgets/FocusedScrollMouseArea.qml +++ b/.config/quickshell/ii/modules/common/widgets/FocusedScrollMouseArea.qml @@ -19,6 +19,7 @@ MouseArea { // Right side | scroll to change volume property real lastScrollX: 0 property real lastScrollY: 0 property bool trackingScroll: false + property real moveThreshold: 20 acceptedButtons: Qt.LeftButton hoverEnabled: true @@ -47,7 +48,7 @@ MouseArea { // Right side | scroll to change volume if (root.trackingScroll) { const dx = mouse.x - root.lastScrollX; const dy = mouse.y - root.lastScrollY; - if (Math.sqrt(dx * dx + dy * dy) > osdHideMouseMoveThreshold) { + if (Math.sqrt(dx * dx + dy * dy) > root.moveThreshold) { root.movedAway(); root.trackingScroll = false; } diff --git a/.config/quickshell/ii/modules/common/widgets/RoundCorner.qml b/.config/quickshell/ii/modules/common/widgets/RoundCorner.qml index 269ab578d..a2177a13b 100644 --- a/.config/quickshell/ii/modules/common/widgets/RoundCorner.qml +++ b/.config/quickshell/ii/modules/common/widgets/RoundCorner.qml @@ -17,13 +17,17 @@ Item { property bool isBottomLeft: corner === RoundCorner.CornerEnum.BottomLeft property bool isTopRight: corner === RoundCorner.CornerEnum.TopRight property bool isBottomRight: corner === RoundCorner.CornerEnum.BottomRight + property bool isTop: isTopLeft || isTopRight + property bool isBottom: isBottomLeft || isBottomRight + property bool isLeft: isTopLeft || isBottomLeft + property bool isRight: isTopRight || isBottomRight Shape { anchors { - top: (isTopLeft || isTopRight) ? parent.top : undefined - bottom: (isBottomLeft || isBottomRight) ? parent.bottom : undefined - left: (isTopLeft || isBottomLeft) ? parent.left : undefined - right: (isTopRight || isBottomRight) ? parent.right : undefined + top: root.isTop ? parent.top : undefined + bottom: root.isBottom ? parent.bottom : undefined + left: root.isLeft ? parent.left : undefined + right: root.isRight ? parent.right : undefined } layer.enabled: true layer.smooth: true diff --git a/.config/quickshell/ii/modules/screenCorners/ScreenCorners.qml b/.config/quickshell/ii/modules/screenCorners/ScreenCorners.qml index 4767d26d3..4e3102fb0 100644 --- a/.config/quickshell/ii/modules/screenCorners/ScreenCorners.qml +++ b/.config/quickshell/ii/modules/screenCorners/ScreenCorners.qml @@ -1,6 +1,7 @@ import qs import qs.modules.common import qs.modules.common.widgets +import qs.services import QtQuick import QtQuick.Controls import QtQuick.Layouts @@ -12,14 +13,16 @@ Scope { id: screenCorners readonly property Toplevel activeWindow: ToplevelManager.activeToplevel property var actionForCorner: ({ - [RoundCorner.CornerEnum.TopLeft]: () => GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen, - [RoundCorner.CornerEnum.BottomLeft]: () => GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen, - [RoundCorner.CornerEnum.TopRight]: () => GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen, - [RoundCorner.CornerEnum.BottomRight]: () => GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen - }) + [RoundCorner.CornerEnum.TopLeft]: () => GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen, + [RoundCorner.CornerEnum.BottomLeft]: () => GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen, + [RoundCorner.CornerEnum.TopRight]: () => GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen, + [RoundCorner.CornerEnum.BottomRight]: () => GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen + }) component CornerPanelWindow: PanelWindow { id: cornerPanelWindow + property var screen: QsWindow.window?.screen + property var brightnessMonitor: Brightness.getMonitorForScreen(screen) property bool fullscreen visible: (Config.options.appearance.fakeScreenRounding === 1 || (Config.options.appearance.fakeScreenRounding === 2 && !fullscreen)) property var corner @@ -51,25 +54,60 @@ Scope { Loader { id: sidebarCornerOpenInteractionLoader - active: !fullscreen && Config.options.sidebar.cornerOpen.enabled + active: (!cornerPanelWindow.fullscreen && Config.options.sidebar.cornerOpen.enable && (Config.options.sidebar.cornerOpen.bottom == cornerWidget.isBottom)) anchors { top: (cornerWidget.isTopLeft || cornerWidget.isTopRight) ? parent.top : undefined bottom: (cornerWidget.isBottomLeft || cornerWidget.isBottomRight) ? parent.bottom : undefined - left: (cornerWidget.isTopLeft || cornerWidget.isBottomLeft) ? parent.left : undefined + left: (cornerWidget.isLeft) ? parent.left : undefined right: (cornerWidget.isTopRight || cornerWidget.isBottomRight) ? parent.right : undefined } - sourceComponent: MouseArea { + sourceComponent: FocusedScrollMouseArea { implicitWidth: Config.options.sidebar.cornerOpen.cornerRegionWidth implicitHeight: Config.options.sidebar.cornerOpen.cornerRegionHeight - hoverEnabled: Config.options.sidebar.cornerOpen.clickless - onEntered: screenCorners.actionForCorner[cornerPanelWindow.corner]() + hoverEnabled: true + onEntered: { + if (Config.options.sidebar.cornerOpen.clickless) + screenCorners.actionForCorner[cornerPanelWindow.corner](); + } + onPressed: { + screenCorners.actionForCorner[cornerPanelWindow.corner](); + } + onScrollDown: { + if (!Config.options.sidebar.cornerOpen.valueScroll) + return; + if (cornerWidget.isLeft) + cornerPanelWindow.brightnessMonitor.setBrightness(cornerPanelWindow.brightnessMonitor.brightness - 0.05); + else { + const currentVolume = Audio.value; + const step = currentVolume < 0.1 ? 0.01 : 0.02 || 0.2; + Audio.sink.audio.volume -= step; + } + } + onScrollUp: { + if (!Config.options.sidebar.cornerOpen.valueScroll) + return; + if (cornerWidget.isLeft) + cornerPanelWindow.brightnessMonitor.setBrightness(cornerPanelWindow.brightnessMonitor.brightness + 0.05); + else { + const currentVolume = Audio.value; + const step = currentVolume < 0.1 ? 0.01 : 0.02 || 0.2; + Audio.sink.audio.volume = Math.min(1, Audio.sink.audio.volume + step); + } + } + onMovedAway: { + if (!Config.options.sidebar.cornerOpen.valueScroll) + return; + if (cornerWidget.isLeft) + GlobalStates.osdBrightnessOpen = false; + else + GlobalStates.osdVolumeOpen = false; + } Loader { active: Config.options.sidebar.cornerOpen.visualize anchors.fill: parent sourceComponent: Rectangle { - // DEBUG color: Appearance.colors.colPrimary } } diff --git a/.config/quickshell/ii/modules/settings/InterfaceConfig.qml b/.config/quickshell/ii/modules/settings/InterfaceConfig.qml index 7f825dea7..9f753ff7b 100644 --- a/.config/quickshell/ii/modules/settings/InterfaceConfig.qml +++ b/.config/quickshell/ii/modules/settings/InterfaceConfig.qml @@ -412,7 +412,32 @@ ContentPage { } StyledToolTip { - content: "When this is off you'll have to click" + content: Translation.tr("When this is off you'll have to click") + } + } + } + ConfigRow { + uniform: true + ConfigSwitch { + text: Translation.tr("Place at bottom") + checked: Config.options.sidebar.cornerOpen.bottom + onCheckedChanged: { + Config.options.sidebar.cornerOpen.bottom = checked; + } + + StyledToolTip { + content: Translation.tr("Place the corners to trigger at the bottom") + } + } + ConfigSwitch { + text: Translation.tr("Value scroll") + checked: Config.options.sidebar.cornerOpen.valueScroll + onCheckedChanged: { + Config.options.sidebar.cornerOpen.valueScroll = checked; + } + + StyledToolTip { + content: Translation.tr("Brightness and volume") } } } diff --git a/.config/quickshell/ii/modules/verticalBar/VerticalBar.qml b/.config/quickshell/ii/modules/verticalBar/VerticalBar.qml index 3a734e94e..d23eb43be 100644 --- a/.config/quickshell/ii/modules/verticalBar/VerticalBar.qml +++ b/.config/quickshell/ii/modules/verticalBar/VerticalBar.qml @@ -13,8 +13,6 @@ import qs.modules.common.functions Scope { id: bar - - readonly property int osdHideMouseMoveThreshold: 20 property bool showBarBackground: Config.options.bar.showBackground Variants {