sidebar esc to close

This commit is contained in:
end-4
2025-04-14 12:59:52 +02:00
parent ab04d1e10d
commit ab81e79eec
5 changed files with 54 additions and 7 deletions
+2 -1
View File
@@ -67,6 +67,7 @@ Scope {
ColumnLayout {
id: layout
spacing: 10
anchors {
top: parent.top
topMargin: 10
@@ -78,7 +79,7 @@ Scope {
font.family: "Rubik"
font.pointSize: 14
// color: Appearance.colors.colOnBackground
text: root.failed ? "Reload failed" : "Reload completed"
text: root.failed ? "Quickshell: Reload failed" : "Quickshell reloaded"
color: failed ? "#ff93000A" : "#ff0C1F13"
}
@@ -9,7 +9,7 @@ Item {
required property var bar
readonly property HyprlandMonitor monitor: Hyprland.monitorFor(bar.screen)
readonly property Toplevel activeWindow: ToplevelManager.activeToplevel
property int preferredWidth: 400
property int preferredWidth: Appearance.sizes.barPreferredSideSectionWidth
height: parent.height
width: colLayout.width
+35 -5
View File
@@ -4,6 +4,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Io
Scope {
id: bar
@@ -11,6 +12,15 @@ Scope {
readonly property int barHeight: Appearance.sizes.barHeight
readonly property int barCenterSideModuleWidth: Appearance.sizes.barCenterSideModuleWidth
Process {
id: toggleSidebarRight
command: ["qs", "ipc", "call", "sidebarRight", "toggle"]
}
Process {
id: toggleSidebarLeft
command: ["qs", "ipc", "call", "sidebarLeft", "toggle"]
}
Variants {
model: Quickshell.screens
@@ -42,6 +52,7 @@ Scope {
height: barHeight
// Left section
RowLayout {
id: leftSection
anchors.left: parent.left
implicitHeight: barHeight
@@ -64,6 +75,7 @@ Scope {
// Middle section
RowLayout {
id: middleSection
anchors.centerIn: parent
spacing: 8
@@ -117,18 +129,37 @@ Scope {
// Right section
RowLayout {
id: rightSection
anchors.right: parent.right
implicitHeight: barHeight
width: Appearance.sizes.barPreferredSideSectionWidth
spacing: 20
SysTray {
bar: barRoot
}
layoutDirection: Qt.RightToLeft
Item { // TODO make this wifi & bluetooth
Layout.leftMargin: Appearance.rounding.screenRounding
Layout.fillWidth: false
}
SysTray {
bar: barRoot
Layout.fillWidth: false
}
Item {
Layout.fillWidth: true
}
}
MouseArea {
anchors.fill: rightSection
acceptedButtons: Qt.LeftButton
onPressed: (event) => {
if (event.button === Qt.LeftButton) {
toggleSidebarRight.running = true
}
}
// Scroll to change volume
WheelHandler {
onWheel: (event) => {
@@ -141,7 +172,6 @@ Scope {
}
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
}
}
}
@@ -162,6 +162,7 @@ Singleton {
sizes: QtObject {
property int barHeight: 40
property int barCenterSideModuleWidth: 360
property int barPreferredSideSectionWidth: 400
property int sidebarWidth: 450
property int hyprlandGapsOut: 5
property int elevationMargin: 7
@@ -21,6 +21,7 @@ Scope {
PanelWindow {
id: sidebarRoot
visible: false
focusable: true
property var modelData
@@ -36,6 +37,12 @@ Scope {
bottom: true
}
HyprlandFocusGrab {
active: sidebarRoot.visible
id: grab
windows: [ sidebarRoot ]
}
// Background
Rectangle {
id: sidebarRightBackground
@@ -45,6 +52,14 @@ Scope {
height: parent.height - Appearance.sizes.hyprlandGapsOut * 2
color: Appearance.colors.colLayer0
radius: Appearance.rounding.screenRounding - Appearance.sizes.elevationMargin + 1
focus: true
Keys.onPressed: {
if (event.key === Qt.Key_Escape) {
sidebarRoot.visible = false;
event.accepted = true; // Prevent further propagation of the event
}
}
}
// Shadow