mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-24 07:08:07 +00:00
feat(ui/views/App/Settings/SettingsUi): ask restart to user when language is updated
This commit is contained in:
parent
2cd19ab5d8
commit
6aceba9deb
4 changed files with 45 additions and 30 deletions
|
|
@ -1277,6 +1277,10 @@ your friend'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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue