Commit 9db9d9d3 authored by Timothée Giet's avatar Timothée Giet

core, improve the settings to enable/disable external full image set

Refactor a bit the wordsetBox to properly enable/disable the full image set,
and add a wordsetButton to manually download the image set.

As a user pointed out, the previous wordsetBox configuration entry
was confusing and not very useful, hence this change was needed.
parent 019a79bf
......@@ -180,18 +180,46 @@ Item {
}
}
Button {
id: wordsetButton
height: 30 * ApplicationInfo.ratio
visible: ApplicationInfo.isDownloadAllowed
text: qsTr("Download full word image set")
style: GCButtonStyle {}
onClicked: {
if(DownloadManager.downloadResource("data2/words/words.rcc"))
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
}
}
Connections {
target: DownloadManager
onDownloadFinished: wordsetBox.updateStatus()
}
/* Technically wordset config is a string that holds the wordset name or '' for the
* internal wordset. But as we support only internal and words its best to show the
* user a boolean choice.
*/
GCDialogCheckBox {
id: wordsetBox
checked: DownloadManager.isDataRegistered("words")
text: enabled ? qsTr("Use full word image set") : qsTr("Download full word image set")
checked: useWordset
text: enabled ? qsTr("Use full word image set") : qsTr("Full word image set is not installed")
visible: ApplicationInfo.isDownloadAllowed
enabled: !DownloadManager.isDataRegistered("words")
enabled: DownloadManager.isDataRegistered("words")
onCheckedChanged: {
wordset = checked ? 'data2/words/words.rcc' : '';
if(checked) {
wordset = "data2/words/words.rcc";
useWordset = true;
} else {
wordset = "";
useWordset = false;
}
}
function updateStatus() {
enabled = DownloadManager.isDataRegistered("words")
}
}
......@@ -459,6 +487,7 @@ Item {
property bool isAutomaticDownloadsEnabled: ApplicationSettings.isAutomaticDownloadsEnabled
property bool sectionVisible: ApplicationSettings.sectionVisible
property string wordset: ApplicationSettings.wordset
property bool useWordset: ApplicationSettings.useWordset
property var filteredBackgroundMusic: ApplicationSettings.filteredBackgroundMusic
property var allBackgroundMusic: ApplicationInfo.getBackgroundMusicFromRcc()
property int baseFontSize // don't bind to ApplicationSettings.baseFontSize
......@@ -500,9 +529,8 @@ Item {
sectionVisible = ApplicationSettings.sectionVisible
sectionVisibleBox.checked = sectionVisible
wordset = ApplicationSettings.wordset
wordsetBox.checked = DownloadManager.isDataRegistered("words") || ApplicationSettings.wordset == 'data2/words/words.rcc'
wordsetBox.enabled = !DownloadManager.isDataRegistered("words")
wordset = useWordset ? ApplicationSettings.wordset : ""
wordsetBox.checked = useWordset
baseFontSize = ApplicationSettings.baseFontSize
fontLetterSpacing = ApplicationSettings.fontLetterSpacing
......@@ -547,6 +575,7 @@ Item {
ApplicationSettings.isAutomaticDownloadsEnabled = isAutomaticDownloadsEnabled
ApplicationSettings.sectionVisible = sectionVisible
ApplicationSettings.wordset = wordset
ApplicationSettings.useWordset = useWordset
ApplicationSettings.isEmbeddedFont = fonts.get(fontBox.currentIndex).isLocalResource;
ApplicationSettings.font = fonts.get(fontBox.currentIndex).text
ApplicationSettings.fontCapitalization = fontCapitalizationModel[fontCapitalizationBox.currentIndex].value
......@@ -613,7 +642,7 @@ Item {
if (DownloadManager.downloadResource(wordset))
var downloadDialog = Core.showDownloadDialog(pageView.currentItem, {});
},
qsTr("No"), function() { ApplicationSettings.wordset = '' },
qsTr("No"), function() { ApplicationSettings.wordset = "" },
null
);
}
......@@ -715,6 +744,7 @@ Item {
return (ApplicationSettings.locale !== dialogConfig.languages[languageBox.currentIndex].locale ||
(ApplicationSettings.sectionVisible != sectionVisible) ||
(ApplicationSettings.wordset != wordset) ||
(ApplicationSettings.useWordset != useWordset) ||
(ApplicationSettings.font != fonts.get(fontBox.currentIndex).text) ||
(ApplicationSettings.isEmbeddedFont != fonts.get(fontBox.currentIndex).isLocalResource) ||
(ApplicationSettings.isEmbeddedFont != fonts.get(fontBox.currentIndex).isLocalResource) ||
......
......@@ -79,6 +79,7 @@ static const char *NO_CURSOR = "noCursor";
static const char *KIOSK_KEY = "kiosk";
static const char *SECTION_VISIBLE = "sectionVisible";
static const char *WORDSET = "wordset";
static const char *USE_WORDSET = "useWordset";
static const char *PROGRESS_KEY = "progress";
......@@ -123,6 +124,7 @@ ApplicationSettings::ApplicationSettings(const QString &configPath, QObject *par
m_sectionVisible = m_config.value(SECTION_VISIBLE, true).toBool();
m_wordset = m_config.value(WORDSET, "").toString();
m_useWordset = m_config.value(USE_WORDSET, true).toBool();
m_isAutomaticDownloadsEnabled = m_config.value(ENABLE_AUTOMATIC_DOWNLOADS,
!ApplicationInfo::getInstance()->isMobile() && ApplicationInfo::isDownloadAllowed()).toBool();
m_filterLevelMin = m_config.value(FILTER_LEVEL_MIN, 1).toUInt();
......@@ -169,6 +171,7 @@ ApplicationSettings::ApplicationSettings(const QString &configPath, QObject *par
connect(this, &ApplicationSettings::filterLevelMaxChanged, this, &ApplicationSettings::notifyFilterLevelMaxChanged);
connect(this, &ApplicationSettings::sectionVisibleChanged, this, &ApplicationSettings::notifySectionVisibleChanged);
connect(this, &ApplicationSettings::wordsetChanged, this, &ApplicationSettings::notifyWordsetChanged);
connect(this, &ApplicationSettings::useWordsetChanged, this, &ApplicationSettings::notifyUseWordsetChanged);
connect(this, &ApplicationSettings::kioskModeChanged, this, &ApplicationSettings::notifyKioskModeChanged);
connect(this, &ApplicationSettings::downloadServerUrlChanged, this, &ApplicationSettings::notifyDownloadServerUrlChanged);
connect(this, &ApplicationSettings::cachePathChanged, this, &ApplicationSettings::notifyCachePathChanged);
......@@ -204,6 +207,7 @@ ApplicationSettings::~ApplicationSettings()
m_config.setValue(KIOSK_KEY, m_isKioskMode);
m_config.setValue(SECTION_VISIBLE, m_sectionVisible);
m_config.setValue(WORDSET, m_wordset);
m_config.setValue(USE_WORDSET, m_useWordset);
m_config.setValue(DEFAULT_CURSOR, m_defaultCursor);
m_config.setValue(NO_CURSOR, m_noCursor);
m_config.setValue(BASE_FONT_SIZE_KEY, m_baseFontSize);
......@@ -373,6 +377,12 @@ void ApplicationSettings::notifyWordsetChanged()
qDebug() << "notifyWordset: " << m_wordset;
}
void ApplicationSettings::notifyUseWordsetChanged()
{
updateValueInConfig(GENERAL_GROUP_KEY, USE_WORDSET, m_useWordset);
qDebug() << "notifyUseWordset: " << m_useWordset;
}
void ApplicationSettings::notifyDownloadServerUrlChanged()
{
updateValueInConfig(ADMIN_GROUP_KEY, DOWNLOAD_SERVER_URL_KEY, m_downloadServerUrl);
......
......@@ -187,6 +187,11 @@ class ApplicationSettings : public QObject
*/
Q_PROPERTY(QString wordset READ wordset WRITE setWordset NOTIFY wordsetChanged)
/**
* Wether the extra word set should be used.
*/
Q_PROPERTY(bool useWordset READ useWordset WRITE setUseWordset NOTIFY useWordsetChanged)
/**
* Current base font-size used for font scaling.
*
......@@ -402,6 +407,12 @@ public:
emit wordsetChanged();
}
bool useWordset() const { return m_useWordset; }
void setUseWordset(const bool newMode) {
m_useWordset = newMode;
emit useWordsetChanged();
}
QString downloadServerUrl() const { return m_downloadServerUrl; }
void setDownloadServerUrl(const QString &newDownloadServerUrl) {
m_downloadServerUrl = newDownloadServerUrl;
......@@ -497,6 +508,7 @@ protected slots:
Q_INVOKABLE void notifyKioskModeChanged();
Q_INVOKABLE void notifySectionVisibleChanged();
Q_INVOKABLE void notifyWordsetChanged();
Q_INVOKABLE void notifyUseWordsetChanged();
Q_INVOKABLE void notifyFilteredBackgroundMusicChanged();
Q_INVOKABLE void notifyBackgroundMusicVolumeChanged();
Q_INVOKABLE void notifyAudioEffectsVolumeChanged();
......@@ -575,6 +587,7 @@ signals:
void kioskModeChanged();
void sectionVisibleChanged();
void wordsetChanged();
void useWordsetChanged();
void baseFontSizeChanged();
void filteredBackgroundMusicChanged();
void backgroundMusicVolumeChanged();
......@@ -618,6 +631,7 @@ private:
bool m_isKioskMode;
bool m_sectionVisible;
QString m_wordset;
bool m_useWordset;
QStringList m_filteredBackgroundMusic;
qreal m_backgroundMusicVolume;
qreal m_audioEffectsVolume;
......
......@@ -183,7 +183,7 @@ Window {
if(DownloadManager.updateResource(wordset)) {
ApplicationSettings.wordset = wordset
}
} else if(ApplicationSettings.wordset) { // Only if wordset specified
} else if(ApplicationSettings.useWordset) { // Only if external wordset is enabled
// words.rcc has not been downloaded yet -> ask for download
Core.showMessageDialog(
main,
......@@ -198,6 +198,11 @@ Window {
function() { pageView.currentItem.focus = true }
);
}
//disable wordset is useWordset config is false
if(!ApplicationSettings.useWordset) {
ApplicationSettings.wordset = "";
}
}
function checkBackgroundMusic() {
......
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