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