lhstylemanager.h_ 1.1 KB

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