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 { ColumnLayout {
id: layout id: layout
spacing: 10
anchors { anchors {
top: parent.top top: parent.top
topMargin: 10 topMargin: 10
@@ -78,7 +79,7 @@ Scope {
font.family: "Rubik" font.family: "Rubik"
font.pointSize: 14 font.pointSize: 14
// color: Appearance.colors.colOnBackground // color: Appearance.colors.colOnBackground
text: root.failed ? "Reload failed" : "Reload completed" text: root.failed ? "Quickshell: Reload failed" : "Quickshell reloaded"
color: failed ? "#ff93000A" : "#ff0C1F13" color: failed ? "#ff93000A" : "#ff0C1F13"
} }
@@ -9,7 +9,7 @@ Item {
required property var bar required property var bar
readonly property HyprlandMonitor monitor: Hyprland.monitorFor(bar.screen) readonly property HyprlandMonitor monitor: Hyprland.monitorFor(bar.screen)
readonly property Toplevel activeWindow: ToplevelManager.activeToplevel readonly property Toplevel activeWindow: ToplevelManager.activeToplevel
property int preferredWidth: 400 property int preferredWidth: Appearance.sizes.barPreferredSideSectionWidth
height: parent.height height: parent.height
width: colLayout.width width: colLayout.width
+35 -5
View File
@@ -4,6 +4,7 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import Quickshell import Quickshell
import Quickshell.Io
Scope { Scope {
id: bar id: bar
@@ -11,6 +12,15 @@ Scope {
readonly property int barHeight: Appearance.sizes.barHeight readonly property int barHeight: Appearance.sizes.barHeight
readonly property int barCenterSideModuleWidth: Appearance.sizes.barCenterSideModuleWidth 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 { Variants {
model: Quickshell.screens model: Quickshell.screens
@@ -42,6 +52,7 @@ Scope {
height: barHeight height: barHeight
// Left section // Left section
RowLayout { RowLayout {
id: leftSection
anchors.left: parent.left anchors.left: parent.left
implicitHeight: barHeight implicitHeight: barHeight
@@ -64,6 +75,7 @@ Scope {
// Middle section // Middle section
RowLayout { RowLayout {
id: middleSection
anchors.centerIn: parent anchors.centerIn: parent
spacing: 8 spacing: 8
@@ -117,18 +129,37 @@ Scope {
// Right section // Right section
RowLayout { RowLayout {
id: rightSection
anchors.right: parent.right anchors.right: parent.right
implicitHeight: barHeight implicitHeight: barHeight
width: Appearance.sizes.barPreferredSideSectionWidth
spacing: 20 spacing: 20
layoutDirection: Qt.RightToLeft
SysTray {
bar: barRoot
}
Item { // TODO make this wifi & bluetooth Item { // TODO make this wifi & bluetooth
Layout.leftMargin: Appearance.rounding.screenRounding 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 // Scroll to change volume
WheelHandler { WheelHandler {
onWheel: (event) => { onWheel: (event) => {
@@ -141,7 +172,6 @@ Scope {
} }
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
} }
} }
} }
@@ -162,6 +162,7 @@ Singleton {
sizes: QtObject { sizes: QtObject {
property int barHeight: 40 property int barHeight: 40
property int barCenterSideModuleWidth: 360 property int barCenterSideModuleWidth: 360
property int barPreferredSideSectionWidth: 400
property int sidebarWidth: 450 property int sidebarWidth: 450
property int hyprlandGapsOut: 5 property int hyprlandGapsOut: 5
property int elevationMargin: 7 property int elevationMargin: 7
@@ -21,6 +21,7 @@ Scope {
PanelWindow { PanelWindow {
id: sidebarRoot id: sidebarRoot
visible: false visible: false
focusable: true
property var modelData property var modelData
@@ -36,6 +37,12 @@ Scope {
bottom: true bottom: true
} }
HyprlandFocusGrab {
active: sidebarRoot.visible
id: grab
windows: [ sidebarRoot ]
}
// Background // Background
Rectangle { Rectangle {
id: sidebarRightBackground id: sidebarRightBackground
@@ -45,6 +52,14 @@ Scope {
height: parent.height - Appearance.sizes.hyprlandGapsOut * 2 height: parent.height - Appearance.sizes.hyprlandGapsOut * 2
color: Appearance.colors.colLayer0 color: Appearance.colors.colLayer0
radius: Appearance.rounding.screenRounding - Appearance.sizes.elevationMargin + 1 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 // Shadow