Skip to content

Commit a826181

Browse files
committed
feat: Enhance accessibility in dialogs and wizard components
- Added focusable properties to dialog titles and messages for improved screen reader navigation. - Registered new focus groups for error, storage removal, and quit confirmation dialogs to streamline focus management. - Updated WizardContainer to include focusable elements for title and body text, ensuring better accessibility. - Adjusted focus group order to maintain consistent navigation flow across components.
1 parent cbd3a5a commit a826181

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

src/main.qml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,17 @@ ApplicationWindow {
9292

9393
// Register focus groups when component is ready
9494
Component.onCompleted: {
95+
registerFocusGroup("content", function(){
96+
return [errorTitle, errorMessage]
97+
}, 0)
9598
registerFocusGroup("buttons", function(){
9699
return [errorContinueButton]
97-
}, 0)
100+
}, 1)
98101
}
99102

100103
// Dialog content
101104
Text {
105+
id: errorTitle
102106
text: errorDialog.titleText
103107
font.pixelSize: Style.fontSizeHeading
104108
font.family: Style.fontFamilyBold
@@ -107,9 +111,13 @@ ApplicationWindow {
107111
Layout.fillWidth: true
108112
Accessible.role: Accessible.Heading
109113
Accessible.name: text
114+
Accessible.focusable: true
115+
focusPolicy: Qt.TabFocus
116+
activeFocusOnTab: true
110117
}
111118

112119
Text {
120+
id: errorMessage
113121
text: errorDialog.message
114122
wrapMode: Text.WordWrap
115123
font.pixelSize: Style.fontSizeDescription
@@ -118,6 +126,9 @@ ApplicationWindow {
118126
Layout.fillWidth: true
119127
Accessible.role: Accessible.StaticText
120128
Accessible.name: text
129+
Accessible.focusable: true
130+
focusPolicy: Qt.TabFocus
131+
activeFocusOnTab: true
121132
}
122133

123134
RowLayout {
@@ -149,13 +160,17 @@ ApplicationWindow {
149160

150161
// Register focus groups when component is ready
151162
Component.onCompleted: {
163+
registerFocusGroup("content", function(){
164+
return [storageRemovedTitle, storageRemovedMessage]
165+
}, 0)
152166
registerFocusGroup("buttons", function(){
153167
return [storageOkButton]
154-
}, 0)
168+
}, 1)
155169
}
156170

157171
// Dialog content
158172
Text {
173+
id: storageRemovedTitle
159174
text: qsTr("Storage device removed")
160175
font.pixelSize: Style.fontSizeHeading
161176
font.family: Style.fontFamilyBold
@@ -164,9 +179,13 @@ ApplicationWindow {
164179
Layout.fillWidth: true
165180
Accessible.role: Accessible.Heading
166181
Accessible.name: text
182+
Accessible.focusable: true
183+
focusPolicy: Qt.TabFocus
184+
activeFocusOnTab: true
167185
}
168186

169187
Text {
188+
id: storageRemovedMessage
170189
text: qsTr("The storage device was removed while writing, so the operation was cancelled. Please reinsert the device or select a different one to continue.")
171190
wrapMode: Text.WordWrap
172191
font.pixelSize: Style.fontSizeDescription
@@ -175,6 +194,9 @@ ApplicationWindow {
175194
Layout.fillWidth: true
176195
Accessible.role: Accessible.StaticText
177196
Accessible.name: text
197+
Accessible.focusable: true
198+
focusPolicy: Qt.TabFocus
199+
activeFocusOnTab: true
178200
}
179201

180202
RowLayout {
@@ -206,13 +228,17 @@ ApplicationWindow {
206228

207229
// Register focus groups when component is ready
208230
Component.onCompleted: {
231+
registerFocusGroup("content", function(){
232+
return [quitTitle, quitMessage]
233+
}, 0)
209234
registerFocusGroup("buttons", function(){
210235
return [quitNoButton, quitYesButton]
211-
}, 0)
236+
}, 1)
212237
}
213238

214239
// Dialog content
215240
Text {
241+
id: quitTitle
216242
text: qsTr("Are you sure you want to quit?")
217243
font.pixelSize: Style.fontSizeHeading
218244
font.family: Style.fontFamilyBold
@@ -221,9 +247,13 @@ ApplicationWindow {
221247
Layout.fillWidth: true
222248
Accessible.role: Accessible.Heading
223249
Accessible.name: text
250+
Accessible.focusable: true
251+
focusPolicy: Qt.TabFocus
252+
activeFocusOnTab: true
224253
}
225254

226255
Text {
256+
id: quitMessage
227257
text: qsTr("Raspberry Pi Imager is still busy. Are you sure you want to quit?")
228258
font.pixelSize: Style.fontSizeDescription
229259
font.family: Style.fontFamily
@@ -232,6 +262,9 @@ ApplicationWindow {
232262
Layout.fillWidth: true
233263
Accessible.role: Accessible.StaticText
234264
Accessible.name: text
265+
Accessible.focusable: true
266+
focusPolicy: Qt.TabFocus
267+
activeFocusOnTab: true
235268
}
236269

237270
RowLayout {

src/wizard/WizardContainer.qml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,9 +1000,12 @@ Item {
10001000

10011001
Component.onCompleted: {
10021002
// match your focus group style
1003+
registerFocusGroup("token_conflict_content", function() {
1004+
return [titleText, bodyText]
1005+
}, 0)
10031006
registerFocusGroup("token_conflict_buttons", function() {
10041007
return [keepBtn, replaceBtn]
1005-
}, 0)
1008+
}, 1)
10061009
}
10071010

10081011
onClosed: {
@@ -1024,6 +1027,9 @@ Item {
10241027
Accessible.role: Accessible.Heading
10251028
Accessible.name: text
10261029
Accessible.ignored: false
1030+
Accessible.focusable: true
1031+
focusPolicy: Qt.TabFocus
1032+
activeFocusOnTab: true
10271033
}
10281034

10291035
// Body / security note
@@ -1041,6 +1047,9 @@ Item {
10411047
Accessible.role: Accessible.StaticText
10421048
Accessible.name: text
10431049
Accessible.ignored: false
1050+
Accessible.focusable: true
1051+
focusPolicy: Qt.TabFocus
1052+
activeFocusOnTab: true
10441053
}
10451054

10461055
// Buttons row

0 commit comments

Comments
 (0)