Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
core: PIMPL refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
wangwenx190 committed Aug 24, 2023
1 parent 01f3750 commit 3bc44c2
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 353 deletions.
4 changes: 1 addition & 3 deletions include/FramelessHelper/Core/private/chromepalette_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ class FRAMELESSHELPER_CORE_API ChromePalettePrivate : public QObject
Q_NODISCARD static ChromePalettePrivate *get(ChromePalette *q);
Q_NODISCARD static const ChromePalettePrivate *get(const ChromePalette *q);

public Q_SLOTS:
void refresh();
Q_SLOT void refresh();

private:
ChromePalette *q_ptr = nullptr;
// System-defined ones:
QColor titleBarActiveBackgroundColor_sys = {};
Expand Down
34 changes: 11 additions & 23 deletions include/FramelessHelper/Core/private/framelessmanager_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,39 +49,27 @@ class FRAMELESSHELPER_CORE_API FramelessManagerPrivate : public QObject
static void initializeIconFont();
Q_NODISCARD static QFont getIconFont();

Q_NODISCARD Global::SystemTheme systemTheme() const;
Q_NODISCARD QColor systemAccentColor() const;
Q_NODISCARD QString wallpaper() const;
Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const;
Q_SLOT void notifySystemThemeHasChangedOrNot();
Q_SLOT void notifyWallpaperHasChangedOrNot();

static void addWindow(const SystemParameters *params);
static void removeWindow(const WId windowId);

Q_INVOKABLE void notifySystemThemeHasChangedOrNot();
Q_INVOKABLE void notifyWallpaperHasChangedOrNot();

Q_NODISCARD static bool usePureQtImplementation();

void setOverrideTheme(const Global::SystemTheme theme);
Q_NODISCARD bool isThemeOverrided() const;

private:
void initialize();

void doNotifySystemThemeHasChangedOrNot();
void doNotifyWallpaperHasChangedOrNot();

private:
FramelessManager *q_ptr = nullptr;
Global::SystemTheme m_systemTheme = Global::SystemTheme::Unknown;
std::optional<Global::SystemTheme> m_overrideTheme = std::nullopt;
QColor m_accentColor = {};
Global::SystemTheme systemTheme = Global::SystemTheme::Unknown;
std::optional<Global::SystemTheme> overrideTheme = std::nullopt;
QColor accentColor = {};
#ifdef Q_OS_WINDOWS
Global::DwmColorizationArea m_colorizationArea = Global::DwmColorizationArea::None;
Global::DwmColorizationArea colorizationArea = Global::DwmColorizationArea::None;
#endif
QString m_wallpaper = {};
Global::WallpaperAspectStyle m_wallpaperAspectStyle = Global::WallpaperAspectStyle::Fill;
QTimer m_themeTimer{};
QTimer m_wallpaperTimer{};
QString wallpaper = {};
Global::WallpaperAspectStyle wallpaperAspectStyle = Global::WallpaperAspectStyle::Fill;
QTimer themeTimer{};
QTimer wallpaperTimer{};
};

FRAMELESSHELPER_END_NAMESPACE
14 changes: 5 additions & 9 deletions include/FramelessHelper/Core/private/micamaterial_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,18 @@ class FRAMELESSHELPER_CORE_API MicaMaterialPrivate : public QObject
Q_NODISCARD QSize mapToWallpaper(const QSize &size) const;
Q_NODISCARD QRect mapToWallpaper(const QRect &rect) const;

public Q_SLOTS:
void maybeGenerateBlurredWallpaper(const bool force = false);
void updateMaterialBrush();
void paint(QPainter *painter, const QRect &rect, const bool active = true);
void forceRebuildWallpaper();
Q_SLOT void maybeGenerateBlurredWallpaper(const bool force = false);
Q_SLOT void updateMaterialBrush();
Q_SLOT void forceRebuildWallpaper();

private:
void initialize();
void prepareGraphicsResources();

private:
MicaMaterial *q_ptr = nullptr;
QColor tintColor = {};
qreal tintOpacity = 0.0;
qreal tintOpacity = qreal(0);
QColor fallbackColor = {};
qreal noiseOpacity = 0.0;
qreal noiseOpacity = qreal(0);
bool fallbackEnabled = true;
QBrush micaBrush = {};
bool initialized = false;
Expand Down
2 changes: 1 addition & 1 deletion include/FramelessHelper/Core/private/registrykey_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class FRAMELESSHELPER_CORE_API RegistryKey : public QObject
Q_NODISCARD std::optional<T> value(const QString &name) const
{
const QVariant var = value(name);
if (var.isValid()) {
if (var.isValid() && !var.isNull()) {
return qvariant_cast<T>(var);
}
return std::nullopt;
Expand Down
19 changes: 4 additions & 15 deletions include/FramelessHelper/Core/private/windowborderpainter_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,11 @@ class FRAMELESSHELPER_CORE_API WindowBorderPainterPrivate : public QObject
Q_NODISCARD static WindowBorderPainterPrivate *get(WindowBorderPainter *q);
Q_NODISCARD static const WindowBorderPainterPrivate *get(const WindowBorderPainter *q);

Q_NODISCARD static int getNativeBorderThickness();
Q_NODISCARD static QColor getNativeBorderColor(const bool active);
Q_NODISCARD static Global::WindowEdges getNativeBorderEdges();

public Q_SLOTS:
void paint(QPainter *painter, const QSize &size, const bool active) const;

private:
void initialize();

private:
WindowBorderPainter *q_ptr = nullptr;
std::optional<int> m_thickness = std::nullopt;
std::optional<Global::WindowEdges> m_edges = std::nullopt;
std::optional<QColor> m_activeColor = std::nullopt;
std::optional<QColor> m_inactiveColor = std::nullopt;
std::optional<int> thickness = std::nullopt;
std::optional<Global::WindowEdges> edges = std::nullopt;
std::optional<QColor> activeColor = std::nullopt;
std::optional<QColor> inactiveColor = std::nullopt;
};

FRAMELESSHELPER_END_NAMESPACE
2 changes: 1 addition & 1 deletion include/FramelessHelper/Core/windowborderpainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class FRAMELESSHELPER_CORE_API WindowBorderPainter : public QObject
Q_NODISCARD QColor nativeInactiveColor() const;

public Q_SLOTS:
void paint(QPainter *painter, const QSize &size, const bool active) const;
void paint(QPainter *painter, const QSize &size, const bool active);
void setThickness(const int value);
void setEdges(const Global::WindowEdges value);
void setActiveColor(const QColor &value);
Expand Down
Loading

0 comments on commit 3bc44c2

Please sign in to comment.