From bcd3660a3527327117b46e104d16204a64fe0b9f Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Wed, 19 Oct 2016 15:56:14 +0200 Subject: Scale QWebView DPI resolution to match desktop DPI resolution Test-Information: Tested that at 1em scaling, the default, the main text in the chat style has the same height as the nicknames in the roster. Tested with Qt 5.4.2 on macOS 10.12 on a retina system, with Qt 5.4.2 on macOS 10.12 on a non-retina system, and Windows 8 with Qt 5.7.0 with QtWebKit Technology Preview 4. Change-Id: I10701c411d9f787bf497eb6aab208a0f3fda621c diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp index c3320d8..414f098 100644 --- a/Swift/QtUI/QtWebKitChatView.cpp +++ b/Swift/QtUI/QtWebKitChatView.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -347,7 +348,11 @@ void QtWebKitChatView::resetView() { assert(!body.isNull()); body.setAttribute("onscroll", "chatwindow.verticalScrollBarPositionChanged(document.body.scrollTop / (document.body.scrollHeight - window.innerHeight))"); - webView_->settings()->setFontSize(QWebSettings::DefaultFontSize, QApplication::font().pointSize()); + // Adjust web view default 96 DPI setting to screen DPI. + // For more information see https://webkit.org/blog/57/css-units/ + webView_->setZoomFactor(QApplication::desktop()->screen()->logicalDpiX() / 96.0); + + body.setStyleProperty("font-size", QString("%1pt").arg(QApplication::font().pointSize())); } static QWebElement findElementWithID(QWebElement document, QString elementName, QString id) { -- cgit v0.10.2-6-g49f6