37 lines
969 B
C++
37 lines
969 B
C++
|
|
#ifndef THEMEMANAGER_H
|
||
|
|
#define THEMEMANAGER_H
|
||
|
|
|
||
|
|
#include <QObject>
|
||
|
|
#include <QHash>
|
||
|
|
#include "IThemePlugin.h"
|
||
|
|
|
||
|
|
// ============================================================
|
||
|
|
// ThemeManager — 主题管理器
|
||
|
|
//
|
||
|
|
// 管理主题插件的注册、切换和应用。
|
||
|
|
// 在 AppController 初始化时创建,MainWindow 通过它设置主题。
|
||
|
|
// ============================================================
|
||
|
|
class ThemeManager : public QObject
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
public:
|
||
|
|
explicit ThemeManager(QObject *parent = nullptr);
|
||
|
|
|
||
|
|
void registerTheme(IThemePlugin *theme);
|
||
|
|
void setCurrentTheme(const QString &name);
|
||
|
|
IThemePlugin *currentTheme() const { return m_current; }
|
||
|
|
QStringList themeNames() const;
|
||
|
|
IThemePlugin *theme(const QString &name) const;
|
||
|
|
|
||
|
|
void applyToApplication(QApplication *app);
|
||
|
|
|
||
|
|
signals:
|
||
|
|
void themeChanged(const QString &name);
|
||
|
|
|
||
|
|
private:
|
||
|
|
QHash<QString, IThemePlugin*> m_themes;
|
||
|
|
IThemePlugin *m_current = nullptr;
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif
|