From 67bdf467a505a87f75b52f7142fce4dcb3153d5d Mon Sep 17 00:00:00 2001 From: lbartoletti Date: Wed, 7 Nov 2018 22:57:30 +0100 Subject: 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 --- src-qt5/desktop-utils/lumina-photo/PhotoView.cpp | 51 ++++++++++++++++++++++++ src-qt5/desktop-utils/lumina-photo/PhotoView.h | 8 ++++ src-qt5/desktop-utils/lumina-photo/mainUI.cpp | 4 ++ src-qt5/desktop-utils/lumina-photo/mainUI.h | 2 +- src-qt5/desktop-utils/lumina-photo/mainUI.ui | 10 ++++- 5 files changed, 72 insertions(+), 3 deletions(-) (limited to 'src-qt5') 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 +#include 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 (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 (); + } } diff --git a/src-qt5/desktop-utils/lumina-photo/PhotoView.h b/src-qt5/desktop-utils/lumina-photo/PhotoView.h index 521e705d..a04a70d0 100644 --- a/src-qt5/desktop-utils/lumina-photo/PhotoView.h +++ b/src-qt5/desktop-utils/lumina-photo/PhotoView.h @@ -1,6 +1,7 @@ #pragma once #include +#include class PhotoView : public QGraphicsView { @@ -15,4 +16,11 @@ class PhotoView : public QGraphicsView private: const double scaleFactor = 1.25; const double invScaleFactor = 1 / 1.25; + bool eventFilter(QObject *, QEvent *event); + void mouseDoubleClickEvent(QMouseEvent *event); + bool isFit = true; + + signals: + void nextImage(); + void prevImage(); }; diff --git a/src-qt5/desktop-utils/lumina-photo/mainUI.cpp b/src-qt5/desktop-utils/lumina-photo/mainUI.cpp index 781e8d0b..b6b468c2 100644 --- a/src-qt5/desktop-utils/lumina-photo/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-photo/mainUI.cpp @@ -72,6 +72,8 @@ void MainUI::setupConnections () connect (ui->actionBack, SIGNAL (triggered ()), this, SLOT (backToggled ())); connect (ui->actionFirst, SIGNAL (triggered ()), this, SLOT (firstToggled ())); connect (ui->actionLast, SIGNAL (triggered ()), this, SLOT (lastToggled ())); + connect (ui->photoView, SIGNAL (nextImage ()), this, SLOT (nextToggled ())); + connect (ui->photoView, SIGNAL (prevImage ()), this, SLOT (backToggled ())); } void MainUI::setupIcons () @@ -99,6 +101,8 @@ void MainUI::setupFilters () mimeTypeFiltersWriter.sort (); } + + // ==== PRIVATE SLOTS ==== void MainUI::fitZoomToggled () { diff --git a/src-qt5/desktop-utils/lumina-photo/mainUI.h b/src-qt5/desktop-utils/lumina-photo/mainUI.h index 27464183..610ec3f2 100644 --- a/src-qt5/desktop-utils/lumina-photo/mainUI.h +++ b/src-qt5/desktop-utils/lumina-photo/mainUI.h @@ -52,7 +52,7 @@ private: QString pfilter; //previous filter QSettings *settings; - private slots: +private slots: void open (); bool save(); void print(); diff --git a/src-qt5/desktop-utils/lumina-photo/mainUI.ui b/src-qt5/desktop-utils/lumina-photo/mainUI.ui index 1f992b57..d622050a 100644 --- a/src-qt5/desktop-utils/lumina-photo/mainUI.ui +++ b/src-qt5/desktop-utils/lumina-photo/mainUI.ui @@ -26,7 +26,7 @@ 0 0 524 - 20 + 22 @@ -148,7 +148,13 @@ - &Fit to windows + &Fit to Windows + + + Fit to Windows + + + Fit to Windows -- cgit