add corner scrolling for brightness/volume

This commit is contained in:
end-4
2025-08-26 14:38:37 +07:00
parent e7ffd2455a
commit 9f4aa3f7e1
7 changed files with 89 additions and 23 deletions
@@ -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 {
@@ -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
}
@@ -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;
}
@@ -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
@@ -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
}
}
@@ -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")
}
}
}
@@ -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 {