Commit ef19df75 authored by siddhesh suthar's avatar siddhesh suthar Committed by Bruno Coudoin
Browse files

Able to save the lang progress. minor fixes like image going out of box

parent 1dff5616
......@@ -88,6 +88,8 @@ ActivityBase {
property alias englishFallbackDialog: englishFallbackDialog
property alias miniGameLoader: miniGameLoader
property alias locale: background.locale
property alias progress: background.progress
property alias dialogActivityConfig: dialogActivityConfig
function checkWordExistence(wordForCheck) {
return activity.audioVoices.fileExists(ApplicationInfo.getAudioFilePath(wordForCheck.voice))
......@@ -117,7 +119,6 @@ ActivityBase {
Activity.init(items)
items.menu_screen.visible = true
repeatItem.visible = false
keyNavigation = false
activity.audioVoices.error.connect(voiceError)
activity.audioVoices.done.connect(voiceDone)
......@@ -136,6 +137,9 @@ ActivityBase {
}
onStop: {
DownloadManager.resourceRegistered.disconnect(handleResourceRegistered);
dialogActivityConfig.saveDatainConfiguration()
// var progressToSave = {'progress': Activity.savedProgress}
// ApplicationSettings.saveActivityConfiguration(activity,progressToSave)
Activity.stop()
}
......@@ -574,21 +578,32 @@ ActivityBase {
onClose: home()
onLoadData: {
if(dataToSave && dataToSave["locale"]) {
// if(dataToSave && dataToSave["locale"] && dataToSave["progress"] && dataToSave["favorites"]) {
if(dataToSave && dataToSave["locale"] && dataToSave["progress"]) {
background.locale = dataToSave["locale"];
Activity.savedProgress = dataToSave["progress"];
// Activity.favorites = dataToSave["favorites"];
}
}
onSaveData: {
var oldLocale = background.locale;
var newLocale = dialogActivityConfig.configItem.availableLangs[dialogActivityConfig.loader.item.localeBox.currentIndex].locale;
var newLocale = oldLocale;
if(dialogActivityConfig.loader.item)
newLocale = dialogActivityConfig.configItem.availableLangs[dialogActivityConfig.loader.item.localeBox.currentIndex].locale;
// Remove .UTF-8
if(newLocale.indexOf('.') != -1) {
newLocale = newLocale.substring(0, newLocale.indexOf('.'))
}
dataToSave = {"locale": newLocale}
var newProgress = Activity.savedProgress
// var newFavorites = Activity.favorites
console.log("new progress "+newProgress )
// console.log("new favorites "+newFavorites )
dataToSave = {"locale": newLocale, "progress": newProgress}
// dataToSave = {"locale": newLocale, "progress": newProgress, "favorites": newFavorites}
background.locale = newLocale;
Activity.savedProgress = newProgress;
Activity.favorites = newFavorites;
// Restart the activity with new information
if(oldLocale !== newLocale) {
background.stop();
......
......@@ -119,7 +119,6 @@ Image {
model: menuModel
keyNavigationWraps: true
property int spacing: 10
delegate: Item {
id: delegateItem
width: levelCellWidth - menuGrid.spacing
......@@ -165,7 +164,6 @@ Image {
maximumValue: wordCount
minimumValue: 0
value: Activity.savedProgress[index]
// value: savedProgress
orientation: Qt.Horizontal
}
......@@ -185,10 +183,9 @@ Image {
Activity.initLevel(index)
}
property bool favorite: false
Image {
source: menu_screen.favtUrl + (favorite ? "all.svg" : "all_disabled.svg");
source: menu_screen.favtUrl + ( Activity.favorites[index] ? "all.svg" : "all_disabled.svg");
anchors {
top: parent.top
right: parent.right
......@@ -198,7 +195,12 @@ Image {
visible: ApplicationSettings.sectionVisible
MouseArea {
anchors.fill: parent
onClicked: favorite = !favorite
onClicked: {
console.log("before Activity.favorites[index] is "+Activity.favorites)
Activity.favorites[index] = !(Activity.favorites[index])
parent.source = menu_screen.favtUrl + ( Activity.favorites[index] ? "all.svg" : "all_disabled.svg");
console.log("now Activity.favorites[index] is "+Activity.favorites)
}
}
}
......
......@@ -105,6 +105,7 @@ Item {
border.color: "#000000"
border.width: 2
radius: 16
anchors.top: parent.top
anchors.bottom: imageFrame.top
anchors.left: imageFrame.left
anchors.bottomMargin: 5
......@@ -118,6 +119,8 @@ Item {
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
color: "white"
wrapMode: Text.WordWrap
......@@ -170,6 +173,8 @@ Item {
Image {
id: wordImage
sourceSize.width: parent.width * 0.6
width: parent.width * 0.6
height: parent.height * 0.6
anchors {
centerIn: parent
......
......@@ -43,6 +43,7 @@ var subLevelsLeft
var menus = []
var currentProgress = []
var savedProgress = []
var favorites= []
var subWordList
var currentSubLesson
var maxSubLesson
......@@ -109,14 +110,19 @@ function start() {
}
for (var k =0; k<maxLevel; k++) {
if(!(savedProgress[k] > 0))
if(!(savedProgress[k] >0)) {
savedProgress[k] = 0
}
if(!favorites[k])
favorites[k] = false
// menus.push({'savedProgress': savedProgress[k] })
}
items.menuModel.clear()
items.menuModel.append(menus)
// console.log("model length "+ items.menuModel.count)
items.imageFrame.visible = false
items.score.visible = false
......@@ -129,10 +135,6 @@ function start() {
}
function stop() {
// for (var k =0; k<maxLevel; k++) {
// items.savedData[k] = savedProgress[k]
// console.log(items.savedData[k])
// }
}
function initLevel(currentLevel_) {
......@@ -173,8 +175,10 @@ function initLevel(currentLevel_) {
subLevelsLeft.push(i) // This is available in all editors.
}
for(i =0 ;i < maxLevel;i++)
// items.progress = savedProgress
if(currentSubLesson == 0)
currentProgress[currentLevel] = 0 //change to saved progress
currentProgress[currentLevel] = savedProgress[currentLevel] //change to saved progress
initSubLevel()
}
......
......@@ -136,7 +136,7 @@ function getMenuModel(dataset, items) {
'image': currentLesson.content[0].image,
'index': levelCount,
'wordCount': tempWordList.length * 4 + modifiedWordCount,
'savedProgress': 0
'savedProgress': 0,
})
}
prevLevelcount = levelCount+ 1
......
......@@ -90,7 +90,6 @@ function initLevel() {
row++;
}
layout[row-1].push({ label: items.keyboard.backspace });
items.keyboard.layout = [];
items.keyboard.layout = layout;
items.keyboard.visibleFlag = true;
......
......@@ -140,6 +140,11 @@ Rectangle {
loadData()
}
function saveDatainConfiguration() {
saveData()
ApplicationSettings.saveActivityConfiguration(activityName, dataToSave)
}
Row {
visible: dialogActivityContent.active
spacing: 2
......
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