aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-03-28 11:37:34 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-03-28 11:12:35 +0000
commit72e12f8e5ee54a919c254000a017f3f918825406 (patch)
tree37d7eed07ad198002aabf89bb626ba87f662ba07 /src/quicktemplates2
parentb44048ae27bd916d0eaa1e7d6a5456488ff76f29 (diff)
Slider: add horizontal and vertical properties for convenience
[ChangeLog][Controls][Slider] Added horizontal and vertical properties to make it more convenient to create orientation-dependent bindings in styles. Change-Id: Iec3332f873e482590ab4f0cca08323c905527c77 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickslider.cpp32
-rw-r--r--src/quicktemplates2/qquickslider_p.h5
2 files changed, 37 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp
index 266f883f..47f51cf2 100644
--- a/src/quicktemplates2/qquickslider.cpp
+++ b/src/quicktemplates2/qquickslider.cpp
@@ -478,6 +478,36 @@ void QQuickSlider::setPressed(bool pressed)
}
/*!
+ \since QtQuick.Controls 2.3
+ \qmlproperty bool QtQuick.Controls::Slider::horizontal
+ \readonly
+
+ This property holds whether the slider is horizontal.
+
+ \sa orientation
+*/
+bool QQuickSlider::isHorizontal() const
+{
+ Q_D(const QQuickSlider);
+ return d->orientation == Qt::Horizontal;
+}
+
+/*!
+ \since QtQuick.Controls 2.3
+ \qmlproperty bool QtQuick.Controls::Slider::vertical
+ \readonly
+
+ This property holds whether the slider is vertical.
+
+ \sa orientation
+*/
+bool QQuickSlider::isVertical() const
+{
+ Q_D(const QQuickSlider);
+ return d->orientation == Qt::Vertical;
+}
+
+/*!
\qmlproperty enumeration QtQuick.Controls::Slider::orientation
This property holds the orientation.
@@ -485,6 +515,8 @@ void QQuickSlider::setPressed(bool pressed)
Possible values:
\value Qt.Horizontal Horizontal (default)
\value Qt.Vertical Vertical
+
+ \sa horizontal, vertical
*/
Qt::Orientation QQuickSlider::orientation() const
{
diff --git a/src/quicktemplates2/qquickslider_p.h b/src/quicktemplates2/qquickslider_p.h
index a6cf02fb..f2a13217 100644
--- a/src/quicktemplates2/qquickslider_p.h
+++ b/src/quicktemplates2/qquickslider_p.h
@@ -66,6 +66,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSlider : public QQuickControl
Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL)
Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged FINAL REVISION 2)
Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL)
+ Q_PROPERTY(bool horizontal READ isHorizontal NOTIFY orientationChanged FINAL REVISION 3)
+ Q_PROPERTY(bool vertical READ isVertical NOTIFY orientationChanged FINAL REVISION 3)
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL)
Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL)
@@ -103,6 +105,9 @@ public:
bool isPressed() const;
void setPressed(bool pressed);
+ bool isHorizontal() const;
+ bool isVertical() const;
+
Qt::Orientation orientation() const;
void setOrientation(Qt::Orientation orientation);