diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-09-23 16:29:28 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-09-24 17:55:11 +0200 |
commit | 49e7591dd3bc22f0ed02f14f330f1dd834ad537b (patch) | |
tree | a7d9b8c56396a6ccfd5624f8811ce72867b677ad /src/assistant/assistant/helpviewer_p.h | |
parent | 401d691d40df404ec0a4fc2c06d438deff796ca6 (diff) |
Zoom the documentation according to the system DPI by default
QtWebKit follows the web standard use of 96 DPI for font sizes and
this is a good compromise for the web, but this would require each
Assistant user to zoom the text manually without the benefit of
keeping existing content working (since we don't show any external
content in Assistant that could break with a higher DPI).
HiDPI on OS X already handles the issue by scaling the whole page by
two, but since we don't completely support DPI awareness on Windows,
Assistant assets and text will be scaled but the documentation
itself will be microscopic.
Use the zoomFactor to adjust the DPI according to system settings
by dividing QScreen::logicalDotsPerInch() by 96.
Task-number: QTBUG-41076
Change-Id: I5644d0b383fcaf04bed156207afca9b322ea18a6
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'src/assistant/assistant/helpviewer_p.h')
-rw-r--r-- | src/assistant/assistant/helpviewer_p.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/assistant/assistant/helpviewer_p.h b/src/assistant/assistant/helpviewer_p.h index 136950e90..304162351 100644 --- a/src/assistant/assistant/helpviewer_p.h +++ b/src/assistant/assistant/helpviewer_p.h @@ -49,6 +49,9 @@ #include <QtCore/QObject> #ifdef QT_NO_WEBKIT #include <QtWidgets/QTextBrowser> +#else +#include <QtGui/QGuiApplication> +#include <QtGui/QScreen> #endif QT_BEGIN_NAMESPACE @@ -63,12 +66,22 @@ public: : zoomCount(zoom) , forceFont(false) , lastAnchor(QString()) + , m_loadFinished(false) + { } #else HelpViewerPrivate() -#endif + : m_loadFinished(false) { - m_loadFinished = false; + // The web uses 96dpi by default on the web to preserve the font size across platforms, but + // since we control the content for the documentation, we want the system DPI to be used. + // - OS X reports 72dpi but doesn't allow changing the DPI, ignore anything below a 1.0 ratio to handle this. + // - On Windows and Linux don't zoom the default web 96dpi below a 1.25 ratio to avoid + // filtered images in the doc unless the font readability difference is considerable. + webDpiRatio = QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96.; + if (webDpiRatio < 1.25) + webDpiRatio = 1.0; } +#endif #ifdef QT_NO_WEBKIT bool hasAnchorAt(QTextBrowser *browser, const QPoint& pos) @@ -112,6 +125,8 @@ public: int zoomCount; bool forceFont; QString lastAnchor; +#else + qreal webDpiRatio; #endif // QT_NO_WEBKIT public: |