mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-06 23:39:27 -05:00
153 lines
6.7 KiB
QML
153 lines
6.7 KiB
QML
pragma ComponentBehavior: Bound
|
|
import qs
|
|
import qs.services
|
|
import qs.modules.common
|
|
import qs.modules.common.widgets
|
|
import qs.modules.common.functions
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
|
|
Item {
|
|
id: root
|
|
readonly property var keybinds: HyprlandKeybinds.keybinds
|
|
property real spacing: 20
|
|
property real titleSpacing: 7
|
|
property real padding: 4
|
|
implicitWidth: row.implicitWidth + padding * 2
|
|
implicitHeight: row.implicitHeight + padding * 2
|
|
|
|
property var keyBlacklist: ["Super_L"]
|
|
property var keySubstitutions: ({
|
|
"Super": "",
|
|
"mouse_up": "Scroll ↓", // ikr, weird
|
|
"mouse_down": "Scroll ↑", // trust me bro
|
|
"mouse:272": "LMB",
|
|
"mouse:273": "RMB",
|
|
"mouse:275": "MouseBack",
|
|
"Slash": "/",
|
|
"Hash": "#",
|
|
"Return": "Enter",
|
|
// "Shift": "",
|
|
})
|
|
|
|
Row { // Keybind columns
|
|
id: row
|
|
spacing: root.spacing
|
|
|
|
Repeater {
|
|
model: keybinds.children
|
|
|
|
delegate: Column { // Keybind sections
|
|
spacing: root.spacing
|
|
required property var modelData
|
|
anchors.top: row.top
|
|
|
|
Repeater {
|
|
model: modelData.children
|
|
|
|
delegate: Item { // Section with real keybinds
|
|
id: keybindSection
|
|
required property var modelData
|
|
implicitWidth: sectionColumn.implicitWidth
|
|
implicitHeight: sectionColumn.implicitHeight
|
|
|
|
Column {
|
|
id: sectionColumn
|
|
anchors.centerIn: parent
|
|
spacing: root.titleSpacing
|
|
|
|
StyledText {
|
|
id: sectionTitle
|
|
font.family: Appearance.font.family.title
|
|
font.pixelSize: Appearance.font.pixelSize.huge
|
|
color: Appearance.colors.colOnLayer0
|
|
text: keybindSection.modelData.name
|
|
}
|
|
|
|
GridLayout {
|
|
id: keybindGrid
|
|
columns: 2
|
|
columnSpacing: 4
|
|
rowSpacing: 4
|
|
|
|
Repeater {
|
|
model: {
|
|
var result = [];
|
|
for (var i = 0; i < keybindSection.modelData.keybinds.length; i++) {
|
|
const keybind = keybindSection.modelData.keybinds[i];
|
|
result.push({
|
|
"type": "keys",
|
|
"mods": keybind.mods,
|
|
"key": keybind.key,
|
|
});
|
|
result.push({
|
|
"type": "comment",
|
|
"comment": keybind.comment,
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
delegate: Item {
|
|
required property var modelData
|
|
implicitWidth: keybindLoader.implicitWidth
|
|
implicitHeight: keybindLoader.implicitHeight
|
|
|
|
Loader {
|
|
id: keybindLoader
|
|
sourceComponent: (modelData.type === "keys") ? keysComponent : commentComponent
|
|
}
|
|
|
|
Component {
|
|
id: keysComponent
|
|
Row {
|
|
spacing: 4
|
|
Repeater {
|
|
model: modelData.mods
|
|
delegate: KeyboardKey {
|
|
required property var modelData
|
|
key: keySubstitutions[modelData] || modelData
|
|
}
|
|
}
|
|
StyledText {
|
|
id: keybindPlus
|
|
visible: !keyBlacklist.includes(modelData.key) && modelData.mods.length > 0
|
|
text: "+"
|
|
}
|
|
KeyboardKey {
|
|
id: keybindKey
|
|
visible: !keyBlacklist.includes(modelData.key)
|
|
key: keySubstitutions[modelData.key] || modelData.key
|
|
color: Appearance.colors.colOnLayer0
|
|
}
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: commentComponent
|
|
Item {
|
|
id: commentItem
|
|
implicitWidth: commentText.implicitWidth + 8 * 2
|
|
implicitHeight: commentText.implicitHeight
|
|
|
|
StyledText {
|
|
id: commentText
|
|
anchors.centerIn: parent
|
|
font.pixelSize: Appearance.font.pixelSize.smaller
|
|
text: modelData.comment
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
} |