Mercurial > minori
comparison include/core/session.h @ 315:34347fd2a2de
session: allow printing status messages
...!
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Tue, 11 Jun 2024 14:16:40 -0400 |
| parents | ac1451035c85 |
| children | d928ec7b6a0d |
comparison
equal
deleted
inserted
replaced
| 314:76d7315504c4 | 315:34347fd2a2de |
|---|---|
| 2 #define MINORI_CORE_SESSION_H_ | 2 #define MINORI_CORE_SESSION_H_ |
| 3 | 3 |
| 4 #include "core/config.h" | 4 #include "core/config.h" |
| 5 #include "gui/locale.h" | 5 #include "gui/locale.h" |
| 6 | 6 |
| 7 #include <QObject> | |
| 7 #include <QElapsedTimer> | 8 #include <QElapsedTimer> |
| 8 | 9 |
| 9 #include "semver/semver.hpp" | 10 #include "semver/semver.hpp" |
| 10 | 11 |
| 11 #include <atomic> | 12 #include <atomic> |
| 13 #include <string> | |
| 12 | 14 |
| 13 struct Session { | 15 class MainWindow; |
| 16 | |
| 17 struct Session : public QObject { | |
| 18 Q_OBJECT | |
| 19 | |
| 14 public: | 20 public: |
| 15 Session() { timer.start(); } | 21 Session(); |
| 22 | |
| 23 void SetMainWindow(MainWindow* window); | |
| 24 | |
| 25 void SetStatusBar(const std::string& message); | |
| 26 | |
| 16 /* we literally *cannot* be lying to the user by doing this */ | 27 /* we literally *cannot* be lying to the user by doing this */ |
| 17 void IncrementRequests() { requests++; }; | 28 void IncrementRequests(); |
| 18 unsigned int GetRequests() { return requests; }; | 29 unsigned int GetRequests(); |
| 19 int uptime() { return timer.elapsed(); } | 30 int uptime(); |
| 20 | 31 |
| 21 Config config; | 32 Config config; |
| 22 static constexpr semver::version version{PACKAGE_VERSION}; | 33 static constexpr semver::version version{PACKAGE_VERSION}; |
| 23 | 34 |
| 35 signals: | |
| 36 void StatusBarChange(const std::string& message); | |
| 37 | |
| 24 private: | 38 private: |
| 25 /* IncrementRequests() gets called by different threads */ | 39 /* IncrementRequests() gets called by different threads */ |
| 26 std::atomic<unsigned int> requests = 0; | 40 std::atomic<unsigned int> requests_ = 0; |
| 27 QElapsedTimer timer; | 41 QElapsedTimer timer_; |
| 42 MainWindow* window_; | |
| 28 }; | 43 }; |
| 29 | 44 |
| 30 extern Session session; | 45 extern Session session; |
| 31 | 46 |
| 32 #endif // MINORI_CORE_SESSION_H_ | 47 #endif // MINORI_CORE_SESSION_H_ |
