Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qabstractslider_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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// Qt-Security score:significant reason:default
4
5#ifndef QABSTRACTSLIDER_P_H
6#define QABSTRACTSLIDER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
20#include "QtCore/qbasictimer.h"
21#include "QtCore/qelapsedtimer.h"
22#include "private/qwidget_p.h"
23#include "qstyle.h"
24
25QT_REQUIRE_CONFIG(abstractslider);
26
27QT_BEGIN_NAMESPACE
28
29class QAbstractSliderPrivate : public QWidgetPrivate
30{
31 Q_DECLARE_PUBLIC(QAbstractSlider)
32public:
33 QAbstractSliderPrivate();
34 ~QAbstractSliderPrivate();
35
36 void setSteps(int single, int page);
37
38 int minimum, maximum, pageStep, value, position, pressValue;
39
40 /**
41 * Call effectiveSingleStep() when changing the slider value.
42 */
43 int singleStep;
44 int singleStepFromItemView; // If we have itemViews we track the views preferred singleStep value.
45 bool viewMayChangeSingleStep;
46
47 float offset_accumulated;
48 uint tracking : 1;
49 uint blocktracking :1;
50 uint pressed : 1;
51 uint invertedAppearance : 1;
52 uint invertedControls : 1;
53 Qt::Orientation orientation;
54
55 QBasicTimer repeatActionTimer;
56 int repeatActionTime;
57 QAbstractSlider::SliderAction repeatAction;
58
59#ifdef QT_KEYPAD_NAVIGATION
60 int origValue;
61
62 /**
63 */
64 bool isAutoRepeating;
65
66 /**
67 * When we're auto repeating, we multiply singleStep with this value to
68 * get our effective step.
69 */
70 qreal repeatMultiplier;
71
72 /**
73 * The time of when the first auto repeating key press event occurs.
74 */
75 QElapsedTimer firstRepeat;
76
77#endif
78
79 inline int effectiveSingleStep() const
80 {
81 return singleStep
82#ifdef QT_KEYPAD_NAVIGATION
83 * repeatMultiplier
84#endif
85 ;
86 }
87 void itemviewChangeSingleStep(int step);
88
89 virtual int bound(int val) const { return qMax(minimum, qMin(maximum, val)); }
90 inline int overflowSafeAdd(int add) const
91 {
92 int newValue = value + add;
93 if (add > 0 && newValue < value)
94 newValue = maximum;
95 else if (add < 0 && newValue > value)
96 newValue = minimum;
97 return newValue;
98 }
99 inline void setAdjustedSliderPosition(int position)
100 {
101 Q_Q(QAbstractSlider);
102 if (q->style()->styleHint(QStyle::SH_Slider_StopMouseOverSlider, nullptr, q)) {
103 if ((position > pressValue - 2 * pageStep) && (position < pressValue + 2 * pageStep)) {
104 repeatAction = QAbstractSlider::SliderNoAction;
105 q->setSliderPosition(pressValue);
106 return;
107 }
108 }
109 q->triggerAction(repeatAction);
110 }
111 bool scrollByDelta(Qt::Orientation orientation, Qt::KeyboardModifiers modifiers, int delta);
112};
113
114QT_END_NAMESPACE
115
116#endif // QABSTRACTSLIDER_P_H
The QAbstractSlider class provides an integer value within a range.
QT_REQUIRE_CONFIG(thread)