diff options
Diffstat (limited to 'src/plugins/platformthemes/gtk3/qgtk3theme.cpp')
-rw-r--r-- | src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp index c2bc49af47..9d23ba7e48 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> @@ -101,7 +100,11 @@ QGtk3Theme::QGtk3Theme() SETTING_CONNECT("gtk-font-name"); SETTING_CONNECT("gtk-application-prefer-dark-theme"); SETTING_CONNECT("gtk-theme-name"); + SETTING_CONNECT("gtk-cursor-theme-name"); + SETTING_CONNECT("gtk-cursor-theme-size"); #undef SETTING_CONNECT + + m_storage.reset(new QGtk3Storage); } static inline QVariant gtkGetLongPressTime() @@ -136,6 +139,14 @@ QVariant QGtk3Theme::themeHint(QPlatformTheme::ThemeHint hint) const return QVariant(gtkSetting("gtk-icon-theme-name")); case QPlatformTheme::SystemIconFallbackThemeName: return QVariant(gtkSetting("gtk-fallback-icon-theme")); + case QPlatformTheme::MouseCursorTheme: + return QVariant(gtkSetting("gtk-cursor-theme-name")); + case QPlatformTheme::MouseCursorSize: { + int s = gtkSetting<gint>("gtk-cursor-theme-size"); + if (s > 0) + return QVariant(QSize(s, s)); + return QGnomeTheme::themeHint(hint); + } default: return QGnomeTheme::themeHint(hint); } @@ -149,45 +160,10 @@ QString QGtk3Theme::gtkFontName() const return QGnomeTheme::gtkFontName(); } -Qt::Appearance QGtk3Theme::appearance() const +Qt::ColorScheme QGtk3Theme::colorScheme() const { - /* - 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"); - const QRegularExpression darkRegex(QStringLiteral("[:-]dark"), QRegularExpression::CaseInsensitiveOption); - if (!themeName.isEmpty()) - return darkRegex.match(themeName).hasMatch() ? 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<bool>("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 darkRegex.match(themeName).hasMatch() ? Qt::Appearance::Dark : Qt::Appearance::Light; - - return Qt::Appearance::Unknown; + Q_ASSERT(m_storage); + return m_storage->colorScheme(); } bool QGtk3Theme::usePlatformNativeDialog(DialogType type) const @@ -243,4 +219,30 @@ bool QGtk3Theme::useNativeFileDialog() return gtk_check_version(3, 15, 5) == nullptr; } +const QPalette *QGtk3Theme::palette(Palette type) const +{ + Q_ASSERT(m_storage); + return m_storage->palette(type); +} + +QPixmap QGtk3Theme::standardPixmap(StandardPixmap sp, const QSizeF &size) const +{ + Q_ASSERT(m_storage); + return m_storage->standardPixmap(sp, size); +} + +const QFont *QGtk3Theme::font(Font type) const +{ + Q_ASSERT(m_storage); + return m_storage->font(type); +} + +QIcon QGtk3Theme::fileIcon(const QFileInfo &fileInfo, + QPlatformTheme::IconOptions iconOptions) const +{ + Q_UNUSED(iconOptions); + Q_ASSERT(m_storage); + return m_storage->fileIcon(fileInfo); +} + QT_END_NAMESPACE |