KDeclarative

fallbacktaphandler.h
1 /*
2  SPDX-FileCopyrightText: 2019 Marco Martin <[email protected]>
3  SPDX-FileCopyrightText: 2014-2015 Eike Hein <[email protected]>
4 
5  SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #pragma once
9 
10 #include <QPointer>
11 #include <QQuickItem>
12 
13 class FallbackTapHandlerMouseEvent : public QObject {
14  Q_OBJECT
15  Q_PROPERTY(Qt::MouseButton button MEMBER m_button)
16  Q_PROPERTY(Qt::MouseButtons buttons MEMBER m_buttons)
17  Q_PROPERTY(Qt::KeyboardModifiers modifiers MEMBER m_modifiers)
18  Q_PROPERTY(qreal x MEMBER m_x)
19  Q_PROPERTY(qreal y MEMBER m_y)
20 
21 public:
22  FallbackTapHandlerMouseEvent(Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, qreal x, qreal y);
23  ~FallbackTapHandlerMouseEvent() = default;
24 
25 private:
26  Qt::MouseButton m_button = Qt::NoButton;
27  Qt::MouseButtons m_buttons = Qt::NoButton;
29  qreal m_x = 0;
30  qreal m_y = 0;
31 };
32 
33 class FallbackTapHandler : public QQuickItem
34 {
35  Q_OBJECT
36  Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedMouseButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
37 
38 public:
39  explicit FallbackTapHandler(QQuickItem *parent = nullptr);
40  ~FallbackTapHandler() override;
41 
42  void setAcceptedButtons(Qt::MouseButtons buttons);
43 
44 Q_SIGNALS:
45  void pressed(FallbackTapHandlerMouseEvent *event);
46  void tapped(FallbackTapHandlerMouseEvent *event);
47  void released(FallbackTapHandlerMouseEvent *event);
48  void acceptedButtonsChanged();
49 
50 protected:
51  bool childMouseEventFilter(QQuickItem *item, QEvent *event) override;
52  void mousePressEvent(QMouseEvent *event) override;
53  void mouseReleaseEvent(QMouseEvent *event) override;
54 
55 private:
56  QPointer<QQuickItem> m_mouseDownItem;
57  QPointF m_mouseDownPos;
58 };
59 
typedef KeyboardModifiers
MouseButton
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 25 2021 22:44:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.