sort ws by number
This commit is contained in:
parent
57896a5a47
commit
935a87a8ed
2 changed files with 22 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@
|
|||
},
|
||||
"wallpaper": {
|
||||
"wallDir": "/home/lucy/.walls/",
|
||||
"wallpaper": "/home/lucy/.walls/walkingcastle.png"
|
||||
"wallpaper": "/home/lucy/.walls/lain_blue.jpg"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue