forked from Shinonome/dots-hyprland
add corner scrolling for brightness/volume
This commit is contained in:
@@ -14,8 +14,6 @@ import qs.modules.common.functions
|
|||||||
|
|
||||||
Scope {
|
Scope {
|
||||||
id: bar
|
id: bar
|
||||||
|
|
||||||
readonly property int osdHideMouseMoveThreshold: 20
|
|
||||||
property bool showBarBackground: Config.options.bar.showBackground
|
property bool showBarBackground: Config.options.bar.showBackground
|
||||||
|
|
||||||
Variants {
|
Variants {
|
||||||
|
|||||||
@@ -295,8 +295,10 @@ Singleton {
|
|||||||
}
|
}
|
||||||
property JsonObject cornerOpen: JsonObject {
|
property JsonObject cornerOpen: JsonObject {
|
||||||
property bool enable: true
|
property bool enable: true
|
||||||
property bool clickless: true
|
property bool bottom: false
|
||||||
property real cornerRegionWidth: 30
|
property bool valueScroll: true
|
||||||
|
property bool clickless: false
|
||||||
|
property real cornerRegionWidth: 60
|
||||||
property real cornerRegionHeight: 2
|
property real cornerRegionHeight: 2
|
||||||
property bool visualize: false
|
property bool visualize: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ MouseArea { // Right side | scroll to change volume
|
|||||||
property real lastScrollX: 0
|
property real lastScrollX: 0
|
||||||
property real lastScrollY: 0
|
property real lastScrollY: 0
|
||||||
property bool trackingScroll: false
|
property bool trackingScroll: false
|
||||||
|
property real moveThreshold: 20
|
||||||
|
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
@@ -47,7 +48,7 @@ MouseArea { // Right side | scroll to change volume
|
|||||||
if (root.trackingScroll) {
|
if (root.trackingScroll) {
|
||||||
const dx = mouse.x - root.lastScrollX;
|
const dx = mouse.x - root.lastScrollX;
|
||||||
const dy = mouse.y - root.lastScrollY;
|
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.movedAway();
|
||||||
root.trackingScroll = false;
|
root.trackingScroll = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,17 @@ Item {
|
|||||||
property bool isBottomLeft: corner === RoundCorner.CornerEnum.BottomLeft
|
property bool isBottomLeft: corner === RoundCorner.CornerEnum.BottomLeft
|
||||||
property bool isTopRight: corner === RoundCorner.CornerEnum.TopRight
|
property bool isTopRight: corner === RoundCorner.CornerEnum.TopRight
|
||||||
property bool isBottomRight: corner === RoundCorner.CornerEnum.BottomRight
|
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 {
|
Shape {
|
||||||
anchors {
|
anchors {
|
||||||
top: (isTopLeft || isTopRight) ? parent.top : undefined
|
top: root.isTop ? parent.top : undefined
|
||||||
bottom: (isBottomLeft || isBottomRight) ? parent.bottom : undefined
|
bottom: root.isBottom ? parent.bottom : undefined
|
||||||
left: (isTopLeft || isBottomLeft) ? parent.left : undefined
|
left: root.isLeft ? parent.left : undefined
|
||||||
right: (isTopRight || isBottomRight) ? parent.right : undefined
|
right: root.isRight ? parent.right : undefined
|
||||||
}
|
}
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
layer.smooth: true
|
layer.smooth: true
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import qs
|
import qs
|
||||||
import qs.modules.common
|
import qs.modules.common
|
||||||
import qs.modules.common.widgets
|
import qs.modules.common.widgets
|
||||||
|
import qs.services
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
@@ -12,14 +13,16 @@ Scope {
|
|||||||
id: screenCorners
|
id: screenCorners
|
||||||
readonly property Toplevel activeWindow: ToplevelManager.activeToplevel
|
readonly property Toplevel activeWindow: ToplevelManager.activeToplevel
|
||||||
property var actionForCorner: ({
|
property var actionForCorner: ({
|
||||||
[RoundCorner.CornerEnum.TopLeft]: () => GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen,
|
[RoundCorner.CornerEnum.TopLeft]: () => GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen,
|
||||||
[RoundCorner.CornerEnum.BottomLeft]: () => GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen,
|
[RoundCorner.CornerEnum.BottomLeft]: () => GlobalStates.sidebarLeftOpen = !GlobalStates.sidebarLeftOpen,
|
||||||
[RoundCorner.CornerEnum.TopRight]: () => GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen,
|
[RoundCorner.CornerEnum.TopRight]: () => GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen,
|
||||||
[RoundCorner.CornerEnum.BottomRight]: () => GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen
|
[RoundCorner.CornerEnum.BottomRight]: () => GlobalStates.sidebarRightOpen = !GlobalStates.sidebarRightOpen
|
||||||
})
|
})
|
||||||
|
|
||||||
component CornerPanelWindow: PanelWindow {
|
component CornerPanelWindow: PanelWindow {
|
||||||
id: cornerPanelWindow
|
id: cornerPanelWindow
|
||||||
|
property var screen: QsWindow.window?.screen
|
||||||
|
property var brightnessMonitor: Brightness.getMonitorForScreen(screen)
|
||||||
property bool fullscreen
|
property bool fullscreen
|
||||||
visible: (Config.options.appearance.fakeScreenRounding === 1 || (Config.options.appearance.fakeScreenRounding === 2 && !fullscreen))
|
visible: (Config.options.appearance.fakeScreenRounding === 1 || (Config.options.appearance.fakeScreenRounding === 2 && !fullscreen))
|
||||||
property var corner
|
property var corner
|
||||||
@@ -51,25 +54,60 @@ Scope {
|
|||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: sidebarCornerOpenInteractionLoader
|
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 {
|
anchors {
|
||||||
top: (cornerWidget.isTopLeft || cornerWidget.isTopRight) ? parent.top : undefined
|
top: (cornerWidget.isTopLeft || cornerWidget.isTopRight) ? parent.top : undefined
|
||||||
bottom: (cornerWidget.isBottomLeft || cornerWidget.isBottomRight) ? parent.bottom : 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
|
right: (cornerWidget.isTopRight || cornerWidget.isBottomRight) ? parent.right : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceComponent: MouseArea {
|
sourceComponent: FocusedScrollMouseArea {
|
||||||
implicitWidth: Config.options.sidebar.cornerOpen.cornerRegionWidth
|
implicitWidth: Config.options.sidebar.cornerOpen.cornerRegionWidth
|
||||||
implicitHeight: Config.options.sidebar.cornerOpen.cornerRegionHeight
|
implicitHeight: Config.options.sidebar.cornerOpen.cornerRegionHeight
|
||||||
hoverEnabled: Config.options.sidebar.cornerOpen.clickless
|
hoverEnabled: true
|
||||||
onEntered: screenCorners.actionForCorner[cornerPanelWindow.corner]()
|
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 {
|
Loader {
|
||||||
active: Config.options.sidebar.cornerOpen.visualize
|
active: Config.options.sidebar.cornerOpen.visualize
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
sourceComponent: Rectangle {
|
sourceComponent: Rectangle {
|
||||||
// DEBUG
|
|
||||||
color: Appearance.colors.colPrimary
|
color: Appearance.colors.colPrimary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -412,7 +412,32 @@ ContentPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StyledToolTip {
|
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 {
|
Scope {
|
||||||
id: bar
|
id: bar
|
||||||
|
|
||||||
readonly property int osdHideMouseMoveThreshold: 20
|
|
||||||
property bool showBarBackground: Config.options.bar.showBackground
|
property bool showBarBackground: Config.options.bar.showBackground
|
||||||
|
|
||||||
Variants {
|
Variants {
|
||||||
|
|||||||
Reference in New Issue
Block a user