diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-08-02 14:14:15 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-02 20:38:54 +0200 |
commit | 0e3dcf362460a2e4457f7059343d9720638360b8 (patch) | |
tree | bcbdc7b4098b2408050004fac236883acbebc493 /src/platformsupport/themes/genericunix | |
parent | e247e2810cf12254335f2f4418424d99995579bc (diff) |
Fix default font for X11.
Qt 5 X11 applications currently have differing fonts since they
no longer read ~/.config/Trolltech.conf.
Set the default font value 4.8 would return for
XRender/FontConfig in the theme classes.
Change-Id: Ie0a77e6781a47a68fd67895821ab1773c25e0470
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/platformsupport/themes/genericunix')
-rw-r--r-- | src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 35 | ||||
-rw-r--r-- | src/platformsupport/themes/genericunix/qgenericunixthemes_p.h | 11 |
2 files changed, 43 insertions, 3 deletions
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 970b57de63..a26592d6ac 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -82,6 +82,23 @@ void ResourceHelper::clear() const char *QGenericUnixTheme::name = "generic"; +// Default system font, corresponding to the value returned by 4.8 for +// XRender/FontConfig which we can now assume as default. +static const char defaultSystemFontNameC[] = "Sans Serif"; +enum { defaultSystemFontSize = 9 }; + +QGenericUnixTheme::QGenericUnixTheme() + : m_systemFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize) +{ +} + +const QFont *QGenericUnixTheme::font(Font type) const +{ + if (type == QPlatformTheme::SystemFont) + return &m_systemFont; + return 0; +} + // Helper to return the icon theme paths from XDG. QStringList QGenericUnixTheme::xdgIconThemePaths() { @@ -250,7 +267,11 @@ void QKdeTheme::refresh() } // Read system font, ignore 'fixed' 'smallestReadableFont' - m_resources.fonts[SystemFont] = readKdeFontSetting(kdeSettings, QStringLiteral("font")); + if (QFont *systemFont = readKdeFontSetting(kdeSettings, QStringLiteral("font"))) { + m_resources.fonts[SystemFont] = systemFont; + } else { + m_resources.fonts[SystemFont] = new QFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize); + } } QString QKdeTheme::globalSettingsFile() const @@ -340,6 +361,11 @@ QPlatformTheme *QKdeTheme::createKdeTheme() const char *QGnomeTheme::name = "gnome"; +QGnomeTheme::QGnomeTheme() + : m_systemFont(QLatin1String(defaultSystemFontNameC), defaultSystemFontSize) +{ +} + QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const { switch (hint) { @@ -365,6 +391,13 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const return QPlatformTheme::themeHint(hint); } +const QFont *QGnomeTheme::font(Font type) const +{ + if (type == QPlatformTheme::SystemFont) + return &m_systemFont; + return 0; +} + /*! \brief Creates a UNIX theme according to the detected desktop environment. */ diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h index 64b2db0a10..215162945e 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h @@ -45,6 +45,7 @@ #include <qpa/qplatformtheme.h> #include <QtCore/QString> #include <QtCore/QStringList> +#include <QtGui/QFont> QT_BEGIN_HEADER @@ -65,16 +66,20 @@ public: class QGenericUnixTheme : public QPlatformTheme { public: - QGenericUnixTheme() {} + QGenericUnixTheme(); static QPlatformTheme *createUnixTheme(const QString &name); static QStringList themeNames(); + virtual const QFont *font(Font type) const; virtual QVariant themeHint(ThemeHint hint) const; static QStringList xdgIconThemePaths(); static const char *name; + +private: + const QFont m_systemFont; }; #ifndef QT_NO_SETTINGS @@ -113,12 +118,14 @@ private: class QGnomeTheme : public QPlatformTheme { public: - QGnomeTheme() {} + QGnomeTheme(); virtual QVariant themeHint(ThemeHint hint) const; + virtual const QFont *font(Font type) const; static const char *name; private: + const QFont m_systemFont; }; QPlatformTheme *qt_createUnixTheme(); |