diff --git a/src/app/settingsview/SettingsSidePanel.qml b/src/app/settingsview/SettingsSidePanel.qml index 2dce657a732cf978f3ce90ad6cff02036d6c1fc4..fd26c07b0c40c1bbdfb445f4f31f7eccc360f6fc 100644 --- a/src/app/settingsview/SettingsSidePanel.qml +++ b/src/app/settingsview/SettingsSidePanel.qml @@ -33,6 +33,7 @@ SidePanelBase { color: JamiTheme.backgroundColor property int currentIndex property bool isSinglePane + signal updated function getHeaders() { if (AppVersionManager.isUpdaterEnabled()) { @@ -188,8 +189,19 @@ SidePanelBase { function updateModel() { if (visible) { - listView.model = {}; listView.model = getHeaders(); + root.updated() + } + } + + Timer { + id: timerTranslate + + interval: 100 + repeat: false + + onTriggered: { + updateModel() } } @@ -206,7 +218,10 @@ SidePanelBase { target: UtilsAdapter function onChangeLanguage() { - updateModel(); + // For some reason, under Qt 6.5.3, even if locale is changed before + // model is not computer correctly. + // Delaying the update works + timerTranslate.restart() } } @@ -253,6 +268,8 @@ SidePanelBase { ListView { id: listView + objectName: "listView" + width: page.width height: page.height clip: true diff --git a/src/app/utilsadapter.cpp b/src/app/utilsadapter.cpp index 8ff4253a843554ea92be344c507381bc3dd431b5..e6bb76ac91fadd4f0a977d76ac61682384198800 100644 --- a/src/app/utilsadapter.cpp +++ b/src/app/utilsadapter.cpp @@ -82,8 +82,8 @@ UtilsAdapter::setAppValue(const Settings::Key key, const QVariant& value) // If we change the lang preference, reload the translations if (key == Settings::Key::LANG) { settingsManager_->loadTranslations(); - Q_EMIT changeLanguage(); set_isRTL(isRTL()); + Q_EMIT changeLanguage(); } else if (key == Settings::Key::BaseZoom) Q_EMIT changeFontSize(); else if (key == Settings::Key::DisplayHyperlinkPreviews) diff --git a/tests/qml/src/tst_SettingsSidePanel.qml b/tests/qml/src/tst_SettingsSidePanel.qml new file mode 100644 index 0000000000000000000000000000000000000000..a553bf95c1d669cd83e5316c0c04d79cfe9dca2a --- /dev/null +++ b/tests/qml/src/tst_SettingsSidePanel.qml @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2021-2024 Savoir-faire Linux Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +import QtQuick +import QtTest + +import net.jami.Adapters 1.1 +import net.jami.Models 1.1 +import net.jami.Constants 1.1 +import net.jami.Enums 1.1 + +import "../../../src/app/settingsview" +import "../../../src/app/commoncomponents" + +SettingsSidePanel { + id: uut + + SignalSpy { + id: spyUpdated + + target: uut + signalName: "updated" + } + + SignalSpy { + id: spyChangeLang + + target: UtilsAdapter + signalName: "changeLanguage" + } + + TestCase { + name: "WelcomePage to different account creation page and return back" + when: windowShown + + function test_retranslate() { + spyUpdated.clear() + UtilsAdapter.setAppValue(Settings.Key.LANG, "en_EN") + spyChangeLang.wait(1000) + compare(spyChangeLang.count, 1) + spyUpdated.wait(1000) + compare(spyUpdated.count, 1) + UtilsAdapter.setAppValue(Settings.Key.LANG, "fr") + spyChangeLang.wait(1000) + compare(spyChangeLang.count, 2) + spyUpdated.wait(1000) + compare(spyUpdated.count, 2) + } + } + +}