summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2021-06-29 11:58:04 +0200
committerMitch Curtis <mitch.curtis@qt.io>2021-09-17 13:31:59 +0200
commit2248487c6ca9d5459c70a16868d5aeee07d96157 (patch)
treed0e2c0dcb5338f58668be422bfc833215ee05323 /src/gui/kernel
parentb6200de5d0894e63d58848e291f52a6ff98f3d9a (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>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qplatformtheme.cpp5
-rw-r--r--src/gui/kernel/qplatformtheme.h8
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;