UIStyleManager.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef UISTYLEMANAGER_H
  2. #define UISTYLEMANAGER_H
  3. #include <QObject>
  4. /**
  5. * @brief UI样式
  6. *
  7. */
  8. enum class enum_UIStyle
  9. {
  10. UI_Light = 0, /* 亮色 */
  11. UI_Dark = 1 /* 暗色 */
  12. };
  13. #define EPUIStyle UIStyleManager::getInstance()
  14. /**
  15. * @brief 全局皮肤管理器,大部分的UI从这里加载qss文件
  16. *
  17. */
  18. class UIStyleManager : public QObject
  19. {
  20. Q_OBJECT
  21. UIStyleManager();
  22. UIStyleManager(const UIStyleManager& config) = delete;
  23. UIStyleManager& operator=(const UIStyleManager& config) = delete;
  24. public:
  25. ~UIStyleManager() {}
  26. static UIStyleManager& getInstance()
  27. {
  28. static UIStyleManager config;
  29. return config;
  30. }
  31. QString StrQSS_TransmitterSwitch; /* 主窗口样式表 */
  32. QString StrQSS_PBtnFrequency; /* 频率按钮样式表 */
  33. QString StrQSS_PlanCard; /* 计划卡片样式表 */
  34. /* 获取样式表路径 */
  35. QString getQSSPath();
  36. /* 换肤,修改样式表 */
  37. void setUIStyle(enum_UIStyle style);
  38. /* 获取当前UI风格 */
  39. enum_UIStyle getUIStyle() { return m_UIStyle; }
  40. signals:
  41. /* 样式表改变了 */
  42. void signal_qssChanged();
  43. private:
  44. /* 读取qss样式文件 */
  45. void readQSSFile();
  46. private:
  47. enum_UIStyle m_UIStyle; /* 当前UI样式 */
  48. QString m_qssPath; /* 样式表路径 */
  49. const QString m_lightQSS = "/white"; /* 亮色样式表路径 */
  50. const QString m_darkQSS = "/dark"; /* 暗色样式表路径 */
  51. };
  52. #endif /* UISTYLEMANAGER_H */