Commit 910fe87f authored by Holger Kaelberer's avatar Holger Kaelberer
Browse files

balancebox: fix back-button on android

- We left GCompris immediately due to disabled Keys.
- Also need to handle Key_Back explicitly for page stack interaction
  in editor.
- Also unlock screen orientation onStop.
parent 7e125dd8
......@@ -44,7 +44,6 @@ ActivityBase {
}
onStop: {console.log("XXX BalanceBox onStop");}
Keys.enabled: ApplicationInfo.isMobile ? false : true
Keys.onPressed: Activity.processKeyPress(event.key)
Keys.onReleased: Activity.processKeyRelease(event.key)
......@@ -56,22 +55,6 @@ ActivityBase {
signal start
signal stop
Keys.onPressed: {
if (event.key == Qt.Key_A) {
startEditor()
}
}
Keys.onEscapePressed: {
console.log("XXX Balancebox onEscape");
if (activity.mode == "test") {
console.log("XXX Balancebox onEscape");
startEditor();
event.accepted = true;
} else
event.accepted = false;
}
function startEditor() {
console.log("XXX: launching editor");
editorLoader.active = true;
......@@ -81,6 +64,23 @@ ActivityBase {
displayDialog(editorLoader.item);
}
function handleBackEvent() {
console.log("XXX Balancebox onEscape/back");
if (activity.mode == "test") {
console.log("XXX Balancebox onEscape/back");
startEditor();
return true;
} else
return false;
}
Keys.onEscapePressed: event.accepted = handleBackEvent();
Keys.onReleased: {
if (event.key === Qt.Key_Back)
event.accepted = handleBackEvent();
}
Component.onCompleted: {
dialogActivityConfig.getInitialConfiguration()
activity.start.connect(start)
......
......@@ -21,11 +21,12 @@
/* ToDo:
- levels, levels, levels
(- fix inconsistent tilting behaviour on different android devices)
- make sensitivity configurable?
- use Qt classes instead of jni for orientation?
- visualize when in test-mode in Balancebox
- fix back-button on android (missing parent?)
- catch case of user levelset without or empty levels file
- editor: detect and warn invalid levels (no start, no goal)
- handle resize events
*/
.pragma library
.import QtQuick 2.0 as Quick
......@@ -99,7 +100,6 @@ function start(items_) {
if (items.mode === "play") {
if (GCompris.ApplicationInfo.isMobile) {
// lock screen orientation
var or = GCompris.ApplicationInfo.getRequestedOrientation();
GCompris.ApplicationInfo.setRequestedOrientation(0);
if (GCompris.ApplicationInfo.getNativeOrientation() === Qt.PortraitOrientation) {
/*
......@@ -214,6 +214,9 @@ function finishBall(won, x, y)
function stop() {
// reset everything
tearDown();
// unlock screen orientation
if (GCompris.ApplicationInfo.isMobile)
GCompris.ApplicationInfo.setRequestedOrientation(-1);
}
function createObject(component, properties)
......
......@@ -93,6 +93,9 @@ function showMessageDialog(parent, informativeText,
button1Text, button1Callback,
button2Text, button2Callback,
closeCallback) {
console.log("XXXXXXXXXXXXXXXXX " + parent + " trace=");
console.trace();
var qmlStr =
'import QtQuick 2.0\n'
+ 'GCDialog {\n'
......
......@@ -61,7 +61,7 @@ Window {
}
}
onClosing: Core.quit()
onClosing: Core.quit(main)
GCAudio {
id: audioVoices
......
Markdown is supported
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