KDStateMachineEditor API Documentation 2.1
Loading...
Searching...
No Matches
quickmaskedmousearea_p.h
Go to the documentation of this file.
1/*
2 This file is part of the KDAB State Machine Editor Library.
3
4 SPDX-FileCopyrightText: 2015 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: Kevin Funk <kevin.funk@kdab.com>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor
8
9 Licensees holding valid commercial KDAB State Machine Editor Library
10 licenses may use this file in accordance with the KDAB State Machine Editor
11 Library License Agreement provided with the Software.
12
13 Contact info@kdab.com if any conditions of this licensing are not clear to you.
14*/
15
16#ifndef KDSME_QUICK_QUICKMASKEDMOUSEAREA_P_H
17#define KDSME_QUICK_QUICKMASKEDMOUSEAREA_P_H
18
19#include <QObject>
20#include <QPainterPath>
21#include <QQuickItem>
22
23class AbstractMask : public QObject
24{
25 Q_OBJECT
26public:
27 explicit AbstractMask(QObject *parent = nullptr);
28
29 virtual bool contains(const QPointF &point) const = 0;
30 virtual bool intersects(const QRectF &rect) const = 0;
31};
32
33Q_DECLARE_METATYPE(AbstractMask *)
34
36{
37 Q_OBJECT
38 Q_PROPERTY(QPainterPath path READ path WRITE setPath NOTIFY pathChanged)
39
40public:
41 explicit PainterPathMask(QObject *parent = nullptr);
42
43 QPainterPath path() const;
44 void setPath(const QPainterPath &path);
45
46 bool contains(const QPointF &point) const override;
47 bool intersects(const QRectF &rect) const override;
48
49Q_SIGNALS:
50 void pathChanged(const QPainterPath &path);
51
52private:
53 QPainterPath m_path;
54};
55
56class QuickMaskedMouseArea : public QQuickItem
57{
58 Q_OBJECT
59 Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged)
61 Q_PROPERTY(AbstractMask *mask READ mask WRITE setMask NOTIFY maskChanged)
62 Q_PROPERTY(qreal tolerance READ tolerance WRITE setTolerance NOTIFY toleranceChanged)
63
64public:
65 explicit QuickMaskedMouseArea(QQuickItem *parent = nullptr);
66
67 bool isPressed() const
68 {
69 return m_pressed;
70 }
71 bool containsMouse() const
72 {
73 return m_containsMouse;
74 }
75
76 AbstractMask *mask() const;
78
79 qreal tolerance() const;
80 void setTolerance(qreal tolerance);
81
82 bool contains(const QPointF &point) const override;
83
84Q_SIGNALS:
85 void pressed();
86 void released();
87 void clicked();
88 void canceled();
93
94protected:
95 void setPressed(bool pressed);
97
98 void mousePressEvent(QMouseEvent *event) override;
99 void mouseReleaseEvent(QMouseEvent *event) override;
100 void hoverEnterEvent(QHoverEvent *event) override;
101 void hoverLeaveEvent(QHoverEvent *event) override;
102 void mouseUngrabEvent() override;
103
104private:
105 bool m_pressed;
106 bool m_containsMouse;
107 QPointF m_pressPoint;
108 AbstractMask *m_mask;
109 qreal m_tolerance;
110};
111
112#endif // QUICKMASKEDMOUSEAREA_P_H
virtual bool intersects(const QRectF &rect) const =0
virtual bool contains(const QPointF &point) const =0
void pathChanged(const QPainterPath &path)
bool contains(const QPointF &point) const override
void mousePressEvent(QMouseEvent *event) override
void toleranceChanged(qreal tolerance)
void hoverLeaveEvent(QHoverEvent *event) override
void containsMouseChanged(bool containsMouse)
void hoverEnterEvent(QHoverEvent *event) override
void pressedChanged(bool pressed)
void mouseReleaseEvent(QMouseEvent *event) override
void setTolerance(qreal tolerance)
void setPressed(bool pressed)
void setMask(AbstractMask *mask)
void setContainsMouse(bool containsMouse)
void maskChanged(AbstractMask *mask)

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDStateMachineEditor
Create Qt State Machine metacode using a graphical user interface
https://github.com/KDAB/KDStateMachineEditor
Generated on Tue Jul 15 2025 15:21:47 for KDStateMachineEditor API Documentation by doxygen 1.9.8