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>
This commit is contained in:
parent
e247e2810c
commit
0e3dcf3624
@ -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.
|
||||
*/
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user