diff options
Diffstat (limited to 'src/platformsupport/themes')
-rw-r--r-- | src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 62 |
1 files changed, 46 insertions, 16 deletions
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index fdd45a49c5..ee295afe6c 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -58,20 +58,22 @@ #include <qpa/qplatformintegration.h> #include <qpa/qplatformservices.h> +#include <algorithm> + QT_BEGIN_NAMESPACE ResourceHelper::ResourceHelper() { - qFill(palettes, palettes + QPlatformTheme::NPalettes, static_cast<QPalette *>(0)); - qFill(fonts, fonts + QPlatformTheme::NFonts, static_cast<QFont *>(0)); + std::fill(palettes, palettes + QPlatformTheme::NPalettes, static_cast<QPalette *>(0)); + std::fill(fonts, fonts + QPlatformTheme::NFonts, static_cast<QFont *>(0)); } void ResourceHelper::clear() { qDeleteAll(palettes, palettes + QPlatformTheme::NPalettes); qDeleteAll(fonts, fonts + QPlatformTheme::NFonts); - qFill(palettes, palettes + QPlatformTheme::NPalettes, static_cast<QPalette *>(0)); - qFill(fonts, fonts + QPlatformTheme::NFonts, static_cast<QFont *>(0)); + std::fill(palettes, palettes + QPlatformTheme::NPalettes, static_cast<QPalette *>(0)); + std::fill(fonts, fonts + QPlatformTheme::NFonts, static_cast<QFont *>(0)); } /*! @@ -95,9 +97,13 @@ public: QGenericUnixThemePrivate() : QPlatformThemePrivate() , systemFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize) - { } + , fixedFont(QStringLiteral("monospace"), systemFont.pointSize()) + { + fixedFont.setStyleHint(QFont::TypeWriter); + } const QFont systemFont; + QFont fixedFont; }; QGenericUnixTheme::QGenericUnixTheme() @@ -108,9 +114,14 @@ QGenericUnixTheme::QGenericUnixTheme() const QFont *QGenericUnixTheme::font(Font type) const { Q_D(const QGenericUnixTheme); - if (type == QPlatformTheme::SystemFont) + switch (type) { + case QPlatformTheme::SystemFont: return &d->systemFont; - return 0; + case QPlatformTheme::FixedFont: + return &d->fixedFont; + default: + return 0; + } } // Helper to return the icon theme paths from XDG. @@ -240,11 +251,18 @@ void QKdeThemePrivate::refresh() toolButtonStyle = Qt::ToolButtonTextUnderIcon; } - // Read system font, ignore 'fixed' 'smallestReadableFont' - if (QFont *systemFont = readKdeFontSetting(kdeSettings, QStringLiteral("font"))) { + // Read system font, ignore 'smallestReadableFont' + if (QFont *systemFont = readKdeFontSetting(kdeSettings, QStringLiteral("font"))) resources.fonts[QPlatformTheme::SystemFont] = systemFont; - } else { + else resources.fonts[QPlatformTheme::SystemFont] = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize); + + if (QFont *fixedFont = readKdeFontSetting(kdeSettings, QStringLiteral("fixed"))) { + resources.fonts[QPlatformTheme::FixedFont] = fixedFont; + } else { + fixedFont = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize); + fixedFont->setStyleHint(QFont::TypeWriter); + resources.fonts[QPlatformTheme::FixedFont] = fixedFont; } } @@ -461,9 +479,13 @@ class QGnomeThemePrivate : public QPlatformThemePrivate public: QGnomeThemePrivate() : systemFont(QLatin1Literal(defaultSystemFontNameC), defaultSystemFontSize) - {} + , fixedFont(QStringLiteral("monospace"), systemFont.pointSize()) + { + fixedFont.setStyleHint(QFont::TypeWriter); + } const QFont systemFont; + QFont fixedFont; }; QGnomeTheme::QGnomeTheme() @@ -501,10 +523,14 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const const QFont *QGnomeTheme::font(Font type) const { Q_D(const QGnomeTheme); - if (type == QPlatformTheme::SystemFont) - return &d->systemFont; - - return 0; + switch (type) { + case QPlatformTheme::SystemFont: + return &d->systemFont; + case QPlatformTheme::FixedFont: + return &d->fixedFont; + default: + return 0; + } } /*! @@ -534,7 +560,11 @@ QStringList QGenericUnixTheme::themeNames() #ifndef QT_NO_SETTINGS result.push_back(QLatin1String(QKdeTheme::name)); #endif - } else { // Gnome, Unity, other Gtk-based desktops like XFCE. + } else if (desktopEnvironment == QByteArrayLiteral("GNOME") || + desktopEnvironment == QByteArrayLiteral("UNITY") || + desktopEnvironment == QByteArrayLiteral("MATE") || + desktopEnvironment == QByteArrayLiteral("XFCE") || + desktopEnvironment == QByteArrayLiteral("LXDE")) { // Gtk-based desktops // prefer the GTK2 theme implementation with native dialogs etc. result.push_back(QStringLiteral("gtk2")); // fallback to the generic Gnome theme if loading the GTK2 theme fails |