1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKSCROLLBAR_P_H
5#define QQUICKSCROLLBAR_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuickTemplates2/private/qquickcontrol_p.h>
19#include <QtQuickTemplates2/private/qquickindicatorbutton_p.h>
20QT_BEGIN_NAMESPACE
21
22class QQuickScrollBarAttached;
23class QQuickScrollBarPrivate;
24
25class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickScrollBar : public QQuickControl
26{
27 Q_OBJECT
28 Q_PROPERTY(qreal size READ size WRITE setSize NOTIFY sizeChanged FINAL)
29 Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged FINAL)
30 Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL)
31 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged FINAL)
32 Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL)
33 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL)
34 // 2.2 (Qt 5.9)
35 Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL REVISION(2, 2))
36 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive RESET resetInteractive NOTIFY interactiveChanged FINAL REVISION(2, 2))
37 Q_PROPERTY(Policy policy READ policy WRITE setPolicy NOTIFY policyChanged FINAL REVISION(2, 2))
38 // 2.3 (Qt 5.10)
39 Q_PROPERTY(bool horizontal READ isHorizontal NOTIFY orientationChanged FINAL REVISION(2, 3))
40 Q_PROPERTY(bool vertical READ isVertical NOTIFY orientationChanged FINAL REVISION(2, 3))
41 // 2.4 (Qt 5.11)
42 Q_PROPERTY(qreal minimumSize READ minimumSize WRITE setMinimumSize NOTIFY minimumSizeChanged FINAL REVISION(2, 4))
43 Q_PROPERTY(qreal visualSize READ visualSize NOTIFY visualSizeChanged FINAL REVISION(2, 4))
44 Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL REVISION(2, 4))
45
46 Q_PROPERTY(QQuickIndicatorButton *__decreaseVisual READ decreaseVisual CONSTANT FINAL)
47 Q_PROPERTY(QQuickIndicatorButton *__increaseVisual READ increaseVisual CONSTANT FINAL)
48
49 QML_NAMED_ELEMENT(ScrollBar)
50 QML_ATTACHED(QQuickScrollBarAttached)
51 QML_ADDED_IN_VERSION(2, 0)
52
53public:
54 explicit QQuickScrollBar(QQuickItem *parent = nullptr);
55
56 static QQuickScrollBarAttached *qmlAttachedProperties(QObject *object);
57
58 qreal size() const;
59 qreal position() const;
60
61 qreal stepSize() const;
62 void setStepSize(qreal step);
63
64 bool isActive() const;
65 void setActive(bool active);
66
67 bool isPressed() const;
68 void setPressed(bool pressed);
69
70 Qt::Orientation orientation() const;
71 void setOrientation(Qt::Orientation orientation);
72
73 // 2.2 (Qt 5.9)
74 enum SnapMode {
75 NoSnap,
76 SnapAlways,
77 SnapOnRelease
78 };
79 Q_ENUM(SnapMode)
80
81 SnapMode snapMode() const;
82 void setSnapMode(SnapMode mode);
83
84 bool isInteractive() const;
85 void setInteractive(bool interactive);
86 void resetInteractive();
87
88 enum Policy {
89 AsNeeded = Qt::ScrollBarAsNeeded,
90 AlwaysOff = Qt::ScrollBarAlwaysOff,
91 AlwaysOn = Qt::ScrollBarAlwaysOn
92 };
93 Q_ENUM(Policy)
94
95 Policy policy() const;
96 void setPolicy(Policy policy);
97
98 // 2.3 (Qt 5.10)
99 bool isHorizontal() const;
100 bool isVertical() const;
101
102 // 2.4 (Qt 5.11)
103 qreal minimumSize() const;
104 void setMinimumSize(qreal minimumSize);
105
106 qreal visualSize() const;
107 qreal visualPosition() const;
108
109 QQuickIndicatorButton *decreaseVisual();
110 QQuickIndicatorButton *increaseVisual();
111
112public Q_SLOTS:
113 void increase();
114 void decrease();
115 void setSize(qreal size);
116 void setPosition(qreal position);
117
118Q_SIGNALS:
119 void sizeChanged();
120 void positionChanged();
121 void stepSizeChanged();
122 void activeChanged();
123 void pressedChanged();
124 void orientationChanged();
125 // 2.2 (Qt 5.9)
126 Q_REVISION(2, 2) void snapModeChanged();
127 Q_REVISION(2, 2) void interactiveChanged();
128 Q_REVISION(2, 2) void policyChanged();
129 // 2.4 (Qt 5.11)
130 Q_REVISION(2, 4) void minimumSizeChanged();
131 Q_REVISION(2, 4) void visualSizeChanged();
132 Q_REVISION(2, 4) void visualPositionChanged();
133
134protected:
135 void mousePressEvent(QMouseEvent *event) override;
136
137#if QT_CONFIG(quicktemplates2_hover)
138 void hoverChange() override;
139 void hoverEnterEvent(QHoverEvent *event) override;
140 void hoverMoveEvent(QHoverEvent *event) override;
141 void hoverLeaveEvent(QHoverEvent *event) override;
142#endif
143
144 void classBegin() override;
145 void componentComplete() override;
146
147#if QT_CONFIG(accessibility)
148 void accessibilityActiveChanged(bool active) override;
149 QAccessible::Role accessibleRole() const override;
150#endif
151
152private:
153 Q_DISABLE_COPY(QQuickScrollBar)
154 Q_DECLARE_PRIVATE(QQuickScrollBar)
155};
156
157class QQuickScrollBarAttachedPrivate;
158
159class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickScrollBarAttached : public QObject
160{
161 Q_OBJECT
162 Q_PROPERTY(QQuickScrollBar *horizontal READ horizontal WRITE setHorizontal NOTIFY horizontalChanged FINAL)
163 Q_PROPERTY(QQuickScrollBar *vertical READ vertical WRITE setVertical NOTIFY verticalChanged FINAL)
164
165public:
166 explicit QQuickScrollBarAttached(QObject *parent = nullptr);
167 ~QQuickScrollBarAttached();
168
169 QQuickScrollBar *horizontal() const;
170 void setHorizontal(QQuickScrollBar *horizontal);
171
172 QQuickScrollBar *vertical() const;
173 void setVertical(QQuickScrollBar *vertical);
174
175Q_SIGNALS:
176 void horizontalChanged();
177 void verticalChanged();
178
179private:
180 Q_DISABLE_COPY(QQuickScrollBarAttached)
181 Q_DECLARE_PRIVATE(QQuickScrollBarAttached)
182};
183
184QT_END_NAMESPACE
185
186QML_DECLARE_TYPE(QQuickScrollBar)
187
188#endif // QQUICKSCROLLBAR_P_H
189

source code of qtdeclarative/src/quicktemplates/qquickscrollbar_p.h