lhstylemanager.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef LHSTYLEMANAGER_H
  2. #define LHSTYLEMANAGER_H
  3. #include <QWidget>
  4. #include <QList>
  5. #include <QMutex>
  6. enum SkinStyle{eBrightStyle, eDarkStyle};
  7. class LHStyleManager : public QObject
  8. {
  9. Q_OBJECT
  10. public:
  11. explicit LHStyleManager(QObject *parent = nullptr);
  12. ~LHStyleManager();
  13. static LHStyleManager* Instance();
  14. void AddWidget(QWidget* widget);
  15. void SetSkinStyle(const QString& style);
  16. SkinStyle GetCurSkinStyle() const {return m_nCurStyle;}
  17. QString GetCurSkinName() const {return m_nCurStyle == eBrightStyle ? QString("Bright") : QString("Dark");}
  18. signals:
  19. public slots:
  20. private:
  21. bool UpdateWidgetStyle(QWidget* widget);
  22. void QssToSkin(bool reserve = false);
  23. private:
  24. //当前样式
  25. SkinStyle m_nCurStyle;
  26. //所有需要更改样式的widget
  27. QWidgetList m_widgetList;
  28. //白色样式表
  29. QString m_strBrightStyle;
  30. //黑色样式表
  31. QString m_strDarkStyle;
  32. bool m_bQss;
  33. static LHStyleManager *m_instance;
  34. static QMutex m_mtx;
  35. };
  36. #endif // LHSTYLEMANAGER_H