summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2013-06-25 19:12:08 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-07-05 17:29:18 +0200
commit691cb20d95357cdaa7d158a3c26f3ca66cdbe537 (patch)
treef84cb5cab52f036325c5da48d6b9cc486dbb8e39 /src/plugins/platforms
parentea7da7c241c7334305f256102d767bf3904370bd (diff)
Add API to let applications integrate with the system fonts
This patch does 2 things mainly: - Adds a QPlatformTheme font type for fixed fonts. It's important because some OS provide specific monospaced fonts and we want to let our applications to use the preferred fonts by default. - Adds a new method and enum to QFontDatabase that expose the font types that applications might need, so that they can make the applications use the specific fonts that the system recommends. This data was already available within Qt through the QPlatformTheme, but it was not possible to use this data by Qt users. This new method exposes such data. Change-Id: Ic194c1e4bc07a70640672afd82ba756b87606985 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: David Faure (KDE) <faure@kde.org>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemsettings.mm4
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp3
2 files changed, 7 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
index af817bd4c5..194394d11a 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
@@ -264,6 +264,10 @@ QHash<QPlatformTheme::Font, QFont *> qt_mac_createRoleFonts()
fonts.insert(QPlatformTheme::SmallFont, qt_mac_qfontForThemeFont(kThemeSmallSystemFont));
fonts.insert(QPlatformTheme::MiniFont, qt_mac_qfontForThemeFont(kThemeMiniSystemFont));
+ QFont* fixedFont = new QFont(QStringLiteral("Monaco"), fonts[QPlatformTheme::SystemFont]->pointSize());
+ fixedFont->setStyleHint(QFont::TypeWriter);
+ fonts.insert(QPlatformTheme::FixedFont, fixedFont);
+
return fonts;
}
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index 2531dc681a..83d93b08bd 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -404,6 +404,8 @@ void QWindowsTheme::refreshFonts()
const QFont messageBoxFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMessageFont);
const QFont statusFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfStatusFont);
const QFont titleFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfCaptionFont);
+ QFont fixedFont(QStringLiteral("Courier New"), messageBoxFont.pointSize());
+ fixedFont.setStyleHint(QFont::TypeWriter);
LOGFONT lfIconTitleFont;
SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0);
@@ -418,6 +420,7 @@ void QWindowsTheme::refreshFonts()
m_fonts[MdiSubWindowTitleFont] = new QFont(titleFont);
m_fonts[DockWidgetTitleFont] = new QFont(titleFont);
m_fonts[ItemViewFont] = new QFont(iconTitleFont);
+ m_fonts[FixedFont] = new QFont(fixedFont);
if (QWindowsContext::verboseTheming)
qDebug() << __FUNCTION__ << '\n'