0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
obs-studio/UI/slider-ignorewheel.cpp
VodBox 89b4e9136f UI: Various screen reader fixes
This commit fixes various issues with screen readers in the main OBS
interface. These were tested using NVDA on Windows 10 2004.

Audio track selection in Settings now says Track 1, 2, etc, rather than
just the number.

Various checkboxes that just say "Enable" now have accessible text that
says what the enable is for (since it says "checkbox", the fact it's an
enable should hopefully be clear).

Type in the recording tab of output now has accessible text which says
"Recording Type".

Items in the Advanced Audio Properties window now have accessible text
for what they are for. Currently some do not report correct values, but
that will require an accessible interface in Qt to be written
specifically for that, which will be done at a later date.

Buttons in the filters window now have accessible text for what they do.

All the right side buttons in hotkeys now have tooltips, and by
extension, accessible text.
2020-11-25 19:38:05 -08:00

98 lines
1.9 KiB
C++

#include "slider-ignorewheel.hpp"
#include "volume-control.hpp"
SliderIgnoreScroll::SliderIgnoreScroll(QWidget *parent) : QSlider(parent)
{
setFocusPolicy(Qt::StrongFocus);
}
SliderIgnoreScroll::SliderIgnoreScroll(Qt::Orientation orientation,
QWidget *parent)
: QSlider(parent)
{
setFocusPolicy(Qt::StrongFocus);
setOrientation(orientation);
}
void SliderIgnoreScroll::wheelEvent(QWheelEvent *event)
{
if (!hasFocus())
event->ignore();
else
QSlider::wheelEvent(event);
}
VolumeSlider::VolumeSlider(obs_fader_t *fader, QWidget *parent)
: SliderIgnoreScroll(parent)
{
fad = fader;
}
VolumeSlider::VolumeSlider(obs_fader_t *fader, Qt::Orientation orientation,
QWidget *parent)
: SliderIgnoreScroll(orientation, parent)
{
fad = fader;
}
VolumeAccessibleInterface::VolumeAccessibleInterface(QWidget *w)
: QAccessibleWidget(w)
{
}
VolumeSlider *VolumeAccessibleInterface::slider() const
{
return qobject_cast<VolumeSlider *>(object());
}
QString VolumeAccessibleInterface::text(QAccessible::Text t) const
{
if (slider()->isVisible()) {
switch (t) {
case QAccessible::Text::Value:
return currentValue().toString();
default:
break;
}
}
return QAccessibleWidget::text(t);
}
QVariant VolumeAccessibleInterface::currentValue() const
{
QString text;
float db = obs_fader_get_db(slider()->fad);
if (db < -96.0f)
text = "-inf dB";
else
text = QString::number(db, 'f', 1).append(" dB");
return text;
}
void VolumeAccessibleInterface::setCurrentValue(const QVariant &value)
{
slider()->setValue(value.toInt());
}
QVariant VolumeAccessibleInterface::maximumValue() const
{
return slider()->maximum();
}
QVariant VolumeAccessibleInterface::minimumValue() const
{
return slider()->minimum();
}
QVariant VolumeAccessibleInterface::minimumStepSize() const
{
return slider()->singleStep();
}
QAccessible::Role VolumeAccessibleInterface::role() const
{
return QAccessible::Role::Slider;
}