From kde-commits Wed Dec 31 18:34:16 2014 From: Bruno Coudoin Date: Wed, 31 Dec 2014 18:34:16 +0000 To: kde-commits Subject: [gcompris/devel2] src/activities/imageid: imageid, add key navigation Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=142005175506298 Git commit d74c9ff09807ab6acfd34c638998657a1bfa14cb by Bruno Coudoin. Committed on 19/12/2014 at 23:08. Pushed by bcoudoin into branch 'devel2'. imageid, add key navigation M +50 -2 src/activities/imageid/Imageid.qml http://commits.kde.org/gcompris/d74c9ff09807ab6acfd34c638998657a1bfa14cb diff --git a/src/activities/imageid/Imageid.qml b/src/activities/imageid/Im= ageid.qml index 5dfc9e5..882e825 100644 --- a/src/activities/imageid/Imageid.qml +++ b/src/activities/imageid/Imageid.qml @@ -44,6 +44,7 @@ ActivityBase { = property bool horizontalLayout: background.width > background.heig= ht property Item dialog + property bool keyNavigation: false = signal start signal stop @@ -102,12 +103,42 @@ ActivityBase { DownloadManager.updateResource("data/words/words.rcc") } repeatItem.visible =3D false + keyNavigation =3D false activity.audioVoices.error.connect(voiceError) activity.audioVoices.done.connect(voiceDone) } = onStop: { Activity.stop() } = + Keys.onRightPressed: { + keyNavigation =3D true + wordListView.incrementCurrentIndex() + } + Keys.onLeftPressed: { + keyNavigation =3D true + wordListView.decrementCurrentIndex() + } + Keys.onDownPressed: { + keyNavigation =3D true + wordListView.incrementCurrentIndex() + } + Keys.onUpPressed: { + keyNavigation =3D true + wordListView.decrementCurrentIndex() + } + Keys.onSpacePressed: { + keyNavigation =3D true + wordListView.currentItem.pressed() + } + Keys.onEnterPressed: { + keyNavigation =3D true + wordListView.currentItem.pressed() + } + Keys.onReturnPressed: { + keyNavigation =3D true + wordListView.currentItem.pressed() + } + JsonParser { id: parser = @@ -166,10 +197,27 @@ ActivityBase { orientation: Qt.Vertical verticalLayoutDirection: ListView.TopToBottom interactive: false + model: wordListModel = - property int buttonHeight: height / wordListModel.count * = 0.9 + highlight: Rectangle { + width: wordListView.width + height: wordListView.buttonHeight + color: "lightsteelblue" + radius: 5 + visible: background.keyNavigation + y: wordListView.currentItem.y + Behavior on y { + SpringAnimation { + spring: 3 + damping: 0.2 + } + } + } + highlightFollowsCurrentItem: false + focus: true + keyNavigationWraps: true = - model: wordListModel + property int buttonHeight: height / wordListModel.count * = 0.9 = delegate: AnswerButton { id: wordRectangle