Falkon Develop
Cross-platform Qt-based web browser
QjtMouseGestureFilter.h
Go to the documentation of this file.
1/*
2 * This file is part of the mouse gesture package.
3 * Copyright (C) 2006 Johan Thelin <e8johan@gmail.com>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or
7 * without modification, are permitted provided that the
8 * following conditions are met:
9 *
10 * - Redistributions of source code must retain the above
11 * copyright notice, this list of conditions and the
12 * following disclaimer.
13 * - Redistributions in binary form must reproduce the
14 * above copyright notice, this list of conditions and
15 * the following disclaimer in the documentation and/or
16 * other materials provided with the distribution.
17 * - The names of its contributors may be used to endorse
18 * or promote products derived from this software without
19 * specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38#ifndef QJTMOUSEGESTUREFILTER_H
39#define QJTMOUSEGESTUREFILTER_H
40
41#include <QObject>
42#include <QEvent>
43#include <QMouseEvent>
44
45class QjtMouseGesture;
46
47/*
48 * The QjtMouseGestureFilter class is a mouse
49 * gesture recognizing event filter.
50 *
51 * Use it by creating it, install it as a filter
52 * for the affected widget and add QjtMouseGesture
53 * instances to it.
54 *
55 */
56class QjtMouseGestureFilter : public QObject
57{
58public:
59 /*
60 * The gestureButton controls which mouse button
61 * that has to be pressed during the mouse gesture.
62 * Notice that this all events for this button are
63 * swallowed by the filter.
64 */
65 QjtMouseGestureFilter(bool allowDiagonals = false, Qt::MouseButton gestureButton = Qt::RightButton, int minimumMovement = 5, double minimumMatch = 0.9, QObject* parent = nullptr);
66 ~QjtMouseGestureFilter() override;
67
68 /*
69 * Adds a gesture to the filter.
70 */
71 void addGesture(QjtMouseGesture* gesture);
72
73 /*
74 * Clears the filter from gestures.
75 *
76 * If deleteGestures is true, the QjtMouseGesture objects are deleted.
77 */
78 void clearGestures(bool deleteGestures = false);
79
80 bool mouseButtonPressEvent(QMouseEvent* event, QObject* obj = nullptr);
81 bool mouseButtonReleaseEvent(QMouseEvent* event, QObject* obj = nullptr);
82 bool mouseMoveEvent(QMouseEvent* event, QObject* obj = nullptr);
83
84protected:
85 bool eventFilter(QObject* obj, QEvent* event) override;
86
87private:
88 bool paintEvent(QObject* obj, QPaintEvent* event);
89 class Private;
90 Private* d;
91};
92
93#endif // QJTMOUSEGESTUREFILTER_H
94
bool mouseButtonReleaseEvent(QMouseEvent *event, QObject *obj=nullptr)
bool mouseMoveEvent(QMouseEvent *event, QObject *obj=nullptr)
QjtMouseGestureFilter(bool allowDiagonals=false, Qt::MouseButton gestureButton=Qt::RightButton, int minimumMovement=5, double minimumMatch=0.9, QObject *parent=nullptr)
void addGesture(QjtMouseGesture *gesture)
void clearGestures(bool deleteGestures=false)
bool eventFilter(QObject *obj, QEvent *event) override
bool mouseButtonPressEvent(QMouseEvent *event, QObject *obj=nullptr)