| 1 |
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#ifndef DREGIONMONITOR_H |
| 6 |
#define DREGIONMONITOR_H |
| 7 |
|
| 8 |
#include <DObject> |
| 9 |
#include <dtkgui_global.h> |
| 10 |
|
| 11 |
#include <QObject> |
| 12 |
|
| 13 |
DGUI_BEGIN_NAMESPACE |
| 14 |
|
| 15 |
class DRegionMonitorPrivate; |
| 16 |
class DRegionMonitor : public QObject, public DTK_CORE_NAMESPACE::DObject |
| 17 |
{ |
| 18 |
Q_OBJECT |
| 19 |
D_DECLARE_PRIVATE(DRegionMonitor) |
| 20 |
Q_DISABLE_COPY(DRegionMonitor) |
| 21 |
Q_PROPERTY(CoordinateType coordinateType READ coordinateType WRITE setCoordinateType NOTIFY coordinateTypeChanged) |
| 22 |
Q_PROPERTY(RegisterdFlags registerdFlags READ registerFlags WRITE setRegisterFlags NOTIFY registerdFlagsChanged) |
| 23 |
|
| 24 |
public: |
| 25 |
explicit DRegionMonitor(QObject *parent = nullptr); |
| 26 |
|
| 27 |
enum RegisterdFlag { |
| 28 |
Motion = 1 << 0, |
| 29 |
Button = 1 << 1, |
| 30 |
Key = 1 << 2 |
| 31 |
}; |
| 32 |
Q_DECLARE_FLAGS(RegisterdFlags, RegisterdFlag) |
| 33 |
|
| 34 |
enum WatchedFlags { |
| 35 |
Button_Left = 1, |
| 36 |
Button_Middle, |
| 37 |
Button_Right, |
| 38 |
Wheel_Up, |
| 39 |
Wheel_Down |
| 40 |
}; |
| 41 |
|
| 42 |
enum CoordinateType { |
| 43 |
ScaleRatio, |
| 44 |
Original |
| 45 |
}; |
| 46 |
Q_ENUM(CoordinateType) |
| 47 |
|
| 48 |
bool registered() const; |
| 49 |
QRegion watchedRegion() const; |
| 50 |
RegisterdFlags registerFlags() const; |
| 51 |
CoordinateType coordinateType() const; |
| 52 |
|
| 53 |
Q_SIGNALS: |
| 54 |
void buttonPress(const QPoint &p, const int flag) const; |
| 55 |
void buttonRelease(const QPoint &p, const int flag) const; |
| 56 |
void cursorMove(const QPoint &p) const; |
| 57 |
void cursorEnter(const QPoint &p) const; |
| 58 |
void cursorLeave(const QPoint &p) const; |
| 59 |
void keyPress(const QString &keyname) const; |
| 60 |
void keyRelease(const QString &keyname) const; |
| 61 |
void registerdFlagsChanged(RegisterdFlags flags) const; |
| 62 |
void coordinateTypeChanged(CoordinateType type) const; |
| 63 |
|
| 64 |
public Q_SLOTS: |
| 65 |
void registerRegion(); |
| 66 |
inline void registerRegion(const QRegion ®ion) { setWatchedRegion(region); registerRegion(); } |
| 67 |
void unregisterRegion(); |
| 68 |
void setWatchedRegion(const QRegion ®ion); |
| 69 |
void setRegisterFlags(RegisterdFlags flags); |
| 70 |
void setCoordinateType(CoordinateType type); |
| 71 |
|
| 72 |
private: |
| 73 |
Q_PRIVATE_SLOT(d_func(), void _q_ButtonPress(const int, const int, const int, const QString&)) |
| 74 |
Q_PRIVATE_SLOT(d_func(), void _q_ButtonRelease(const int, const int, const int, const QString&)) |
| 75 |
Q_PRIVATE_SLOT(d_func(), void _q_CursorMove(const int, const int, const QString &)) |
| 76 |
Q_PRIVATE_SLOT(d_func(), void _q_CursorEnter(const int, const int, const QString &)) |
| 77 |
Q_PRIVATE_SLOT(d_func(), void _q_CursorLeave(const int, const int, const QString &)) |
| 78 |
Q_PRIVATE_SLOT(d_func(), void _q_KeyPress(const QString &, const int, const int, const QString &)) |
| 79 |
Q_PRIVATE_SLOT(d_func(), void _q_KeyRelease(const QString &, const int, const int, const QString &)) |
| 80 |
}; |
| 81 |
|
| 82 |
Q_DECLARE_OPERATORS_FOR_FLAGS (DRegionMonitor::RegisterdFlags); |
| 83 |
|
| 84 |
DGUI_END_NAMESPACE |
| 85 |
|
| 86 |
#endif // DREGIONMONITOR_H |