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