forked from pool/libqt5-qtbase
e4c21e8f38
- Added 0001-QFileDialog-emit-urlsSelected-urlSelected-in-accept.patch, 0002-QUrl-fromLocalFile-QString-should-lead-to-an-empty-U.patch, 0003-QFileDialog-turn-workingDirectory-into-a-QUrl.patch and 0004-QFileDialog-implement-getOpenFileUrl-and-friends-for.patch from upstream to improve QFileDialog behaviour with both local and remote URL's - Added 0001-QKdeTheme-use-system-wide-kdeglobals-as-a-fallback.patch: QTBUG-36184 - Added 0001-Add-QFont-strategy-to-disable-subpixel-antialiasing.patch, 0002-Move-SubpixelAntialiasingType-from-QFontEngineFT-to-.patch, 0003-Support-autohint-and-lcdfilter-fontconfig-configurat.patch and 0004-GTK2-theme-should-use-GTK-configured-font-variant.patch QTBUG-40396, QTBUG-32254, QTBUG-39643 OBS-URL: https://build.opensuse.org/request/show/255354 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libqt5-qtbase?expand=0&rev=30
127 lines
4.7 KiB
Diff
127 lines
4.7 KiB
Diff
From d7afdc53b28d107bbf8cdfd52777cb7cb9f2c10d Mon Sep 17 00:00:00 2001
|
|
From: Allan Sandfeld Jensen <allan.jensen@digia.com>
|
|
Date: Tue, 12 Aug 2014 16:59:18 +0200
|
|
Subject: [PATCH 4/4] GTK2 theme should use GTK configured font variant
|
|
|
|
This patch makes the GTK2 theme read the font configuration and use
|
|
that as the default system font.
|
|
|
|
Task-number: QTBUG-39643
|
|
Change-Id: Ieacf8968e54f34c6d44669350d349c9a96ed6cc5
|
|
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
|
|
(cherry picked from commit 2a33bfcfd174d503e2f98c66d8de0a68783015da)
|
|
---
|
|
.../themes/genericunix/qgenericunixthemes.cpp | 27 +++++++++++++++++-----
|
|
.../themes/genericunix/qgenericunixthemes_p.h | 2 ++
|
|
src/plugins/platformthemes/gtk2/qgtk2theme.cpp | 8 +++++++
|
|
src/plugins/platformthemes/gtk2/qgtk2theme.h | 3 ++-
|
|
4 files changed, 33 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
|
|
index 4a1d67f..b68aa85 100644
|
|
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
|
|
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
|
|
@@ -482,15 +482,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()
|
|
@@ -528,9 +536,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:
|
|
@@ -538,6 +548,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 36fcdd8..fd65402 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 812f4bc..4df3a30 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 a0bd34e..c74e58e 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;
|
|
--
|
|
2.1.1
|
|
|