appevent.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef APPEVENT_H
  2. #define APPEVENT_H
  3. #include <QIODevice>
  4. #include <QObject>
  5. #include <QVariant>
  6. class AppEvent : public QObject
  7. {
  8. Q_OBJECT
  9. explicit AppEvent(QObject *parent = nullptr);
  10. ~AppEvent();
  11. public:
  12. static AppEvent *instance(); // 静态方法返回单例实例
  13. static qint64 time();
  14. static QString formatElapsedTime(qint64 ms);
  15. static void captureDesktop(QIODevice *device, const char *format = nullptr, int quality = -1);
  16. static void captureDesktop(const QString &path);
  17. static void saveTimeFile(qint64 elapsed, const QString &path);
  18. QString machineCode() const;
  19. // 语言设置
  20. QString locale() const;
  21. void setLocale(const QString &locale);
  22. //判断是否登录
  23. bool isLogin();
  24. void setJwtToken(const QString &token);
  25. QString jwtToken() const;
  26. bool isRefreshToken() const;
  27. void setRefreshTime(qint64 time) const;
  28. // 是否启用自动刷新令牌
  29. bool isEnableRefreshToken() const;
  30. void setEnableRefreshToken(bool enable);
  31. // 配置
  32. bool setConfigValue(const QString &key, const QVariant &value);
  33. QVariant configValue(const QString &key);
  34. QVariant configReadValue(const QString &key, bool *isok = nullptr);
  35. bool configLoadJson(const QJsonObject &object);
  36. bool configLoad();
  37. bool configSave();
  38. QJsonObject config() const;
  39. void serverLink(bool);
  40. void unLockScreen();
  41. signals:
  42. void refreshTokenNeeded(); // 通知需要刷新 token
  43. void serverLinkSignals(int time);
  44. void unLockScreenSignals();
  45. void connectionStateChanged(bool); // websocket 在线标识
  46. // 登录过期的信号
  47. void loginExpired(bool expired);
  48. // 错误消息信号
  49. void errorMessage(const QString &message);
  50. private:
  51. class AppEventPrivate *d;
  52. };
  53. #endif // APPEVENT_H