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 inline int effectiveSingleStep() const
60 {
61 return singleStep;
62 }
63 void itemviewChangeSingleStep(int step);
64
65 virtual int bound(int val) const { return qMax(minimum, qMin(maximum, val)); }
66 inline int overflowSafeAdd(int add) const
67 {
68 int newValue = value + add;
69 if (add > 0 && newValue < value)
70 newValue = maximum;
71 else if (add < 0 && newValue > value)
72 newValue = minimum;
73 return newValue;
74 }
75 inline void setAdjustedSliderPosition(int position)
76 {
77 Q_Q(QAbstractSlider);
78 if (q->style()->styleHint(QStyle::SH_Slider_StopMouseOverSlider, nullptr, q)) {
79 if ((position > pressValue - 2 * pageStep) && (position < pressValue + 2 * pageStep)) {
80 repeatAction = QAbstractSlider::SliderNoAction;
81 q->setSliderPosition(pressValue);
82 return;
83 }
84 }
85 q->triggerAction(repeatAction);
86 }
87 bool scrollByDelta(Qt::Orientation orientation, Qt::KeyboardModifiers modifiers, int delta);
88};
89
90QT_END_NAMESPACE
91
92#endif // QABSTRACTSLIDER_P_H
The QAbstractSlider class provides an integer value within a range.
Combined button and popup list for selecting options.
QT_REQUIRE_CONFIG(liburing)