aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-photo
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/desktop-utils/lumina-photo')
-rw-r--r--src-qt5/desktop-utils/lumina-photo/PhotoView.cpp51
-rw-r--r--src-qt5/desktop-utils/lumina-photo/PhotoView.h8
-rw-r--r--src-qt5/desktop-utils/lumina-photo/mainUI.cpp4
-rw-r--r--src-qt5/desktop-utils/lumina-photo/mainUI.h2
-rw-r--r--src-qt5/desktop-utils/lumina-photo/mainUI.ui10
5 files changed, 72 insertions, 3 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 ();
+ }
}
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 <QGraphicsView>
+#include <QEvent>
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 @@
<x>0</x>
<y>0</y>
<width>524</width>
- <height>20</height>
+ <height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -148,7 +148,13 @@
</action>
<action name="action_Fit_to_windows">
<property name="text">
- <string>&amp;Fit to windows</string>
+ <string>&amp;Fit to Windows</string>
+ </property>
+ <property name="iconText">
+ <string>Fit to Windows</string>
+ </property>
+ <property name="toolTip">
+ <string>Fit to Windows</string>
</property>
</action>
<action name="action_About">
bgstack15