aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-02-23 15:27:49 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-02-24 12:03:26 +0000
commitcd58c278f30bdd7f806e9a15552cb3954d336d15 (patch)
treea02c8976f97d61655ea445e446913e2b14d7a350 /src
parent256779a8e2eb3a012bd13a7fcf4294a18f0cd07f (diff)
Add Control::wheelEnabled
Change-Id: I1ea2c93e908c98119ba25e3e40e02ab96eca8dd2 Task-number: QTBUG-50220 Task-number: QTBUG-50221 Task-number: QTBUG-50222 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/imports/controls/plugins.qmltypes1
-rw-r--r--src/imports/templates/plugins.qmltypes1
-rw-r--r--src/templates/qquickcontrol.cpp25
-rw-r--r--src/templates/qquickcontrol_p.h5
-rw-r--r--src/templates/qquickcontrol_p_p.h1
5 files changed, 31 insertions, 2 deletions
diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes
index efe56ce8..27cefe97 100644
--- a/src/imports/controls/plugins.qmltypes
+++ b/src/imports/controls/plugins.qmltypes
@@ -187,6 +187,7 @@ Module {
Property { name: "mirrored"; type: "bool"; isReadonly: true }
Property { name: "focusPolicy"; type: "Qt::FocusPolicy" }
Property { name: "focusReason"; type: "Qt::FocusReason" }
+ Property { name: "wheelEnabled"; type: "bool" }
Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "contentItem"; type: "QQuickItem"; isPointer: true }
}
diff --git a/src/imports/templates/plugins.qmltypes b/src/imports/templates/plugins.qmltypes
index 05ea33ec..11f6a50a 100644
--- a/src/imports/templates/plugins.qmltypes
+++ b/src/imports/templates/plugins.qmltypes
@@ -181,6 +181,7 @@ Module {
Property { name: "mirrored"; type: "bool"; isReadonly: true }
Property { name: "focusPolicy"; type: "Qt::FocusPolicy" }
Property { name: "focusReason"; type: "Qt::FocusReason" }
+ Property { name: "wheelEnabled"; type: "bool" }
Property { name: "background"; type: "QQuickItem"; isPointer: true }
Property { name: "contentItem"; type: "QQuickItem"; isPointer: true }
}
diff --git a/src/templates/qquickcontrol.cpp b/src/templates/qquickcontrol.cpp
index ad7e6924..e509ec3f 100644
--- a/src/templates/qquickcontrol.cpp
+++ b/src/templates/qquickcontrol.cpp
@@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE
*/
QQuickControlPrivate::QQuickControlPrivate() :
- hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false), hasLocale(false),
+ hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false), hasLocale(false), wheelEnabled(false),
padding(0), topPadding(0), leftPadding(0), rightPadding(0), bottomPadding(0), spacing(0),
focusPolicy(Qt::NoFocus), focusReason(Qt::OtherFocusReason),
background(nullptr), contentItem(nullptr), accessibleAttached(nullptr)
@@ -809,6 +809,27 @@ void QQuickControl::setFocusReason(Qt::FocusReason reason)
}
/*!
+ \qmlproperty bool Qt.labs.controls::Control::wheelEnabled
+
+ This property determines whether the control handles wheel events. The default value is \c false.
+*/
+bool QQuickControl::isWheelEnabled() const
+{
+ Q_D(const QQuickControl);
+ return d->wheelEnabled;
+}
+
+void QQuickControl::setWheelEnabled(bool enabled)
+{
+ Q_D(QQuickControl);
+ if (d->wheelEnabled == enabled)
+ return;
+
+ d->wheelEnabled = enabled;
+ emit wheelEnabledChanged();
+}
+
+/*!
\qmlproperty Item Qt.labs.controls::Control::background
This property holds the background item.
@@ -931,7 +952,7 @@ void QQuickControl::wheelEvent(QWheelEvent *event)
if ((d->focusPolicy & Qt::WheelFocus) == Qt::WheelFocus)
forceActiveFocus(Qt::MouseFocusReason);
- QQuickItem::wheelEvent(event);
+ event->setAccepted(d->wheelEnabled);
}
void QQuickControl::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
diff --git a/src/templates/qquickcontrol_p.h b/src/templates/qquickcontrol_p.h
index 9f5559af..55116dc1 100644
--- a/src/templates/qquickcontrol_p.h
+++ b/src/templates/qquickcontrol_p.h
@@ -72,6 +72,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickControl : public QQuickItem
Q_PROPERTY(bool mirrored READ isMirrored NOTIFY mirroredChanged FINAL)
Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged FINAL)
Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL)
+ Q_PROPERTY(bool wheelEnabled READ isWheelEnabled WRITE setWheelEnabled NOTIFY wheelEnabledChanged FINAL)
Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL)
Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL)
@@ -121,6 +122,9 @@ public:
Qt::FocusReason focusReason() const;
void setFocusReason(Qt::FocusReason reason);
+ bool isWheelEnabled() const;
+ void setWheelEnabled(bool enabled);
+
QQuickItem *background() const;
void setBackground(QQuickItem *background);
@@ -141,6 +145,7 @@ Q_SIGNALS:
void mirroredChanged();
void focusPolicyChanged();
void focusReasonChanged();
+ void wheelEnabledChanged();
void backgroundChanged();
void contentItemChanged();
diff --git a/src/templates/qquickcontrol_p_p.h b/src/templates/qquickcontrol_p_p.h
index 1b1c969a..ef4cd17e 100644
--- a/src/templates/qquickcontrol_p_p.h
+++ b/src/templates/qquickcontrol_p_p.h
@@ -112,6 +112,7 @@ public:
bool hasRightPadding;
bool hasBottomPadding;
bool hasLocale;
+ bool wheelEnabled;
qreal padding;
qreal topPadding;
qreal leftPadding;