quickshell: anchor-based layout instead of RowLayout

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
rope 2026-05-26 12:08:04 +01:00
parent 1cb2389b0d
commit 45275e29c9

View file

@ -457,84 +457,82 @@ in
implicitHeight: 30
color: "#D1${c.base00}"
RowLayout {
anchors.fill: parent
// Left workspaces
Row {
anchors.left: parent.left
anchors.leftMargin: 6
anchors.verticalCenter: parent.verticalCenter
spacing: 0
// Workspaces
Row {
spacing: 0
Layout.leftMargin: 6
Repeater {
model: Hyprland.workspaces
Repeater {
model: Hyprland.workspaces
Item {
required property var modelData
width: 28
height: 30
Item {
required property var modelData
width: 28
height: 30
Text {
anchors.centerIn: parent
text: modelData.name
color: modelData.focused ? "#${c.base05}" : "#${c.base03}"
font.family: "FiraMono Nerd Font"
font.pixelSize: 13
}
Text {
anchors.centerIn: parent
text: modelData.name
color: modelData.focused ? "#${c.base05}" : "#${c.base03}"
font.family: "FiraMono Nerd Font"
font.pixelSize: 13
}
Rectangle {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 8
height: 2
color: "#${c.base05}"
visible: modelData.focused
}
// Underline indicator
Rectangle {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width - 8
height: 2
color: "#${c.base05}"
visible: modelData.focused
}
MouseArea {
anchors.fill: parent
onClicked: modelData.activate()
}
MouseArea {
anchors.fill: parent
onClicked: modelData.activate()
}
}
}
}
// Spacer
Item { Layout.fillWidth: true }
// Center clock
Text {
id: clockText
anchors.centerIn: parent
property date now: new Date()
text: now.toLocaleTimeString(Qt.locale(), "HH:mm")
color: "#${c.base05}"
font.family: "FiraMono Nerd Font"
font.pixelSize: 13
font.weight: Font.Medium
// Clock
Text {
id: clockText
property date now: new Date()
text: now.toLocaleTimeString(Qt.locale(), "HH:mm")
color: "#${c.base05}"
font.family: "FiraMono Nerd Font"
font.pixelSize: 13
font.weight: Font.Medium
Timer {
interval: 1000
running: true
repeat: true
onTriggered: clockText.now = new Date()
}
MouseArea {
anchors.fill: parent
onClicked: calPopup.visible = !calPopup.visible
}
Timer {
interval: 1000
running: true
repeat: true
onTriggered: clockText.now = new Date()
}
// Spacer
Item { Layout.fillWidth: true }
MouseArea {
anchors.fill: parent
onClicked: calPopup.visible = !calPopup.visible
}
}
// Right network, battery, tray
Row {
anchors.right: parent.right
anchors.rightMargin: 8
anchors.verticalCenter: parent.verticalCenter
spacing: 10
// Network status
Item {
id: netWidget
Layout.preferredHeight: 30
Layout.preferredWidth: netRow.width
Layout.rightMargin: 10
width: 16
height: 30
property string netState: ""
property string netConn: ""
@ -571,17 +569,12 @@ in
}
}
RowLayout {
id: netRow
anchors.verticalCenter: parent.verticalCenter
spacing: 6
Text {
text: netWidget.netIcon
color: "#${c.base05}"
font.family: "FiraMono Nerd Font"
font.pixelSize: 14
}
Text {
anchors.centerIn: parent
text: netWidget.netIcon
color: "#${c.base05}"
font.family: "FiraMono Nerd Font"
font.pixelSize: 14
}
Process {
@ -599,9 +592,8 @@ in
// Battery
Item {
id: batteryWidget
Layout.preferredHeight: 30
Layout.preferredWidth: batteryRow.width
Layout.rightMargin: 10
width: batteryText.width + 4 + batteryIconText.width
height: 30
property int batteryLevel: 0
property bool charging: false
@ -641,12 +633,12 @@ in
}
}
RowLayout {
id: batteryRow
Row {
anchors.verticalCenter: parent.verticalCenter
spacing: 4
Text {
id: batteryText
text: batteryWidget.batteryLevel + "%"
color: batteryWidget.batteryLevel <= 15 ? "#${c.base08}"
: batteryWidget.batteryLevel <= 30 ? "#${c.base0A}"
@ -656,6 +648,7 @@ in
}
Text {
id: batteryIconText
text: batteryWidget.batteryIcon
color: batteryWidget.batteryLevel <= 15 ? "#${c.base08}"
: batteryWidget.batteryLevel <= 30 ? "#${c.base0A}"
@ -667,19 +660,19 @@ in
}
''}
// Tray icons inline
RowLayout {
// Tray icons
Row {
id: trayArea
spacing: 8
Layout.rightMargin: 8
anchors.verticalCenter: parent.verticalCenter
Repeater {
model: SystemTray.items
Item {
required property var modelData
Layout.preferredWidth: 16
Layout.preferredHeight: 16
width: 16
height: 16
Image {
id: trayIcon