Skip to content

Commit

Permalink
FIX(a11y): Add semantic description to sliders in Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Jan 2, 2024
1 parent 2d69a14 commit 5413949
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/mumble/Accessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <queue>

#include <QDebug>

namespace Mumble {
namespace Accessibility {

Expand Down Expand Up @@ -150,6 +152,9 @@ namespace Accessibility {
// We set the value for the slider, any potential focus proxy,
// and the QAccessibleInterface. Orca will still read the
// raw slider value.

qDebug() << value;

QVariant newValue = QVariant(value);
slider->setFocus();

Expand Down
37 changes: 34 additions & 3 deletions src/mumble/AudioConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "AudioConfigDialog.h"

#include "Accessibility.h"
#include "AudioInput.h"
#include "AudioOutput.h"
#include "AudioOutputSample.h"
Expand Down Expand Up @@ -287,8 +288,11 @@ void AudioInputDialog::save() const {
}

void AudioInputDialog::on_qsFrames_valueChanged(int v) {
qlFrames->setText(tr("%1 ms").arg((v == 1) ? 10 : (v - 1) * 20));
int val = (v == 1) ? 10 : (v - 1) * 20;
qlFrames->setText(tr("%1 ms").arg(val));
updateBitrate();

Mumble::Accessibility::setSliderSemanticValue(qsFrames, QString("%1 %2").arg(val).arg(tr("milliseconds")));
}

void AudioInputDialog::on_qsDoublePush_valueChanged(int v) {
Expand All @@ -299,21 +303,29 @@ void AudioInputDialog::on_qsDoublePush_valueChanged(int v) {
}

void AudioInputDialog::on_qsPTTHold_valueChanged(int v) {
if (v == 0)
if (v == 0) {
qlPTTHold->setText(tr("Off"));
else
Mumble::Accessibility::setSliderSemanticValue(qsPTTHold, tr("Off"));
} else {
qlPTTHold->setText(tr("%1 ms").arg(v));
Mumble::Accessibility::setSliderSemanticValue(qsPTTHold, QString("%1 %2").arg(v).arg(tr("milliseconds")));
}
}

void AudioInputDialog::on_qsTransmitHold_valueChanged(int v) {
float val = static_cast< float >(v * 10);
val = val / 1000.0f;
qlTransmitHold->setText(tr("%1 s").arg(val, 0, 'f', 2));
Mumble::Accessibility::setSliderSemanticValue(qsTransmitHold,
QString("%1 %2").arg(val, 0, 'f', 2).arg(tr("seconds")));
}

void AudioInputDialog::on_qsQuality_valueChanged(int v) {
qlQuality->setText(tr("%1 kb/s").arg(static_cast< float >(v) / 1000.0f, 0, 'f', 1));
updateBitrate();

Mumble::Accessibility::setSliderSemanticValue(
qsQuality, QString("%1 %2").arg(static_cast< float >(v) / 1000.0f, 0, 'f', 1).arg(tr("kilobit per second")));
}

void AudioInputDialog::on_qsSpeexNoiseSupStrength_valueChanged(int v) {
Expand All @@ -322,8 +334,11 @@ void AudioInputDialog::on_qsSpeexNoiseSupStrength_valueChanged(int v) {
if (v < 15) {
qlSpeexNoiseSupStrength->setText(tr("Off"));
pal.setColor(qlSpeexNoiseSupStrength->foregroundRole(), Qt::red);
Mumble::Accessibility::setSliderSemanticValue(qsSpeexNoiseSupStrength, tr("Off"));
} else {
qlSpeexNoiseSupStrength->setText(tr("-%1 dB").arg(v));
Mumble::Accessibility::setSliderSemanticValue(qsSpeexNoiseSupStrength,
QString("-%1 %2").arg(v).arg(tr("decibel")));
}
qlSpeexNoiseSupStrength->setPalette(pal);
}
Expand All @@ -332,6 +347,8 @@ void AudioInputDialog::on_qsAmp_valueChanged(int v) {
v = 18000 - v + 2000;
float d = 20000.0f / static_cast< float >(v);
qlAmp->setText(QString::fromLatin1("%1").arg(d, 0, 'f', 2));

Mumble::Accessibility::setSliderSemanticValue(qsAmp, QString("%1").arg(d, 0, 'f', 2));
}

void AudioInputDialog::updateBitrate() {
Expand Down Expand Up @@ -813,6 +830,7 @@ void AudioOutputDialog::on_qcbSystem_currentIndexChanged(int) {

void AudioOutputDialog::on_qsJitter_valueChanged(int v) {
qlJitter->setText(tr("%1 ms").arg(v * 10));
Mumble::Accessibility::setSliderSemanticValue(qsJitter, QString("%1 %2").arg(v * 10).arg(tr("milliseconds")));
}

void AudioOutputDialog::on_qsVolume_valueChanged(int v) {
Expand All @@ -824,22 +842,30 @@ void AudioOutputDialog::on_qsVolume_valueChanged(int v) {
qlVolume->setPalette(pal);

qlVolume->setText(tr("%1 %").arg(v));
Mumble::Accessibility::setSliderSemanticValue(qsVolume, Mumble::Accessibility::SliderAccesibilityMode::PERCENT,
"%");
}

void AudioOutputDialog::on_qsOtherVolume_valueChanged(int v) {
qlOtherVolume->setText(tr("%1 %").arg(v));
Mumble::Accessibility::setSliderSemanticValue(qsOtherVolume, Mumble::Accessibility::SliderAccesibilityMode::PERCENT,
"%");
}

void AudioOutputDialog::on_qsPacketDelay_valueChanged(int v) {
qlPacketDelay->setText(tr("%1 ms").arg(v));
Mumble::Accessibility::setSliderSemanticValue(qsPacketDelay, QString("%1 %2").arg(v).arg(tr("milliseconds")));
}

void AudioOutputDialog::on_qsPacketLoss_valueChanged(int v) {
qlPacketLoss->setText(tr("%1 %").arg(v));
Mumble::Accessibility::setSliderSemanticValue(qsPacketLoss, Mumble::Accessibility::SliderAccesibilityMode::PERCENT,
"%");
}

void AudioOutputDialog::on_qsDelay_valueChanged(int v) {
qlDelay->setText(tr("%1 ms").arg(v * 10));
Mumble::Accessibility::setSliderSemanticValue(qsDelay, QString("%1 %2").arg(v * 10).arg(tr("milliseconds")));
}

void AudioOutputDialog::on_qcbLoopback_currentIndexChanged(int v) {
Expand All @@ -864,6 +890,7 @@ void AudioOutputDialog::on_qsMinDistance_valueChanged(int value) {
void AudioOutputDialog::on_qsbMinimumDistance_valueChanged(double value) {
QSignalBlocker blocker(qsMinDistance);
qsMinDistance->setValue(value * 10);
Mumble::Accessibility::setSliderSemanticValue(qsMinDistance, QString("%1 %2").arg(value * 10).arg(tr("meters")));

// Ensure that max distance is always a least 1m larger than min distance
qsMaxDistance->setValue(std::max(qsMaxDistance->value(), static_cast< int >(value * 10) + 10));
Expand All @@ -879,6 +906,7 @@ void AudioOutputDialog::on_qsMaxDistance_valueChanged(int value) {
void AudioOutputDialog::on_qsbMaximumDistance_valueChanged(double value) {
QSignalBlocker blocker(qsMaxDistance);
qsMaxDistance->setValue(value * 10);
Mumble::Accessibility::setSliderSemanticValue(qsMaxDistance, QString("%1 %2").arg(value * 10).arg(tr("meters")));

// Ensure that min distance is always a least 1m less than max distance
qsMinDistance->setValue(std::min(qsMinDistance->value(), static_cast< int >(value * 10) - 10));
Expand All @@ -887,6 +915,8 @@ void AudioOutputDialog::on_qsbMaximumDistance_valueChanged(double value) {
void AudioOutputDialog::on_qsMinimumVolume_valueChanged(int value) {
QSignalBlocker blocker(qsbMinimumVolume);
qsbMinimumVolume->setValue(value);
Mumble::Accessibility::setSliderSemanticValue(qsMinimumVolume,
Mumble::Accessibility::SliderAccesibilityMode::PERCENT, "%");
}

void AudioOutputDialog::on_qsbMinimumVolume_valueChanged(int value) {
Expand All @@ -897,6 +927,7 @@ void AudioOutputDialog::on_qsbMinimumVolume_valueChanged(int value) {
void AudioOutputDialog::on_qsBloom_valueChanged(int value) {
QSignalBlocker blocker(qsbBloom);
qsbBloom->setValue(value);
Mumble::Accessibility::setSliderSemanticValue(qsBloom, Mumble::Accessibility::SliderAccesibilityMode::PERCENT, "%");
}

void AudioOutputDialog::on_qsbBloom_valueChanged(int value) {
Expand Down
7 changes: 6 additions & 1 deletion src/mumble/AudioInput.ui
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="qsTransmitHold">
<widget class="SemanticSlider" name="qsTransmitHold">
<property name="toolTip">
<string>How long to keep transmitting after silence</string>
</property>
Expand Down Expand Up @@ -1072,6 +1072,11 @@
<extends>QComboBox</extends>
<header>widgets/MUComboBox.h</header>
</customwidget>
<customwidget>
<class>SemanticSlider</class>
<extends>QSlider</extends>
<header>widgets/SemanticSlider.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>qcbSystem</tabstop>
Expand Down
2 changes: 2 additions & 0 deletions src/mumble/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ set(MUMBLE_SOURCES
"widgets/SearchDialogItemDelegate.h"
"widgets/SearchDialogTree.cpp"
"widgets/SearchDialogTree.h"
"widgets/SemanticSlider.cpp"
"widgets/SemanticSlider.h"


"${SHARED_SOURCE_DIR}/ACL.cpp"
Expand Down
5 changes: 5 additions & 0 deletions src/mumble/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "Log.h"

#include "Accessibility.h"
#include "AudioOutput.h"
#include "AudioOutputSample.h"
#include "AudioOutputToken.h"
Expand Down Expand Up @@ -370,14 +371,18 @@ void LogConfig::browseForAudioFile() {

void LogConfig::on_qsNotificationVolume_valueChanged(int value) {
qsbNotificationVolume->setValue(value);
Mumble::Accessibility::setSliderSemanticValue(qsNotificationVolume, QString("%1 %2").arg(value).arg(tr("decibel")));
}

void LogConfig::on_qsCueVolume_valueChanged(int value) {
qsbCueVolume->setValue(value);
Mumble::Accessibility::setSliderSemanticValue(qsCueVolume, QString("%1 %2").arg(value).arg(tr("decibel")));
}

void LogConfig::on_qsTTSVolume_valueChanged(int value) {
qsbTTSVolume->setValue(value);
Mumble::Accessibility::setSliderSemanticValue(qsTTSVolume, Mumble::Accessibility::SliderAccesibilityMode::PERCENT,
"%");
}

void LogConfig::on_qsbNotificationVolume_valueChanged(int value) {
Expand Down
21 changes: 21 additions & 0 deletions src/mumble/widgets/SemanticSlider.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2023-2024 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#include "SemanticSlider.h"

SemanticSlider::SemanticSlider(QWidget *parent = nullptr) : QSlider(parent), m_semanticValue("") {
}

QString SemanticSlider::text(Text t, int child) const {
if (!slider()->isVisible()) {
return QSlider::text(t, child);
}

if (t == Value && !m_semanticValue.isEmpty()) {
return m_semanticValue;
}

return QSlider::text(t, child);
}
23 changes: 23 additions & 0 deletions src/mumble/widgets/SemanticSlider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2023-2024 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#ifndef MUMBLE_MUMBLE_WIDGETS_SEMANTICSLIDER_H_
#define MUMBLE_MUMBLE_WIDGETS_SEMANTICSLIDER_H_

#include <QString>
#include <QWidget>
#include <QtWidgets/QSlider>

class SemanticSlider : public QSlider {
Q_OBJECT

public:
SemanticSlider(QWidget *parent = nullptr);
QString text(Text t, int child) const;

QString m_semanticValue;
};

#endif

0 comments on commit 5413949

Please sign in to comment.