34 Q_PROPERTY(qreal x READ x CONSTANT FINAL)
35 Q_PROPERTY(qreal y READ y CONSTANT FINAL)
36 Q_PROPERTY(QPointF angleDelta READ angleDelta CONSTANT FINAL)
37 Q_PROPERTY(QPointF pixelDelta READ pixelDelta CONSTANT FINAL)
38 Q_PROPERTY(
int buttons READ buttons CONSTANT FINAL)
39 Q_PROPERTY(
int modifiers READ modifiers CONSTANT FINAL)
40 Q_PROPERTY(
bool inverted READ inverted CONSTANT FINAL)
41 Q_PROPERTY(
bool accepted READ isAccepted WRITE setAccepted FINAL)
47 void initializeFromEvent(QWheelEvent* event);
51 QPointF angleDelta()
const;
52 QPointF pixelDelta()
const;
54 int modifiers()
const;
55 bool inverted()
const;
57 void setAccepted(
bool accepted);
64 Qt::MouseButtons m_buttons = Qt::NoButton;
65 Qt::KeyboardModifiers m_modifiers = Qt::NoModifier;
66 bool m_inverted =
false;
67 bool m_accepted =
false;
81 Q_INTERFACES(QQmlParserStatus)
84 Q_PROPERTY(QQuickItem* target READ target WRITE setTarget NOTIFY targetChanged FINAL)
85 Q_PROPERTY(
bool active READ active WRITE setActive NOTIFY activeChanged FINAL)
86 Q_PROPERTY(qreal verticalStepSize READ verticalStepSize WRITE setVerticalStepSize RESET
87 resetVerticalStepSize NOTIFY verticalStepSizeChanged FINAL)
88 Q_PROPERTY(qreal horizontalStepSize READ horizontalStepSize WRITE setHorizontalStepSize RESET
89 resetHorizontalStepSize NOTIFY horizontalStepSizeChanged FINAL)
90 Q_PROPERTY(Qt::KeyboardModifiers pageScrollModifiers READ pageScrollModifiers WRITE
91 setPageScrollModifiers RESET resetPageScrollModifiers NOTIFY
92 pageScrollModifiersChanged FINAL)
93 Q_PROPERTY(
bool filterMouseEvents READ filterMouseEvents WRITE setFilterMouseEvents NOTIFY
94 filterMouseEventsChanged FINAL)
95 Q_PROPERTY(
bool keyNavigationEnabled READ keyNavigationEnabled WRITE setKeyNavigationEnabled
96 NOTIFY keyNavigationEnabledChanged FINAL)
97 Q_PROPERTY(
bool blockTargetWheel MEMBER m_blockTargetWheel NOTIFY blockTargetWheelChanged FINAL)
98 Q_PROPERTY(
bool scrollFlickableTarget MEMBER m_scrollFlickableTarget NOTIFY
99 scrollFlickableTargetChanged FINAL)
101 bool useAnimation READ useAnimation WRITE setUseAnimation NOTIFY useAnimationChanged FINAL)
107 QQuickItem* target()
const;
108 void setTarget(QQuickItem* target);
110 auto active()
const -> bool;
111 void setActive(
bool);
112 qreal verticalStepSize()
const;
113 void setVerticalStepSize(qreal stepSize);
114 void resetVerticalStepSize();
116 qreal horizontalStepSize()
const;
117 void setHorizontalStepSize(qreal stepSize);
118 void resetHorizontalStepSize();
120 Qt::KeyboardModifiers pageScrollModifiers()
const;
121 void setPageScrollModifiers(Qt::KeyboardModifiers modifiers);
122 void resetPageScrollModifiers();
124 bool filterMouseEvents()
const;
125 void setFilterMouseEvents(
bool enabled);
127 bool keyNavigationEnabled()
const;
128 void setKeyNavigationEnabled(
bool enabled);
130 bool useAnimation()
const;
131 void setUseAnimation(
bool);
133 Q_INVOKABLE
bool scrollUp(qreal stepSize = -1);
134 Q_INVOKABLE
bool scrollDown(qreal stepSize = -1);
136 Q_INVOKABLE
bool scrollLeft(qreal stepSize = -1);
137 Q_INVOKABLE
bool scrollRight(qreal stepSize = -1);
140 void targetChanged();
141 void activeChanged();
142 void verticalStepSizeChanged();
143 void horizontalStepSizeChanged();
144 void pageScrollModifiersChanged();
145 void filterMouseEventsChanged();
146 void keyNavigationEnabledChanged();
147 void blockTargetWheelChanged();
148 void scrollFlickableTargetChanged();
149 void useAnimationChanged();
155 bool eventFilter(QObject* watched, QEvent* event)
override;
158 void refreshAttach();
161 void rebindScrollBarV();
162 void rebindScrollBarH();
166 void rebindScrollBar(ScrollBar& scrollBar);
167 void classBegin()
override;
168 void componentComplete()
override;
170 void setScrolling(
bool scrolling);
171 bool scrollFlickable(QPointF pixelDelta, QPointF angleDelta = {},
172 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
174 QPointer<QQuickItem> m_target;
177 QMetaObject::Connection m_verticalChangedConnection;
178 QMetaObject::Connection m_horizontalChangedConnection;
180 qreal m_defaultPixelStepSize = 20 * QGuiApplication::styleHints()->wheelScrollLines();
181 qreal m_verticalStepSize = m_defaultPixelStepSize;
182 qreal m_horizontalStepSize = m_defaultPixelStepSize;
183 bool m_explicitVStepSize =
false;
184 bool m_explicitHStepSize =
false;
185 bool m_wheelScrolling =
false;
186 constexpr static qreal m_wheelScrollingDuration = 400;
187 bool m_filterMouseEvents =
false;
188 bool m_keyNavigationEnabled =
false;
189 bool m_blockTargetWheel =
true;
190 bool m_scrollFlickableTarget =
true;
191 constexpr static Qt::KeyboardModifiers m_defaultHorizontalScrollModifiers = Qt::AltModifier;
192 constexpr static Qt::KeyboardModifiers m_defaultPageScrollModifiers =
193 Qt::ControlModifier | Qt::ShiftModifier;
194 Qt::KeyboardModifiers m_pageScrollModifiers = m_defaultPageScrollModifiers;
195 QTimer m_wheelScrollingTimer;
198 QQmlEngine* m_engine =
nullptr;
199 bool m_wasTouched =
false;
202 QQmlProperty originX, originY;
203 QQmlProperty leftMargin, rightMargin;
204 QQmlProperty topMargin, bottomMargin;
205 QQmlProperty contentX, contentY;
206 QQmlProperty contentHeight, contentWidth;
207 QQmlProperty height, width;
208 QQmlProperty interactive;
212 QQmlProperty scrollBar;
213 QQmlProperty stepSize;
214 QMetaMethod increaseMethod;
215 QMetaMethod decreaseMethod;
216 QQuickItem* item =
nullptr;
217 bool valid()
const {
return item !=
nullptr; };
218 } m_scrollBarV, m_scrollBarH;
220 bool m_useAnimation =
false;