diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2021-06-29 11:58:04 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2021-10-07 13:47:37 +0200 |
commit | 77659e03393820daace991c28021cfb8b67f871a (patch) | |
tree | 365b3f94c17b902c19f82255e48cf567c2c5c748 /src/gui | |
parent | fbaf6d0bdf232d598afd651883d8cb8d9065f21c (diff) |
Add QPlatformTheme::Appearance for detecting light/dark modes
And implement it on Windows and macOS.
Fixes: QTBUG-83908
Fixes: QTBUG-94859
Change-Id: I7b0c062adf5d4dbaefa64c862ab8ab1348809d71
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 2248487c6ca9d5459c70a16868d5aeee07d96157)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qplatformtheme.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.h | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 34f7307cd7..f8d580ca79 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -401,6 +401,11 @@ QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType typ return nullptr; } +QPlatformTheme::Appearance QPlatformTheme::appearance() const +{ + return Appearance::Unknown; +} + const QPalette *QPlatformTheme::palette(Palette type) const { Q_D(const QPlatformTheme); diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 0b6c0254f0..011f8d548c 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -128,6 +128,12 @@ public: MessageDialog }; + enum class Appearance { + Unknown = 0x0000, + Light = 0x0001, + Dark = 0x0002 + }; + enum Palette { SystemPalette, ToolTipPalette, @@ -299,6 +305,8 @@ public: virtual QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const; #endif + virtual Appearance appearance() const; + virtual const QPalette *palette(Palette type = SystemPalette) const; virtual const QFont *font(Font type = SystemFont) const; |