itom
Loading...
Searching...
No Matches
sliderWidget.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom and its software development toolkit (SDK).
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 In addition, as a special exception, the Institut für Technische
15 Optik (ITO) gives you certain additional rights.
16 These rights are described in the ITO LGPL Exception version 1.0,
17 which can be found in the file LGPL_EXCEPTION.txt in this package.
18
19 itom is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22 General Public Licence for more details.
23
24 You should have received a copy of the GNU Library General Public License
25 along with itom. If not, see <http://www.gnu.org/licenses/>.
26
27 This file is a port and modified version of the
28 Common framework (http://www.commontk.org)
29*********************************************************************** */
30
31#ifndef SLIDERWIDGET_H
32#define SLIDERWIDGET_H
33
34// Qt includes
35#include <QSlider>
36
37
38#include "commonWidgets.h"
39
40class DoubleSlider;
41class PopupWidget;
43class DoubleSpinBox;
44class ValueProxy;
45
51class ITOMWIDGETS_EXPORT SliderWidget : public QWidget
52{
53 Q_OBJECT
54 Q_FLAGS(SynchronizeSiblings)
55
56
59 Q_PROPERTY(int decimals READ decimals WRITE setDecimals NOTIFY decimalsChanged)
60 Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
61 Q_PROPERTY(double pageStep READ pageStep WRITE setPageStep)
62 Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
63 Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
64 Q_PROPERTY(double value READ value WRITE setValue)
65 Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
66 Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
67 Q_PROPERTY(double tickInterval READ tickInterval WRITE setTickInterval)
68 Q_PROPERTY(QSlider::TickPosition tickPosition READ tickPosition WRITE setTickPosition)
69 Q_PROPERTY(SynchronizeSiblings synchronizeSiblings READ synchronizeSiblings WRITE setSynchronizeSiblings)
70 Q_PROPERTY(Qt::Alignment spinBoxAlignment READ spinBoxAlignment WRITE setSpinBoxAlignment)
71 Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking)
72 Q_PROPERTY(bool spinBoxVisible READ isSpinBoxVisible WRITE setSpinBoxVisible);
73 Q_PROPERTY(bool popupSlider READ hasPopupSlider WRITE setPopupSlider);
74 Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance)
75 Q_PROPERTY(bool invertedControls READ invertedControls WRITE setInvertedControls)
76
77public:
78
93 {
94 NoSynchronize = 0x000,
95 SynchronizeWidth = 0x001,
96 SynchronizeDecimals = 0x002,
97 };
98 Q_DECLARE_FLAGS(SynchronizeSiblings, SynchronizeSibling)
99
100
101 typedef QWidget Superclass;
102
104 explicit SliderWidget(QWidget* parent = 0);
105 virtual ~SliderWidget();
106
113 virtual double minimum()const;
114 virtual void setMinimum(double minimum);
115
122 virtual double maximum()const;
123 virtual void setMaximum(double maximum);
126 virtual void setRange(double min, double max);
127
131 //double sliderPosition()const;
132 //void setSliderPosition(double position);
133
138 virtual double value()const;
139
145 virtual double singleStep()const;
146 virtual void setSingleStep(double step);
147
152 virtual double pageStep()const;
153 virtual void setPageStep(double step);
154
158 virtual int decimals()const;
159
164 virtual QString prefix()const;
165 virtual void setPrefix(const QString& prefix);
166
171 virtual QString suffix()const;
172 virtual void setSuffix(const QString& suffix);
173
179 virtual double tickInterval()const;
180 virtual void setTickInterval(double tick);
181
186 virtual void setTickPosition(QSlider::TickPosition position);
187 virtual QSlider::TickPosition tickPosition()const;
188
193 virtual void setSpinBoxAlignment(Qt::Alignment alignment);
194 virtual Qt::Alignment spinBoxAlignment()const;
195
202 virtual void setTracking(bool enable);
203 virtual bool hasTracking()const;
204
210 virtual SliderWidget::SynchronizeSiblings synchronizeSiblings() const;
211 virtual void setSynchronizeSiblings(SliderWidget::SynchronizeSiblings options);
212
222 virtual void setInvertedAppearance(bool invertedAppearance);
223 virtual bool invertedAppearance()const;
224
232 virtual void setInvertedControls(bool invertedControls);
233 virtual bool invertedControls()const;
234
238 virtual bool isSpinBoxVisible()const;
239
247 virtual bool hasPopupSlider()const;
248 virtual void setPopupSlider(bool popup);
249
254 virtual PopupWidget* popup()const;
255
260 virtual DoubleSpinBox* spinBox();
261
266 virtual DoubleSlider* slider();
267
273 virtual void setValueProxy(ValueProxy* proxy);
274 virtual ValueProxy* valueProxy() const;
275
276public Q_SLOTS:
279 virtual void reset();
280 virtual void setValue(double value);
281 virtual void setSpinBoxVisible(bool);
282
285 virtual void setDecimals(int decimals);
286
287Q_SIGNALS:
293 void valueChanged(double value);
294
299 void valueIsChanging(double value);
300
303 void decimalsChanged(int decimals);
304
305protected Q_SLOTS:
306
307 virtual void startChanging();
308 virtual void stopChanging();
309 virtual void setSpinBoxValue(double sliderValue);
310 virtual void setSliderValue(double spinBoxValue);
311 virtual void onValueProxyAboutToBeModified();
312 virtual void onValueProxyModified();
313
314protected:
315 virtual bool eventFilter(QObject *obj, QEvent *event);
316
317protected:
318 QScopedPointer<SliderWidgetPrivate> d_ptr;
319
320private:
321 Q_DECLARE_PRIVATE(SliderWidget);
322 Q_DISABLE_COPY(SliderWidget);
323
324};
325
326Q_DECLARE_OPERATORS_FOR_FLAGS(SliderWidget::SynchronizeSiblings);
327
328#endif
Definition doubleSlider.h:53
Custom SpinBox The DoubleSpinBox internally uses a QDoubleSpinBox while it retain controls over it.
Definition doubleSpinBox.h:55
Definition popupWidget.h:42
Definition sliderWidget.h:52
SynchronizeSibling
Definition sliderWidget.h:93
QWidget Superclass
Superclass typedef.
Definition sliderWidget.h:101
Definition sliderWidget.cpp:48
Base class for value proxies. Value proxy allows to decouple the displayed value from the values acce...
Definition valueProxy.h:46