summaryrefslogtreecommitdiffstats
path: root/src/plugins/platformthemes
diff options
context:
space:
mode:
authorYuhang Zhao <2546789017@qq.com>2022-12-20 17:19:51 +0800
committerYuhang Zhao <2546789017@qq.com>2022-12-21 06:38:09 +0800
commit09141ebad7109b90e5dfdbf3b065543b8be14641 (patch)
tree2ce9236261eab055955886e9ddad87c564aeb16d /src/plugins/platformthemes
parent528f28f380e3f0c55b9a305f6b208dc1a2db73d6 (diff)
Cleanup QGtk3Theme
1. Remove unused include. 2. Replace unnecessary null checks with asserts. 3. Remove dead code after the cleanup. Change-Id: Ia3c01ae8a1fb491d513071c09f8095c93e35c292 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'src/plugins/platformthemes')
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3theme.cpp55
1 files changed, 10 insertions, 45 deletions
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
index 7e7e3e5d9d..03371f0492 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
@@ -5,7 +5,6 @@
#include "qgtk3dialoghelpers.h"
#include "qgtk3menu.h"
#include <QVariant>
-#include <QtCore/qregularexpression.h>
#include <QGuiApplication>
#include <qpa/qwindowsysteminterface.h>
@@ -177,46 +176,8 @@ QString QGtk3Theme::gtkFontName() const
Qt::Appearance QGtk3Theme::appearance() const
{
- if (m_storage)
- return m_storage->appearance();
- /*
- https://docs.gtk.org/gtk3/running.html
-
- It's possible to set a theme variant after the theme name when using GTK_THEME:
-
- GTK_THEME=Adwaita:dark
-
- Some themes also have "-dark" as part of their name.
-
- We test this environment variable first because the documentation says
- it's mainly used for easy debugging, so it should be possible to use it
- to override any other settings.
- */
- QString themeName = qEnvironmentVariable("GTK_THEME");
- if (!themeName.isEmpty())
- return themeName.contains("dark"_L1, Qt::CaseInsensitive)
- ? Qt::Appearance::Dark : Qt::Appearance::Light;
-
- /*
- https://docs.gtk.org/gtk3/property.Settings.gtk-application-prefer-dark-theme.html
-
- This setting controls which theme is used when the theme specified by
- gtk-theme-name provides both light and dark variants. We can save a
- regex check by testing this property first.
- */
- const auto preferDark = gtkSetting<gboolean>("gtk-application-prefer-dark-theme");
- if (preferDark)
- return Qt::Appearance::Dark;
-
- /*
- https://docs.gtk.org/gtk3/property.Settings.gtk-theme-name.html
- */
- themeName = gtkSetting("gtk-theme-name");
- if (!themeName.isEmpty())
- return themeName.contains("dark"_L1, Qt::CaseInsensitive)
- ? Qt::Appearance::Dark : Qt::Appearance::Light;
-
- return Qt::Appearance::Unknown;
+ Q_ASSERT(m_storage);
+ return m_storage->appearance();
}
bool QGtk3Theme::usePlatformNativeDialog(DialogType type) const
@@ -274,23 +235,27 @@ bool QGtk3Theme::useNativeFileDialog()
const QPalette *QGtk3Theme::palette(Palette type) const
{
- return m_storage ? m_storage->palette(type) : QPlatformTheme::palette(type);
+ Q_ASSERT(m_storage);
+ return m_storage->palette(type);
}
QPixmap QGtk3Theme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
{
- return m_storage ? m_storage->standardPixmap(sp, size) : QPlatformTheme::standardPixmap(sp, size);
+ Q_ASSERT(m_storage);
+ return m_storage->standardPixmap(sp, size);
}
const QFont *QGtk3Theme::font(Font type) const
{
- return m_storage ? m_storage->font(type) : QGnomeTheme::font(type);
+ Q_ASSERT(m_storage);
+ return m_storage->font(type);
}
QIcon QGtk3Theme::fileIcon(const QFileInfo &fileInfo,
QPlatformTheme::IconOptions iconOptions) const
{
- return m_storage ? m_storage->fileIcon(fileInfo) : QGnomeTheme::fileIcon(fileInfo, iconOptions);
+ Q_ASSERT(m_storage);
+ return m_storage->fileIcon(fileInfo);
}
QT_END_NAMESPACE