Commit 01a6ed83 authored by Sebastian Gottfried's avatar Sebastian Gottfried
Browse files

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.
parent 7cca7d0d
......@@ -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()
}
}
......
......@@ -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()
}
}
}
}
}
}
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