linphone-desktop/Linphone/view/Page/Layout/Settings/ContactsSettingsProviderLayout.qml
Gaelle Braud 79b15f4178 account parameters save
settings parameters save

ldap enabled save
2024-12-18 15:50:57 +01:00

130 lines
3.1 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls.Basic as Control
import SettingsCpp 1.0
import UtilsCpp
import Linphone
RowLayout {
id: mainItem
property string title
property string addText
property string addTextDescription
property string editText
property var newItemGui
property string settingsLayout
property var proxyModel
property var owner
property string titleProperty
property bool supportsEnableDisable
property bool showAddButton
signal save()
signal undo()
spacing: 5 * DefaultStyle.dp
ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 16 * DefaultStyle.dp
Repeater {
model: mainItem.proxyModel
RowLayout {
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft|Qt.AlignHCenter
Layout.preferredHeight: 74 * DefaultStyle.dp
spacing: 20 * DefaultStyle.dp
Text {
text: modelData.core[titleProperty]
font: Typography.p2l
wrapMode: Text.WordWrap
color: DefaultStyle.main2_600
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
}
Item {
Layout.fillWidth: true
}
Button {
background: Item{}
icon.source: AppIcons.pencil
icon.width: 24 * DefaultStyle.dp
icon.height: 24 * DefaultStyle.dp
contentImageColor: DefaultStyle.main2_600
onClicked: {
mainItem.owner.container.push(mainItem.settingsLayout, {
titleText: mainItem.editText,
model: modelData,
container: mainItem.owner.container,
isNew: false})
}
}
Switch {
id: switchButton
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
checked: supportsEnableDisable && modelData.core["enabled"]
visible: supportsEnableDisable
onToggled: {
binding.when = true
}
}
Binding {
id: binding
target: modelData.core
property: "enabled"
value: switchButton.checked
when: false
}
Connections {
target: mainItem
function onSave() {
modelData.core.save()
}
function onUndo() {
modelData.core.undo()
}
}
Connections {
target: modelData.core
function onSavedChanged() {
if (modelData.core.saved) UtilsCpp.showInformationPopup(qsTr("Succès"), qsTr("Les changements ont été sauvegardés"), true, mainWindow)
}
}
}
onVisibleChanged: {
if (visible)
proxyModel.updateView()
}
Component.onCompleted: {
proxyModel.updateView()
}
}
RowLayout {
Layout.fillWidth: true
spacing: 5 * DefaultStyle.dp
Item {
Layout.fillWidth: true
}
Button {
Layout.preferredHeight: 47 * DefaultStyle.dp
Layout.alignment: Qt.AlignRight | Qt.AlignHCenter
text: qsTr("Ajouter")
leftPadding: 20 * DefaultStyle.dp
rightPadding: 20 * DefaultStyle.dp
topPadding: 11 * DefaultStyle.dp
bottomPadding: 11 * DefaultStyle.dp
visible: mainItem.showAddButton
onClicked: {
mainItem.owner.container.push(mainItem.settingsLayout, {
titleText: mainItem.addText,
model: mainItem.newItemGui,
container: mainItem.owner.container,
isNew: true})
}
}
}
}
}