Skip to content

Commit

Permalink
Experimental volume slider fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Jan 4, 2024
1 parent 8dc98c9 commit 8518070
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/mumble/VolumeSliderWidgetAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
#include "VolumeAdjustment.h"
#include "widgets/EventFilters.h"

#include <QSlider>
#include <QToolTip>

VolumeSliderWidgetAction::VolumeSliderWidgetAction(QWidget *parent)
: QWidgetAction(parent), m_volumeSlider(make_qt_unique< QSlider >(Qt::Horizontal, parent)) {
: QWidgetAction(parent), m_volumeSlider(make_qt_unique< SemanticSlider >(parent)) {
m_volumeSlider->setMinimum(-30);
m_volumeSlider->setMaximum(30);
m_volumeSlider->setAccessibleName(tr("Slider for volume adjustment"));
Expand All @@ -33,9 +32,9 @@ VolumeSliderWidgetAction::VolumeSliderWidgetAction(QWidget *parent)
new MouseWheelEventObserver(this, { Qt::ScrollMomentum, Qt::ScrollUpdate, Qt::ScrollEnd }, false);
m_volumeSlider->installEventFilter(wheelEventFilter);

connect(m_volumeSlider.get(), &QSlider::valueChanged, this,
connect(m_volumeSlider.get(), &SemanticSlider::valueChanged, this,
&VolumeSliderWidgetAction::on_VolumeSlider_valueChanged);
connect(m_volumeSlider.get(), &QSlider::sliderReleased, this,
connect(m_volumeSlider.get(), &SemanticSlider::sliderReleased, this,
&VolumeSliderWidgetAction::on_VolumeSlider_changeCompleted);
connect(keyEventFilter, &KeyEventObserver::keyEventObserved, this,
&VolumeSliderWidgetAction::on_VolumeSlider_changeCompleted);
Expand All @@ -54,6 +53,8 @@ void VolumeSliderWidgetAction::updateSliderValue(float value) {
int dbShift = VolumeAdjustment::toIntegerDBAdjustment(value);
m_volumeSlider->setValue(dbShift);
updateTooltip(dbShift);

Mumble::Accessibility::setSliderSemanticValue(m_volumeSlider, QString("%1 %2").arg(dbShift).arg(tr("decibels")));
}

void VolumeSliderWidgetAction::updateTooltip(int value) {
Expand Down
5 changes: 3 additions & 2 deletions src/mumble/VolumeSliderWidgetAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#include <QWidgetAction>

#include "QtUtils.h"
#include "widgets/SemanticSlider.h"

class QSlider;
class SemanticSlider;

class VolumeSliderWidgetAction : public QWidgetAction {
Q_OBJECT
Expand All @@ -19,7 +20,7 @@ class VolumeSliderWidgetAction : public QWidgetAction {
VolumeSliderWidgetAction(QWidget *parent = nullptr);

protected:
qt_unique_ptr< QSlider > m_volumeSlider;
qt_unique_ptr< SemanticSlider > m_volumeSlider;

void updateSliderValue(float value);
void displayTooltip(int value);
Expand Down

0 comments on commit 8518070

Please sign in to comment.