mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-17 20:08:28 +00:00
* Fix focus and screen reader on Dialog #LINQT-2197 * Fix dialer accessibility #LINQT-2204 * Add accessibility to voicemail button #LINQT-2200 *Add list annoncement on magicsearch suggestions #LINQT-2205 * Fix accessibility on contact lists #LINQT-2206 * Fix screen reader does not say values on combobox #LINQT-2195 * Fix focus when close modal #LINQT-2220 * Focus end call button when accepting a call #LINQT-2223
185 lines
5.7 KiB
QML
185 lines
5.7 KiB
QML
import QtQuick
|
|
import QtQuick.Controls.Basic as Control
|
|
import QtQuick.Effects
|
|
import QtQuick.Layouts
|
|
import Linphone
|
|
import 'qrc:/qt/qml/Linphone/view/Style/buttonStyle.js' as ButtonStyle
|
|
import "qrc:/qt/qml/Linphone/view/Control/Tool/Helper/utils.js" as Utils
|
|
|
|
Popup {
|
|
id: mainItem
|
|
modal: true
|
|
anchors.centerIn: parent
|
|
closePolicy: Control.Popup.NoAutoClose
|
|
leftPadding: Utils.getSizeWithScreenRatio(title.length === 0 ? 10 : 33)
|
|
rightPadding: Utils.getSizeWithScreenRatio(title.length === 0 ? 10 : 33)
|
|
topPadding: Utils.getSizeWithScreenRatio(title.length === 0 ? 10 : 37)
|
|
bottomPadding: Utils.getSizeWithScreenRatio(title.length === 0 ? 10 : 37)
|
|
underlineColor: DefaultStyle.main1_500_main
|
|
radius: title.length === 0 ? Utils.getSizeWithScreenRatio(16) : 0
|
|
property string title
|
|
property var titleColor: DefaultStyle.main1_500_main
|
|
property string text
|
|
property string details
|
|
//: "Confirmer"
|
|
property string firstButtonText: firstButtonAccept ? qsTr("dialog_confirm")
|
|
//: "Annuler"
|
|
: qsTr("dialog_cancel")
|
|
property string secondButtonText: secondButtonAccept ? qsTr("dialog_confirm")
|
|
: qsTr("dialog_cancel")
|
|
property alias content: contentLayout.data
|
|
property alias buttons: buttonsLayout.data
|
|
property alias firstButton: firstButtonId
|
|
property alias secondButton: secondButtonId
|
|
property bool firstButtonAccept: true
|
|
property bool secondButtonAccept: false
|
|
|
|
signal accepted()
|
|
signal rejected()
|
|
|
|
property Item itemToFocusOnClose: null
|
|
property bool quitWithKeyboard : false
|
|
|
|
function updateQuitWithKeyboardPress (event) {
|
|
if(visible && (event.key == Qt.Key_Escape || event.key == Qt.Key_Enter || event.key == Qt.Key_Space || event.key == Qt.Key_Return)){
|
|
mainItem.quitWithKeyboard = true
|
|
}
|
|
}
|
|
|
|
onAboutToHide: {
|
|
if(mainItem.itemToFocusOnClose && mainItem.itemToFocusOnClose.visible && mainItem.quitWithKeyboard){
|
|
// Focus last element that was focused before Dialog was opened
|
|
mainItem.itemToFocusOnClose.forceActiveFocus(Qt.TabFocusReason)
|
|
}
|
|
mainItem.itemToFocusOnClose = null
|
|
}
|
|
|
|
contentItem: FocusScope {
|
|
Accessible.role: Accessible.Dialog
|
|
Accessible.name: mainItem.title
|
|
Accessible.description: mainItem.details
|
|
implicitWidth: child.implicitWidth
|
|
implicitHeight: child.implicitHeight
|
|
onVisibleChanged: {
|
|
if(visible){
|
|
mainItem.itemToFocusOnClose = FocusNavigator.lastFocusItem
|
|
const focusReason = FocusNavigator.doesLastFocusWasKeyboard() ? Qt.TabFocusReason : Qt.OtherFocusReason
|
|
forceActiveFocus(focusReason)
|
|
}
|
|
}
|
|
Keys.onPressed: (event) => {
|
|
mainItem.updateQuitWithKeyboardPress(event)
|
|
if(visible && event.key == Qt.Key_Escape){
|
|
mainItem.close()
|
|
event.accepted = true
|
|
}
|
|
}
|
|
ColumnLayout {
|
|
id: child
|
|
anchors.fill: parent
|
|
spacing: Utils.getSizeWithScreenRatio(15)
|
|
|
|
Text{
|
|
id: titleText
|
|
Layout.fillWidth: true
|
|
visible: text.length != 0
|
|
text: mainItem.title
|
|
color: mainItem.titleColor
|
|
font {
|
|
pixelSize: Typography.h3.pixelSize
|
|
weight: Typography.h3.weight
|
|
}
|
|
wrapMode: Text.Wrap
|
|
horizontalAlignment: Text.AlignLeft
|
|
}
|
|
Rectangle{
|
|
Layout.fillWidth: true
|
|
Layout.preferredHeight: 1
|
|
color: DefaultStyle.main2_400
|
|
visible: titleText.visible
|
|
}
|
|
|
|
Text {
|
|
id: defaultText
|
|
visible: text.length != 0
|
|
Layout.fillWidth: true
|
|
Layout.alignment: Qt.AlignCenter
|
|
text: mainItem.text
|
|
font {
|
|
pixelSize: Typography.p1.pixelSize
|
|
weight: Typography.p1.weight
|
|
}
|
|
wrapMode: Text.Wrap
|
|
horizontalAlignment: titleText.visible ? Text.AlignLeft : Text.AlignHCenter
|
|
}
|
|
Text {
|
|
id: detailsText
|
|
visible: text.length != 0
|
|
Layout.fillWidth: true
|
|
//Layout.preferredWidth: Utils.getSizeWithScreenRatio(278)
|
|
Layout.alignment: Qt.AlignCenter
|
|
text: mainItem.details
|
|
font {
|
|
pixelSize: Typography.p1.pixelSize
|
|
weight: Typography.p1.weight
|
|
italic: true
|
|
}
|
|
wrapMode: Text.Wrap
|
|
horizontalAlignment: Text.AlignHCenter
|
|
}
|
|
|
|
ColumnLayout {
|
|
id: contentLayout
|
|
Layout.alignment: Qt.AlignHCenter
|
|
Layout.fillHeight: false
|
|
}
|
|
|
|
RowLayout {
|
|
id: buttonsLayout
|
|
Layout.alignment: Qt.AlignBottom | ( titleText.visible ? Qt.AlignRight : Qt.AlignHCenter)
|
|
spacing: Utils.getSizeWithScreenRatio(titleText.visible ? 20 : 10)
|
|
|
|
// Default buttons only visible if no other children
|
|
// have been set
|
|
MediumButton {
|
|
id:firstButtonId
|
|
visible: mainItem.buttons.length === 2
|
|
text: mainItem.firstButtonText
|
|
style: mainItem.firstButtonAccept ? ButtonStyle.main : ButtonStyle.secondary
|
|
focus: !mainItem.firstButtonAccept
|
|
onClicked: {
|
|
if(mainItem.firstButtonAccept)
|
|
mainItem.accepted()
|
|
else
|
|
mainItem.rejected()
|
|
mainItem.close()
|
|
}
|
|
Keys.onPressed: (event) => {
|
|
mainItem.updateQuitWithKeyboardPress(event)
|
|
}
|
|
KeyNavigation.left: secondButtonId
|
|
KeyNavigation.right: secondButtonId
|
|
}
|
|
MediumButton {
|
|
id: secondButtonId
|
|
visible: mainItem.buttons.length === 2
|
|
text: mainItem.secondButtonText
|
|
style: mainItem.firstButtonAccept ? ButtonStyle.secondary : ButtonStyle.main
|
|
focus: !mainItem.secondButtonAccept
|
|
onClicked: {
|
|
if(mainItem.secondButtonAccept)
|
|
mainItem.accepted()
|
|
else
|
|
mainItem.rejected()
|
|
mainItem.close()
|
|
}
|
|
Keys.onPressed: (event) => {
|
|
mainItem.updateQuitWithKeyboardPress(event)
|
|
}
|
|
KeyNavigation.left: firstButtonId
|
|
KeyNavigation.right: firstButtonId
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|