Files
Aurora/config/aurora/modules/Bar.qml
2026-04-10 16:09:16 -05:00

246 lines
6.2 KiB
QML

import Quickshell // for PanelWindow
import QtQuick // for Text
import QtQuick.Shapes
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell.Io
import Quickshell.Widgets
import Quickshell.Wayland
import Quickshell.Hyprland
PanelWindow {
property real radius: 10
property list<string> hyprcmds: [
"exec hyprctl --batch '" +
"keyword general:gaps_out 5;" +
"keyword general:border_size 1;" +
"keyword windowrule match:title lockscreen, no_blur on, fullscreen on;" +
"keyword misc:session_lock_xray true;" +
"keyword decoration:blur:enabled true;" +
"keyword decoration:active_opacity 0.96;" +
"keyword decoration:inactive_opacity 0.96;" +
"keyword decoration:rounding " + radius + ";" +
"keyword monitor " + Hyprland.monitorFor(root.screen).name + ",1920x1080@60,0x0,1" + ";" +
"keyword monitor " + Hyprland.monitorFor(root.screen).name + ",addreserved," + topEx + "," + botEx + "," + leftEx + "," + rightEx + ";" +
"'"
]
onRadiusChanged: root.hyprcmds.forEach((c) => Hyprland.dispatch(c))
anchors {
top: true
left: true
right: true
bottom: true
}
IpcHandler {
target: "shell"
function reload() {
Quickshell.reload(false)
}
}
Component.onCompleted: {
root.hyprcmds.forEach((c) => { Hyprland.dispatch(c) })
Hyprland.rawEvent.connect((e) => {
if(e.name == "configreloaded") {
root.hyprcmds.forEach((c) => { Hyprland.dispatch(c) })
}
})
Settings.reload()
}
property int topEx: topRect.reserve
property int botEx: botRect.reserve
property int leftEx: leftRect.reserve
property int rightEx: rightRect.reserve
property color bg: (Settings.special.background)
id: root
exclusionMode: ExclusionMode.Ignore
WlrLayershell.layer: WlrLayer.Top
color: "transparent"
mask: Region {
Region {
item: topRect.topRectArea
}
Region {
item: leftRect
}
Region {
item: topRect.midFO.visible ? topRect.midFO : leftRect
}
Region {
item: dash.visible ? dash : leftRect
}
Region {
item: botRect
}
Region {
item: botRect.midFO.visible ? botRect.midFO : botRect
}
}
BarBottom {
id: botRect
radius: root.radius
hyprcmds: root.hyprcmds
x: leftRect.x + leftRect.width
implicitWidth: rightRect.x - (leftRect.x + leftRect.width)
color: root.bg
}
BarLeft {
id: leftRect
window: root
color: root.bg
}
BarRight {
id: rightRect
color: root.bg
}
Shape {
x: leftRect.cornerX
y: topRect.cornerY
ShapePath {
strokeWidth: 1
strokeColor: "transparent"
fillColor: root.bg
startX: 0; startY: 0
PathLine { relativeX: 0; relativeY: radius }
PathArc {
radiusX: radius
radiusY: -radius
relativeX: radius
relativeY: -radius
}
PathLine { relativeX: -radius; relativeY: 0 }
}
}
Shape {
x: rightRect.x
y: topRect.cornerY
ShapePath {
strokeWidth: 1
strokeColor: "transparent"
fillColor: root.bg
startX: 0; startY: 0
PathLine { relativeX: 0; relativeY: radius }
PathArc {
direction: PathArc.Counterclockwise
radiusX: radius
radiusY: radius
relativeX: -radius
relativeY: -radius
}
PathLine { relativeX: radius; relativeY: 0 }
}
}
Shape {
x: leftRect.cornerX
y: botRect.cornerY
ShapePath {
strokeWidth: 1
strokeColor: "transparent"
fillColor: root.bg
startX: 0; startY: 0
PathLine { relativeX: 0; relativeY: -radius }
PathArc {
direction: PathArc.Counterclockwise
radiusX: radius
radiusY: radius
relativeX: radius
relativeY: radius
}
PathLine { relativeX: -radius; relativeY: 0 }
}
}
Shape {
x: rightRect.x
y: botRect.cornerY
ShapePath {
strokeWidth: 1
strokeColor: "transparent"
fillColor: root.bg
startX: 0; startY: 0
PathLine { relativeX: 0; relativeY: -radius }
PathArc {
radiusX: radius
radiusY: -radius
relativeX: -radius
relativeY: radius
}
PathLine { relativeX: radius; relativeY: 0 }
}
}
BarTop {
id: topRect
x: leftRect.x + leftRect.width
width: rightRect.x - x
//y: topRect.y + topRect.height - 1
window: root
radius: root.radius
color: root.bg
onShowDashChanged: dash.visible = showDash
}
onTopExChanged: Hyprland.dispatch("exec hyprctl keyword monitor " + Hyprland.monitorFor(root.screen).name + ",addreserved," + topEx + "," + botEx + "," + leftEx + "," + rightEx)
onBotExChanged: Hyprland.dispatch("exec hyprctl keyword monitor " + Hyprland.monitorFor(root.screen).name + ",addreserved," + topEx + "," + botEx + "," + leftEx + "," + rightEx)
onRightExChanged: Hyprland.dispatch("exec hyprctl keyword monitor " + Hyprland.monitorFor(root.screen).name + ",addreserved," + topEx + "," + botEx + "," + leftEx + "," + rightEx)
onLeftExChanged: Hyprland.dispatch("exec hyprctl keyword monitor " + Hyprland.monitorFor(root.screen).name + ",addreserved," + topEx + "," + botEx + "," + leftEx + "," + rightEx)
Dashboard {
id: dash
x: root.screen.width / 2 - width / 2
y: topRect.reserve - 1
onVisibleChanged: topRect.showDash = visible
//onEntered: topRect.midFO.visible = true
onHoveredChanged: topRect.midFO.visible = !hovered
radius: root.radius
}
}