mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
A11Y: Improve the accessibility of the Preferences dialog (#3255)
* Configure buddy widgets for labels in the Preferences dialog Labels are often used to describe the purpose of a different widget like a combobox, edit field or a spinbox by providing a textual name for their functionality. The relation between a label and a widget is typically expressed by placing the label next to the relevant object. In addition to this visual linking intended for human users, frameworks usually also offer semantic way to link labels with other widgets, so the relation can be noticed by programs like screenreaders, which can figure out the correct textual description for the focused widgets based on this information. By default, labels on their own are not focusable elements, so users dependend on keyboard navigation and speech get to notice only the widget types (textbox, spinbox, etc.) while moving around without any contextual information if labels are not linked. When the linking is done, the component names get included as well. QT provides the "buddy" property for QLabel, which creates a semantic link between the label and its buddy widget. This commit configures the buddy properties on labels of the Anki Preferences dialog. * Configure spinbox suffixes in Preferrences dialog QSpinBox provides a suffix property. This property makes it possible to display a measurement unit next to the component value, which is linked to it both visually and semantically for the GUI framework without affecting the spinbox value itself. For purposes of accessibility, it's better to use this property than simply place a label next to the component, since it can be directly accessed by screenreaders and other assistive technology. This commit configures suffix properties for spinboxes in the Anki Preferences dialog. Note: Removal of the original unit labels may have altered the UI a little bit. * Assign buddy widgets in the ID and password retrieval dialog Set buddy widgets of the labels in the Get ID and password for synchronization dialog. * Fix positioning/size of text boxes * Style the suffixes of Preferences' QSpinBoxes Style QSpinBox suffixes (for those that have one) in the Preferences dialog by prepending them by a space character.
This commit is contained in:
parent
d108bff862
commit
e985fec9c4
4 changed files with 70 additions and 41 deletions
|
@ -177,6 +177,7 @@ RRomeroJr <117.rromero@gmail.com>
|
|||
Xidorn Quan <me@upsuper.org>
|
||||
Alexander Bocken <alexander@bocken.org>
|
||||
James Elmore <email@jameselmore.org>
|
||||
Rastislav Kish <rastislav.kish@protonmail.com>
|
||||
|
||||
********************
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_language</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lang</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
|
@ -64,6 +67,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_video_driver</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>video_driver</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
|
@ -116,6 +122,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_style</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>styleComboBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
|
@ -123,6 +132,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_theme</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>theme</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
|
@ -130,6 +142,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_user_interface_size</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>uiScale</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
|
@ -264,33 +279,25 @@
|
|||
<widget class="QSpinBox" name="lrnCutoff">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>preferences_mins</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_29">
|
||||
<property name="text">
|
||||
<string>preferences_mins</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_30">
|
||||
<property name="text">
|
||||
<string>preferences_timebox_time_limit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_40">
|
||||
<property name="text">
|
||||
<string>preferences_hours_past_midnight</string>
|
||||
<property name="buddy">
|
||||
<cstring>timeLimit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -298,10 +305,13 @@
|
|||
<widget class="QSpinBox" name="dayOffset">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>preferences_hours_past_midnight</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>23</number>
|
||||
</property>
|
||||
|
@ -312,6 +322,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_learn_ahead_limit</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lrnCutoff</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
|
@ -319,17 +332,16 @@
|
|||
<property name="text">
|
||||
<string>preferences_next_day_starts_at</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_39">
|
||||
<property name="text">
|
||||
<string>preferences_mins</string>
|
||||
<property name="buddy">
|
||||
<cstring>dayOffset</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="timeLimit">
|
||||
<property name="suffix">
|
||||
<string>preferences_mins</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>9999</number>
|
||||
</property>
|
||||
|
@ -513,6 +525,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_default_deck</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>useCurrent</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -553,6 +568,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_default_search_text</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>default_search_text</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -705,10 +723,16 @@
|
|||
<property name="text">
|
||||
<string>preferences_network_timeout</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>network_timeout</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="network_timeout">
|
||||
<property name="suffix">
|
||||
<string>scheduling_seconds</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>30</number>
|
||||
</property>
|
||||
|
@ -717,26 +741,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>scheduling_seconds</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -853,6 +857,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_custom_sync_url</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>custom_sync_url</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -954,6 +961,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_daily_backups</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>daily_backups</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
|
@ -968,6 +978,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_monthly_backups</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>monthly_backups</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
|
@ -975,6 +988,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_weekly_backups</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>weekly_backups</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
@ -982,6 +998,9 @@
|
|||
<property name="text">
|
||||
<string>preferences_minutes_between_backups</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>minutes_between_backups</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
|
|
|
@ -36,6 +36,13 @@ class Preferences(QDialog):
|
|||
self.prof = self.mw.pm.profile
|
||||
self.form = aqt.forms.preferences.Ui_Preferences()
|
||||
self.form.setupUi(self)
|
||||
for spinbox in (
|
||||
self.form.lrnCutoff,
|
||||
self.form.dayOffset,
|
||||
self.form.timeLimit,
|
||||
self.form.network_timeout,
|
||||
):
|
||||
spinbox.setSuffix(f" {spinbox.suffix()}")
|
||||
disable_help_button(self)
|
||||
self.form.buttonBox.button(QDialogButtonBox.StandardButton.Help).setAutoDefault(
|
||||
False
|
||||
|
|
|
@ -355,12 +355,14 @@ def get_id_and_pass_from_user(
|
|||
user = QLineEdit()
|
||||
user.setText(username)
|
||||
g.addWidget(user, 0, 1)
|
||||
l1.setBuddy(user)
|
||||
l2 = QLabel(tr.sync_password_label())
|
||||
g.addWidget(l2, 1, 0)
|
||||
passwd = QLineEdit()
|
||||
passwd.setText(password)
|
||||
passwd.setEchoMode(QLineEdit.EchoMode.Password)
|
||||
g.addWidget(passwd, 1, 1)
|
||||
l2.setBuddy(passwd)
|
||||
vbox.addLayout(g)
|
||||
bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) # type: ignore
|
||||
bb.button(QDialogButtonBox.StandardButton.Ok).setAutoDefault(True)
|
||||
|
|
Loading…
Reference in a new issue