Skip to content
Snippets Groups Projects
Commit 07b05f01 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

settingsmenu: make it dynamically translatable

Components.onCompleted is not called after engine_->retranslate(),
causing the menu to not change. Doing a model for 4 buttons is
overkill, so just do the menu.

jami-project#1342

Change-Id: I412230cc2152948666e37fe11824ee347bf55644
parent 72d794d5
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
<file>src/settingsview/components/ChatviewSettings.qml</file> <file>src/settingsview/components/ChatviewSettings.qml</file>
<file>src/settingsview/components/FileTransferSettings.qml</file> <file>src/settingsview/components/FileTransferSettings.qml</file>
<file>src/settingsview/components/SettingsMenu.qml</file> <file>src/settingsview/components/SettingsMenu.qml</file>
<file>src/settingsview/components/SettingsMenuButton.qml</file>
<file>src/settingsview/components/SettingsHeader.qml</file> <file>src/settingsview/components/SettingsHeader.qml</file>
<file>src/settingsview/components/SystemSettings.qml</file> <file>src/settingsview/components/SystemSettings.qml</file>
<file>src/settingsview/components/RecordingSettings.qml</file> <file>src/settingsview/components/RecordingSettings.qml</file>
......
...@@ -32,17 +32,6 @@ Rectangle { ...@@ -32,17 +32,6 @@ Rectangle {
signal itemSelected(int index) signal itemSelected(int index)
signal buttonSelectedManually(int index) signal buttonSelectedManually(int index)
Component.onCompleted: {
listModel.append({ 'type': SettingsView.Account, 'name': JamiStrings.accountSettingsMenuTitle,
'iconSource': JamiResources.account_24dp_svg})
listModel.append({ 'type': SettingsView.General, 'name': JamiStrings.generalSettingsTitle,
'iconSource': JamiResources.gear_black_24dp_svg})
listModel.append({ 'type': SettingsView.Media, 'name': JamiStrings.avSettingsMenuTitle,
'iconSource': JamiResources.media_black_24dp_svg})
listModel.append({ 'type': SettingsView.Plugin, 'name': JamiStrings.pluginSettingsTitle,
'iconSource': JamiResources.plugin_settings_black_24dp_svg})
}
anchors.fill: parent anchors.fill: parent
color: JamiTheme.backgroundColor color: JamiTheme.backgroundColor
...@@ -61,49 +50,69 @@ Rectangle { ...@@ -61,49 +50,69 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
height: childrenRect.height height: childrenRect.height
Repeater { SettingsMenuButton {
id: repeater id: accountPushButton
property int menuType: SettingsView.Account
model: ListModel { id: listModel } Connections {
target: root
PushButton {
id: pushButton
property int menuType: type function onButtonSelectedManually(index) {
if (accountPushButton.menuType === index)
Connections { buttonGroup.checkedButton = accountPushButton
target: root
function onButtonSelectedManually(index) {
if (pushButton.menuType === index)
buttonGroup.checkedButton = pushButton
}
} }
}
checked: true
buttonText: JamiStrings.accountSettingsMenuTitle
source: JamiResources.account_24dp_svg
normalColor: root.color
}
Component.onCompleted: checked = type === SettingsView.Account SettingsMenuButton {
id: generalPushButton
property int menuType: SettingsView.General
Connections {
target: root
preferredHeight: 64 function onButtonSelectedManually(index) {
preferredWidth: root.width if (generalPushButton.menuType === index)
preferredMargin: 24 buttonGroup.checkedButton = generalPushButton
}
}
buttonText: JamiStrings.generalSettingsTitle
source: JamiResources.gear_black_24dp_svg
normalColor: root.color
}
buttonText: name SettingsMenuButton {
buttonTextFont.pointSize: JamiTheme.textFontSize + 2 id: mediaPushButton
textHAlign: Text.AlignLeft property int menuType: SettingsView.Media
Connections {
target: root
source: iconSource function onButtonSelectedManually(index) {
imageColor: JamiTheme.textColor if (mediaPushButton.menuType === index)
imageContainerHeight: 40 buttonGroup.checkedButton = mediaPushButton
imageContainerWidth: 40 }
}
buttonText: JamiStrings.avSettingsMenuTitle
source: JamiResources.media_black_24dp_svg
normalColor: root.color
}
normalColor: root.color SettingsMenuButton {
pressedColor: Qt.lighter(JamiTheme.pressedButtonColor, 1.25) id: pluginPushButton
checkedColor: JamiTheme.selectedColor property int menuType: SettingsView.Plugin
hoveredColor: JamiTheme.hoverColor Connections {
target: root
duration: 0 function onButtonSelectedManually(index) {
checkable: true if (pluginPushButton.menuType === index)
radius: 0 buttonGroup.checkedButton = pluginPushButton
}
} }
buttonText: JamiStrings.pluginSettingsTitle
source: JamiResources.plugin_settings_black_24dp_svg
normalColor: root.color
} }
} }
} }
......
/*
* Copyright (C) 2020-2022 Savoir-faire Linux Inc.
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
* Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
import QtQuick
import QtQuick.Controls
import net.jami.Models 1.1
import net.jami.Constants 1.1
import "../../commoncomponents"
PushButton {
id: root
property int menuType: 0
preferredHeight: 64
preferredMargin: 24
anchors.left: parent.left
anchors.right: parent.right
buttonTextFont.pointSize: JamiTheme.textFontSize + 2
textHAlign: Text.AlignLeft
imageColor: JamiTheme.textColor
imageContainerHeight: 40
imageContainerWidth: 40
pressedColor: Qt.lighter(JamiTheme.pressedButtonColor, 1.25)
checkedColor: JamiTheme.selectedColor
hoveredColor: JamiTheme.hoverColor
duration: 0
checkable: true
radius: 0
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment