2019-04-06 17:56:52 -07:00
|
|
|
#include "slider-ignorewheel.hpp"
|
2020-11-25 01:45:28 -08:00
|
|
|
#include "volume-control.hpp"
|
2019-04-06 17:56:52 -07:00
|
|
|
|
|
|
|
SliderIgnoreScroll::SliderIgnoreScroll(QWidget *parent) : QSlider(parent)
|
|
|
|
{
|
|
|
|
setFocusPolicy(Qt::StrongFocus);
|
|
|
|
}
|
|
|
|
|
2019-04-18 19:02:35 -07:00
|
|
|
SliderIgnoreScroll::SliderIgnoreScroll(Qt::Orientation orientation,
|
2019-06-22 22:13:45 -07:00
|
|
|
QWidget *parent)
|
2019-04-18 19:02:35 -07:00
|
|
|
: QSlider(parent)
|
|
|
|
{
|
|
|
|
setFocusPolicy(Qt::StrongFocus);
|
|
|
|
setOrientation(orientation);
|
|
|
|
}
|
|
|
|
|
2019-04-21 04:05:51 -07:00
|
|
|
void SliderIgnoreScroll::wheelEvent(QWheelEvent *event)
|
2019-04-06 17:56:52 -07:00
|
|
|
{
|
|
|
|
if (!hasFocus())
|
|
|
|
event->ignore();
|
|
|
|
else
|
|
|
|
QSlider::wheelEvent(event);
|
|
|
|
}
|
2020-11-25 01:45:28 -08:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|