Details
- Reviewers
sars davidedmundson - Commits
- R382:23c3a433d339: Add HiDPI support
Diff Detail
- Branch
- master
- Lint
No Linters Available - Unit
No Unit Test Coverage - Build Status
Buildable 11255 Build 11273: arc lint + arc unit
src/ksanewidget_p.cpp | ||
---|---|---|
870 | I don't understand this bit. What does m_previewImg's devicePixelRatio have to do with anything if we're only now about to create m_previewImg? It looks more like this needs a fix in m_previewViewer |
src/ksanewidget_p.cpp | ||
---|---|---|
870 | Ah, yes, it's needless, thanks. |
Now I must show my ignorance... why do we need this devicePixelRatio in ksanevewer/selectionitem?
When setting and reading the scan areas we are using ratios of maximum....
https://doc.qt.io/qt-5/highdpi.html
Qt supports a high DPI mode where the main coordinate system is virtualized and made independent of the display pixel density.
...
Geometry is now specified in device independent pixels. This includes widget and item geometry, event geometry, desktop, window and screen
geometry, and animation velocities. Rendered output is in device pixels, which corresponds to the display resolution. The ratio between the
device independent and device pixel coordinate systems is the devicePixelRatio.
https://doc.qt.io/qt-5/qpainter.html#drawing-high-resolution-versions-of-pixmaps-and-images
High resolution versions of pixmaps have a device pixel ratio value larger than 1 (see QImageReader, QPixmap::devicePixelRatio()). Should it
match the value of the underlying QPaintDevice, it is drawn directly onto the device with no additional transformation applied.This is for example the case when drawing a QPixmap of 64x64 pixels size with a device pixel ratio of 2 onto a high DPI screen which also has
a device pixel ratio of 2. Note that the pixmap is then effectively 32x32 pixels in user space.
We want to draw scanned images without highdpi scaling by Qt, so we set devicePixelRatio for them,
and thus the size of the scanned image is in device pixels. SelectionItem was modified to keep its
geometry also in device pixels to avoid extra changes in ksaneviewer.cpp. For consistency the same
should be done for "hide" items to avoid transforms such as "d->hideLeft->setRect(fromNative(rect, dpr));",
but it requires to create a separate class for them.
You can test the change without HiDPI monitor by setting env var QT_SCALE_FACTOR=2
src/selectionitem.cpp | ||
---|---|---|
261 | use pen->setWidth(0) instead;
|
emulate missing QGraphicsView::mapToScene(const QPointF &) by using QPainterPath wrapper