diff options
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp')
-rw-r--r-- | accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp b/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp index 788fa88e..04080187 100644 --- a/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp +++ b/accounts/gkleen@sif/shell/quickshell-plugins/Chrono.hpp | |||
@@ -1,17 +1,18 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | 2 | ||
3 | #include <chrono> | ||
4 | |||
5 | #include <QDateTime> | ||
3 | #include <QObject> | 6 | #include <QObject> |
4 | #include <QTimer> | 7 | #include <QTimer> |
5 | 8 | ||
6 | #include <qqmlintegration.h> | 9 | #include <qqmlintegration.h> |
7 | #include <chrono> | ||
8 | 10 | ||
9 | class Chrono : public QObject { | 11 | class Chrono : public QObject { |
10 | Q_OBJECT; | 12 | Q_OBJECT; |
11 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged); | 13 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged); |
12 | Q_PROPERTY(Chrono::Precision precision READ precision WRITE setPrecision NOTIFY precisionChanged); | 14 | Q_PROPERTY(Chrono::Precision precision READ precision WRITE setPrecision NOTIFY precisionChanged); |
13 | Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged); | 15 | Q_PROPERTY(QDateTime date READ date NOTIFY dateChanged) |
14 | Q_PROPERTY(QString date READ date NOTIFY dateChanged); | ||
15 | QML_ELEMENT; | 16 | QML_ELEMENT; |
16 | 17 | ||
17 | public: | 18 | public: |
@@ -30,15 +31,13 @@ public: | |||
30 | Chrono::Precision precision() const; | 31 | Chrono::Precision precision() const; |
31 | void setPrecision(Chrono::Precision precision); | 32 | void setPrecision(Chrono::Precision precision); |
32 | 33 | ||
33 | QString format() const; | 34 | Q_INVOKABLE QString format(const QString& fmt) const; |
34 | void setFormat (QString format); | ||
35 | 35 | ||
36 | QString date() const; | 36 | QDateTime date() const; |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | void enabledChanged(); | 39 | void enabledChanged(); |
40 | void precisionChanged(); | 40 | void precisionChanged(); |
41 | void formatChanged(); | ||
42 | void dateChanged(); | 41 | void dateChanged(); |
43 | 42 | ||
44 | private slots: | 43 | private slots: |
@@ -47,7 +46,6 @@ private slots: | |||
47 | private: | 46 | private: |
48 | bool mEnabled = true; | 47 | bool mEnabled = true; |
49 | Chrono::Precision mPrecision = Chrono::Seconds; | 48 | Chrono::Precision mPrecision = Chrono::Seconds; |
50 | QString mFormat = "{:%c}"; | ||
51 | QTimer timer; | 49 | QTimer timer; |
52 | std::chrono::time_point<std::chrono::system_clock> currentTime, targetTime; | 50 | std::chrono::time_point<std::chrono::system_clock> currentTime, targetTime; |
53 | 51 | ||