Commit 64db022c authored by Timothée Giet's avatar Timothée Giet

core, update download dialogs

-only have a single dialog to ask to download all missing external assets on first start
-fix DownloadDialog and related dialogs parent/focus handling
-do not download automatically wordSet and backgroundMusic on closing configuration page
-add button to download backgroundMusic manually
parent 09e5818a
......@@ -33,6 +33,7 @@ Item {
property var languages: allLangs.languages
property int contentWidth: Math.floor(dialogConfig.width * 0.9)
property var parentActivity
height: contentColumn.height
LanguageList {
......@@ -85,6 +86,19 @@ Item {
scrollEnabled: false
}
Button {
id: backgroundMusicButton
height: 30 * ApplicationInfo.ratio
visible: ApplicationInfo.isDownloadAllowed
text: qsTr("Download background music")
style: GCButtonStyle {}
onClicked: {
if(DownloadManager.downloadResource(DownloadManager.getBackgroundMusicResources()))
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
}
}
GCDialogCheckBox {
id: enableBackgroundMusicBox
text: qsTr("Enable background music")
......@@ -355,9 +369,9 @@ Item {
onClicked: {
if (DownloadManager.downloadResource(
DownloadManager.getVoicesResourceForLocale(dialogConfig.languages[languageBox.currentIndex].locale)))
DownloadManager.getVoicesResourceForLocale(dialogConfig.languages[languageBox.currentIndex].locale)))
{
var downloadDialog = Core.showDownloadDialog(dialogConfig.parent.rootItem, {});
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
}
}
}
......@@ -598,86 +612,14 @@ Item {
))
{
// ask for downloading new voices
Core.showMessageDialog(main,
qsTr("You selected a new locale. You need to restart GCompris to play in your new locale.<br/>Do you want to download the corresponding sound files now?"),
qsTr("Yes"), function() {
// yes -> start download
if (DownloadManager.downloadResource(
DownloadManager.getVoicesResourceForLocale(ApplicationSettings.locale)))
var downloadDialog = Core.showDownloadDialog(main, {});
},
qsTr("No"), null,
null
);
parentActivity.newVoicesSignal();
} else {
// check for updates or/and register new voices
DownloadManager.updateResource(
DownloadManager.getVoicesResourceForLocale(ApplicationSettings.locale))
}
}
// download words.rcc if needed
if(ApplicationSettings.wordset != "") {
// we want to use the external dataset, it is either in
// words/words.rcc or full-${CA}.rcc
if(DownloadManager.isDataRegistered("words")) {
// we either have it, we try to update in the background
// or we are downloading it
if(DownloadManager.haveLocalResource(wordset))
DownloadManager.updateResource(wordset)
}
else {
// download automatically if automatic download else ask for download
if(isAutomaticDownloadsEnabled) {
var prevAutomaticDownload = ApplicationSettings.isAutomaticDownloadsEnabled
ApplicationSettings.isAutomaticDownloadsEnabled = true;
DownloadManager.updateResource(wordset);
ApplicationSettings.isAutomaticDownloadsEnabled = prevAutomaticDownload
}
else {
Core.showMessageDialog(main,
qsTr("The images for several activities are not yet installed. ")
+ qsTr("Do you want to download them now?"),
qsTr("Yes"),
function() {
if (DownloadManager.downloadResource(wordset))
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
},
qsTr("No"), function() { ApplicationSettings.wordset = "" },
null
);
}
}
}
// download backgroundMusic.rcc if needed
if(DownloadManager.isDataRegistered("backgroundMusic")) {
// we either have it, we try to update in the background
// or we are downloading it
if(DownloadManager.haveLocalResource(DownloadManager.getBackgroundMusicResources()))
DownloadManager.updateResource(DownloadManager.getBackgroundMusicResources())
}
else {
// download automatically if automatic download else ask for download
if(isAutomaticDownloadsEnabled) {
var prevAutomaticDownload = ApplicationSettings.isAutomaticDownloadsEnabled
ApplicationSettings.isAutomaticDownloadsEnabled = true;
DownloadManager.updateResource(DownloadManager.getBackgroundMusicResources());
ApplicationSettings.isAutomaticDownloadsEnabled = prevAutomaticDownload
}
else if(ApplicationSettings.isBackgroundMusicEnabled) {
Core.showMessageDialog(main,
qsTr("The background music is not yet installed. ")
+ qsTr("Do you want to download it now?"),
qsTr("Yes"),
function() {
if (DownloadManager.downloadResource(DownloadManager.getBackgroundMusicResources()))
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
},
qsTr("No"),null
);
}
}
}
}
ListModel {
id: fonts
......
......@@ -76,6 +76,30 @@ ActivityBase {
pageView.push(toPush);
}
//when selecting a new language in config, we need to open the newVoicesDialog,
//but only after the config page is closed, hence the need to have a signal calling a Timer calling the function
signal newVoicesSignal
onNewVoicesSignal: newVoicesDialogTimer.restart();
Timer {
id: newVoicesDialogTimer
interval: 250
onTriggered: newVoicesDialog();
}
function newVoicesDialog() {
Core.showMessageDialog(activity,
qsTr("You selected a new locale. You need to restart GCompris to play in your new locale.<br/>Do you want to download the corresponding sound files now?"),
qsTr("Yes"), function() {
// yes -> start download
if (DownloadManager.downloadResource(
DownloadManager.getVoicesResourceForLocale(ApplicationSettings.locale)))
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
},
qsTr("No"), null,
null
);
}
Connections {
// At the launch of the application, box2d check is performed after we
// first initialize the menu. This connection is to refresh
......@@ -620,7 +644,7 @@ ActivityBase {
anchors.fill: activitiesGrid
}
}
// The scroll buttons
GCButtonScroll {
visible: !ApplicationInfo.useOpenGL
......@@ -1030,7 +1054,7 @@ ActivityBase {
displayDialog(dialogActivityConfig)
}
}
DialogAbout {
id: dialogAbout
onClose: home()
......@@ -1048,6 +1072,7 @@ ActivityBase {
content: Component {
ConfigurationItem {
id: configItem
parentActivity: activity
width: dialogActivityConfig.width - 50 * ApplicationInfo.ratio
}
}
......@@ -1061,7 +1086,7 @@ ActivityBase {
ActivityInfoTree.filterEnabledActivities()
} else
ActivityInfoTree.filterBySearch(searchTextField.text);
backgroundMusic.clearQueue()
/**
* 1. If the current playing background music is in new filtered playlist too, continue playing it and append all the next filtered musics to backgroundMusic element.
......@@ -1084,14 +1109,14 @@ ActivityBase {
}
nextMusicIndex++
}
while(nextMusicIndex < dialogActivityConfig.configItem.filteredBackgroundMusic.length)
backgroundMusic.append(ApplicationInfo.getAudioFilePath("backgroundMusic/" + dialogActivityConfig.configItem.filteredBackgroundMusic[nextMusicIndex++]))
backgroundMusic.nextAudio()
}
home()
}
BackgroundMusicList {
id: backgroundMusicList
onClose: {
......
......@@ -116,8 +116,25 @@ Item {
signal finished
onStart: opacity = 1
onStop: opacity = 0
focus: true
onVisibleChanged: {
if(visible) {
downloadDialog.forceActiveFocus();
parent.Keys.enabled = false;
}
}
onStart: {
opacity = 1;
downloadDialog.forceActiveFocus();
parent.Keys.enabled = false;
}
onStop: {
opacity = 0;
parent.Keys.enabled = true;
parent.forceActiveFocus();
}
onClose: destroy()
Behavior on opacity { NumberAnimation { duration: 200 } }
......@@ -241,6 +258,13 @@ Item {
}
Keys.onEscapePressed: {
if(backgroundButtonVisible)
backgroundButton.clicked();
else if(abortButtonVisible)
abortButton.clicked();
}
Connections {
target: DownloadManager
......@@ -250,7 +274,7 @@ Item {
if (downloadDialog.reportError
&& code != 5) { // no error: OperationCanceledError
// show error message
var messageDialog = Core.showMessageDialog(main.pageView,
var messageDialog = Core.showMessageDialog(parent,
qsTr("Download error (code: %1): %2").arg(code).arg(msg),
"", null,
"", null,
......@@ -285,7 +309,7 @@ Item {
} else if (code == 2) // NoChange
infText = qsTr("Your local data files are up-to-date.")
var messageDialog = Core.showMessageDialog(main.pageView,
var messageDialog = Core.showMessageDialog(parent,
infText,
"", null,
"", null,
......
......@@ -56,6 +56,9 @@ Window {
property var rccBackgroundMusic: ApplicationInfo.getBackgroundMusicFromRcc()
property var filteredBackgroundMusic: ApplicationSettings.filteredBackgroundMusic
property alias backgroundMusic: backgroundMusic
property bool voicesDownloaded: true
property bool wordSetDownloaded: true
property bool musicDownloaded: true
/**
* type: bool
......@@ -185,21 +188,10 @@ Window {
}
} else if(ApplicationSettings.useWordset) { // Only if external wordset is enabled
// words.rcc has not been downloaded yet -> ask for download
Core.showMessageDialog(
pageView,
qsTr("The images for several activities are not yet installed. " +
"Do you want to download them now?"),
qsTr("Yes"),
function() {
if (DownloadManager.downloadResource(wordset))
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
},
qsTr("No"), null,
function() { pageView.currentItem.focus = true }
);
wordSetDownloaded = false;
}
//disable wordset is useWordset config is false
//disable wordset if useWordset config is false
if(!ApplicationSettings.useWordset) {
ApplicationSettings.wordset = "";
}
......@@ -225,19 +217,47 @@ Window {
}
}
else if(ApplicationSettings.isBackgroundMusicEnabled && !DownloadManager.haveLocalResource(music)) {
Core.showMessageDialog(
pageView,
qsTr("The background music is not yet downloaded. ")
+ qsTr("Do you want to download it now?"),
qsTr("Yes"),
function() {
if(DownloadManager.downloadResource(DownloadManager.getBackgroundMusicResources())) {
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
musicDownloaded = false;
}
}
function checkVoices() {
if(!DownloadManager.haveLocalResource(DownloadManager.getVoicesResourceForLocale(ApplicationSettings.locale)))
voicesDownloaded = false;
}
function initialAssetsDownload() {
checkVoices();
checkWordset();
checkBackgroundMusic();
var voicesLine = voicesDownloaded ? "" : ("<br>") + "-" + qsTr("Voices for your language");
var wordSetLine = wordSetDownloaded ? "" : ("<br>") + "-" + qsTr("Full word image set");
var musicLine = musicDownloaded ? "" : ("<br>") + "-" + qsTr("Background music");
if(!voicesDownloaded || !wordSetDownloaded || ! musicDownloaded) {
var dialog;
dialog = Core.showMessageDialog(
pageView,
qsTr("Do you want to download the following external assets ?")
+ ("<br>")
+ voicesLine
+ wordSetLine
+ musicLine,
qsTr("Yes"),
function() {
if(!voicesDownloaded)
DownloadManager.downloadResource(DownloadManager.getVoicesResourceForLocale(ApplicationSettings.locale));
if(!wordSetDownloaded)
DownloadManager.downloadResource('data2/words/words.rcc');
if(!musicDownloaded)
DownloadManager.downloadResource(DownloadManager.getBackgroundMusicResources());
var downloadDialog = Core.showDownloadDialog(pageView, {});
},
qsTr("No"), null,
function() {
pageView.currentItem.focus = true;
}
},
qsTr("No"), null,
function() { pageView.currentItem.focus = true }
);
}
}
......@@ -259,40 +279,32 @@ Window {
var dialog;
dialog = Core.showMessageDialog(
pageView,
qsTr("Welcome to GCompris!") + '\n'
+ qsTr("You are running GCompris for the first time.") + '\n'
qsTr("Welcome to GCompris!") + ("<br>")
+ qsTr("You are running GCompris for the first time.") + "\n"
+ qsTr("You should verify that your application settings especially your language is set correctly, and that all language specific sound files are installed. You can do this in the Preferences Dialog.")
+ "\n"
+ qsTr("Have Fun!")
+ "\n"
+ ("<br><br>")
+ qsTr("Your current language is %1 (%2).")
.arg(Qt.locale(ApplicationInfo.getVoicesLocale(ApplicationSettings.locale)).nativeLanguageName)
.arg(ApplicationInfo.getVoicesLocale(ApplicationSettings.locale))
+ "\n"
+ qsTr("Do you want to download the corresponding sound files now?"),
qsTr("Yes"),
function() {
if (DownloadManager.downloadResource(
DownloadManager.getVoicesResourceForLocale(ApplicationSettings.locale)))
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
},
qsTr("No"), null,
.arg(ApplicationInfo.getVoicesLocale(ApplicationSettings.locale)),
"", null,
"", null,
function() {
pageView.currentItem.focus = true
checkWordset()
checkBackgroundMusic()
pageView.currentItem.focus = true;
initialAssetsDownload();
}
);
}
else {
// Register voices-resources for current locale, updates/downloads only if
// not prohibited by the settings
if (!DownloadManager.areVoicesRegistered()) {
if(!DownloadManager.areVoicesRegistered()) {
DownloadManager.updateResource(
DownloadManager.getVoicesResourceForLocale(ApplicationSettings.locale));
}
checkWordset()
checkBackgroundMusic()
checkWordset();
checkBackgroundMusic();
if(changelog.isNewerVersion(ApplicationSettings.lastGCVersionRan, ApplicationInfo.GCVersionCode)) {
// display log between ApplicationSettings.lastGCVersionRan and ApplicationInfo.GCVersionCode
Core.showMessageDialog(
......
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