1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWidgets module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QABSTRACTSLIDER_H
41#define QABSTRACTSLIDER_H
42
43#include <QtWidgets/qtwidgetsglobal.h>
44#include <QtWidgets/qwidget.h>
45
46QT_REQUIRE_CONFIG(abstractslider);
47
48QT_BEGIN_NAMESPACE
49
50
51class QAbstractSliderPrivate;
52
53class Q_WIDGETS_EXPORT QAbstractSlider : public QWidget
54{
55 Q_OBJECT
56
57 Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
58 Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
59 Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
60 Q_PROPERTY(int pageStep READ pageStep WRITE setPageStep)
61 Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true)
62 Q_PROPERTY(int sliderPosition READ sliderPosition WRITE setSliderPosition NOTIFY sliderMoved)
63 Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking)
64 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
65 Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance)
66 Q_PROPERTY(bool invertedControls READ invertedControls WRITE setInvertedControls)
67 Q_PROPERTY(bool sliderDown READ isSliderDown WRITE setSliderDown DESIGNABLE false)
68
69public:
70 explicit QAbstractSlider(QWidget *parent = nullptr);
71 ~QAbstractSlider();
72
73 Qt::Orientation orientation() const;
74
75 void setMinimum(int);
76 int minimum() const;
77
78 void setMaximum(int);
79 int maximum() const;
80
81 void setSingleStep(int);
82 int singleStep() const;
83
84 void setPageStep(int);
85 int pageStep() const;
86
87 void setTracking(bool enable);
88 bool hasTracking() const;
89
90 void setSliderDown(bool);
91 bool isSliderDown() const;
92
93 void setSliderPosition(int);
94 int sliderPosition() const;
95
96 void setInvertedAppearance(bool);
97 bool invertedAppearance() const;
98
99 void setInvertedControls(bool);
100 bool invertedControls() const;
101
102 enum SliderAction {
103 SliderNoAction,
104 SliderSingleStepAdd,
105 SliderSingleStepSub,
106 SliderPageStepAdd,
107 SliderPageStepSub,
108 SliderToMinimum,
109 SliderToMaximum,
110 SliderMove
111 };
112
113 int value() const;
114
115 void triggerAction(SliderAction action);
116
117public Q_SLOTS:
118 void setValue(int);
119 void setOrientation(Qt::Orientation);
120 void setRange(int min, int max);
121
122Q_SIGNALS:
123 void valueChanged(int value);
124
125 void sliderPressed();
126 void sliderMoved(int position);
127 void sliderReleased();
128
129 void rangeChanged(int min, int max);
130
131 void actionTriggered(int action);
132
133protected:
134 bool event(QEvent *e) override;
135
136 void setRepeatAction(SliderAction action, int thresholdTime = 500, int repeatTime = 50);
137 SliderAction repeatAction() const;
138
139 enum SliderChange {
140 SliderRangeChange,
141 SliderOrientationChange,
142 SliderStepsChange,
143 SliderValueChange
144 };
145 virtual void sliderChange(SliderChange change);
146
147 void keyPressEvent(QKeyEvent *ev) override;
148 void timerEvent(QTimerEvent *) override;
149#if QT_CONFIG(wheelevent)
150 void wheelEvent(QWheelEvent *e) override;
151#endif
152 void changeEvent(QEvent *e) override;
153
154
155protected:
156 QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent = nullptr);
157
158private:
159 Q_DISABLE_COPY(QAbstractSlider)
160 Q_DECLARE_PRIVATE(QAbstractSlider)
161};
162
163QT_END_NAMESPACE
164
165#endif // QABSTRACTSLIDER_H
166