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
|
id: root
|
||||||
required property ShellScreen barScreen
|
required property ShellScreen barScreen
|
||||||
implicitWidth: wsLayout.implicitWidth + 16
|
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 {
|
RowLayout {
|
||||||
id: wsLayout
|
id: wsLayout
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
spacing: 4
|
spacing: 4
|
||||||
Repeater {
|
Repeater {
|
||||||
model: WindowManager.screenProjection(root.barScreen).windowsets
|
model: root.sortedWindowsets
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
id: wsContainer
|
id: wsContainer
|
||||||
required property var modelData
|
required property var modelData
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,6 @@
|
||||||
},
|
},
|
||||||
"wallpaper": {
|
"wallpaper": {
|
||||||
"wallDir": "/home/lucy/.walls/",
|
"wallDir": "/home/lucy/.walls/",
|
||||||
"wallpaper": "/home/lucy/.walls/walkingcastle.png"
|
"wallpaper": "/home/lucy/.walls/lain_blue.jpg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue