Commit be44b176 authored by Sebastian Gottfried's avatar Sebastian Gottfried
Browse files

Fix Keyboard Control Issues On Training Screen

 * focus first button in menu overlay when shown
 * don't let the user focus items outside the menu with tab or backtab
 * allow button navigation with up and down
 * return focus to training widget when menu is closed
 * pause training when training widget looses focus
parent 6126bb1b
......@@ -112,8 +112,9 @@ FocusScope {
TrainingStats {
id: stats
onTimeIsRunningChanged: {
if (timeIsRunning)
if (timeIsRunning) {
screen.trainingStarted = false
}
}
}
......@@ -306,11 +307,7 @@ FocusScope {
id: menuOverlay
blurSource: screenContent
anchors.fill: parent
onVisibleChanged: {
if (!visible) {
trainingWidget.forceActiveFocus()
}
}
onClosed: trainingWidget.forceActiveFocus()
onRestartRequested: screen.restartRequested()
onAbortRequested: screen.abortRequested()
}
......
......@@ -22,11 +22,12 @@ import QtQuick.Layouts 1.1
import QtGraphicalEffects 1.0
import ktouch 1.0
Item {
FocusScope {
id: item
property alias blurSource: effectSource.sourceItem
signal closed()
signal restartRequested()
signal abortRequested()
......@@ -41,11 +42,12 @@ Item {
function show() {
item.opacity = 1
groupBox.forceActiveFocus()
resumeButton.forceActiveFocus()
}
function hide() {
item.opacity = 0
closed()
}
ShaderEffectSource {
......@@ -101,6 +103,9 @@ Item {
text: i18n("Resume Training")
width: parent.width
onClicked: hide()
KeyNavigation.backtab: returnButton
KeyNavigation.tab: restartButton
KeyNavigation.down: restartButton
}
Button {
......@@ -112,6 +117,10 @@ Item {
restartRequested()
hide()
}
KeyNavigation.backtab: resumeButton
KeyNavigation.tab: returnButton
KeyNavigation.up: resumeButton
KeyNavigation.down: returnButton
}
Button {
......@@ -123,6 +132,9 @@ Item {
abortRequested()
hide()
}
KeyNavigation.backtab: restartButton
KeyNavigation.tab: resumeButton
KeyNavigation.up: restartButton
}
Keys.onDownPressed: {
......
......@@ -118,7 +118,7 @@ FocusScope {
trainingStats: stats
cursorItem: cursor
onFocusChanged: {
onActiveFocusChanged: {
if (!trainingLine.activeFocus) {
trainingStats.stopTraining()
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment