summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml')
-rw-r--r--accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml61
1 files changed, 33 insertions, 28 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml
index b9f91580..bc3750f9 100644
--- a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml
+++ b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml
@@ -3,25 +3,16 @@ import QtQuick
3import qs.Services 3import qs.Services
4import Quickshell.Widgets 4import Quickshell.Widgets
5 5
6Rectangle { 6Item {
7 id: kbdWidget
8
9 property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" }
10
11 width: kbdLabel.contentWidth + 8 7 width: kbdLabel.contentWidth + 8
12 color: {
13 if (kbdMouseArea.containsMouse) {
14 return "#33808080";
15 }
16 return "transparent";
17 }
18 height: parent.height 8 height: parent.height
19 anchors.verticalCenter: parent.verticalCenter 9 anchors.verticalCenter: parent.verticalCenter
20 10
21 MouseArea { 11 WrapperMouseArea {
22 id: kbdMouseArea 12 id: kbdMouseArea
23 13
24 anchors.fill: parent 14 anchors.fill: parent
15
25 hoverEnabled: true 16 hoverEnabled: true
26 cursorShape: Qt.PointingHandCursor 17 cursorShape: Qt.PointingHandCursor
27 enabled: true 18 enabled: true
@@ -31,25 +22,39 @@ Rectangle {
31 onWheel: event => { 22 onWheel: event => {
32 NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": event.angleDelta > 0 ? "Next" : "Prev" } } }, _ => {}) 23 NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": event.angleDelta > 0 ? "Next" : "Prev" } } }, _ => {})
33 } 24 }
34 }
35 25
36 Text { 26 Rectangle {
37 id: kbdLabel 27 id: kbdWidget
38 28
39 font.pointSize: 10 29 property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" }
40 font.family: "Fira Sans" 30
41 color: { 31 anchors.fill: parent
42 if (NiriService.keyboardLayouts?.current_idx === 0) 32 color: {
43 return "#555"; 33 if (kbdMouseArea.containsMouse) {
44 return "white"; 34 return "#33808080";
45 } 35 }
46 anchors.centerIn: parent 36 return "transparent";
37 }
47 38
48 text: { 39 Text {
49 const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; 40 id: kbdLabel
50 if (!currentLayout) 41
51 return ""; 42 font.pointSize: 10
52 return kbdWidget.keyboardAbbrev[currentLayout] ? kbdWidget.keyboardAbbrev[currentLayout] : currentLayout; 43 font.family: "Fira Sans"
44 color: {
45 if (NiriService.keyboardLayouts?.current_idx === 0)
46 return "#555";
47 return "white";
48 }
49 anchors.centerIn: parent
50
51 text: {
52 const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx];
53 if (!currentLayout)
54 return "";
55 return kbdWidget.keyboardAbbrev[currentLayout] ? kbdWidget.keyboardAbbrev[currentLayout] : currentLayout;
56 }
57 }
53 } 58 }
54 } 59 }
55 60