Commit 6aceba9d authored by Wescoeur's avatar Wescoeur

feat(ui/views/App/Settings/SettingsUi): ask restart to user when language is updated

parent 2cd19ab5
......@@ -1277,6 +1277,10 @@ your friend&apos;s SIP address or username.</translation>
<source>downloadLabel</source>
<translation>Download folder</translation>
</message>
<message>
<source>setLocaleDescription</source>
<translation>It is necessary to restart the application. Do you want to restart now?</translation>
</message>
</context>
<context>
<name>SettingsVideo</name>
......
......@@ -1275,6 +1275,10 @@ Url du serveur non configurée.</translation>
<source>downloadLabel</source>
<translation>Dossier des téléchargements</translation>
</message>
<message>
<source>setLocaleDescription</source>
<translation>Voulez-vous redémarrer maintenant pour prendre en compte ces modifications ?</translation>
</message>
</context>
<context>
<name>SettingsVideo</name>
......
......@@ -17,3 +17,35 @@ function cleanAvatars () {
}
})
}
function getAvailableLocales () {
var locales = []
Linphone.App.availableLocales.forEach(function (locale) {
locales.push({
key: Utils.capitalizeFirstLetter(locale.nativeLanguageName),
value: locale.name
})
})
return [{
key: qsTr('systemLocale'),
value: ''
}].concat(locales.sort(function (a, b) {
return a > b
}))
}
function setLocale (locale) {
var App = Linphone.App
App.configLocale = locale
window.detachVirtualWindow()
window.attachVirtualWindow(Utils.buildDialogUri('ConfirmDialog'), {
descriptionText: qsTr('setLocaleDescription'),
}, function (status) {
if (status) {
App.restart()
}
})
}
......@@ -28,34 +28,11 @@ TabContainer {
label: qsTr('languagesLabel')
ComboBox {
function _getAvailableLocales () {
var locales = []
App.availableLocales.forEach(function (locale) {
locales.push({
key: Utils.capitalizeFirstLetter(locale.nativeLanguageName),
value: locale.name
})
})
return locales.sort(function (a, b) {
return a > b
})
}
textRole: 'key'
model: ListModel {}
Component.onCompleted: {
var locales = _getAvailableLocales()
model.append({
key: qsTr('systemLocale'),
value: ''
})
locales.forEach(function (locale) {
model.append(locale)
})
var locales = Logic.getAvailableLocales()
model = locales
var locale = App.configLocale
if (!locale.length) {
......@@ -64,14 +41,12 @@ TabContainer {
}
var value = Qt.locale(locale).name
var index = Utils.findIndex(locales, function (locale) {
currentIndex = Number(Utils.findIndex(locales, function (locale) {
return locale.value === value
})
currentIndex = index != null ? index + 1 : 0
}))
}
onActivated: App.configLocale = model.get(index).value
onActivated: Logic.setLocale(model[index].value)
}
}
}
......
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