diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet build", + "type": "shell", + "group": "build", + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/src/activities/solar_system/QuizScreen.qml b/src/activities/solar_system/QuizScreen.qml --- a/src/activities/solar_system/QuizScreen.qml +++ b/src/activities/solar_system/QuizScreen.qml @@ -109,6 +109,31 @@ readonly property real itemHeightHorizontal: background.height - bar.height - closenessMeter.height - questionArea.height - 10 * ApplicationInfo.ratio readonly property real itemHeightVertical: (items.bar.level != 2 && !items.assessmentMode) ? itemHeightHorizontal * 0.39 : itemHeightHorizontal * 0.8 + property bool keyNavigation: false + + Keys.onPressed: { + keyNavigation = true + if(event.key === Qt.Key_Space) { + optionListView.currentItem.children[1].pressed() + event.accepted = true + } + if(event.key === Qt.Key_Enter) { + optionListView.currentItem.children[1].pressed() + event.accepted = true + } + if(event.key === Qt.Key_Return) { + optionListView.currentItem.children[1].pressed() + event.accepted = true + } + if(event.key === Qt.Key_Up) { + optionListView.moveCurrentIndexUp() + event.accepted = true + } + if(event.key === Qt.Key_Down) { + optionListView.moveCurrentIndexDown() + event.accepted = true + } + } ListView { id: optionListView @@ -123,6 +148,24 @@ verticalLayoutDirection: ListView.TopToBottom interactive: false model: optionListModel + focus: true + + highlight: Rectangle { + width: optionListView.width + height: optionListView.buttonHeight + color: "red" + radius: 5 + visible: keyNavigation + y: optionListView.currentItem ? optionListView.currentItem.y : 0 + Behavior on y { + SpringAnimation { + spring: 3 + damping: 0.2 + } + } + } + highlightFollowsCurrentItem: false + keyNavigationWraps: true readonly property real buttonHeight: (height - 3 * spacing) / 4 @@ -187,6 +230,7 @@ border.color: "black" opacity: 0.78 visible: !items.assessmentMode + Item { width: parent.width - 3 * ApplicationInfo.ratio height: parent.height diff --git a/src/activities/solar_system/SolarSystem.qml b/src/activities/solar_system/SolarSystem.qml --- a/src/activities/solar_system/SolarSystem.qml +++ b/src/activities/solar_system/SolarSystem.qml @@ -35,6 +35,7 @@ id: background anchors.fill: parent property bool horizontalLayout: background.width >= background.height + property bool keyNavigation: false Image { id: stars @@ -88,6 +89,38 @@ onStop: Activity.stop() + Keys.onPressed: { + background.keyNavigation = true + if(event.key === Qt.Key_Space) { + Activity.showQuizScreen(planetView.currentIndex) + event.accepted = true + } + if(event.key === Qt.Key_Enter) { + Activity.showQuizScreen(planetView.currentIndex) + event.accepted = true + } + if(event.key === Qt.Key_Return) { + Activity.showQuizScreen(planetView.currentIndex) + event.accepted = true + } + if(event.key === Qt.Key_Left) { + planetView.moveCurrentIndexLeft() + event.accepted = true + } + if(event.key === Qt.Key_Right) { + planetView.moveCurrentIndexRight() + event.accepted = true + } + if(event.key === Qt.Key_Up) { + planetView.moveCurrentIndexUp() + event.accepted = true + } + if(event.key === Qt.Key_Down) { + planetView.moveCurrentIndexDown() + event.accepted = true + } + } + IntroMessage { id: message anchors { @@ -131,13 +164,31 @@ id: planetView layoutDirection: Qt.LeftToRight verticalLayoutDirection: GridView.BottomToTop - clip: false + clip: true interactive: false visible: items.solarSystemVisible cellWidth: background.itemWidth cellHeight: cellWidth model: planetsModel + highlight: Rectangle { + width: planetView.width + height: planetView.height + color: "red" + radius: 5 + visible: background.keyNavigation + Behavior on y { + SpringAnimation { + spring: 3 + damping: 0.2 + } + } + } + + highlightFollowsCurrentItem: true + focus: true + keyNavigationWraps: true + delegate: PlanetInSolarModel { planetImageSource: realImg planetName: bodyName