sort ws by number

This commit is contained in:
lucy 2026-10-26 11:13:24 +01:00
commit 935a87a8ed
2 changed files with 22 additions and 2 deletions

View file

@ -10,13 +10,33 @@ BarComponent {
id: root
required property ShellScreen barScreen
implicitWidth: wsLayout.implicitWidth + 16
readonly property var sortedWindowsets: {
const projection = WindowManager.screenProjection(root.barScreen)
const sets = projection ? (projection.windowsets ?? []) : []
const numericName = ws => {
const name = ws ? String(ws.name ?? "") : ""
return name !== "" && Number.isFinite(Number(name)) ? Number(name) : NaN
}
return Array.from(sets).sort((a, b) => {
const na = numericName(a)
const nb = numericName(b)
if (!isNaN(na) && !isNaN(nb))
return na - nb
const byName = String(a?.name ?? "").localeCompare(String(b?.name ?? ""), undefined, { numeric: true })
return byName !== 0 ? byName : (a?.id ?? 0) - (b?.id ?? 0)
})
}
RowLayout {
id: wsLayout
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
spacing: 4
Repeater {
model: WindowManager.screenProjection(root.barScreen).windowsets
model: root.sortedWindowsets
delegate: Rectangle {
id: wsContainer
required property var modelData

View file

@ -14,6 +14,6 @@
},
"wallpaper": {
"wallDir": "/home/lucy/.walls/",
"wallpaper": "/home/lucy/.walls/walkingcastle.png"
"wallpaper": "/home/lucy/.walls/lain_blue.jpg"
}
}