aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-19 15:39:29 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-19 16:37:00 +0000
commite5079c1828dd0fe2e90347f20da40da033fbec5a (patch)
treeb732dbd411fc56df6a57408b2661d94c2ada06f3 /src
parent935974e174d87f9bf10a56d14bb73ade726d827a (diff)
QQuickSwitch: utilize checkStateSet()
QQuickAbstractButton::checkStateSet() did not exist when QQuickSwitch was originally implemented. QQuickSwitch no longer has to establish a signal-slot connection, but can just override the virtual to update the position when the checked state changes. Change-Id: Ic18f13bcd7b0fe9fe657c41094b4d1db5cbb2e5a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quicktemplates2/qquickswitch.cpp14
-rw-r--r--src/quicktemplates2/qquickswitch_p.h2
2 files changed, 8 insertions, 8 deletions
diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp
index 7941bf69..beb9a764 100644
--- a/src/quicktemplates2/qquickswitch.cpp
+++ b/src/quicktemplates2/qquickswitch.cpp
@@ -90,7 +90,6 @@ class QQuickSwitchPrivate : public QQuickAbstractButtonPrivate
public:
QQuickSwitchPrivate() : position(0) { }
- void updatePosition();
qreal positionAt(const QPoint &point) const;
bool handleMousePressEvent(QQuickItem *child, QMouseEvent *event);
@@ -102,12 +101,6 @@ public:
QPoint pressPoint;
};
-void QQuickSwitchPrivate::updatePosition()
-{
- Q_Q(QQuickSwitch);
- q->setPosition(checked ? 1.0 : 0.0);
-}
-
qreal QQuickSwitchPrivate::positionAt(const QPoint &point) const
{
Q_Q(const QQuickSwitch);
@@ -188,7 +181,6 @@ QQuickSwitch::QQuickSwitch(QQuickItem *parent) :
d->keepPressed = true;
setCheckable(true);
setFiltersChildMouseEvents(true);
- QObjectPrivate::connect(this, &QQuickAbstractButton::checkedChanged, d_func(), &QQuickSwitchPrivate::updatePosition);
}
/*!
@@ -255,4 +247,10 @@ bool QQuickSwitch::childMouseEventFilter(QQuickItem *child, QEvent *event)
return false;
}
+void QQuickSwitch::checkStateSet()
+{
+ Q_D(QQuickSwitch);
+ setPosition(d->checked ? 1.0 : 0.0);
+}
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickswitch_p.h b/src/quicktemplates2/qquickswitch_p.h
index fa92e9f3..bfbcceed 100644
--- a/src/quicktemplates2/qquickswitch_p.h
+++ b/src/quicktemplates2/qquickswitch_p.h
@@ -76,6 +76,8 @@ protected:
void mirrorChange() override;
bool childMouseEventFilter(QQuickItem *child, QEvent *event) override;
+ void checkStateSet() override;
+
private:
Q_DISABLE_COPY(QQuickSwitch)
Q_DECLARE_PRIVATE(QQuickSwitch)