1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-04 23:05:48 +02:00

accessibility: make the shortcuts focusable

Gitlab: #1211
Change-Id: Idf6a9971ceb06d1f9d42a907f948f402623fccd2
This commit is contained in:
Charles 2023-08-14 10:48:56 -04:00 committed by Sébastien Blin
parent b291728472
commit e7436dbc05
2 changed files with 288 additions and 306 deletions

View file

@ -25,6 +25,9 @@ RowLayout {
layoutDirection: UtilsAdapter.isRTL ? Qt.RightToLeft : Qt.LeftToRight layoutDirection: UtilsAdapter.isRTL ? Qt.RightToLeft : Qt.LeftToRight
focus: true
// Needs to get focus so Orca can read the shortcut
Rectangle { Rectangle {
id: descriptionTextRect id: descriptionTextRect
@ -36,6 +39,8 @@ RowLayout {
color: JamiTheme.transparentColor color: JamiTheme.transparentColor
focus: true
Text { Text {
id: descriptionText id: descriptionText
@ -48,6 +53,7 @@ RowLayout {
} }
} }
// Needs to get focus as well so Orca can read the shortcut
Rectangle { Rectangle {
id: shortcutTextRect id: shortcutTextRect
@ -58,6 +64,7 @@ RowLayout {
Layout.rightMargin: 10 Layout.rightMargin: 10
color: JamiTheme.backgroundColor color: JamiTheme.backgroundColor
radius: JamiTheme.primaryRadius radius: JamiTheme.primaryRadius
Text { Text {

View file

@ -32,342 +32,317 @@ Window {
height: 480 height: 480
minimumHeight: 300 minimumHeight: 300
ListModel { readonly property list<ListModel> keyboardShortcutsModelList: [
id: keyboardGeneralShortcutsModel ListModel {
id: keyboardGeneralShortcutsModel
ListElement { ListElement {
shortcut: "Ctrl + J" shortcut: "Ctrl + J"
shortcut2: "" description: qsTr("Open account list")
description: qsTr("Open account list") }
} ListElement {
ListElement { shortcut: "Ctrl + L"
shortcut: "Ctrl + L" description: qsTr("Focus conversations list")
shortcut2: "" }
description: qsTr("Focus conversations list") ListElement {
} shortcut: "Ctrl + R"
ListElement { description: qsTr("Requests list")
shortcut: "Ctrl + R" }
shortcut2: "" ListElement {
description: qsTr("Requests list") shortcut: "Ctrl + ↑"
} description: qsTr("Previous conversation")
ListElement { }
shortcut: "Ctrl + ↑" ListElement {
shortcut2: "" shortcut: "Ctrl + ↓"
description: qsTr("Previous conversation") description: qsTr("Next conversation")
} }
ListElement { ListElement {
shortcut: "Ctrl + ↓" shortcut: "Ctrl + F"
shortcut2: "" description: qsTr("Search bar")
description: qsTr("Next conversation") }
} ListElement {
ListElement { shortcut: "F11"
shortcut: "Ctrl + F" description: qsTr("Full screen")
shortcut2: "" }
description: qsTr("Search bar") ListElement {
} shortcut: "Ctrl + +"
ListElement { description: qsTr("Increase font size")
shortcut: "F11" }
shortcut2: "" ListElement {
description: qsTr("Full screen") shortcut: "Ctrl + -"
} description: qsTr("Decrease font size")
ListElement { }
shortcut: "Ctrl + +" ListElement {
shortcut2: "" shortcut: "Ctrl + 0"
description: qsTr("Increase font size") description: qsTr("Reset font size")
} }
ListElement { },
shortcut: "Ctrl + -" ListModel {
shortcut2: "" id: keyboardConversationShortcutsModel
description: qsTr("Decrease font size")
}
ListElement {
shortcut: "Ctrl + 0"
shortcut2: ""
description: qsTr("Reset font size")
}
}
ListModel { ListElement {
id: keyboardConversationShortcutsModel shortcut: "Ctrl + Shift + C"
description: qsTr("Start an audio call")
}
ListElement {
shortcut: "Ctrl + Shift + X"
description: qsTr("Start a video call")
}
ListElement {
shortcut: "Ctrl + Shift + L"
description: qsTr("Clear history")
}
ListElement {
shortcut: "Ctrl + Shift + F"
description: qsTr("Search messages/files")
}
ListElement {
shortcut: "Ctrl + Shift + B"
description: qsTr("Block contact")
}
ListElement {
shortcut: "Ctrl + Shift + Delete"
description: qsTr("Remove conversation")
}
ListElement {
shortcut: "Ctrl + Shift + A"
description: qsTr("Accept contact request")
}
ListElement {
shortcut: "↑"
description: qsTr("Edit last message")
}
ListElement {
shortcut: "Esc"
description: qsTr("Cancel message edition")
}
},
ListModel {
id: keyboardSettingsShortcutsModel
ListElement { ListElement {
shortcut: "Ctrl + Shift + C" shortcut: "Ctrl + M"
shortcut2: "" description: qsTr("Media settings")
description: qsTr("Start an audio call") }
} ListElement {
ListElement { shortcut: "Ctrl + G"
shortcut: "Ctrl + Shift + X" description: qsTr("General settings")
shortcut2: "" }
description: qsTr("Start a video call") ListElement {
} shortcut: "Ctrl + Alt + I"
ListElement { description: qsTr("Account settings")
shortcut: "Ctrl + Shift + L" }
shortcut2: "" ListElement {
description: qsTr("Clear history") shortcut: "Ctrl + P"
} description: qsTr("Plugin settings")
ListElement { }
shortcut: "Ctrl + Shift + F" ListElement {
shortcut2: "" shortcut: "Ctrl + Shift + N"
description: qsTr("Search messages/files") description: qsTr("Open account creation wizard")
} }
ListElement { ListElement {
shortcut: "Ctrl + Shift + B" shortcut: "F10"
shortcut2: "" shortcut2: ""
description: qsTr("Block contact") description: qsTr("Open keyboard shortcut table")
} }
ListElement { },
shortcut: "Ctrl + Shift + Delete" ListModel {
shortcut2: "" id: keyboardCallsShortcutsModel
description: qsTr("Remove conversation")
}
ListElement {
shortcut: "Ctrl + Shift + A"
shortcut2: ""
description: qsTr("Accept contact request")
}
ListElement {
shortcut: "↑"
shortcut2: ""
description: qsTr("Edit last message")
}
ListElement {
shortcut: "Esc"
shortcut2: ""
description: qsTr("Cancel message edition")
}
}
ListModel { ListElement {
id: keyboardSettingsShortcutsModel shortcut: "Ctrl + Y"
description: qsTr("Answer an incoming call")
}
ListElement {
shortcut: "Ctrl + D"
description: qsTr("End call")
}
ListElement {
shortcut: "Ctrl + Shift + D"
description: qsTr("Decline the call request")
}
ListElement {
shortcut: "M"
description: qsTr("Mute microphone")
}
ListElement {
shortcut: "V"
description: qsTr("Stop camera")
}
ListElement {
shortcut: "Ctrl"
description: qsTr("Take tile screenshot")
}
},
ListModel {
id: keyboardMarkdownShortcutsModel
ListElement { ListElement {
shortcut: "Ctrl + M" shortcut: "Ctrl + B"
shortcut2: "" description: qsTr("Bold")
description: qsTr("Media settings") }
ListElement {
shortcut: "Ctrl + I"
description: qsTr("Italic")
}
ListElement {
shortcut: "Shift + Alt + X"
description: qsTr("Strikethrough")
}
ListElement {
shortcut: "Ctrl + Alt + H"
description: qsTr("Heading")
}
ListElement {
shortcut: "Ctrl + Alt + K"
description: qsTr("Link")
}
ListElement {
shortcut: "Ctrl + Alt + C"
description: qsTr("Code")
}
ListElement {
shortcut: "Shift + Alt + 9"
description: qsTr("Quote")
}
ListElement {
shortcut: "Shift + Alt + 8"
description: qsTr("Unordered list")
}
ListElement {
shortcut: "Shift + Alt + 7"
description: qsTr("Ordered list")
}
ListElement {
shortcut: "Shift + Alt + T"
description: qsTr("Show formatting")
}
ListElement {
shortcut: "Shift + Alt + P"
description: qsTr("Show preview")
}
} }
ListElement { ]
shortcut: "Ctrl + G"
shortcut2: ""
description: qsTr("General settings")
}
ListElement {
shortcut: "Ctrl + Alt + I"
shortcut2: ""
description: qsTr("Account settings")
}
ListElement {
shortcut: "Ctrl + P"
shortcut2: ""
description: qsTr("Plugin settings")
}
ListElement {
shortcut: "Ctrl + Shift + N"
shortcut2: ""
description: qsTr("Open account creation wizard")
}
ListElement {
shortcut: "F10"
shortcut2: ""
description: qsTr("Open keyboard shortcut table")
}
}
ListModel { Page {
id: keyboardCallsShortcutsModel id: page
ListElement {
shortcut: "Ctrl + Y"
shortcut2: ""
description: qsTr("Answer an incoming call")
}
ListElement {
shortcut: "Ctrl + D"
shortcut2: ""
description: qsTr("End call")
}
ListElement {
shortcut: "Ctrl + Shift + D"
shortcut2: ""
description: qsTr("Decline the call request")
}
ListElement {
shortcut: "M"
shortcut2: ""
description: qsTr("Mute microphone")
}
ListElement {
shortcut: "V"
shortcut2: ""
description: qsTr("Stop camera")
}
ListElement {
shortcut: "Ctrl"
shortcut2: qsTr("Mouse middle click")
description: qsTr("Take tile screenshot")
}
}
ListModel {
id: keyboardMarkdownShortcutsModel
ListElement {
shortcut: "Ctrl + B"
shortcut2: ""
description: qsTr("Bold")
}
ListElement {
shortcut: "Ctrl + I"
shortcut2: ""
description: qsTr("Italic")
}
ListElement {
shortcut: "Shift + Alt + X"
shortcut2: ""
description: qsTr("Strikethrough")
}
ListElement {
shortcut: "Ctrl + Alt + H"
shortcut2: ""
description: qsTr("Heading")
}
ListElement {
shortcut: "Ctrl + Alt + K"
shortcut2: ""
description: qsTr("Link")
}
ListElement {
shortcut: "Ctrl + Alt + C"
shortcut2: ""
description: qsTr("Code")
}
ListElement {
shortcut: "Shift + Alt + 9"
shortcut2: ""
description: qsTr("Quote")
}
ListElement {
shortcut: "Shift + Alt + 8"
shortcut2: ""
description: qsTr("Unordered list")
}
ListElement {
shortcut: "Shift + Alt + 7"
shortcut2: ""
description: qsTr("Ordered list")
}
ListElement {
shortcut: "Shift + Alt + T"
shortcut2: ""
description: qsTr("Show formatting")
}
ListElement {
shortcut: "Shift + Alt + P"
shortcut2: ""
description: qsTr("Show preview")
}
}
Rectangle {
id: windowRect
anchors.fill: parent anchors.fill: parent
color: JamiTheme.secondaryBackgroundColor // make a list view of keyboardShortcutsModelList[selectionBar.currentIndex]
JamiListView {
id: keyboardShortcutsListView
Rectangle { anchors.fill: parent
id: titleRect anchors.leftMargin: 48
anchors.rightMargin: 48
anchors.top: parent.top Keys.onUpPressed: keyboardShortcutsListView.decrementCurrentIndex()
anchors.horizontalCenter: parent.horizontalCenter Keys.onDownPressed: keyboardShortcutsListView.incrementCurrentIndex()
anchors.topMargin: JamiTheme.titleRectMargin
height: titleName.contentHeight + JamiTheme.titleRectMargin // on key tab forceActiveFocus
width: titleName.contentWidth + JamiTheme.titleRectMargin Keys.onTabPressed: if (activeFocus)
selectionBar.forceActiveFocus()
color: JamiTheme.backgroundColor model: keyboardShortcutsModelList[selectionBar.currentIndex]
radius: JamiTheme.primaryRadius spacing: 24
delegate: FocusScope {
id: fs
height: childrenRect.height
focus: true
Text { // Accessible.role: Accessible.Button
id: titleName Accessible.name: descriptionLabel.text
Accessible.description: shortcutLabel.text
anchors.centerIn: parent RowLayout {
width: keyboardShortcutsListView.width
font.pointSize: JamiTheme.titleFontSize Label {
text: { id: descriptionLabel
var modelId = UtilsAdapter.isRTL ? 4 - selectionBar.currentIndex : selectionBar.currentIndex Layout.alignment: Qt.AlignLeft
switch (modelId) { Layout.topMargin: 8
case 0: Layout.leftMargin: 20
return JamiStrings.generalSettingsTitle; text: description
case 1: background: Rectangle {
return JamiStrings.conversationKeyboardShortcuts; width: parent.width + 16
case 2: height: parent.height + 16
return JamiStrings.callKeyboardShortcuts; border.color: fs.activeFocus ? "darkblue" : "transparent"
case 3: border.width: 2
return JamiStrings.settings; radius: 5
case 4: anchors.centerIn: parent
return JamiStrings.markdownKeyboardShortcuts; }
}
Label {
id: shortcutLabel
Layout.alignment: Qt.AlignRight
Layout.topMargin: 8
Layout.rightMargin: 20
text: shortcut
background: Rectangle {
width: parent.width + 16
height: parent.height + 16
border.color: fs.activeFocus ? "darkblue" : "transparent"
border.width: 2
radius: 5
anchors.centerIn: parent
}
} }
} }
color: JamiTheme.textColor
} }
} }
JamiListView { header: TabBar {
id: keyboardShortCutList
anchors.top: titleRect.bottom
anchors.topMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
height: parent.height - titleRect.height - JamiTheme.titleRectMargin - keyboardShortCutList.anchors.topMargin - selectionBar.height - selectionBar.anchors.bottomMargin
model: {
var modelId = UtilsAdapter.isRTL ? 4 - selectionBar.currentIndex : selectionBar.currentIndex
switch (modelId) {
case 0:
return keyboardGeneralShortcutsModel;
case 1:
return keyboardConversationShortcutsModel;
case 2:
return keyboardCallsShortcutsModel;
case 3:
return keyboardSettingsShortcutsModel;
case 4:
return keyboardMarkdownShortcutsModel;
}
}
delegate: KeyboardShortcutKeyDelegate {
width: keyboardShortCutList.width
height: Math.max(JamiTheme.keyboardShortcutDelegateSize, implicitHeight)
}
}
TabBar {
id: selectionBar id: selectionBar
anchors.bottom: parent.bottom readonly property real lambda: 12
anchors.bottomMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
width: 96 spacing: lambda
height: JamiTheme.keyboardShortcutTabBarSize padding: lambda
contentHeight: JamiTheme.keyboardShortcutTabBarSize
background: Rectangle { focus: true
color: windowRect.color
}
Repeater { Repeater {
model: UtilsAdapter.isRTL ? ["5", "4", "3", "2", "1"] : ["1", "2", "3", "4", "5"] model: [JamiStrings.generalSettingsTitle, JamiStrings.conversationKeyboardShortcuts, JamiStrings.callKeyboardShortcuts, JamiStrings.settings, JamiStrings.markdownKeyboardShortcuts]
KeyboardShortcutTabButton { TabButton {
currentIndex: selectionBar.currentIndex id: tabButton
text: modelData
Accessible.name: modelData + "shortcuts category"
Keys.onTabPressed: if (activeFocus)
keyboardShortcutsListView.forceActiveFocus()
contentItem: Text {
text: modelData
color: JamiTheme.textColor
font.pixelSize: JamiTheme.titleFontSize
horizontalAlignment: Text.AlignHCenter
}
background: Rectangle {
border.color: tabButton.activeFocus ? "darkblue" : "transparent"
border.width: 2
color: {
if (tabButton.checked || tabButton.pressed)
return JamiTheme.pressedButtonColor;
if (tabButton.hovered)
return JamiTheme.hoveredButtonColor;
else
return JamiTheme.normalButtonColor;
}
radius: JamiTheme.primaryRadius
}
} }
} }
}
Component.onCompleted: { footer: Item {
setCurrentIndex(UtilsAdapter.isRTL ? 4 : 0); height: JamiTheme.keyboardShortcutTabBarSize
PageIndicator {
anchors.centerIn: parent
count: selectionBar.count
currentIndex: selectionBar.currentIndex
} }
} }
} }