aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Gottfried <sebastian.gottfried@posteo.de>2016-10-24 15:56:26 (GMT)
committerSebastian Gottfried <sebastian.gottfried@posteo.de>2016-10-24 15:56:26 (GMT)
commitbe44b176fa51fb6fadf5963b571a36ecb9762257 (patch)
tree6eb853ed09193519ea879a9001708e33b758cd7d
parent6126bb1b23ad5ae1441bc821cd0fefd83b41ea91 (diff)
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
-rw-r--r--src/qml/TrainingScreen.qml9
-rw-r--r--src/qml/TrainingScreenMenuOverlay.qml16
-rw-r--r--src/qml/TrainingWidget.qml2
3 files changed, 18 insertions, 9 deletions
diff --git a/src/qml/TrainingScreen.qml b/src/qml/TrainingScreen.qml
index 3afebdc..71c3403 100644
--- a/src/qml/TrainingScreen.qml
+++ b/src/qml/TrainingScreen.qml
@@ -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()
}
diff --git a/src/qml/TrainingScreenMenuOverlay.qml b/src/qml/TrainingScreenMenuOverlay.qml
index 71858fe..ae94fa2 100644
--- a/src/qml/TrainingScreenMenuOverlay.qml
+++ b/src/qml/TrainingScreenMenuOverlay.qml
@@ -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: {
diff --git a/src/qml/TrainingWidget.qml b/src/qml/TrainingWidget.qml
index 90ce60c..cfe5605 100644
--- a/src/qml/TrainingWidget.qml
+++ b/src/qml/TrainingWidget.qml
@@ -118,7 +118,7 @@ FocusScope {
trainingStats: stats
cursorItem: cursor
- onFocusChanged: {
+ onActiveFocusChanged: {
if (!trainingLine.activeFocus) {
trainingStats.stopTraining()
}