#ifndef THEME_H #define THEME_H #include "AccentColor.h" #include "Utilities.h" #include #include #include #include #include class Theme : public QObject { Q_OBJECT QML_ELEMENT QML_SINGLETON Q_PROPERTY(bool dark READ dark NOTIFY darkChanged) Q_PROPERTY_AUTO_P(AccentColor *, accentColor) Q_PROPERTY_AUTO(int, darkMode) Q_PROPERTY_AUTO(QColor, primaryColor) Q_PROPERTY_AUTO(QColor, backgroundColor) Q_PROPERTY_AUTO(QColor, dividerColor) Q_PROPERTY_AUTO(QColor, itemPressColor) Q_PROPERTY_AUTO(bool, nativeText) Q_PROPERTY_AUTO(bool, animationEnabled) Q_PROPERTY(QColor fontPrimaryColor READ fontPrimaryColor WRITE setFontPrimaryColor NOTIFY fontPrimaryColorChanged) Q_PROPERTY_AUTO(QColor, fontSecondaryColor) Q_PROPERTY_AUTO(QColor, fontTertiaryColor) Q_PROPERTY_AUTO(QColor, frameColor) Q_PROPERTY_AUTO(QColor, frameActiveColor) Q_PROPERTY_AUTO(QColor, itemCheckColor) Q_PROPERTY(QColor itemNormalColor READ itemNormalColor WRITE setItemNormalColor NOTIFY itemNormalColorChanged) Q_PROPERTY(QColor itemHoverColor READ itemHoverColor WRITE setItemHoverColor NOTIFY itemHoverColorChanged) Q_PROPERTY(QColor windowBackgroundColor READ windowBackgroundColor WRITE setWindowBackgroundColor NOTIFY windowBackgroundColorChanged) Q_PROPERTY(QColor windowActiveBackgroundColor READ windowActiveBackgroundColor WRITE setWindowActiveBackgroundColor NOTIFY windowActiveBackgroundColorChanged) Q_PROPERTY(QString desktopImagePath READ desktopImagePath WRITE setDesktopImagePath NOTIFY desktopImagePathChanged) Q_PROPERTY(bool blurBehindWindowEnabled READ blurBehindWindowEnabled WRITE setBlurBehindWindowEnabled NOTIFY blurBehindWindowEnabledChanged) public: static Theme *instance(); static Theme *create(QQmlEngine *, QJSEngine *); bool dark() const; QColor fontPrimaryColor() const; void setFontPrimaryColor(const QColor &color); QColor itemNormalColor() const; void setItemNormalColor(const QColor &color); QColor itemHoverColor() const; void setItemHoverColor(const QColor &color); QColor windowBackgroundColor() const; void setWindowBackgroundColor(const QColor &color); QColor windowActiveBackgroundColor() const; void setWindowActiveBackgroundColor(const QColor &color); QString desktopImagePath() const; void setDesktopImagePath(const QString &path); bool blurBehindWindowEnabled() const; void setBlurBehindWindowEnabled(bool enabled); signals: void darkChanged(); void fontPrimaryColorChanged(); void itemNormalColorChanged(); void windowBackgroundColorChanged(); void windowActiveBackgroundColorChanged(); void desktopImagePathChanged(); void blurBehindWindowEnabledChanged(); void itemHoverColorChanged(); protected: Theme(QObject *parent = nullptr); void refreshColors(); void checkUpdateDesktopImage(); void timerEvent(QTimerEvent *event) final; bool eventFilter(QObject *obj, QEvent *event) final; private: bool m_systemDark = false; QMutex m_mutex; QFileSystemWatcher m_watcher; QColor m_fontPrimaryColor; QColor m_itemNormalColor; QColor m_itemHoverColor; QColor m_windowBackgroundColor; QColor m_windowActiveBackgroundColor; QString m_desktopImagePath; bool m_blurBehindWindowEnabled; }; #endif // THEME_H