Commit cd500ffe authored by Timothée Giet's avatar Timothée Giet

core, fix GCDialog keyboard focus

allow GCDialog to have keyboard focus, and always give it back to its parent
fix usage of checkForVoices to give the activity as parent
fix to avoid englishFallbackDialog at same time as Missing sound files dialog
fix to not try to destroy englishFallbackDialog as it can not be destroyed
parent 4aa24738
......@@ -68,7 +68,7 @@ ActivityBase {
QtObject {
id: items
property Item main: activity.main
property Item activityPage: activity
property alias bar: bar
property alias trainModel: trainModel
property GCAudio audioVoices: activity.audioVoices
......
......@@ -44,7 +44,7 @@ var mode;
function start(_items, _mode)
{
Core.checkForVoices(_items.main);
Core.checkForVoices(_items.activityPage);
items = _items;
mode = _mode;
......
......@@ -59,6 +59,7 @@ ActivityBase {
}
QtObject {
id: items
property Item activityPage: activity
property alias background: background
property alias bar: bar
property alias bonus: bonus
......
......@@ -33,7 +33,7 @@ var hasWon
function start(items_, dataset_, mode_) {
if (mode_ === "Colors")
Core.checkForVoices(items_.background);
Core.checkForVoices(items_.activityPage);
items = items_
dataset = dataset_.get()
currentLevel = 0
......
......@@ -40,7 +40,7 @@ ActivityBase {
// We need to set it back to the textinput item in order to have key events.
onFocusChanged: {
if(focus) {
Activity.focusTextInput()
Activity.focusTextInput();
}
}
......@@ -109,9 +109,10 @@ ActivityBase {
}
onStart: {
focus = true
Activity.start(items)
Activity.focusTextInput()
focus = true;
Activity.start(items);
if(!background.englishFallback)
Activity.focusTextInput();
}
onStop: {
......@@ -402,12 +403,16 @@ ActivityBase {
Loader {
id: englishFallbackDialog
sourceComponent: GCDialog {
parent: activity.main
parent: activity
isDestructible: false
message: qsTr("We are sorry, we don't have yet a translation for your language.") + " " +
qsTr("GCompris is developed by the KDE community, you can translate GCompris by joining a translation team on <a href=\"%2\">%2</a>").arg("https://l10n.kde.org/") +
"<br /> <br />" +
qsTr("We switched to English for this activity but you can select another language in the configuration dialog.")
onClose: background.englishFallback = false
onClose: {
background.englishFallback = false;
Activity.focusTextInput;
}
}
anchors.fill: parent
focus: true
......
......@@ -147,12 +147,21 @@ ActivityBase {
Loader {
id: englishFallbackDialog
sourceComponent: GCDialog {
parent: activity.main
parent: activity
isDestructible: false
message: qsTr("We are sorry, we don't have yet a translation for your language.") + " " +
qsTr("GCompris is developed by the KDE community, you can translate GCompris by joining a translation team on <a href=\"%2\">%2</a>").arg("https://l10n.kde.org/") +
"<br /> <br />" +
qsTr("We switched to English for this activity but you can select another language in the configuration dialog.")
onClose: background.englishFallback = false
onStart: {
menuScreen.stop();
forceActiveFocus();
parent.Keys.enabled = false;
}
onClose: {
background.englishFallback = false;
menuScreen.start();
}
}
anchors.fill: parent
focus: true
......@@ -233,6 +242,7 @@ ActivityBase {
// Restart the activity with new information
if(oldLocale !== newLocale) {
console.log("activity restarted")
Activity.stop()
Activity.start();
}
......
......@@ -45,6 +45,7 @@ function start() {
lessonModelIndex = 0;
currentSubLevel = 0;
items.imageReview.stop()
items.menuScreen.stop()
var locale = GCompris.ApplicationInfo.getVoicesLocale(items.locale)
......@@ -64,7 +65,9 @@ function start() {
savedPropertiesToLessons(items.dialogActivityConfig.dataToSave)
sortByFavorites();
items.menuScreen.start()
if(!items.background.englishFallback) {
items.menuScreen.start();
}
}
// Insert our specific properties in the lessons
......
......@@ -54,7 +54,8 @@ ActivityBase {
// Add here the QML items you need to access in javascript
QtObject {
id: items
property Item main: activity.main
//property Item main: activity.main
property Item activityPage: activity
property GCAudio audioVoices: activity.audioVoices
property GCSfx audioEffects: activity.audioEffects
property alias background: background
......
......@@ -35,7 +35,7 @@ function start(items_, operationMode_) {
items = items_;
operationMode = operationMode_;
if(!operationMode && items.voicesEnabled)
Core.checkForVoices(items_.main);
Core.checkForVoices(items_.activityPage);
numberOfLevel = items.levels.length;
currentLevel = 0;
initLevel();
......
......@@ -63,7 +63,7 @@ ActivityBase {
QtObject {
id: items
property Item main: activity.main
property Item activityPage: activity
property alias bar: bar
property alias background: background
property alias wordsModel: wordsModel
......@@ -420,12 +420,16 @@ ActivityBase {
Loader {
id: englishFallbackDialog
sourceComponent: GCDialog {
parent: activity.main
parent: activity
isDestructible: false
message: qsTr("We are sorry, we don't have yet a translation for your language.") + " " +
qsTr("GCompris is developed by the KDE community, you can translate GCompris by joining a translation team on <a href=\"%2\">%2</a>").arg("https://l10n.kde.org/") +
"<br /> <br />" +
qsTr("We switched to English for this activity but you can select another language in the configuration dialog.")
onClose: background.englishFallback = false
onClose: {
background.englishFallback = false;
Core.checkForVoices(activity);
}
}
anchors.fill: parent
focus: true
......
......@@ -47,13 +47,12 @@ var incorrectFlag = false;
var locale;
function start(_items) {
Core.checkForVoices(_items.main);
items = _items;
// register the voices for the locale
locale = GCompris.ApplicationInfo.getVoicesLocale(items.locale)
GCompris.DownloadManager.updateResource(GCompris.DownloadManager.getVoicesResourceForLocale(locale))
locale = GCompris.ApplicationInfo.getVoicesLocale(items.locale);
GCompris.DownloadManager.updateResource(GCompris.DownloadManager.getVoicesResourceForLocale(locale));
loadDataset();
levels = Lang.getAllLessons(dataset)
levels = Lang.getAllLessons(dataset);
currentLevel = 0;
currentSubLevel = 0;
maxLevel = levels.length;
......@@ -61,10 +60,12 @@ function start(_items) {
}
function loadDataset() {
var resourceUrl = "qrc:/gcompris/src/activities/lang/resource/"
var resourceUrl = "qrc:/gcompris/src/activities/lang/resource/";
var data = Lang.loadDataset(items.parser, resourceUrl, locale);
dataset = data["dataset"];
items.background.englishFallback = data["englishFallback"];
if(!items.background.englishFallback)
Core.checkForVoices(_items.activityPage);
}
function stop() {
......
......@@ -311,7 +311,8 @@ ActivityBase {
Loader {
id: englishFallbackDialog
sourceComponent: GCDialog {
parent: activity.main
parent: activity
isDestructible: false
message: qsTr("We are sorry, we don't have yet a translation for your language.") + " " +
qsTr("GCompris is developed by the KDE community, you can translate GCompris by joining a translation team on <a href=\"%2\">%2</a>").arg("https://l10n.kde.org/") +
"<br /> <br />" +
......
......@@ -69,6 +69,7 @@ ActivityBase {
QtObject {
id: items
property Item activityPage: activity
property alias background: background
property alias bar: bar
property alias bonus: bonus
......
......@@ -46,7 +46,7 @@ var clouds = new Array;
var cloudsErased = new Array;
function start(items_, dataset_) {
Core.checkForVoices(items_.background);
Core.checkForVoices(items_.activityPage);
items = items_
dataset = dataset_
......
......@@ -62,6 +62,12 @@ Item {
*/
property alias button2Text: button2.text
/**
* type:bool
* Check is the dialog can be destroyed
*/
property bool isDestructible: true
/**
* Emitted when the dialog should be started.
*
......@@ -94,13 +100,31 @@ Item {
focus: true
opacity: 0
onVisibleChanged: {
if(visible) {
gcdialog.forceActiveFocus();
parent.Keys.enabled = false;
}
}
anchors {
fill: parent
}
onStart: opacity = 1
onStop: opacity = 0
onClose: destroy()
onStart: {
opacity = 1;
gcdialog.forceActiveFocus();
parent.Keys.enabled = false;
}
onStop: {
opacity = 0;
parent.Keys.enabled = true;
parent.forceActiveFocus();
}
onClose: {
if(isDestructible)
destroy();
}
Behavior on opacity { NumberAnimation { duration: 200 } }
onOpacityChanged: opacity === 0 ? close() : null
......@@ -210,11 +234,8 @@ Item {
}
}
// Fixme not working, need to properly get the focus on this dialog
Keys.onEscapePressed: {
stop()
event.accepted = true;
stop();
}
// The cancel button
......
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