mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 14:59:27 -05:00
60 lines
1.6 KiB
QML
60 lines
1.6 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import qs.services
|
|
import qs.modules.common
|
|
import qs.modules.common.widgets
|
|
import qs.modules.common.functions
|
|
|
|
Flow {
|
|
id: root
|
|
Layout.fillWidth: true
|
|
spacing: 2
|
|
property list<var> options: [
|
|
{
|
|
"displayName": "Option 1",
|
|
"icon": "check",
|
|
"value": 1
|
|
},
|
|
{
|
|
"displayName": "Option 2",
|
|
"icon": "close",
|
|
"value": 2
|
|
},
|
|
]
|
|
property var currentValue: null
|
|
|
|
function focusSelectedChild() {
|
|
children.find(c => c.value == currentValue).forceActiveFocus()
|
|
}
|
|
|
|
signal selected(var newValue)
|
|
|
|
Repeater {
|
|
model: root.options
|
|
delegate: SelectionGroupButton {
|
|
id: paletteButton
|
|
required property var modelData
|
|
required property int index
|
|
readonly property var value: modelData.value
|
|
onYChanged: {
|
|
if (index === 0) {
|
|
paletteButton.leftmost = true
|
|
} else {
|
|
var prev = root.children[index - 1]
|
|
var thisIsOnNewLine = prev && prev.y !== paletteButton.y
|
|
paletteButton.leftmost = thisIsOnNewLine
|
|
prev.rightmost = thisIsOnNewLine
|
|
}
|
|
}
|
|
leftmost: index === 0
|
|
rightmost: index === root.options.length - 1
|
|
buttonIcon: modelData.icon || ""
|
|
buttonText: modelData.displayName
|
|
toggled: root.currentValue == modelData.value
|
|
onClicked: {
|
|
root.selected(modelData.value);
|
|
}
|
|
}
|
|
}
|
|
}
|