2023-05-22 16:17:51 +08:00
|
|
|
#ifndef FLUTHEME_H
|
2023-03-06 14:22:13 +08:00
|
|
|
#define FLUTHEME_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2023-04-27 09:38:57 +08:00
|
|
|
#include <QtQml/qqml.h>
|
2023-09-27 15:18:10 +08:00
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QJsonObject>
|
2023-11-02 15:33:59 +08:00
|
|
|
#include <QColor>
|
2024-04-12 16:26:32 +08:00
|
|
|
#include <QTimer>
|
|
|
|
#include <QFileSystemWatcher>
|
2024-03-07 13:58:23 +08:00
|
|
|
#include "FluAccentColor.h"
|
2023-03-06 14:22:13 +08:00
|
|
|
#include "stdafx.h"
|
2023-09-13 15:11:22 +08:00
|
|
|
#include "singleton.h"
|
2023-03-06 14:22:13 +08:00
|
|
|
|
2023-04-27 17:29:39 +08:00
|
|
|
/**
|
|
|
|
* @brief The FluTheme class
|
|
|
|
*/
|
2024-04-11 14:51:43 +08:00
|
|
|
class FluTheme : public QObject {
|
|
|
|
Q_OBJECT
|
2024-04-12 16:26:32 +08:00
|
|
|
Q_PROPERTY(bool dark READ dark NOTIFY darkChanged)
|
2024-04-11 14:51:43 +08:00
|
|
|
Q_PROPERTY_AUTO_P(FluAccentColor*, accentColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, primaryColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, backgroundColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, dividerColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, windowBackgroundColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, windowActiveBackgroundColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, fontPrimaryColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, fontSecondaryColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, fontTertiaryColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, itemNormalColor);
|
2024-04-12 16:26:32 +08:00
|
|
|
Q_PROPERTY_AUTO(QColor, frameColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, frameActiveColor);
|
2024-04-11 14:51:43 +08:00
|
|
|
Q_PROPERTY_AUTO(QColor, itemHoverColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, itemPressColor);
|
|
|
|
Q_PROPERTY_AUTO(QColor, itemCheckColor);
|
2024-04-12 16:26:32 +08:00
|
|
|
Q_PROPERTY_AUTO(QString, desktopImagePath);
|
2024-04-11 14:51:43 +08:00
|
|
|
Q_PROPERTY_AUTO(int, darkMode);
|
|
|
|
Q_PROPERTY_AUTO(bool, nativeText);
|
|
|
|
Q_PROPERTY_AUTO(bool, animationEnabled);
|
2024-04-12 16:26:32 +08:00
|
|
|
Q_PROPERTY_AUTO(bool, blurBehindWindowEnabled);
|
2023-04-27 09:38:57 +08:00
|
|
|
QML_NAMED_ELEMENT(FluTheme)
|
|
|
|
QML_SINGLETON
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2023-05-11 18:24:58 +08:00
|
|
|
private:
|
2023-03-06 14:22:13 +08:00
|
|
|
explicit FluTheme(QObject *parent = nullptr);
|
2024-04-11 14:51:43 +08:00
|
|
|
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
|
|
|
2023-11-02 15:33:59 +08:00
|
|
|
void refreshColors();
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2024-04-12 16:26:32 +08:00
|
|
|
void updateBackgroundMainColor();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
void timerEvent(QTimerEvent *event) override;
|
|
|
|
|
|
|
|
void updateDesktopImage();
|
|
|
|
|
2023-05-11 18:24:58 +08:00
|
|
|
public:
|
2024-04-11 14:51:43 +08:00
|
|
|
SINGLETON(FluTheme)
|
|
|
|
|
2024-04-11 19:18:37 +08:00
|
|
|
[[maybe_unused]] Q_INVOKABLE static QJsonArray awesomeList(const QString &keyword = "");
|
2024-04-11 14:51:43 +08:00
|
|
|
|
2023-09-27 15:18:10 +08:00
|
|
|
Q_SIGNAL void darkChanged();
|
2024-04-11 14:51:43 +08:00
|
|
|
|
|
|
|
static FluTheme *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
|
|
|
|
|
|
|
bool dark() const;
|
|
|
|
|
2023-03-06 14:22:13 +08:00
|
|
|
private:
|
2023-05-17 22:02:09 +08:00
|
|
|
bool _systemDark;
|
2024-04-12 16:26:32 +08:00
|
|
|
QFileSystemWatcher _watcher;
|
2023-03-06 14:22:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FLUTHEME_H
|