summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp27
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes_p.h2
-rw-r--r--src/plugins/platformthemes/gtk2/qgtk2theme.cpp8
-rw-r--r--src/plugins/platformthemes/gtk2/qgtk2theme.h3
4 files changed, 33 insertions, 7 deletions
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index bf73d30871..dac417ad80 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -519,15 +519,23 @@ const char *QGnomeTheme::name = "gnome";
class QGnomeThemePrivate : public QPlatformThemePrivate
{
public:
- QGnomeThemePrivate()
- : systemFont(QLatin1Literal(defaultSystemFontNameC), defaultSystemFontSize)
- , fixedFont(QStringLiteral("monospace"), systemFont.pointSize())
+ QGnomeThemePrivate() : fontsConfigured(false) { }
+ void configureFonts(QString gtkFontName) const
{
+ Q_ASSERT(!fontsConfigured);
+ const int split = gtkFontName.lastIndexOf(QChar::Space);
+ float size = gtkFontName.mid(split+1).toFloat();
+ QString fontName = gtkFontName.left(split);
+
+ systemFont = QFont(fontName, size);
+ fixedFont = QFont(QLatin1String("monospace"), systemFont.pointSize());
fixedFont.setStyleHint(QFont::TypeWriter);
+ fontsConfigured = true;
}
- const QFont systemFont;
- QFont fixedFont;
+ mutable QFont systemFont;
+ mutable QFont fixedFont;
+ mutable bool fontsConfigured;
};
QGnomeTheme::QGnomeTheme()
@@ -565,9 +573,11 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
const QFont *QGnomeTheme::font(Font type) const
{
Q_D(const QGnomeTheme);
+ if (!d->fontsConfigured)
+ d->configureFonts(gtkFontName());
switch (type) {
case QPlatformTheme::SystemFont:
- return &d->systemFont;
+ return &d->systemFont;
case QPlatformTheme::FixedFont:
return &d->fixedFont;
default:
@@ -575,6 +585,11 @@ const QFont *QGnomeTheme::font(Font type) const
}
}
+QString QGnomeTheme::gtkFontName() const
+{
+ return QStringLiteral("%1 %2").arg(QLatin1String(defaultSystemFontNameC)).arg(defaultSystemFontSize);
+}
+
QString QGnomeTheme::standardButtonText(int button) const
{
switch (button) {
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
index d01e6d485c..509a26d1db 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
@@ -111,6 +111,8 @@ public:
virtual const QFont *font(Font type) const;
QString standardButtonText(int button) const Q_DECL_OVERRIDE;
+ virtual QString gtkFontName() const;
+
static const char *name;
};
diff --git a/src/plugins/platformthemes/gtk2/qgtk2theme.cpp b/src/plugins/platformthemes/gtk2/qgtk2theme.cpp
index 812f4bc000..4df3a304e1 100644
--- a/src/plugins/platformthemes/gtk2/qgtk2theme.cpp
+++ b/src/plugins/platformthemes/gtk2/qgtk2theme.cpp
@@ -85,6 +85,14 @@ QVariant QGtk2Theme::themeHint(QPlatformTheme::ThemeHint hint) const
}
}
+QString QGtk2Theme::gtkFontName() const
+{
+ QString cfgFontName = gtkSetting("gtk-font-name");
+ if (!cfgFontName.isEmpty())
+ return cfgFontName;
+ return QGnomeTheme::gtkFontName();
+}
+
bool QGtk2Theme::usePlatformNativeDialog(DialogType type) const
{
switch (type) {
diff --git a/src/plugins/platformthemes/gtk2/qgtk2theme.h b/src/plugins/platformthemes/gtk2/qgtk2theme.h
index a0bd34ed9f..c74e58e648 100644
--- a/src/plugins/platformthemes/gtk2/qgtk2theme.h
+++ b/src/plugins/platformthemes/gtk2/qgtk2theme.h
@@ -51,7 +51,8 @@ class QGtk2Theme : public QGnomeTheme
public:
QGtk2Theme();
- QVariant themeHint(ThemeHint hint) const;
+ virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
+ virtual QString gtkFontName() const Q_DECL_OVERRIDE;
bool usePlatformNativeDialog(DialogType type) const;
QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const;