ktwofingerswipe.h 1.45 KB
Newer Older
Steffen Hartleib's avatar
Steffen Hartleib committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
/*
 * SPDX-FileCopyrightText: 2020 Steffen Hartleib <steffenhartleib@t-online.de>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef KTWOFINGERSWIPE_H
#define KTWOFINGERSWIPE_H

#include "dolphin_export.h"
// Qt
#include <QGesture>
#include <QGestureRecognizer>

class DOLPHIN_EXPORT KTwoFingerSwipe : public QGesture
{
    Q_OBJECT
    Q_PROPERTY(QPointF pos READ pos WRITE setPos)
    Q_PROPERTY(QPointF screenPos READ screenPos WRITE setScreenPos)
    Q_PROPERTY(QPointF scenePos READ scenePos WRITE setScenePos)
    Q_PROPERTY(qreal swipeAngle READ swipeAngle WRITE setSwipeAngle)
public:
    explicit KTwoFingerSwipe(QObject* parent = nullptr);
    ~KTwoFingerSwipe();
    QPointF pos() const;
    void setPos(QPointF pos);
    QPointF screenPos() const;
    void setScreenPos(QPointF screenPos);
    QPointF scenePos() const;
    void setScenePos(QPointF scenePos);
    qreal swipeAngle() const;
    void setSwipeAngle(qreal swipeAngle);
private:
    QPointF m_pos;
    QPointF m_screenPos;
    QPointF m_scenePos;
    qreal m_swipeAngle;
};

class DOLPHIN_EXPORT KTwoFingerSwipeRecognizer : public QGestureRecognizer
{
public:
    explicit KTwoFingerSwipeRecognizer();
    ~KTwoFingerSwipeRecognizer();
    QGesture* create(QObject*) override;
    Result recognize(QGesture*, QObject*, QEvent*) override;
private:
    Q_DISABLE_COPY( KTwoFingerSwipeRecognizer )
    qint64 m_touchBeginnTimestamp;
    bool m_gestureAlreadyTriggered;
};

#endif /* KTWOFINGERSWIPE_H */