aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-photo/PhotoView.cpp
diff options
context:
space:
mode:
authorlbartoletti <l.bartoletti@free.fr>2018-11-07 22:57:30 +0100
committerlbartoletti <l.bartoletti@free.fr>2018-11-07 22:57:30 +0100
commit67bdf467a505a87f75b52f7142fce4dcb3153d5d (patch)
tree6497ef766ee6266895cccc37dc3529819a077ad4 /src-qt5/desktop-utils/lumina-photo/PhotoView.cpp
parentinit lumina-photo (diff)
downloadlumina-67bdf467a505a87f75b52f7142fce4dcb3153d5d.tar.gz
lumina-67bdf467a505a87f75b52f7142fce4dcb3153d5d.tar.bz2
lumina-67bdf467a505a87f75b52f7142fce4dcb3153d5d.zip
q5sys review:
- Menu > View > reword last entry to "Fit to Window" - Double Click : Toggle between Normal size and Fit Graphics View - Scroll Wheel : zoom in = down / zoom out = up - Ctrl + Scroll Wheel : next image = down / previous image = up
Diffstat (limited to 'src-qt5/desktop-utils/lumina-photo/PhotoView.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-photo/PhotoView.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src-qt5/desktop-utils/lumina-photo/PhotoView.cpp b/src-qt5/desktop-utils/lumina-photo/PhotoView.cpp
index def476b5..718edf99 100644
--- a/src-qt5/desktop-utils/lumina-photo/PhotoView.cpp
+++ b/src-qt5/desktop-utils/lumina-photo/PhotoView.cpp
@@ -1,5 +1,7 @@
#include "PhotoView.h"
+#include <QDebug>
+#include <QWheelEvent>
PhotoView::PhotoView (QWidget *parent) : QGraphicsView (parent)
{
@@ -12,19 +14,68 @@ PhotoView::PhotoView (QWidget *parent) : QGraphicsView (parent)
void PhotoView::zoomIn ()
{
scale (scaleFactor, scaleFactor);
+ isFit = false;
}
void PhotoView::zoomOut ()
{
scale (invScaleFactor, invScaleFactor);
+ isFit = false;
}
void PhotoView::zoomNormal ()
{
resetMatrix ();
+ isFit = false;
}
void PhotoView::zoomFit ()
{
fitInView (sceneRect (), Qt::KeepAspectRatio);
+ isFit = true;
+}
+
+bool PhotoView::eventFilter (QObject *, QEvent *event)
+{
+ if (event->type () == QEvent::Wheel)
+ {
+ QWheelEvent *wheel_event = static_cast<QWheelEvent *> (event);
+ if (wheel_event->delta () > 0)
+ {
+ if (wheel_event->modifiers () == Qt::ControlModifier)
+ {
+ emit nextImage ();
+ }
+ else
+ {
+ scale (scaleFactor, scaleFactor);
+ return true;
+ }
+ }
+ else if (wheel_event->delta () < 0)
+ {
+ if (wheel_event->modifiers () == Qt::ControlModifier)
+ {
+ emit prevImage ();
+ }
+ else
+ {
+ scale (invScaleFactor, invScaleFactor);
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+void PhotoView::mouseDoubleClickEvent (QMouseEvent *event)
+{
+ if (event->button () == Qt::LeftButton)
+ {
+ if (isFit)
+ zoomNormal ();
+ else
+ zoomFit ();
+ }
}
bgstack15