mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-10 03:53:23 +02:00
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. https://git.jami.net/savoirfairelinux/jami-project/-/issues/1342 Change-Id: I412230cc2152948666e37fe11824ee347bf55644
This commit is contained in:
parent
72d794d56b
commit
07b05f0123
3 changed files with 114 additions and 51 deletions
1
qml.qrc
1
qml.qrc
|
@ -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 {
|
||||||
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 {
|
||||||
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
|
||||||
|
Connections {
|
||||||
|
target: root
|
||||||
|
|
||||||
model: ListModel { id: listModel }
|
function onButtonSelectedManually(index) {
|
||||||
|
if (accountPushButton.menuType === index)
|
||||||
PushButton {
|
buttonGroup.checkedButton = accountPushButton
|
||||||
id: pushButton
|
|
||||||
|
|
||||||
property int menuType: type
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: root
|
|
||||||
|
|
||||||
function onButtonSelectedManually(index) {
|
|
||||||
if (pushButton.menuType === index)
|
|
||||||
buttonGroup.checkedButton = pushButton
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: checked = type === SettingsView.Account
|
|
||||||
|
|
||||||
preferredHeight: 64
|
|
||||||
preferredWidth: root.width
|
|
||||||
preferredMargin: 24
|
|
||||||
|
|
||||||
buttonText: name
|
|
||||||
buttonTextFont.pointSize: JamiTheme.textFontSize + 2
|
|
||||||
textHAlign: Text.AlignLeft
|
|
||||||
|
|
||||||
source: iconSource
|
|
||||||
imageColor: JamiTheme.textColor
|
|
||||||
imageContainerHeight: 40
|
|
||||||
imageContainerWidth: 40
|
|
||||||
|
|
||||||
normalColor: root.color
|
|
||||||
pressedColor: Qt.lighter(JamiTheme.pressedButtonColor, 1.25)
|
|
||||||
checkedColor: JamiTheme.selectedColor
|
|
||||||
hoveredColor: JamiTheme.hoverColor
|
|
||||||
|
|
||||||
duration: 0
|
|
||||||
checkable: true
|
|
||||||
radius: 0
|
|
||||||
}
|
}
|
||||||
|
checked: true
|
||||||
|
buttonText: JamiStrings.accountSettingsMenuTitle
|
||||||
|
source: JamiResources.account_24dp_svg
|
||||||
|
normalColor: root.color
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsMenuButton {
|
||||||
|
id: generalPushButton
|
||||||
|
property int menuType: SettingsView.General
|
||||||
|
Connections {
|
||||||
|
target: root
|
||||||
|
|
||||||
|
function onButtonSelectedManually(index) {
|
||||||
|
if (generalPushButton.menuType === index)
|
||||||
|
buttonGroup.checkedButton = generalPushButton
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buttonText: JamiStrings.generalSettingsTitle
|
||||||
|
source: JamiResources.gear_black_24dp_svg
|
||||||
|
normalColor: root.color
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsMenuButton {
|
||||||
|
id: mediaPushButton
|
||||||
|
property int menuType: SettingsView.Media
|
||||||
|
Connections {
|
||||||
|
target: root
|
||||||
|
|
||||||
|
function onButtonSelectedManually(index) {
|
||||||
|
if (mediaPushButton.menuType === index)
|
||||||
|
buttonGroup.checkedButton = mediaPushButton
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buttonText: JamiStrings.avSettingsMenuTitle
|
||||||
|
source: JamiResources.media_black_24dp_svg
|
||||||
|
normalColor: root.color
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsMenuButton {
|
||||||
|
id: pluginPushButton
|
||||||
|
property int menuType: SettingsView.Plugin
|
||||||
|
Connections {
|
||||||
|
target: root
|
||||||
|
|
||||||
|
function onButtonSelectedManually(index) {
|
||||||
|
if (pluginPushButton.menuType === index)
|
||||||
|
buttonGroup.checkedButton = pluginPushButton
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buttonText: JamiStrings.pluginSettingsTitle
|
||||||
|
source: JamiResources.plugin_settings_black_24dp_svg
|
||||||
|
normalColor: root.color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
53
src/settingsview/components/SettingsMenuButton.qml
Normal file
53
src/settingsview/components/SettingsMenuButton.qml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue