2023-03-06 14:22:13 +08:00
|
|
|
|
#ifndef FLUTHEME_H
|
|
|
|
|
#define FLUTHEME_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
2023-04-27 09:38:57 +08:00
|
|
|
|
#include <QtQml/qqml.h>
|
2023-03-06 14:22:13 +08:00
|
|
|
|
#include "FluColorSet.h"
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
2023-04-27 17:29:39 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief The FluTheme class
|
|
|
|
|
*/
|
2023-03-06 14:22:13 +08:00
|
|
|
|
class FluTheme : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2023-04-27 17:29:39 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief dark 改变窗口夜间样式,只读属性,可以通过darkMode切换
|
|
|
|
|
*/
|
2023-04-19 23:53:00 +08:00
|
|
|
|
Q_PROPERTY(bool dark READ dark NOTIFY darkChanged)
|
2023-04-27 17:29:39 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief primaryColor 主题颜色
|
|
|
|
|
*/
|
2023-03-06 14:22:13 +08:00
|
|
|
|
Q_PROPERTY_AUTO(FluColorSet*,primaryColor)
|
2023-04-27 17:29:39 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief darkMode 夜间模式,支持System=0、Light=1、Dark=2
|
|
|
|
|
*/
|
2023-04-19 23:53:00 +08:00
|
|
|
|
Q_PROPERTY_AUTO(int,darkMode);
|
2023-04-27 17:29:39 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief nativeText 本地渲染文本
|
|
|
|
|
*/
|
2023-03-28 21:37:10 +08:00
|
|
|
|
Q_PROPERTY_AUTO(bool,nativeText);
|
2023-04-27 17:29:39 +08:00
|
|
|
|
|
2023-04-27 09:38:57 +08:00
|
|
|
|
QML_NAMED_ELEMENT(FluTheme)
|
|
|
|
|
QML_SINGLETON
|
2023-05-11 18:24:58 +08:00
|
|
|
|
private:
|
|
|
|
|
static FluTheme* m_instance;
|
2023-03-06 14:22:13 +08:00
|
|
|
|
explicit FluTheme(QObject *parent = nullptr);
|
2023-05-11 18:24:58 +08:00
|
|
|
|
public:
|
|
|
|
|
static FluTheme *getInstance();
|
|
|
|
|
static FluTheme *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
|
|
|
|
|
{
|
|
|
|
|
return getInstance();
|
|
|
|
|
}
|
2023-04-19 23:53:00 +08:00
|
|
|
|
bool dark();
|
|
|
|
|
Q_SIGNAL void darkChanged();
|
2023-03-06 14:22:13 +08:00
|
|
|
|
private:
|
2023-04-19 23:53:00 +08:00
|
|
|
|
bool _dark;
|
2023-04-19 22:27:27 +08:00
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
2023-04-19 23:53:00 +08:00
|
|
|
|
bool systemDark();
|
2023-03-06 14:22:13 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // FLUTHEME_H
|