diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2017-12-17 16:17:38 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-12-18 12:07:10 -0800 |
commit | 05a1626c7e14978c55a9670f35ff72e2a3388096 (patch) | |
tree | 191f020470db156e8e757cffc4d75980b16cabf3 /desktop-widgets/divepicturewidget.cpp | |
parent | 0d01c70f3a376fbba09137ccf677cf0cd754719c (diff) | |
download | subsurface-05a1626c7e14978c55a9670f35ff72e2a3388096.tar.gz |
Implement different zoom levels for dive photos tab
This implements different zoom levels for the dive photos tab as
suggested by Stefan Fuchs <sfuchs@gmx.de> in #898.
The zoom level can be changed using a slider or CTRL+mousewheel.
Zoom levels range from a third of the standard thumbnail size to
thrice the standard thumbnail size.
Thumbnails are cached in maximum resolution and scaled down on
the fly. Because the profile widget took its pictures from the
photo list model, an extra picture copy with a fixed size had
to be introduced.
The UI is still a bit crude.
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/divepicturewidget.cpp')
-rw-r--r-- | desktop-widgets/divepicturewidget.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/desktop-widgets/divepicturewidget.cpp b/desktop-widgets/divepicturewidget.cpp index a6864a5d9..46de16d09 100644 --- a/desktop-widgets/divepicturewidget.cpp +++ b/desktop-widgets/divepicturewidget.cpp @@ -59,3 +59,17 @@ void DivePictureWidget::mousePressEvent(QMouseEvent *event) QListView::mousePressEvent(event); } } + +void DivePictureWidget::wheelEvent(QWheelEvent *event) +{ + if (event->modifiers() == Qt::ControlModifier) { + // Angle delta is given in eighth parts of a degree. A classical mouse + // wheel click is 15 degrees. Each click should correspond to one zoom step. + // Therefore, divide by 15*8=120. To also support touch pads and finer-grained + // mouse wheels, take care to always round away from zero. + int delta = event->angleDelta().y(); + int carry = delta > 0 ? 119 : -119; + emit zoomLevelChanged((delta + carry) / 120); + } else + QListView::wheelEvent(event); +} |