linphone-desktop/Linphone/view/Control/Button/Settings/SwitchSetting.qml
Alexandre Jörgensen a9a78cb4bf Accessibility and code improvments:
* Normalize and correct linphone color
* Add border when user focus using keyboard navigation
* Correct some keyboard navigation
* Add accessibility screen reading to interactive elements except chat and meeting
2025-10-15 12:50:43 +02:00

59 lines
1.6 KiB
QML

import QtQuick
import QtQuick.Controls.Basic
import QtQuick.Layouts
import Linphone
import 'qrc:/qt/qml/Linphone/view/Control/Tool/Helper/utils.js' as Utils
RowLayout {
id:mainItem
property string titleText
property string subTitleText
property string propertyName
property var propertyOwner
property var propertyOwnerGui
property bool enabled: true
spacing : Math.round(20 * DefaultStyle.dp)
signal checkedChanged(bool checked)
function setChecked(value) {
switchButton.checked = value
}
ColumnLayout {
Layout.minimumHeight: Math.round(32 * DefaultStyle.dp)
spacing: Math.round(4 * DefaultStyle.dp)
Text {
text: titleText
font: Typography.p2l
wrapMode: Text.WordWrap
color: DefaultStyle.main2_600
Layout.fillWidth: true
}
Text {
text: subTitleText
font: Typography.p1
wrapMode: Text.WordWrap
visible: subTitleText.length > 0
color: DefaultStyle.main2_600
Layout.fillWidth: true
}
}
Switch {
id: switchButton
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
checked: propertyOwnerGui ? propertyOwnerGui.core[mainItem.propertyName]
: propertyOwner ? propertyOwner[mainItem.propertyName] : false
enabled: mainItem.enabled
onCheckedChanged: mainItem.checkedChanged(checked)
onToggled: binding.when = true
implicitHeight: Utils.getSizeWithScreenRatio(30)
Accessible.name: "%1 %2".arg(mainItem.titleText).arg(mainItem.subTitleText)
}
Binding {
id: binding
target: propertyOwnerGui ? propertyOwnerGui.core : propertyOwner ? propertyOwner : null
property: mainItem.propertyName
value: switchButton.checked
when: false
}
}