From 87ff6cdde66e6a0a2798e38390e191ed9eb75b6a Mon Sep 17 00:00:00 2001 From: Hartmnt Date: Thu, 4 Jan 2024 12:44:12 +0000 Subject: [PATCH] Experimental volume slider fix --- src/mumble/VolumeSliderWidgetAction.cpp | 10 ++++++---- src/mumble/VolumeSliderWidgetAction.h | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/mumble/VolumeSliderWidgetAction.cpp b/src/mumble/VolumeSliderWidgetAction.cpp index 7553ae68b9f..2a7fddd4f9d 100644 --- a/src/mumble/VolumeSliderWidgetAction.cpp +++ b/src/mumble/VolumeSliderWidgetAction.cpp @@ -7,12 +7,12 @@ #include "InlineWidgets.h" #include "VolumeAdjustment.h" #include "widgets/EventFilters.h" +#include "widgets/SemanticSlider.h" -#include #include 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")); @@ -33,9 +33,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); @@ -54,6 +54,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) { diff --git a/src/mumble/VolumeSliderWidgetAction.h b/src/mumble/VolumeSliderWidgetAction.h index 25bb408670f..7c453e0a642 100644 --- a/src/mumble/VolumeSliderWidgetAction.h +++ b/src/mumble/VolumeSliderWidgetAction.h @@ -10,7 +10,7 @@ #include "QtUtils.h" -class QSlider; +class SemanticSlider; class VolumeSliderWidgetAction : public QWidgetAction { Q_OBJECT @@ -19,7 +19,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);