summaryrefslogtreecommitdiff
path: root/vcl/qt5/Qt5Graphics.cxx
diff options
context:
space:
mode:
authorLuca Carlon <carlon.luca@gmail.com>2020-02-29 13:39:29 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2020-03-09 14:19:49 +0100
commit358991e3b0a49bb201c2f1e4be900ee99aac9aa8 (patch)
tree320852cd425045cbd1eff4198357bbaa05f348fe /vcl/qt5/Qt5Graphics.cxx
parent2c5655d72401e6b6e917ece381e879b30680d20f (diff)
tdf#127687 Qt5 introduce basic HiDPI scaling
For tdf#124292, Qt's own HiDPI scaling was explicitly disabled, but it turns out, you can't really scale QStyle painting then. This patch series had a 2nd approach also used by Gtk+ currently, which relied on the scaling of ths Cairo surface, which works surprisingly good, but has to lie about the real DPI value, so nothing is scaled twice. Also all icons are then scaled instead of rendered with the proper resolution. When HiDPI support in Qt is enabled, and the application is started using QT_SCALE_FACTOR=1.25, Qt simply lowers the reported resolution, keeps the logical DPI value of 96 and changes the devicePixelRatio to the specified value. But LO still expects the real DPI values and sizes, so we have to multiply a lot of rectangles, sizes and positions. The current result is far from perfect, which you can see with the various graphics glitches, but it at least doesn't crash anymore in the ControlType::Editbox sizing code. The main problem is all the up and downscaling in the getNativeControlRegion code, so LO knows the size of the widgets for the correct layouting, since there seem to be no API to get the scaled values from Qt / QStyle. Change-Id: I687b1df6ef27724ce68326d256e9addccd72e759 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86239 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/qt5/Qt5Graphics.cxx')
-rw-r--r--vcl/qt5/Qt5Graphics.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/vcl/qt5/Qt5Graphics.cxx b/vcl/qt5/Qt5Graphics.cxx
index e9d57d2d86af..34f610812d45 100644
--- a/vcl/qt5/Qt5Graphics.cxx
+++ b/vcl/qt5/Qt5Graphics.cxx
@@ -45,8 +45,10 @@ Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage )
if (!initWidgetDrawBackends(false))
{
if (!Qt5Data::noNativeControls())
- m_pWidgetDraw.reset(new Qt5Graphics_Controls());
+ m_pWidgetDraw.reset(new Qt5Graphics_Controls(*this));
}
+ if (m_pFrame)
+ setDevicePixelRatioF(m_pFrame->devicePixelRatioF());
}
Qt5Graphics::~Qt5Graphics() { ReleaseFonts(); }
@@ -116,8 +118,10 @@ void Qt5Graphics::handleDamage(const tools::Rectangle& rDamagedRegion)
assert(!rDamagedRegion.IsEmpty());
QImage* pImage = static_cast<Qt5Graphics_Controls*>(m_pWidgetDraw.get())->getImage();
+ QImage blit(*pImage);
+ blit.setDevicePixelRatio(1);
Qt5Painter aPainter(*this);
- aPainter.drawImage(QPoint(rDamagedRegion.getX(), rDamagedRegion.getY()), *pImage);
+ aPainter.drawImage(QPoint(rDamagedRegion.getX(), rDamagedRegion.getY()), blit);
aPainter.update(toQRect(rDamagedRegion));
}