2024-12-11 17:43:35 +01:00
|
|
|
#include "VolumeAccessibleInterface.hpp"
|
2024-01-17 08:24:40 +01:00
|
|
|
|
2024-12-11 17:43:35 +01:00
|
|
|
#include <components/VolumeSlider.hpp>
|
2024-04-20 19:58:20 -04:00
|
|
|
|
2024-04-28 12:57:41 -04:00
|
|
|
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;
|
|
|
|
|
}
|