aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickrangeslider.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-04-18 13:52:09 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2018-04-18 13:56:43 +0000
commit00664e8b59af37ab741ba2ae5674354a9a25e6b2 (patch)
tree76dcafd902663cc316d7f57af9d2653838baffe6 /src/quicktemplates2/qquickrangeslider.cpp
parent0e62e78729a3bbba184b657aff2e9ce16a67440b (diff)
RangeSlider: add first|second.implicitHandleWidth|Height
[ChangeLog][Controls][RangeSlider] Added first.implicitHandleWidth, first.implicitHandleHeight, second.implicitHandleWidth, and second.implicitHandleHeight properties. Change-Id: Iab68a7a905c4b6515517e3b9eb11c6fd70782764 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickrangeslider.cpp')
-rw-r--r--src/quicktemplates2/qquickrangeslider.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp
index 49384fe4..e5c0766b 100644
--- a/src/quicktemplates2/qquickrangeslider.cpp
+++ b/src/quicktemplates2/qquickrangeslider.cpp
@@ -270,8 +270,13 @@ void QQuickRangeSliderNode::setHandle(QQuickItem *handle)
if (!d->handle.isExecuting())
d->cancelHandle();
+ const qreal oldImplicitHandleWidth = implicitHandleWidth();
+ const qreal oldImplicitHandleHeight = implicitHandleHeight();
+
+ QQuickControlPrivate::get(d->slider)->removeImplicitSizeListener(d->handle);
delete d->handle;
d->handle = handle;
+
if (handle) {
if (!handle->parentItem())
handle->setParentItem(d->slider);
@@ -295,7 +300,13 @@ void QQuickRangeSliderNode::setHandle(QQuickItem *handle)
}
handle->setActiveFocusOnTab(true);
+ QQuickControlPrivate::get(d->slider)->addImplicitSizeListener(handle);
}
+
+ if (!qFuzzyCompare(oldImplicitHandleWidth, implicitHandleWidth()))
+ emit implicitHandleWidthChanged();
+ if (!qFuzzyCompare(oldImplicitHandleHeight, implicitHandleHeight()))
+ emit implicitHandleHeightChanged();
if (!d->handle.isExecuting())
emit handleChanged();
}
@@ -333,6 +344,22 @@ void QQuickRangeSliderNode::setHovered(bool hovered)
emit hoveredChanged();
}
+qreal QQuickRangeSliderNode::implicitHandleWidth() const
+{
+ Q_D(const QQuickRangeSliderNode);
+ if (!d->handle)
+ return 0;
+ return d->handle->implicitWidth();
+}
+
+qreal QQuickRangeSliderNode::implicitHandleHeight() const
+{
+ Q_D(const QQuickRangeSliderNode);
+ if (!d->handle)
+ return 0;
+ return d->handle->implicitHeight();
+}
+
void QQuickRangeSliderNode::increase()
{
Q_D(QQuickRangeSliderNode);
@@ -380,6 +407,9 @@ public:
void updateHover(const QPointF &pos);
+ void itemImplicitWidthChanged(QQuickItem *item) override;
+ void itemImplicitHeightChanged(QQuickItem *item) override;
+
bool live;
qreal from;
qreal to;
@@ -588,6 +618,24 @@ void QQuickRangeSliderPrivate::updateHover(const QPointF &pos)
second->setHovered(secondHandle && secondHandle->isEnabled() && secondHandle->contains(q->mapToItem(secondHandle, pos)));
}
+void QQuickRangeSliderPrivate::itemImplicitWidthChanged(QQuickItem *item)
+{
+ QQuickControlPrivate::itemImplicitWidthChanged(item);
+ if (item == first->handle())
+ emit first->implicitHandleWidthChanged();
+ else if (item == second->handle())
+ emit second->implicitHandleWidthChanged();
+}
+
+void QQuickRangeSliderPrivate::itemImplicitHeightChanged(QQuickItem *item)
+{
+ QQuickControlPrivate::itemImplicitHeightChanged(item);
+ if (item == first->handle())
+ emit first->implicitHandleHeightChanged();
+ else if (item == second->handle())
+ emit second->implicitHandleHeightChanged();
+}
+
QQuickRangeSlider::QQuickRangeSlider(QQuickItem *parent)
: QQuickControl(*(new QQuickRangeSliderPrivate), parent)
{
@@ -602,6 +650,13 @@ QQuickRangeSlider::QQuickRangeSlider(QQuickItem *parent)
#endif
}
+QQuickRangeSlider::~QQuickRangeSlider()
+{
+ Q_D(QQuickRangeSlider);
+ d->removeImplicitSizeListener(d->first->handle());
+ d->removeImplicitSizeListener(d->second->handle());
+}
+
/*!
\qmlproperty real QtQuick.Controls::RangeSlider::from
@@ -715,6 +770,8 @@ qreal QQuickRangeSlider::valueAt(qreal position) const
\qmlproperty Item QtQuick.Controls::RangeSlider::first.handle
\qmlproperty bool QtQuick.Controls::RangeSlider::first.pressed
\qmlproperty bool QtQuick.Controls::RangeSlider::first.hovered
+ \qmlproperty real QtQuick.Controls::RangeSlider::first.implicitHandleWidth
+ \qmlproperty real QtQuick.Controls::RangeSlider::first.implicitHandleHeight
\qmlsignal void QtQuick.Controls::RangeSlider::moved()
\table
@@ -756,6 +813,14 @@ qreal QQuickRangeSlider::valueAt(qreal position) const
\li This property holds whether the first handle is hovered.
This property was introduced in QtQuick.Controls 2.1.
\row
+ \li implicitHandleWidth
+ \li This property holds the implicit width of the first handle.
+ This property was introduced in QtQuick.Controls 2.5.
+ \row
+ \li implicitHandleHeight
+ \li This property holds the implicit height of the first handle.
+ This property was introduced in QtQuick.Controls 2.5.
+ \row
\li moved()
\li This signal is emitted when the first handle has been interactively moved
by the user by either touch, mouse, or keys.
@@ -779,6 +844,8 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const
\qmlproperty Item QtQuick.Controls::RangeSlider::second.handle
\qmlproperty bool QtQuick.Controls::RangeSlider::second.pressed
\qmlproperty bool QtQuick.Controls::RangeSlider::second.hovered
+ \qmlproperty real QtQuick.Controls::RangeSlider::second.implicitHandleWidth
+ \qmlproperty real QtQuick.Controls::RangeSlider::second.implicitHandleHeight
\qmlsignal void QtQuick.Controls::RangeSlider::moved()
\table
@@ -820,6 +887,14 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const
\li This property holds whether the second handle is hovered.
This property was introduced in QtQuick.Controls 2.1.
\row
+ \li implicitHandleWidth
+ \li This property holds the implicit width of the second handle.
+ This property was introduced in QtQuick.Controls 2.5.
+ \row
+ \li implicitHandleHeight
+ \li This property holds the implicit height of the second handle.
+ This property was introduced in QtQuick.Controls 2.5.
+ \row
\li moved()
\li This signal is emitted when the second handle has been interactively moved
by the user by either touch, mouse, or keys.