1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #ifndef LHSTYLEMANAGER_H
- #define LHSTYLEMANAGER_H
- #include <QWidget>
- #include <QList>
- #include <QMutex>
- #define LHStyleMgr LHStyleManager::Instance()
- enum SkinStyle{eBrightStyle, eDarkStyle};
- class LHStyleManager : public QObject
- {
- Q_OBJECT
- public:
- explicit LHStyleManager(QObject *parent = nullptr);
- ~LHStyleManager();
- static LHStyleManager* Instance();
- void AddWidget(QWidget* widget);
- void SetSkinStyle(const QString& style);
- SkinStyle GetCurSkinStyle() const {return m_nCurStyle;}
- QString GetCurSkinName() const {return m_nCurStyle == eBrightStyle ? QString("Bright") : QString("Dark");}
- signals:
- public slots:
- private:
- bool UpdateWidgetStyle(QWidget* widget);
- void QssToSkin(bool reserve = false);
- private:
- //当前样式
- SkinStyle m_nCurStyle;
- //所有需要更改样式的widget
- QWidgetList m_widgetList;
- //白色样式表
- QString m_strBrightStyle;
- //黑色样式表
- QString m_strDarkStyle;
- bool m_bQss;
- static LHStyleManager *m_instance;
- static QMutex m_mtx;
- };
- #endif // LHSTYLEMANAGER_H
|