blob: 4d3bd1802abb5e82ce156e206a6da362d1bfe0a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
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 + 4
implicitHeight: kbdTooltipText.contentHeight + 4
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 || "";
}
}
}
}
|