Changeset View
Changeset View
Standalone View
Standalone View
src/wheelhandler.h
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 22 | { | |||
---|---|---|---|---|---|
71 | * ... | 71 | * ... | ||
72 | */ | 72 | */ | ||
73 | Q_PROPERTY(int modifiers READ modifiers CONSTANT) | 73 | Q_PROPERTY(int modifiers READ modifiers CONSTANT) | ||
74 | 74 | | |||
75 | /** | 75 | /** | ||
76 | * inverted: bool | 76 | * inverted: bool | ||
77 | * | 77 | * | ||
78 | * Whether the delta values are inverted | 78 | * Whether the delta values are inverted | ||
79 | * On some platformsthe returned delta are inverted, so positive values would mean bottom/left | 79 | * On some platforms the returned delta are inverted, so positive values would mean bottom/left | ||
80 | */ | 80 | */ | ||
81 | Q_PROPERTY(bool inverted READ inverted CONSTANT) | 81 | Q_PROPERTY(bool inverted READ inverted CONSTANT) | ||
82 | 82 | | |||
83 | /** | 83 | /** | ||
84 | * accepted: bool | 84 | * accepted: bool | ||
85 | * | 85 | * | ||
86 | * If set, the event shouldn't be managed anymore, | 86 | * If set, the event shouldn't be managed anymore, | ||
87 | * for instance it can be used to block the handler to manage the scroll of a view on some scenarions | 87 | * for instance it can be used to block the handler to manage the scroll of a view on some scenarions | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 139 | public: | |||
146 | void removeItemHandlerAssociation(QQuickItem *item, WheelHandler *handler); | 146 | void removeItemHandlerAssociation(QQuickItem *item, WheelHandler *handler); | ||
147 | 147 | | |||
148 | protected: | 148 | protected: | ||
149 | bool eventFilter(QObject *watched, QEvent *event) override; | 149 | bool eventFilter(QObject *watched, QEvent *event) override; | ||
150 | 150 | | |||
151 | private: | 151 | private: | ||
152 | void manageWheel(QQuickItem *target, QWheelEvent *wheel); | 152 | void manageWheel(QQuickItem *target, QWheelEvent *wheel); | ||
153 | 153 | | |||
154 | friend class WheelHandler; | ||||
154 | QMultiHash<QQuickItem *, WheelHandler *> m_handlersForItem; | 155 | QMultiHash<QQuickItem *, WheelHandler *> m_handlersForItem; | ||
155 | KirigamiWheelEvent m_wheelEvent; | 156 | KirigamiWheelEvent m_wheelEvent; | ||
156 | }; | 157 | }; | ||
157 | 158 | | |||
158 | 159 | | |||
159 | 160 | | |||
160 | /** | 161 | /** | ||
161 | * This class intercepts the mouse wheel events of its target, and gives them to the user code as a signal, which can be used for custom mouse wheel management code. | 162 | * This class intercepts the mouse wheel events of its target, and gives them to the user code as a signal, which can be used for custom mouse wheel management code. | ||
Show All 28 Lines | |||||
190 | 191 | | |||
191 | public: | 192 | public: | ||
192 | explicit WheelHandler(QObject *parent = nullptr); | 193 | explicit WheelHandler(QObject *parent = nullptr); | ||
193 | ~WheelHandler() override; | 194 | ~WheelHandler() override; | ||
194 | 195 | | |||
195 | QQuickItem *target() const; | 196 | QQuickItem *target() const; | ||
196 | void setTarget(QQuickItem *target); | 197 | void setTarget(QQuickItem *target); | ||
197 | 198 | | |||
199 | Q_SCRIPTABLE void includeWheelEvent(KirigamiWheelEvent *wheel); | ||||
200 | | ||||
198 | Q_SIGNALS: | 201 | Q_SIGNALS: | ||
199 | void targetChanged(); | 202 | void targetChanged(); | ||
200 | void blockTargetWheelChanged(); | 203 | void blockTargetWheelChanged(); | ||
201 | void scrollFlickableTargetChanged(); | 204 | void scrollFlickableTargetChanged(); | ||
202 | void wheel(KirigamiWheelEvent *wheel); | 205 | void wheel(KirigamiWheelEvent *wheel); | ||
203 | 206 | | |||
204 | private: | 207 | private: | ||
205 | QPointer<QQuickItem> m_target; | 208 | QPointer<QQuickItem> m_target; | ||
206 | bool m_blockTargetWheel = true; | 209 | bool m_blockTargetWheel = true; | ||
207 | bool m_scrollFlickableTarget = true; | 210 | bool m_scrollFlickableTarget = true; | ||
208 | KirigamiWheelEvent m_wheelEvent; | 211 | KirigamiWheelEvent m_wheelEvent; | ||
209 | 212 | | |||
210 | friend class GlobalWheelFilter; | 213 | friend class GlobalWheelFilter; | ||
211 | }; | 214 | }; | ||
212 | 215 | | |||
213 | 216 | |