appevent.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. bool isLogin();
  21. void setJwtToken(const QString &token);
  22. QString jwtToken() const;
  23. bool isRefreshToken() const;
  24. void setRefreshTime(qint64 time) const;
  25. void startExam(int time);
  26. qint64 maxExamTime();
  27. void setMaxExamTime(qint64 time);
  28. // 配置
  29. bool setConfigValue(const QString &key, const QVariant &value);
  30. QVariant configValue(const QString &key);
  31. QVariant configReadValue(const QString &key, bool *isok = nullptr);
  32. bool configLoadJson(const QJsonObject &object);
  33. bool configLoad();
  34. bool configSave();
  35. QJsonObject config() const;
  36. void serverLink(bool);
  37. void unLockScreen();
  38. signals:
  39. void startExamSignals(int time);
  40. void serverLinkSignals(int time);
  41. void unLockScreenSignals();
  42. private:
  43. class AppEventPrivate *d;
  44. };
  45. #endif // APPEVENT_H