summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accounts/gkleen@sif/shell/quickshell-plugins/Chrono.cpp12
-rw-r--r--accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp11
-rw-r--r--accounts/gkleen@sif/shell/quickshell/Clock.qml43
-rw-r--r--accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml53
-rw-r--r--accounts/gkleen@sif/shell/quickshell/SystemTray.qml10
-rw-r--r--accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml85
6 files changed, 115 insertions, 99 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.cpp b/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.cpp
index 929b7be6..df0c5781 100644
--- a/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.cpp
+++ b/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.cpp
@@ -75,14 +75,10 @@ void Chrono::schedule(const std::chrono::time_point<std::chrono::system_clock>&
75 this->timer.start(delay); 75 this->timer.start(delay);
76} 76}
77 77
78QString Chrono::format() const { return this->mFormat; } 78QString Chrono::format(const QString& fmt) const {
79void Chrono::setFormat(QString format) { 79 return QString::fromStdString(std::format(std::runtime_format(fmt.toStdString()), std::chrono::zoned_time(std::chrono::current_zone(), std::chrono::time_point_cast<std::chrono::seconds>(this->currentTime))));
80 if (format == this->mFormat) return;
81 this->mFormat = format;
82 emit this->formatChanged();
83 this->update();
84} 80}
85 81
86QString Chrono::date() const { 82QDateTime Chrono::date() const {
87 return QString::fromStdString(std::format(std::runtime_format(this->mFormat.toStdString()), std::chrono::zoned_time(std::chrono::current_zone(), std::chrono::time_point_cast<std::chrono::seconds>(this->currentTime)))); 83 return QDateTime::fromStdTimePoint(std::chrono::time_point_cast<std::chrono::milliseconds>(this->currentTime));
88} 84}
diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp b/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp
index 788fa88e..4d06007d 100644
--- a/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp
+++ b/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp
@@ -1,5 +1,6 @@
1#pragma once 1#pragma once
2 2
3#include <QDateTime>
3#include <QObject> 4#include <QObject>
4#include <QTimer> 5#include <QTimer>
5 6
@@ -10,8 +11,7 @@ class Chrono : public QObject {
10 Q_OBJECT; 11 Q_OBJECT;
11 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged); 12 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged);
12 Q_PROPERTY(Chrono::Precision precision READ precision WRITE setPrecision NOTIFY precisionChanged); 13 Q_PROPERTY(Chrono::Precision precision READ precision WRITE setPrecision NOTIFY precisionChanged);
13 Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged); 14 Q_PROPERTY(QDateTime date READ date NOTIFY dateChanged)
14 Q_PROPERTY(QString date READ date NOTIFY dateChanged);
15 QML_ELEMENT; 15 QML_ELEMENT;
16 16
17public: 17public:
@@ -30,15 +30,13 @@ public:
30 Chrono::Precision precision() const; 30 Chrono::Precision precision() const;
31 void setPrecision(Chrono::Precision precision); 31 void setPrecision(Chrono::Precision precision);
32 32
33 QString format() const; 33 Q_INVOKABLE QString format(const QString& fmt) const;
34 void setFormat (QString format);
35 34
36 QString date() const; 35 QDateTime date() const;
37 36
38signals: 37signals:
39 void enabledChanged(); 38 void enabledChanged();
40 void precisionChanged(); 39 void precisionChanged();
41 void formatChanged();
42 void dateChanged(); 40 void dateChanged();
43 41
44private slots: 42private slots:
@@ -47,7 +45,6 @@ private slots:
47private: 45private:
48 bool mEnabled = true; 46 bool mEnabled = true;
49 Chrono::Precision mPrecision = Chrono::Seconds; 47 Chrono::Precision mPrecision = Chrono::Seconds;
50 QString mFormat = "{:%c}";
51 QTimer timer; 48 QTimer timer;
52 std::chrono::time_point<std::chrono::system_clock> currentTime, targetTime; 49 std::chrono::time_point<std::chrono::system_clock> currentTime, targetTime;
53 50
diff --git a/accounts/gkleen@sif/shell/quickshell/Clock.qml b/accounts/gkleen@sif/shell/quickshell/Clock.qml
index 55fabd1c..a1872ff5 100644
--- a/accounts/gkleen@sif/shell/quickshell/Clock.qml
+++ b/accounts/gkleen@sif/shell/quickshell/Clock.qml
@@ -7,6 +7,8 @@ import QtQuick.Layouts
7import Quickshell.Widgets 7import Quickshell.Widgets
8 8
9Item { 9Item {
10 id: clockItem
11
10 width: clock.contentWidth 12 width: clock.contentWidth
11 height: parent.height 13 height: parent.height
12 anchors.verticalCenter: parent.verticalCenter 14 anchors.verticalCenter: parent.verticalCenter
@@ -30,22 +32,25 @@ Item {
30 32
31 onWheel: event => scrollYear(event) 33 onWheel: event => scrollYear(event)
32 34
33 Text { 35 Item {
34 id: clock 36 anchors.fill: parent
35 color: "white" 37
38 Text {
39 id: clock
40 color: "white"
36 41
37 anchors.verticalCenter: parent.verticalCenter 42 anchors.verticalCenter: parent.verticalCenter
38 43
39 Custom.Chrono { 44 Custom.Chrono {
40 id: chrono 45 id: chrono
41 format: "W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}"
42 }
43 46
44 text: chrono.date 47 onDateChanged: clock.text = format("W{0:%V-%u} {0:%F} {0:%H:%M:%S%Ez}")
48 }
45 49
46 font.pointSize: 10 50 font.pointSize: 10
47 font.family: "Fira Sans" 51 font.family: "Fira Sans"
48 font.features: { "tnum": 1 } 52 font.features: { "tnum": 1 }
53 }
49 } 54 }
50 } 55 }
51 56
@@ -73,8 +78,7 @@ Item {
73 color: "black" 78 color: "black"
74 79
75 onVisibleChanged: { 80 onVisibleChanged: {
76 const d = new Date(); 81 yearCalendar.year = chrono.date.getFullYear();
77 yearCalendar.year = d.getFullYear();
78 clockMouseArea.angleRem = 0; 82 clockMouseArea.angleRem = 0;
79 } 83 }
80 84
@@ -112,7 +116,7 @@ Item {
112 } 116 }
113 117
114 GridLayout { 118 GridLayout {
115 property int year: { const d = new Date(); return d.getFullYear(); } 119 property int year: chrono.date.getFullYear()
116 120
117 id: yearCalendar 121 id: yearCalendar
118 122
@@ -146,10 +150,7 @@ Item {
146 font.pointSize: 10 150 font.pointSize: 10
147 font.family: "Fira Sans" 151 font.family: "Fira Sans"
148 152
149 text: { 153 text: new Date(yearCalendar.year, monthCalendar.month, 1).toLocaleString(Qt.locale("en_DK"), "MMMM")
150 const date = Date.fromLocaleDateString(Qt.locale(), `${yearCalendar.year}-${monthCalendar.month + 1}-01`, "yyyy-M-dd");
151 return date.toLocaleString(Qt.locale("en_DK"), "MMMM")
152 }
153 154
154 color: "#ffead3" 155 color: "#ffead3"
155 } 156 }
@@ -236,8 +237,10 @@ Item {
236 font.family: "Fira Sans" 237 font.family: "Fira Sans"
237 font.features: { "tnum": 1 } 238 font.features: { "tnum": 1 }
238 239
240 property bool today: chrono.date.getFullYear() == model.year && chrono.date.getMonth() == model.month && chrono.date.getDate() == model.day
241
239 text: model.day 242 text: model.day
240 color: model.today ? "#ff6699" : "white" 243 color: today ? "#ff6699" : "white"
241 244
242 horizontalAlignment: Text.AlignRight 245 horizontalAlignment: Text.AlignRight
243 verticalAlignment: Text.AlignVCenter 246 verticalAlignment: Text.AlignVCenter
diff --git a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml
index 4a6b8390..bc3750f9 100644
--- a/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml
+++ b/accounts/gkleen@sif/shell/quickshell/KeyboardLayout.qml
@@ -3,18 +3,8 @@ 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
@@ -22,6 +12,7 @@ Rectangle {
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
@@ -32,23 +23,37 @@ Rectangle {
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 25
35 Text { 26 Rectangle {
36 id: kbdLabel 27 id: kbdWidget
37 28
38 font.pointSize: 10 29 property var keyboardAbbrev: { "English (programmer Dvorak)": "dvp", "English (US)": "us" }
39 font.family: "Fira Sans" 30
31 anchors.fill: parent
40 color: { 32 color: {
41 if (NiriService.keyboardLayouts?.current_idx === 0) 33 if (kbdMouseArea.containsMouse) {
42 return "#555"; 34 return "#33808080";
43 return "white"; 35 }
36 return "transparent";
44 } 37 }
45 anchors.centerIn: parent
46 38
47 text: { 39 Text {
48 const currentLayout = NiriService.keyboardLayouts?.names?.[NiriService.keyboardLayouts.current_idx]; 40 id: kbdLabel
49 if (!currentLayout) 41
50 return ""; 42 font.pointSize: 10
51 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 }
52 } 57 }
53 } 58 }
54 } 59 }
diff --git a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml
index 024026a3..55b1690e 100644
--- a/accounts/gkleen@sif/shell/quickshell/SystemTray.qml
+++ b/accounts/gkleen@sif/shell/quickshell/SystemTray.qml
@@ -17,10 +17,12 @@ Item {
17 spacing: 0 17 spacing: 0
18 18
19 Repeater { 19 Repeater {
20 model: { 20 model: ScriptModel {
21 var trayItems = Array.from(SystemTray.items.values).filter(item => item.status !== Status.Passive); 21 values: {
22 trayItems.sort((a, b) => a.category !== b.category ? b.category - a.category : a.id.localeCompare(b.id)) 22 var trayItems = Array.from(SystemTray.items.values).filter(item => item.status !== Status.Passive);
23 return trayItems; 23 trayItems.sort((a, b) => a.category !== b.category ? b.category - a.category : a.id.localeCompare(b.id))
24 return trayItems;
25 }
24 } 26 }
25 27
26 delegate: Item { 28 delegate: Item {
diff --git a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml
index 153c56bb..9546abb4 100644
--- a/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml
+++ b/accounts/gkleen@sif/shell/quickshell/WorkspaceSwitcher.qml
@@ -1,5 +1,7 @@
1import Quickshell
1import QtQuick 2import QtQuick
2import qs.Services 3import qs.Services
4import Quickshell.Widgets
3 5
4Row { 6Row {
5 id: workspaces 7 id: workspaces
@@ -11,61 +13,72 @@ Row {
11 spacing: 0 13 spacing: 0
12 14
13 Repeater { 15 Repeater {
14 model: { 16 model: ScriptModel {
15 let currWorkspaces = NiriService.workspaces; 17 values: {
16 const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces); 18 let currWorkspaces = NiriService.workspaces;
17 currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name)); 19 const ignoreWorkspaces = Array.from(workspaces.ignoreWorkspaces);
18 currWorkspaces.sort((a, b) => { 20 currWorkspaces = currWorkspaces.filter(ws => ws.is_active || ignoreWorkspaces.every(iws => iws !== ws.name));
19 if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x) 21 currWorkspaces.sort((a, b) => {
20 return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x 22 if (NiriService.outputs?.[a.output]?.logical?.x !== NiriService.outputs?.[b.output]?.logical?.x)
21 if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y) 23 return NiriService.outputs?.[a.output]?.logical?.x - NiriService.outputs?.[b.output]?.logical?.x
22 return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y 24 if (NiriService.outputs?.[a.output]?.logical?.y !== NiriService.outputs?.[b.output]?.logical?.y)
23 return a.idx - b.idx; 25 return NiriService.outputs?.[a.output]?.logical?.y - NiriService.outputs?.[b.output]?.logical?.y
24 }); 26 return a.idx - b.idx;
25 return currWorkspaces; 27 });
28 return currWorkspaces;
29 }
26 } 30 }
27 31
28 Rectangle { 32 Item {
33 id: wsItem
34
29 property var workspaceData: modelData 35 property var workspaceData: modelData
30 36
31 width: wsLabel.contentWidth + 8 37 width: wsLabel.contentWidth + 8
32 color: {
33 if (mouseArea.containsMouse) {
34 return "#33808080";
35 }
36 return "transparent";
37 }
38 height: parent.height 38 height: parent.height
39 anchors.verticalCenter: parent.verticalCenter 39 anchors.verticalCenter: parent.verticalCenter
40 40
41 MouseArea { 41 WrapperMouseArea {
42 id: mouseArea 42 id: mouseArea
43 43
44 anchors.fill: parent 44 anchors.fill: parent
45
45 hoverEnabled: true 46 hoverEnabled: true
46 cursorShape: Qt.PointingHandCursor 47 cursorShape: Qt.PointingHandCursor
47 enabled: true 48 enabled: true
48 onClicked: { 49 onClicked: {
49 NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {}) 50 NiriService.sendCommand({ "Action": { "FocusWorkspace": { "reference": { "Id": workspaceData.id } } } }, _ => {})
50 } 51 }
51 }
52 52
53 Text { 53 Rectangle {
54 id: wsLabel 54 anchors.fill: parent
55 55
56 font.pointSize: 10 56 color: {
57 font.family: "Fira Sans" 57 if (mouseArea.containsMouse) {
58 color: { 58 return "#33808080";
59 if (workspaceData.is_active) 59 }
60 return "#23fd00"; 60 return "transparent";
61 if (workspaceData.active_window_id === null) 61 }
62 return "#555"; 62
63 return "white"; 63 Text {
64 } 64 id: wsLabel
65 anchors.centerIn: parent
66 65
67 text: workspaceData.name ? workspaceData.name : workspaceData.idx 66 anchors.centerIn: parent
67
68 font.pointSize: 10
69 font.family: "Fira Sans"
70 color: {
71 if (workspaceData.is_active)
72 return "#23fd00";
73 if (workspaceData.active_window_id === null)
74 return "#555";
75 return "white";
76 }
77
78 text: workspaceData.name ? workspaceData.name : workspaceData.idx
79 }
80 }
68 } 81 }
69 } 82 }
70 } 83 }
71} \ No newline at end of file 84}