203 lines
8.5 KiB
Diff
203 lines
8.5 KiB
Diff
From 240ce954220d713968e608f2766144c7657bceed Mon Sep 17 00:00:00 2001
|
|
From: Jan Grulich <jgrulich@redhat.com>
|
|
Date: Wed, 26 Jul 2023 12:56:06 +0200
|
|
Subject: [PATCH 08/22] Replace QPlatformTheme::Appearance by Qt:Appearance
|
|
|
|
With the introduction of Qt:Appearance, its predecessor in
|
|
QPlatformTheme has become redundant.
|
|
|
|
This patch replaces all occurrences of QPlatformTheme::Appearance with
|
|
the new enum class.
|
|
---
|
|
src/gui/kernel/qplatformtheme.cpp | 6 +++---
|
|
src/gui/kernel/qplatformtheme.h | 8 +-------
|
|
src/plugins/platforms/cocoa/qcocoatheme.h | 2 +-
|
|
src/plugins/platforms/cocoa/qcocoatheme.mm | 4 ++--
|
|
src/plugins/platforms/windows/qwindowstheme.cpp | 4 ++--
|
|
src/plugins/platforms/windows/qwindowstheme.h | 2 +-
|
|
src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 10 +++++-----
|
|
src/plugins/platformthemes/gtk3/qgtk3theme.h | 2 +-
|
|
src/plugins/styles/mac/qmacstyle_mac.mm | 2 +-
|
|
9 files changed, 17 insertions(+), 23 deletions(-)
|
|
|
|
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
|
|
index 827829c4a5..6dd7d5c923 100644
|
|
--- a/src/gui/kernel/qplatformtheme.cpp
|
|
+++ b/src/gui/kernel/qplatformtheme.cpp
|
|
@@ -368,7 +368,7 @@ Q_GUI_EXPORT QPalette qt_fusionPalette()
|
|
{
|
|
auto theme = QGuiApplicationPrivate::platformTheme();
|
|
const bool darkAppearance = theme
|
|
- ? theme->appearance() == QPlatformTheme::Appearance::Dark
|
|
+ ? theme->appearance() == Qt::Appearance::Dark
|
|
: false;
|
|
const QColor windowText = darkAppearance ? QColor(240, 240, 240) : Qt::black;
|
|
const QColor backGround = darkAppearance ? QColor(50, 50, 50) : QColor(239, 239, 239);
|
|
@@ -448,9 +448,9 @@ QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType typ
|
|
return nullptr;
|
|
}
|
|
|
|
-QPlatformTheme::Appearance QPlatformTheme::appearance() const
|
|
+Qt::Appearance QPlatformTheme::appearance() const
|
|
{
|
|
- return Appearance::Unknown;
|
|
+ return Qt::Appearance::Unknown;
|
|
}
|
|
|
|
const QPalette *QPlatformTheme::palette(Palette type) const
|
|
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
|
|
index c0dee4c581..41213bf32b 100644
|
|
--- a/src/gui/kernel/qplatformtheme.h
|
|
+++ b/src/gui/kernel/qplatformtheme.h
|
|
@@ -131,12 +131,6 @@ public:
|
|
MessageDialog
|
|
};
|
|
|
|
- enum class Appearance {
|
|
- Unknown = 0x0000,
|
|
- Light = 0x0001,
|
|
- Dark = 0x0002
|
|
- };
|
|
-
|
|
enum Palette {
|
|
SystemPalette,
|
|
ToolTipPalette,
|
|
@@ -326,7 +320,7 @@ public:
|
|
virtual QString standardButtonText(int button) const;
|
|
virtual QKeySequence standardButtonShortcut(int button) const;
|
|
|
|
- virtual Appearance appearance() const;
|
|
+ virtual Qt::Appearance appearance() const;
|
|
|
|
static QVariant defaultThemeHint(ThemeHint hint);
|
|
static QString defaultStandardButtonText(int button);
|
|
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h
|
|
index f719fd943b..78ff7cb51c 100644
|
|
--- a/src/plugins/platforms/cocoa/qcocoatheme.h
|
|
+++ b/src/plugins/platforms/cocoa/qcocoatheme.h
|
|
@@ -73,7 +73,7 @@ public:
|
|
QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options = {}) const override;
|
|
|
|
QVariant themeHint(ThemeHint hint) const override;
|
|
- Appearance appearance() const override;
|
|
+ Qt::Appearance appearance() const override;
|
|
QString standardButtonText(int button) const override;
|
|
QKeySequence standardButtonShortcut(int button) const override;
|
|
|
|
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
|
|
index a79fa4e4b9..cd2e7ef90a 100644
|
|
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
|
|
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
|
|
@@ -544,9 +544,9 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
|
|
return QPlatformTheme::themeHint(hint);
|
|
}
|
|
|
|
-QPlatformTheme::Appearance QCocoaTheme::appearance() const
|
|
+Qt::Appearance QCocoaTheme::appearance() const
|
|
{
|
|
- return qt_mac_applicationIsInDarkMode() ? Appearance::Dark : Appearance::Light;
|
|
+ return qt_mac_applicationIsInDarkMode() ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
|
}
|
|
|
|
QString QCocoaTheme::standardButtonText(int button) const
|
|
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
|
|
index 510b8746da..5d006e6ba9 100644
|
|
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
|
|
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
|
|
@@ -520,9 +520,9 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
|
|
return QPlatformTheme::themeHint(hint);
|
|
}
|
|
|
|
-QPlatformTheme::Appearance QWindowsTheme::appearance() const
|
|
+Qt::Appearance QWindowsTheme::appearance() const
|
|
{
|
|
- return QWindowsContext::isDarkMode() ? Appearance::Dark : Appearance::Light;
|
|
+ return QWindowsContext::isDarkMode() ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
|
}
|
|
|
|
void QWindowsTheme::clearPalettes()
|
|
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
|
|
index 9d5fcc92fe..ea72c96049 100644
|
|
--- a/src/plugins/platforms/windows/qwindowstheme.h
|
|
+++ b/src/plugins/platforms/windows/qwindowstheme.h
|
|
@@ -65,7 +65,7 @@ public:
|
|
#endif
|
|
QVariant themeHint(ThemeHint) const override;
|
|
|
|
- Appearance appearance() const override;
|
|
+ Qt::Appearance appearance() const override;
|
|
|
|
const QPalette *palette(Palette type = SystemPalette) const override
|
|
{ return m_palettes[type]; }
|
|
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
|
index a47720384c..2a70d5f3dd 100644
|
|
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
|
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
|
|
@@ -148,7 +148,7 @@ QString QGtk3Theme::gtkFontName() const
|
|
return QGnomeTheme::gtkFontName();
|
|
}
|
|
|
|
-QPlatformTheme::Appearance QGtk3Theme::appearance() const
|
|
+Qt::Appearance QGtk3Theme::appearance() const
|
|
{
|
|
/*
|
|
https://docs.gtk.org/gtk3/running.html
|
|
@@ -166,7 +166,7 @@ QPlatformTheme::Appearance QGtk3Theme::appearance() const
|
|
QString themeName = qEnvironmentVariable("GTK_THEME");
|
|
const QRegularExpression darkRegex(QStringLiteral("[:-]dark"), QRegularExpression::CaseInsensitiveOption);
|
|
if (!themeName.isEmpty())
|
|
- return darkRegex.match(themeName).hasMatch() ? Appearance::Dark : Appearance::Light;
|
|
+ return darkRegex.match(themeName).hasMatch() ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
|
|
|
/*
|
|
https://docs.gtk.org/gtk3/property.Settings.gtk-application-prefer-dark-theme.html
|
|
@@ -177,16 +177,16 @@ QPlatformTheme::Appearance QGtk3Theme::appearance() const
|
|
*/
|
|
const auto preferDark = gtkSetting<bool>("gtk-application-prefer-dark-theme");
|
|
if (preferDark)
|
|
- return Appearance::Dark;
|
|
+ return Qt::Appearance::Dark;
|
|
|
|
/*
|
|
https://docs.gtk.org/gtk3/property.Settings.gtk-theme-name.html
|
|
*/
|
|
themeName = gtkSetting("gtk-theme-name");
|
|
if (!themeName.isEmpty())
|
|
- return darkRegex.match(themeName).hasMatch() ? Appearance::Dark : Appearance::Light;
|
|
+ return darkRegex.match(themeName).hasMatch() ? Qt::Appearance::Dark : Qt::Appearance::Light;
|
|
|
|
- return Appearance::Unknown;
|
|
+ return Qt::Appearance::Unknown;
|
|
}
|
|
|
|
bool QGtk3Theme::usePlatformNativeDialog(DialogType type) const
|
|
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.h b/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
|
index 5f439067af..89a3b98994 100644
|
|
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
|
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.h
|
|
@@ -52,7 +52,7 @@ public:
|
|
virtual QVariant themeHint(ThemeHint hint) const override;
|
|
virtual QString gtkFontName() const override;
|
|
|
|
- Appearance appearance() const override;
|
|
+ Qt::Appearance appearance() const override;
|
|
|
|
bool usePlatformNativeDialog(DialogType type) const override;
|
|
QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const override;
|
|
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
|
|
index 4171e08286..fa748eb38a 100644
|
|
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
|
|
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
|
|
@@ -303,7 +303,7 @@ static const qreal titleBarButtonSpacing = 8;
|
|
// active: window is active
|
|
// selected: tab is selected
|
|
// hovered: tab is hovered
|
|
-bool isDarkMode() { return qt_mac_applicationIsInDarkMode(); }
|
|
+bool isDarkMode() { return QGuiApplicationPrivate::platformTheme()->appearance() == Qt::Appearance::Dark; }
|
|
|
|
#if QT_CONFIG(tabbar)
|
|
static const QColor lightTabBarTabBackgroundActive(190, 190, 190);
|
|
--
|
|
2.41.0
|
|
|