summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml3
-rw-r--r--accounts/gkleen@sif/shell/quickshell/Bar.qml10
-rw-r--r--accounts/gkleen@sif/shell/quickshell/Clock.qml250
-rw-r--r--accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml43
-rw-r--r--accounts/gkleen@sif/shell/quickshell/SystemTray.qml21
-rw-r--r--accounts/gkleen@sif/shell/quickshell/shell.qml12
6 files changed, 230 insertions, 109 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml b/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml
index d7e8e7c5..57ade488 100644
--- a/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml
+++ b/accounts/gkleen@sif/shell/quickshell/ActiveWindowDisplay.qml
@@ -7,10 +7,11 @@ Item {
7 id: activeWindowDisplay 7 id: activeWindowDisplay
8 8
9 required property int maxWidth 9 required property int maxWidth
10 required property var screen
10 11
11 property var activeWindow: { 12 property var activeWindow: {
12 let currWindowId = Array.from(NiriService.workspaces).find(ws => { 13 let currWindowId = Array.from(NiriService.workspaces).find(ws => {
13 return ws.output === bar.screen.name && ws.is_active; 14 return ws.output === screen.name && ws.is_active;
14 })?.active_window_id; 15 })?.active_window_id;
15 16
16 return currWindowId ? Array.from(NiriService.windows).find(win => win.id == currWindowId) : null; 17 return currWindowId ? Array.from(NiriService.windows).find(win => win.id == currWindowId) : null;
diff --git a/accounts/gkleen@sif/shell/quickshell/Bar.qml b/accounts/gkleen@sif/shell/quickshell/Bar.qml
index accad2a9..aab1607f 100644
--- a/accounts/gkleen@sif/shell/quickshell/Bar.qml
+++ b/accounts/gkleen@sif/shell/quickshell/Bar.qml
@@ -5,7 +5,9 @@ import QtQuick
5PanelWindow { 5PanelWindow {
6 id: bar 6 id: bar
7 7
8 property var modelData 8 required property var screen
9
10 property var calendarMouseArea: clock.calendarMouseArea
9 11
10 anchors { 12 anchors {
11 top: true 13 top: true
@@ -17,7 +19,6 @@ PanelWindow {
17 right: 26 + 8 19 right: 26 + 8
18 } 20 }
19 21
20 screen: modelData
21 implicitHeight: 21 22 implicitHeight: 21
22 color: "transparent" 23 color: "transparent"
23 24
@@ -50,6 +51,7 @@ PanelWindow {
50 spacing: 5 51 spacing: 5
51 52
52 ActiveWindowDisplay { 53 ActiveWindowDisplay {
54 screen: bar.screen
53 maxWidth: bar.width - 2*Math.max(left.width, right.width) - 2*8 55 maxWidth: bar.width - 2*Math.max(left.width, right.width) - 2*8
54 } 56 }
55 } 57 }
@@ -78,6 +80,8 @@ PanelWindow {
78 width: 4 80 width: 4
79 } 81 }
80 82
81 Clock {} 83 Clock {
84 id: clock
85 }
82 } 86 }
83} \ No newline at end of file 87} \ No newline at end of file
diff --git a/accounts/gkleen@sif/shell/quickshell/Clock.qml b/accounts/gkleen@sif/shell/quickshell/Clock.qml
index 65b842b3..58600adb 100644
--- a/accounts/gkleen@sif/shell/quickshell/Clock.qml
+++ b/accounts/gkleen@sif/shell/quickshell/Clock.qml
@@ -4,6 +4,7 @@ import Quickshell
4import Custom as Custom 4import Custom as Custom
5import QtQuick.Controls 5import QtQuick.Controls
6import QtQuick.Layouts 6import QtQuick.Layouts
7import Quickshell.Widgets
7 8
8Item { 9Item {
9 width: clock.contentWidth 10 width: clock.contentWidth
@@ -16,6 +17,18 @@ Item {
16 anchors.fill: parent 17 anchors.fill: parent
17 hoverEnabled: true 18 hoverEnabled: true
18 enabled: true 19 enabled: true
20
21 property real angleRem: 0
22 property real sensitivity: 1 / 120
23
24 function scrollYear(event) {
25 angleRem += event.angleDelta.y;
26 const d = Math.round(angleRem * sensitivity);
27 yearCalendar.year += d;
28 angleRem -= d / sensitivity;
29 }
30
31 onWheel: event => scrollYear(event)
19 } 32 }
20 33
21 Text { 34 Text {
@@ -37,145 +50,200 @@ Item {
37 } 50 }
38 51
39 PopupWindow { 52 PopupWindow {
53 id: tooltip
54
55 property bool nextVisible: clockMouseArea.containsMouse || tooltipMouseArea.containsMouse
56
40 anchor { 57 anchor {
41 item: clockMouseArea 58 item: clockMouseArea
42 edges: Edges.Bottom 59 edges: Edges.Bottom | Edges.Left
43 } 60 }
44 visible: clockMouseArea.containsMouse 61 visible: false
45 62
46 implicitWidth: yearCalendar.implicitWidth + 16 63 onNextVisibleChanged: hangTimer.restart()
47 implicitHeight: yearCalendar.implicitHeight + 16
48 color: "black"
49 64
50 GridLayout { 65 Timer {
51 property int year: { const d = new Date(); return d.getFullYear(); } 66 id: hangTimer
67 interval: 100
68 onTriggered: tooltip.visible = tooltip.nextVisible
69 }
52 70
53 id: yearCalendar 71 implicitWidth: clockTooltipContent.width
72 implicitHeight: clockTooltipContent.height
73 color: "black"
54 74
55 columns: 3 75 onVisibleChanged: {
56 columnSpacing: 16 76 const d = new Date();
57 rowSpacing: 16 77 yearCalendar.year = d.getFullYear();
78 clockMouseArea.angleRem = 0;
79 }
58 80
59 anchors.centerIn: parent 81 WrapperMouseArea {
82 id: tooltipMouseArea
60 83
61 Repeater { 84 hoverEnabled: true
62 model: 12 85 enabled: true
63 86
64 GridLayout { 87 onWheel: event => clockMouseArea.scrollYear(event)
65 columns: 2
66 88
67 required property int index 89 anchors.fill: parent
68 property int month: index
69 90
70 id: monthCalendar 91 WrapperItem {
92 id: clockTooltipContent
71 93
72 Layout.alignment: Qt.AlignTop | Qt.AlignRight 94 margin: 8
73 Layout.fillWidth: false 95 leftMargin: 0
74 96
97 ColumnLayout {
75 Text { 98 Text {
76 Layout.column: 1 99 id: yearLabel
77 Layout.fillWidth: true
78 100
79 horizontalAlignment: Text.AlignHCenter 101 horizontalAlignment: Text.AlignHCenter
80 102
81 font.pointSize: 10 103 font.pointSize: 14
82 font.family: "Fira Sans" 104 font.family: "Fira Sans"
105 font.features: { "tnum": 1 }
106 color: "white"
83 107
84 text: { 108 text: yearCalendar.year
85 const date = Date.fromLocaleDateString(Qt.locale(), `${yearCalendar.year}-${monthCalendar.month + 1}-01`, "yyyy-M-dd");
86 return date.toLocaleString(Qt.locale("en_DK"), "MMMM")
87 }
88 109
89 color: "#ffead3" 110 Layout.fillWidth: true
111 Layout.bottomMargin: 8
90 } 112 }
91 113
92 DayOfWeekRow { 114 GridLayout {
93 locale: grid.locale 115 property int year: { const d = new Date(); return d.getFullYear(); }
94 116
95 Layout.row: 1 117 id: yearCalendar
96 Layout.column: 1
97 Layout.fillWidth: true
98 118
99 delegate: Text { 119 columns: 3
100 required property string shortName 120 columnSpacing: 16
121 rowSpacing: 16
101 122
102 font.pointSize: 10 123 Layout.alignment: Qt.AlignHCenter
103 font.family: "Fira Mono" 124 Layout.fillWidth: false
104 125
105 text: shortName 126 Repeater {
106 color: "#ffcc66" 127 model: 12
107 128
108 horizontalAlignment: Text.AlignRight 129 GridLayout {
109 verticalAlignment: Text.AlignVCenter 130 columns: 2
110 } 131
111 } 132 required property int index
133 property int month: index
134
135 id: monthCalendar
136
137 Layout.alignment: Qt.AlignTop | Qt.AlignRight
138 Layout.fillWidth: false
112 139
113 WeekNumberColumn { 140 Text {
114 month: grid.month 141 Layout.column: 1
115 year: grid.year 142 Layout.fillWidth: true
116 locale: grid.locale
117 143
118 Layout.fillHeight: true 144 horizontalAlignment: Text.AlignHCenter
119 145
120 delegate: Text { 146 font.pointSize: 10
121 required property int weekNumber 147 font.family: "Fira Sans"
122 148
123 opacity: { 149 text: {
124 const simple = new Date(weekNumber == 1 && monthCalendar.month == 12 ? yearCalendar.year + 1 : yearCalendar.year, 0, 1 + (weekNumber - 1) * 7); 150 const date = Date.fromLocaleDateString(Qt.locale(), `${yearCalendar.year}-${monthCalendar.month + 1}-01`, "yyyy-M-dd");
125 const dayOfWeek = simple.getDay(); 151 return date.toLocaleString(Qt.locale("en_DK"), "MMMM")
126 const isoWeekStart = simple; 152 }
127 153
128 isoWeekStart.setDate(simple.getDate() - dayOfWeek + 1); 154 color: "#ffead3"
129 if (dayOfWeek > 4) {
130 isoWeekStart.setDate(isoWeekStart.getDate() + 7);
131 } 155 }
132 156
133 for (let i = 0; i < 7; i++) { 157 DayOfWeekRow {
134 const dayInWeek = new Date(isoWeekStart); 158 locale: grid.locale
135 dayInWeek.setDate(dayInWeek.getDate() + i); 159
136 if (dayInWeek.getMonth() == monthCalendar.month) 160 Layout.row: 1
137 return 1; 161 Layout.column: 1
162 Layout.fillWidth: true
163
164 delegate: Text {
165 required property string shortName
166
167 font.pointSize: 10
168 font.family: "Fira Mono"
169
170 text: shortName
171 color: "#ffcc66"
172
173 horizontalAlignment: Text.AlignRight
174 verticalAlignment: Text.AlignVCenter
175 }
138 } 176 }
139 177
140 return 0; 178 WeekNumberColumn {
141 } 179 month: grid.month
180 year: grid.year
181 locale: grid.locale
142 182
143 font.pointSize: 10 183 Layout.fillHeight: true
144 font.family: "Fira Sans"
145 font.features: { "tnum": 1 }
146 184
147 text: weekNumber 185 delegate: Text {
148 color: "#99ffdd" 186 required property int weekNumber
149 187
150 horizontalAlignment: Text.AlignRight 188 opacity: {
151 verticalAlignment: Text.AlignVCenter 189 const simple = new Date(weekNumber == 1 && monthCalendar.month == 12 ? yearCalendar.year + 1 : yearCalendar.year, 0, 1 + (weekNumber - 1) * 7);
152 } 190 const dayOfWeek = simple.getDay();
153 } 191 const isoWeekStart = simple;
154 192
155 MonthGrid { 193 isoWeekStart.setDate(simple.getDate() - dayOfWeek + 1);
156 id: grid 194 if (dayOfWeek > 4) {
195 isoWeekStart.setDate(isoWeekStart.getDate() + 7);
196 }
157 197
158 year: yearCalendar.year 198 for (let i = 0; i < 7; i++) {
159 month: monthCalendar.month 199 const dayInWeek = new Date(isoWeekStart);
160 locale: Qt.locale("en_DK") 200 dayInWeek.setDate(dayInWeek.getDate() + i);
201 if (dayInWeek.getMonth() == monthCalendar.month)
202 return 1;
203 }
161 204
162 Layout.fillWidth: true 205 return 0;
163 Layout.fillHeight: true 206 }
164 207
165 delegate: Text { 208 font.pointSize: 10
166 required property var model 209 font.family: "Fira Sans"
210 font.features: { "tnum": 1 }
167 211
168 opacity: model.month === monthCalendar.month ? 1 : 0 212 text: weekNumber
213 color: "#99ffdd"
169 214
170 font.pointSize: 10 215 horizontalAlignment: Text.AlignRight
171 font.family: "Fira Sans" 216 verticalAlignment: Text.AlignVCenter
172 font.features: { "tnum": 1 } 217 }
218 }
219
220 MonthGrid {
221 id: grid
222
223 year: yearCalendar.year
224 month: monthCalendar.month
225 locale: Qt.locale("en_DK")
226
227 Layout.fillWidth: true
228 Layout.fillHeight: true
229
230 delegate: Text {
231 required property var model
173 232
174 text: model.day 233 opacity: model.month === monthCalendar.month ? 1 : 0
175 color: model.today ? "#ff6699" : "white"
176 234
177 horizontalAlignment: Text.AlignRight 235 font.pointSize: 10
178 verticalAlignment: Text.AlignVCenter 236 font.family: "Fira Sans"
237 font.features: { "tnum": 1 }
238
239 text: model.day
240 color: model.today ? "#ff6699" : "white"
241
242 horizontalAlignment: Text.AlignRight
243 verticalAlignment: Text.AlignVCenter
244 }
245 }
246 }
179 } 247 }
180 } 248 }
181 } 249 }
diff --git a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml
index 710ea10c..b9f91580 100644
--- a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml
+++ b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml
@@ -1,6 +1,7 @@
1import Quickshell 1import Quickshell
2import QtQuick 2import QtQuick
3import qs.Services 3import qs.Services
4import Quickshell.Widgets
4 5
5Rectangle { 6Rectangle {
6 id: kbdWidget 7 id: kbdWidget
@@ -27,6 +28,9 @@ Rectangle {
27 onClicked: { 28 onClicked: {
28 NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": "Next" } } }, _ => {}) 29 NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": "Next" } } }, _ => {})
29 } 30 }
31 onWheel: event => {
32 NiriService.sendCommand({ "Action": { "SwitchLayout": { "layout": event.angleDelta > 0 ? "Next" : "Prev" } } }, _ => {})
33 }
30 } 34 }
31 35
32 Text { 36 Text {
@@ -50,28 +54,47 @@ Rectangle {
50 } 54 }
51 55
52 PopupWindow { 56 PopupWindow {
57 id: tooltip
58
59 property bool nextVisible: kbdMouseArea.containsMouse || tooltipMouseArea.containsMouse
60
53 anchor { 61 anchor {
54 item: kbdMouseArea 62 item: kbdMouseArea
55 edges: Edges.Bottom 63 edges: Edges.Bottom | Edges.Left
64 }
65 visible: false
66
67 onNextVisibleChanged: hangTimer.restart()
68
69 Timer {
70 id: hangTimer
71 interval: 100
72 onTriggered: tooltip.visible = tooltip.nextVisible
56 } 73 }
57 visible: kbdMouseArea.containsMouse
58 74
59 implicitWidth: kbdTooltipText.contentWidth + 16 75 implicitWidth: kbdTooltipText.contentWidth + 16
60 implicitHeight: kbdTooltipText.contentHeight + 16 76 implicitHeight: kbdTooltipText.contentHeight + 16
61 color: "black" 77 color: "black"
62 78
63 Text { 79 WrapperMouseArea {
64 id: kbdTooltipText 80 id: tooltipMouseArea
81
82 hoverEnabled: true
83 enabled: true
65 84
66 anchors.centerIn: parent 85 anchors.centerIn: parent
67 86
68 font.pointSize: 10 87 Text {
69 font.family: "Fira Sans" 88 id: kbdTooltipText
70 color: "white" 89
90 font.pointSize: 10
91 font.family: "Fira Sans"
92 color: "white"
71 93
72 text: { 94 text: {
73 const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; 95 const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx];
74 return currentLayout || ""; 96 return currentLayout || "";
97 }
75 } 98 }
76 } 99 }
77 } 100 }
diff --git a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml
index afed4bf0..ba678138 100644
--- a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml
+++ b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml
@@ -91,18 +91,35 @@ Item {
91 } 91 }
92 92
93 PopupWindow { 93 PopupWindow {
94 id: tooltip
95
96 property bool nextVisible: (trayItem.tooltipTitle || trayItem.tooltipDescription) && (trayItemArea.containsMouse || tooltipMouseArea.containsMouse) && !menuAnchor.visible
97
94 anchor { 98 anchor {
95 item: trayItemArea 99 item: trayItemArea
96 edges: Edges.Bottom 100 edges: Edges.Bottom
97 } 101 }
98 visible: (trayItem.tooltipTitle || trayItem.tooltipDescription) && trayItemArea.containsMouse && !menuAnchor.visible 102
103 visible: false
104 onNextVisibleChanged: hangTimer.restart()
105
106 Timer {
107 id: hangTimer
108 interval: 100
109 onTriggered: tooltip.visible = tooltip.nextVisible
110 }
99 111
100 color: "black" 112 color: "black"
101 113
102 implicitWidth: Math.max(tooltipTitle.contentWidth, tooltipDescription.contentWidth) + 16 114 implicitWidth: Math.max(tooltipTitle.contentWidth, tooltipDescription.contentWidth) + 16
103 implicitHeight: tooltipTitle.contentHeight + tooltipDescription.contentHeight + 16 115 implicitHeight: tooltipTitle.contentHeight + tooltipDescription.contentHeight + 16
104 116
105 WrapperItem { 117 WrapperMouseArea {
118 id: tooltipMouseArea
119
120 hoverEnabled: true
121 enabled: true
122
106 margin: 8 123 margin: 8
107 124
108 Column { 125 Column {
diff --git a/accounts/gkleen@sif/shell/quickshell/shell.qml b/accounts/gkleen@sif/shell/quickshell/shell.qml
index 2abd1fef..4934cd4d 100644
--- a/accounts/gkleen@sif/shell/quickshell/shell.qml
+++ b/accounts/gkleen@sif/shell/quickshell/shell.qml
@@ -8,8 +8,16 @@ ShellRoot {
8 Variants { 8 Variants {
9 model: Quickshell.screens 9 model: Quickshell.screens
10 10
11 delegate: Bar { 11 delegate: Scope {
12 modelData: item 12 id: screenScope
13
14 required property var modelData
15
16 Bar {
17 id: bar
18
19 screen: screenScope.modelData
20 }
13 } 21 }
14 } 22 }
15} 23}