appevent.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef APPEVENT_H
  2. #define APPEVENT_H
  3. #include <QObject>
  4. #include <QVariant>
  5. class AppEvent : public QObject
  6. {
  7. Q_OBJECT
  8. explicit AppEvent(QObject *parent = nullptr);
  9. ~AppEvent();
  10. public:
  11. static AppEvent *instance(); // 静态方法返回单例实例
  12. static qint64 time();
  13. static QString formatElapsedTime(qint64 ms);
  14. static void captureDesktop(const QString &path);
  15. static void saveTimeFile(qint64 elapsed, const QString &path);
  16. QString machineCode() const;
  17. //判断是否登录
  18. bool isLogin();
  19. void setJwtToken(const QString &token);
  20. QString jwtToken() const;
  21. bool isRefreshToken() const;
  22. void setRefreshTime(qint64 time) const;
  23. void startExam(int time);
  24. qint64 maxExamTime();
  25. void setMaxExamTime(qint64 time);
  26. // 配置
  27. bool setConfigValue(const QString &key, const QVariant &value);
  28. QVariant configValue(const QString &key);
  29. QVariant configReadValue(const QString &key, bool *isok = nullptr);
  30. bool configLoadJson(const QJsonObject &object);
  31. bool configLoad();
  32. bool configSave();
  33. QJsonObject config() const;
  34. void serverLink(bool);
  35. void unLockScreen();
  36. signals:
  37. void startExamSignals(int time);
  38. void serverLinkSignals(int time);
  39. void unLockScreenSignals();
  40. private:
  41. class AppEventPrivate *d;
  42. };
  43. #endif // APPEVENT_H