Commit 0069246c authored by Bruno Coudoin's avatar Bruno Coudoin
Browse files

core, add support for a full.rcc local pre downloaded resource file

If present locally the resource file 'full.rcc' is loaded (but never
downloaded). This file is present on gcompris.net/data2 as the other
resource files.

This implies that a data from an rcc can be loaded from either the 'full.rcc'
or a specific one like 'words.rcc'.

Now the resource files are normalized and must include the prefix
'gcompris/data' with <qresource prefix="/gcompris/data"\>.

All the voices are now located under 'voices-ogg' instead of 'voices'
to allow us to support'voices-aac' for other platforms without having
special cases.

This patch replaces the 'isResourceRegistered' api entry by
'isDataRegistered'. We no more check a resource file is registered but if
the needed data is loaded.
parent 2782e31a
......@@ -144,7 +144,7 @@ function initLevel() {
GCompris.DownloadManager.haveLocalResource(
GCompris.DownloadManager.getVoicesResourceForLocale(
GCompris.ApplicationSettings.locale))) {
items.audioVoices.append(GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/misc/click_on_letter.ogg"));
items.audioVoices.append(GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/misc/click_on_letter.ogg"));
items.audioVoices.silence(100)
playLetter(currentLetter)
items.questionItem.visible = false
......@@ -159,7 +159,7 @@ function initLevel() {
}
function playLetter(letter) {
items.audioVoices.append(GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/"
items.audioVoices.append(GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/"
+ Core.getSoundFilenamForChar(letter)))
}
......
......@@ -22,116 +22,116 @@ function get() {
{
"image": "qrc:/gcompris/src/activities/colors/resource/yellow_duck.svg",
"text": qsTr("Find the yellow duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/yellow.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/yellow.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/black_duck.svg",
"text": qsTr("Find the black duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/black.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/black.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/green_duck.svg",
"text": qsTr("Find the green duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/green.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/green.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/red_duck.svg",
"text": qsTr("Find the red duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/red.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/red.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/white_duck.svg",
"text": qsTr("Find the white duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/white.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/white.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/blue_duck.svg",
"text": qsTr("Find the blue duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/blue.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/blue.ogg")
}
],
[ // Level 2
{
"image": "qrc:/gcompris/src/activities/colors/resource/yellow_duck.svg",
"text": qsTr("Find the yellow duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/yellow.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/yellow.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/black_duck.svg",
"text": qsTr("Find the black duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/black.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/black.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/brown_duck.svg",
"text": qsTr("Find the brown duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/brown.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/brown.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/green_duck.svg",
"text": qsTr("Find the green duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/green.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/green.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/grey_duck.svg",
"text": qsTr("Find the grey duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/grey.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/grey.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/orange_duck.svg",
"text": qsTr("Find the orange duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/orange.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/orange.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/purple_duck.svg",
"text": qsTr("Find the purple duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/purple.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/purple.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/white_duck.svg",
"text": qsTr("Find the white duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/white.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/white.ogg")
}
],
[ // Level 3
{
"image": "qrc:/gcompris/src/activities/colors/resource/yellow_duck.svg",
"text": qsTr("Find the yellow duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/yellow.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/yellow.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/brown_duck.svg",
"text": qsTr("Find the brown duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/brown.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/brown.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/green_duck.svg",
"text": qsTr("Find the green duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/green.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/green.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/grey_duck.svg",
"text": qsTr("Find the grey duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/grey.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/grey.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/orange_duck.svg",
"text": qsTr("Find the orange duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/orange.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/orange.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/purple_duck.svg",
"text": qsTr("Find the purple duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/purple.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/purple.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/red_duck.svg",
"text": qsTr("Find the red duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/red.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/red.ogg")
},
{
"image": "qrc:/gcompris/src/activities/colors/resource/blue_duck.svg",
"text": qsTr("Find the blue duck"),
"audio": ApplicationInfo.getAudioFilePath("voices/$LOCALE/colors/blue.ogg")
"audio": ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/colors/blue.ogg")
}
]
];
......
......@@ -379,6 +379,6 @@ function nextSubLevel() {
function playLetter(letter) {
var locale = items.locale == "system" ? "$LOCALE" : items.locale
items.audioVoices.append(GCompris.ApplicationInfo.getAudioFilePath("voices/"+locale+"/alphabet/"
items.audioVoices.append(GCompris.ApplicationInfo.getAudioFilePath("voices-$CA/"+locale+"/alphabet/"
+ Core.getSoundFilenamForChar(letter)))
}
......@@ -43,7 +43,7 @@ ActivityBase {
property bool horizontalLayout: background.width > background.height
property bool keyNavigation: false
readonly property string wordsResource: "data/words/words.rcc"
readonly property string wordsResource: "data2/words/words.rcc"
property bool englishFallback: false
property bool downloadWordsNeeded: false
......@@ -93,7 +93,7 @@ ActivityBase {
activity.audioVoices.done.connect(voiceDone)
// check for words.rcc:
if (DownloadManager.isResourceRegistered(wordsResource)) {
if (DownloadManager.isDataRegistered("words")) {
// words.rcc is already registered -> start right away
Activity.start(items);
} else if(DownloadManager.haveLocalResource(wordsResource)) {
......
......@@ -110,7 +110,7 @@ function initSubLevel() {
for (var j = 0; j < selectedWords.length; j++) {
items.wordListModel.append({"word": selectedWords[j] })
}
items.wordImage.changeSource("qrc:/" + items.goodWord.image)
items.wordImage.changeSource("qrc:/gcompris/data/" + items.goodWord.image)
}
function nextLevel() {
......
This diff is collapsed.
......@@ -48,47 +48,47 @@ var images = [
var sounds = [
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0030.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0030.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0031.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0031.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0032.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0032.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0033.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0033.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0034.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0034.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0035.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0035.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0036.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0036.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0037.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0037.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0038.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0038.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0039.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0039.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/10.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/10.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/11.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/11.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/12.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/12.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/13.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/13.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/14.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/14.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/15.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/15.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/16.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/16.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/17.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/17.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/18.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/18.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/19.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/19.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/20.ogg")]
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/20.ogg")]
]
......
......@@ -44,47 +44,47 @@ var texts = [
var sounds = [
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0030.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0030.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0031.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0031.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0032.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0032.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0033.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0033.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0034.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0034.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0035.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0035.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0036.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0036.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0037.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0037.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0038.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0038.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/U0039.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/U0039.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/10.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/10.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/11.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/11.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/12.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/12.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/13.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/13.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/14.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/14.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/15.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/15.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/16.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/16.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/17.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/17.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/18.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/18.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/19.ogg")],
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/19.ogg")],
["",
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/20.ogg")]
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/20.ogg")]
]
......
......@@ -253,6 +253,6 @@ function createLastLevel()
}
function playLetter(letter) {
items.audioVoices.append(GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/"
items.audioVoices.append(GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/"
+ Core.getSoundFilenamForChar(letter)))
}
......@@ -324,10 +324,10 @@ function handleCollisionsWithCloud() {
function playLetterSound(number) {
if(number < 10)
items.audioVoices.play(
GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/"
GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/"
+ Core.getSoundFilenamForChar(number)))
else
items.audioVoices.play(GCompris.ApplicationInfo.getAudioFilePath("voices/$LOCALE/alphabet/"
items.audioVoices.play(GCompris.ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/alphabet/"
+ number + ".ogg"))
}
......@@ -25,6 +25,7 @@
#include <QQmlProperty>
#include <QQmlComponent>
#include <QResource>
#include <QStandardPaths>
#include <QCoreApplication>
#include <QTextStream>
......@@ -262,6 +263,10 @@ void ActivityInfoTree::init()
if(!QResource::registerResource(ApplicationInfo::getFilePath("activities.rcc")))
qDebug() << "Failed to load the resource file activities.rcc";
if(QResource::registerResource(QStandardPaths::writableLocation(QStandardPaths::DataLocation) +
"/data2/" + "full.rcc"))
qDebug() << "Registered the pre-download full.rcc";
qmlRegisterSingletonType<QObject>("GCompris", 1, 0, "ActivityInfoTree", menuTreeProvider);
qmlRegisterType<ActivityInfo>("GCompris", 1, 0, "ActivityInfo");
}
......
......@@ -244,7 +244,7 @@ protected slots:
* @param file A templated relative path to a language specific file. Any
* occurence of the '$LOCALE' placeholder will be replaced by
* the currently active locale string.
* Example: 'voices/$LOCALE/misc/click_on_letter.ogg'
* Example: 'voices-ogg/$LOCALE/misc/click_on_letter.ogg'
* @returns An absolute path to the corresponding resource file.
*/
Q_INVOKABLE QString getAudioFilePath(const QString &file);
......
......@@ -92,7 +92,7 @@ class ApplicationSettings : public QObject
Q_PROPERTY(bool showLockedActivities READ showLockedActivities WRITE setShowLockedActivities NOTIFY showLockedActivitiesChanged)
/**
* Whether audio voices/speech should be enabled.
* Whether audio voices-ogg/speech should be enabled.
*/
Q_PROPERTY(bool isAudioVoicesEnabled READ isAudioVoicesEnabled WRITE setIsAudioVoicesEnabled NOTIFY audioVoicesEnabledChanged)
......
......@@ -71,17 +71,17 @@ Image {
property string url: "qrc:/gcompris/src/core/resource/"
property bool isWin: false
property var winVoices: [
"voices/$LOCALE/misc/congratulation.ogg",
"voices/$LOCALE/misc/great.ogg",
"voices/$LOCALE/misc/good.ogg",
"voices/$LOCALE/misc/awesome.ogg",
"voices/$LOCALE/misc/fantastic.ogg",
"voices/$LOCALE/misc/waytogo.ogg",
"voices/$LOCALE/misc/super.ogg",
"voices/$LOCALE/misc/perfect.ogg"
"voices-ogg/$LOCALE/misc/congratulation.ogg",
"voices-ogg/$LOCALE/misc/great.ogg",
"voices-ogg/$LOCALE/misc/good.ogg",
"voices-ogg/$LOCALE/misc/awesome.ogg",
"voices-ogg/$LOCALE/misc/fantastic.ogg",
"voices-ogg/$LOCALE/misc/waytogo.ogg",
"voices-ogg/$LOCALE/misc/super.ogg",
"voices-ogg/$LOCALE/misc/perfect.ogg"
]
property var looseVoices: [
"voices/$LOCALE/misc/check_answer.ogg"
"voices-ogg/$LOCALE/misc/check_answer.ogg"
]
/// @endcond
......
......@@ -113,7 +113,8 @@ void DownloadManager::abortDownloads()
QString DownloadManager::getVoicesResourceForLocale(const QString& locale) const
{
return QString("data/voices-" COMPRESSED_AUDIO "/voices-%1.rcc").arg(locale);
return QString("data2/voices-" COMPRESSED_AUDIO "/voices-%1.rcc")
.arg(ApplicationInfo::getInstance()->getVoicesLocale(locale));
}
inline QString DownloadManager::getAbsoluteResourcePath(const QString& path) const
......@@ -467,19 +468,19 @@ bool DownloadManager::registerResource(const QString& filename)
}
}
bool DownloadManager::isResourceRegistered(const QString& resource) const
bool DownloadManager::isDataRegistered(const QString& data) const
{
for (auto &base: getSystemResourcePaths())
if (isRegistered(base + '/' + resource))
return true;
return false;
QString res = QString(":/gcompris/data/%1").arg(data);
return !QDir(res).entryList().empty();
}
bool DownloadManager::areVoicesRegistered() const
{
QString relFilename = getVoicesResourceForLocale(
ApplicationSettings::getInstance()->locale());
return isResourceRegistered(relFilename);
QString resource = QString("voices-" COMPRESSED_AUDIO "/%1").
arg(ApplicationInfo::getInstance()->getVoicesLocale(ApplicationSettings::getInstance()->locale()));
return isDataRegistered(resource);
}
void DownloadManager::downloadFinished()
......
......@@ -60,7 +60,7 @@
* path</em>
*
* <tt>\<path/to/my/resource.rcc\></tt>
* (e.g. <tt>data/voices/voices-en.rcc></tt>)
* (e.g. <tt>data2/voices-ogg/voices-en.rcc></tt>)
*
* Downloading and verification of local files is controlled by MD5
* checksums that are expected to be stored in @c Contents files in each
......@@ -70,6 +70,11 @@
* transfer was complete. Only valid rcc files (with correct checksums)
* are registered.
*
* A resource file must reference the "/gcompris/data" prefix with
* \<qresource prefix="/gcompris/data"\>. All data are loaded and referenced
* from this prefix. It is possible to check if a data is registered with
* isDataRegistered.
*
* @sa DownloadDialog, ApplicationSettings.downloadServerUrl,
* ApplicationSettings.isAutomaticDownloadsEnabled
*/
......@@ -234,19 +239,23 @@ public:
Q_INVOKABLE bool downloadIsRunning() const;
/**
* Whether the passed relative @p resource is registered.
* Whether the passed relative @p data is registered.
*
* For example, if you have a resource file which loads files under the
* 'words' path like 'words/one.png'. You can call this method with 'words/one.png'
* or with 'words'.
*
* @param resource Relative resource path.
* @param data Relative resource path (file or directory).
*
* @sa areVoicesRegistered
*/
Q_INVOKABLE bool isResourceRegistered(const QString& resource) const;
Q_INVOKABLE bool isDataRegistered(const QString& data) const;
/**
* Whether voices for the currently active locale are registered.
*
* @sa isResourceRegistered
* @sa isDataRegistered
*/
Q_INVOKABLE bool areVoicesRegistered() const;
......
......@@ -96,7 +96,8 @@ Item {
if(ApplicationInfo.CompressedAudio === "ogg")
return file
return file.replace('.ogg', "." + ApplicationInfo.CompressedAudio)
return file.replace('-ogg', "-" + ApplicationInfo.CompressedAudio).
replace('.ogg', "." + ApplicationInfo.CompressedAudio)
}
/**
......
......@@ -78,7 +78,7 @@ Window {
}
function playWelcome() {
audioVoices.append(ApplicationInfo.getAudioFilePath("voices/$LOCALE/misc/welcome.ogg"));
audioVoices.append(ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/misc/welcome.ogg"));
}
}
......@@ -103,7 +103,7 @@ Window {
function playIntroVoice(name) {
name = name.split("/")[0]
audioVoices.append(ApplicationInfo.getAudioFilePath("voices/$LOCALE/intro/" + name + ".ogg"))
audioVoices.append(ApplicationInfo.getAudioFilePath("voices-ogg/$LOCALE/intro/" + name + ".ogg"))
}
Component.onCompleted: {
......
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