File indexing completed on 2024-05-12 04:19:52
0001 /* 0002 Gwenview: an image viewer 0003 Copyright 2019 Steffen Hartleib <steffenhartleib@t-online.de> 0004 0005 This program is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU General Public License 0007 as published by the Free Software Foundation; either version 2 0008 of the License, or (at your option) any later version. 0009 0010 This program is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 GNU General Public License for more details. 0014 0015 You should have received a copy of the GNU General Public License 0016 along with this program; if not, write to the Free Software 0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. 0018 0019 */ 0020 #ifndef TOUCH_H 0021 #define TOUCH_H 0022 0023 #include <lib/gwenviewlib_export.h> 0024 // Qt 0025 #include <QObject> 0026 0027 // KF 0028 0029 // Local 0030 #include "lib/touch/doubletap.h" 0031 #include "lib/touch/oneandtwofingerswipe.h" 0032 #include "lib/touch/tapholdandmoving.h" 0033 #include "lib/touch/twofingerpan.h" 0034 #include "lib/touch/twofingertap.h" 0035 0036 namespace Gwenview 0037 { 0038 struct TouchPrivate; 0039 class GWENVIEWLIB_EXPORT Touch : public QObject 0040 { 0041 Q_OBJECT 0042 public: 0043 Touch(QObject *target); 0044 ~Touch() override; 0045 void setZoomParameter(qreal, qreal); 0046 void setRotationThreshold(qreal); 0047 qreal getRotationFromPinchGesture(QGestureEvent *); 0048 qreal getZoomFromPinchGesture(QGestureEvent *); 0049 QPoint positionGesture(QGestureEvent *); 0050 bool checkTwoFingerPanGesture(QGestureEvent *); 0051 bool checkOneAndTwoFingerSwipeGesture(QGestureEvent *); 0052 bool checkTapGesture(QGestureEvent *); 0053 bool checkDoubleTapGesture(QGestureEvent *); 0054 bool checkTwoFingerTapGesture(QGestureEvent *); 0055 bool checkTapHoldAndMovingGesture(QGestureEvent *, QObject *); 0056 bool checkPinchGesture(QGestureEvent *); 0057 void touchToMouseRelease(QPoint, QObject *); 0058 void touchToMouseMove(QPoint, QEvent *, Qt::MouseButton); 0059 void touchToMouseMove(QPoint, QObject *, Qt::MouseButton); 0060 void touchToMouseClick(QPoint, QObject *); 0061 void setPanGestureState(QGestureEvent *event); 0062 Qt::GestureState getLastPanGestureState(); 0063 QPointF getLastTapPos(); 0064 void setLastTapPos(QPointF); 0065 bool getTapHoldandMovingGestureActive(); 0066 void setTapHoldandMovingGestureActive(bool); 0067 0068 Qt::GestureType getTapHoldandMovingGesture(); 0069 Qt::GestureType getTwoFingerPanGesture(); 0070 Qt::GestureType getOneAndTwoFingerSwipeGesture(); 0071 Qt::GestureType getDoubleTapGesture(); 0072 Qt::GestureType getTwoFingerTapGesture(); 0073 0074 protected: 0075 bool eventFilter(QObject *, QEvent *) override; 0076 0077 Q_SIGNALS: 0078 void PanTriggered(const QPointF &); 0079 void swipeLeftTriggered(); 0080 void swipeRightTriggered(); 0081 void doubleTapTriggered(); 0082 void tapHoldAndMovingTriggered(const QPoint &); 0083 void tapTriggered(const QPoint &); 0084 void pinchGestureStarted(qint64); 0085 void twoFingerTapTriggered(); 0086 void pinchZoomTriggered(qreal, const QPoint &, qint64); 0087 void pinchRotateTriggered(qreal); 0088 0089 private: 0090 qreal calculateZoom(qreal, qreal); 0091 void touchToMouseEvent(QPoint, QObject *, QEvent::Type, Qt::MouseButton, Qt::MouseButtons); 0092 bool gestureEvent(QGestureEvent *); 0093 TouchPrivate *const d; 0094 }; 0095 0096 } // namespace 0097 #endif /* TOUCH_H */