forked from Shinonome/dots-hyprland
add corner scrolling for brightness/volume
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user