import Quickshell import QtQuick import qs.Services Rectangle { id: kbdWidget property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" } width: kbdLabel.contentWidth + 8 color: { if (kbdMouseArea.containsMouse) { return "#33808080"; } return "transparent"; } height: parent.height anchors.verticalCenter: parent.verticalCenter MouseArea { id: kbdMouseArea anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor enabled: true onClicked: { NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": "Next" } } }, _ => {}) } } Text { id: kbdLabel font.pointSize: 10 font.family: "Fira Sans" color: { if (NiriService.keyboardLayouts?.current_idx === 0) return "#555"; return "white"; } anchors.centerIn: parent text: { const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; if (!currentLayout) return ""; return kbdWidget.keyboardAbbrev[currentLayout] ? kbdWidget.keyboardAbbrev[currentLayout] : currentLayout; } } PopupWindow { anchor { item: kbdMouseArea edges: Edges.Bottom } visible: kbdMouseArea.containsMouse implicitWidth: kbdTooltipText.contentWidth + 16 implicitHeight: kbdTooltipText.contentHeight + 16 color: "black" Text { id: kbdTooltipText anchors.centerIn: parent font.pointSize: 10 font.family: "Fira Sans" color: "white" text: { const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; return currentLayout || ""; } } } }