From 691cb20d95357cdaa7d158a3c26f3ca66cdbe537 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 25 Jun 2013 19:12:08 +0200 Subject: 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 Reviewed-by: Friedemann Kleint Reviewed-by: David Faure (KDE) --- tests/manual/qpainfo/main.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/manual/qpainfo/main.cpp b/tests/manual/qpainfo/main.cpp index 6b712304a0..0f5119bab3 100644 --- a/tests/manual/qpainfo/main.cpp +++ b/tests/manual/qpainfo/main.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -85,6 +86,12 @@ std::ostream &operator<<(std::ostream &str, const QStringList &l) return str; } +std::ostream &operator<<(std::ostream &str, const QFont &f) +{ + std::cout << '"' << f.family().toStdString() << "\" " << f.pointSize(); + return str; +} + static QStringList toNativeSeparators(QStringList in) { for (int i = 0; i < in.size(); ++i) @@ -184,7 +191,12 @@ int main(int argc, char **argv) << " from " << platformTheme->themeHint(QPlatformTheme::IconThemeSearchPaths).toStringList() << '\n'; } if (const QFont *systemFont = platformTheme->font()) - std::cout << " System font: \"" << systemFont->family().toStdString() << "\" " << systemFont->pointSize() << '\n'; + std::cout << " System font: " << *systemFont<< '\n'; + std::cout << " General font : " << QFontDatabase::systemFont(QFontDatabase::GeneralFont) << '\n' + << " Fixed font : " << QFontDatabase::systemFont(QFontDatabase::FixedFont) << '\n' + << " Title font : " << QFontDatabase::systemFont(QFontDatabase::TitleFont) << '\n' + << " Smallest font: " << QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont) << "\n\n"; + if (platformTheme->usePlatformNativeDialog(QPlatformTheme::FileDialog)) std::cout << " Native file dialog\n"; if (platformTheme->usePlatformNativeDialog(QPlatformTheme::ColorDialog)) -- cgit v1.2.3