summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Gottfried <sebastian.gottfried@posteo.de>2016-11-14 10:20:34 (GMT)
committerSebastian Gottfried <sebastian.gottfried@posteo.de>2016-11-14 10:20:34 (GMT)
commit01a6ed83821e0af7b7b27e6f67898ae67785424c (patch)
tree0a5b3a7be730eaf8facc6032cf1d6e8019fea3f8
parent7cca7d0d97034db48bf8d02dbf59052767c7ce8d (diff)
Training Screen: Use A Loader For The Menu
To make the scene graph smaller than the menu isn't visible. Which is most of the time.
-rw-r--r--src/qml/TrainingScreen.qml6
-rw-r--r--src/qml/TrainingScreenMenuOverlay.qml233
2 files changed, 131 insertions, 108 deletions
diff --git a/src/qml/TrainingScreen.qml b/src/qml/TrainingScreen.qml
index 69b1a14..85d649e 100644
--- a/src/qml/TrainingScreen.qml
+++ b/src/qml/TrainingScreen.qml
@@ -126,11 +126,11 @@ FocusScope {
sequence: "Escape"
enabled: screen.visible
onActivated: {
- if (menuOverlay.opacity === 0) {
- menuOverlay.show()
+ if (menuOverlay.active) {
+ menuOverlay.hide()
}
else {
- menuOverlay.hide()
+ menuOverlay.show()
}
}
diff --git a/src/qml/TrainingScreenMenuOverlay.qml b/src/qml/TrainingScreenMenuOverlay.qml
index ae94fa2..a3a07da 100644
--- a/src/qml/TrainingScreenMenuOverlay.qml
+++ b/src/qml/TrainingScreenMenuOverlay.qml
@@ -22,138 +22,161 @@ import QtQuick.Layouts 1.1
import QtGraphicalEffects 1.0
import ktouch 1.0
-FocusScope {
- id: item
+Loader {
+ id: loader
- property alias blurSource: effectSource.sourceItem
+ property Item blurSource;
signal closed()
signal restartRequested()
signal abortRequested()
- opacity: 0
-
- Behavior on opacity {
- NumberAnimation {
- duration: 300
- easing.type: Easing.InOutQuad
- }
- }
+ active: false
function show() {
- item.opacity = 1
- resumeButton.forceActiveFocus()
+ loader.active = true
}
function hide() {
item.opacity = 0
- closed()
- }
-
- ShaderEffectSource {
- id: effectSource
- anchors.fill: parent
- hideSource: false
- }
-
- HueSaturation {
- id: desaturatedBackground
- source: effectSource
- anchors.fill: parent
- lightness: -0.3
- saturation: -0.5
- visible: false
- }
-
- FastBlur {
- anchors.fill: parent
- source: desaturatedBackground
- radius: 50
- }
-
- Rectangle {
- anchors.fill: parent
- color: "#55000000"
}
- /* swallow all mouse events */
- MouseArea {
- anchors.fill: parent
- enabled: item.opacity > 0
- hoverEnabled: true
- }
+ sourceComponent: Component {
+ FocusScope {
+ id: item
+ anchors.fill: parent
+
+ opacity: loader.status == Loader.Ready? 1: 0
+
+ Component.onCompleted: resumeButton.forceActiveFocus()
+
+ Behavior on opacity {
+ SequentialAnimation {
+ NumberAnimation {
+ duration: 300
+ easing.type: Easing.InOutQuad
+ }
+ ScriptAction {
+ script: {
+ if (opacity == 0) {
+ loader.active = false;
+ closed()
+ }
+ }
+ }
+ }
+ }
- GroupBox {
- id: groupBox
- anchors.centerIn: parent
- width: column.width + 30
- height: column.height + 30
-
- Column {
- id: column
- focus: true
- anchors.centerIn: parent
- spacing: 15
- width: Math.max(resumeButton.implicitWidth, restartButton.implicitWidth, returnButton.implicitWidth)
-
- Button {
- id: resumeButton
- iconName: "go-next-view"
- text: i18n("Resume Training")
- width: parent.width
- onClicked: hide()
- KeyNavigation.backtab: returnButton
- KeyNavigation.tab: restartButton
- KeyNavigation.down: restartButton
+ ShaderEffectSource {
+ id: effectSource
+ sourceItem: blurSource
+ anchors.fill: parent
+ hideSource: false
}
- Button {
- id: restartButton
- iconName: "view-refresh"
- text: i18n("Restart Lesson")
- width: parent.width
- onClicked: {
- restartRequested()
- hide()
- }
- KeyNavigation.backtab: resumeButton
- KeyNavigation.tab: returnButton
- KeyNavigation.up: resumeButton
- KeyNavigation.down: returnButton
+ HueSaturation {
+ id: desaturatedBackground
+ source: effectSource
+ anchors.fill: parent
+ lightness: -0.3
+ saturation: -0.5
+ visible: false
}
- Button {
- id: returnButton
- iconName: "go-home"
- text: i18n("Return to Home Screen")
- width: parent.width
- onClicked: {
- abortRequested()
- hide()
- }
- KeyNavigation.backtab: restartButton
- KeyNavigation.tab: resumeButton
- KeyNavigation.up: restartButton
+ FastBlur {
+ anchors.fill: parent
+ source: desaturatedBackground
+ radius: 50
}
- Keys.onDownPressed: {
- if (resumeButton.focus)
- restartButton.focus = true;
- else if (restartButton.focus)
- returnButton.focus = true;
+ Rectangle {
+ anchors.fill: parent
+ color: "#55000000"
}
- Keys.onUpPressed: {
- if (restartButton.focus)
- resumeButton.focus = true;
- else if (returnButton.focus)
- restartButton.focus = true;
+ /* swallow all mouse events */
+ MouseArea {
+ anchors.fill: parent
+ enabled: false
+ hoverEnabled: enabled
}
- Keys.onEscapePressed: {
- hide()
+
+ GroupBox {
+ id: groupBox
+ anchors.centerIn: parent
+ width: column.width + 30
+ height: column.height + 30
+
+ Column {
+ id: column
+ focus: true
+ anchors.centerIn: parent
+ spacing: 15
+ width: Math.max(resumeButton.implicitWidth, restartButton.implicitWidth, returnButton.implicitWidth)
+
+ Button {
+ id: resumeButton
+ iconName: "go-next-view"
+ text: i18n("Resume Training")
+ width: parent.width
+ onClicked: hide()
+ KeyNavigation.backtab: returnButton
+ KeyNavigation.tab: restartButton
+ KeyNavigation.down: restartButton
+ }
+
+ Button {
+ id: restartButton
+ iconName: "view-refresh"
+ text: i18n("Restart Lesson")
+ width: parent.width
+ onClicked: {
+ restartRequested()
+ hide()
+ }
+ KeyNavigation.backtab: resumeButton
+ KeyNavigation.tab: returnButton
+ KeyNavigation.up: resumeButton
+ KeyNavigation.down: returnButton
+ }
+
+ Button {
+ id: returnButton
+ iconName: "go-home"
+ text: i18n("Return to Home Screen")
+ width: parent.width
+ onClicked: {
+ abortRequested()
+ hide()
+ }
+ KeyNavigation.backtab: restartButton
+ KeyNavigation.tab: resumeButton
+ KeyNavigation.up: restartButton
+ }
+
+ Keys.onDownPressed: {
+ if (resumeButton.focus)
+ restartButton.focus = true;
+ else if (restartButton.focus)
+ returnButton.focus = true;
+ }
+
+ Keys.onUpPressed: {
+ if (restartButton.focus)
+ resumeButton.focus = true;
+ else if (returnButton.focus)
+ restartButton.focus = true;
+ }
+
+ Keys.onEscapePressed: {
+ hide()
+ }
+ }
}
}
+
}
}
+