aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickgridview.cpp
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2015-11-25 16:37:12 +0100
committerMitch Curtis <mitch.curtis@theqtcompany.com>2015-12-08 09:40:54 +0000
commit52954268e9202e33eb8c2db93a51d55a2596051b (patch)
treea803a43285bfdf8a30ab9c606fcf789891a7170f /src/quick/items/qquickgridview.cpp
parentd1fbfbbab7f78e0a1050acce3540c02660a0d68f (diff)
GridView: add keyNavigationEnabled property
It is useful for applications that need to selectively enable or disable mouse and keyboard interaction. [ChangeLog][QtQuick][GridView] added keyNavigationEnabled property to allow mouse and keyboard interaction to be selectively enabled/disabled. Change-Id: Idba0e00c2f228b79ca4c32d9856f22f7eaea98dd Task-number: QTBUG-17051 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/quick/items/qquickgridview.cpp')
-rw-r--r--src/quick/items/qquickgridview.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index 65d7362e84..150fa6a415 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -1502,6 +1502,25 @@ void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
By default, key navigation is not wrapped.
*/
+
+/*!
+ \qmlproperty bool QtQuick::GridView::keyNavigationEnabled
+ \since 5.7
+
+ This property holds whether the key navigation of the grid is enabled.
+
+ If this is \c true, the user can navigate the view with a keyboard.
+ It is useful for applications that need to selectively enable or
+ disable mouse and keyboard interaction.
+
+ By default, the value of this property is bound to
+ \l {Flickable::}{interactive} to ensure behavior compatibility for
+ existing applications. When explicitly set, it will cease to be bound to
+ the interactive property.
+
+ \sa \l {Flickable::}{interactive}
+*/
+
/*!
\qmlproperty int QtQuick::GridView::cacheBuffer
This property determines whether delegates are retained outside the
@@ -2076,7 +2095,8 @@ void QQuickGridView::viewportMoved(Qt::Orientations orient)
void QQuickGridView::keyPressEvent(QKeyEvent *event)
{
Q_D(QQuickGridView);
- if (d->model && d->model->count() && d->interactive) {
+ if (d->model && d->model->count() && ((d->interactive && !d->explicitKeyNavigationEnabled)
+ || (d->explicitKeyNavigationEnabled && d->keyNavigationEnabled))) {
d->moveReason = QQuickGridViewPrivate::SetIndex;
int oldCurrent = currentIndex();
switch (event->key()) {