diff --git a/src/mumble/ListenerVolumeSlider.cpp b/src/mumble/ListenerVolumeSlider.cpp index 6db5a8fdd3e..031b35f1731 100644 --- a/src/mumble/ListenerVolumeSlider.cpp +++ b/src/mumble/ListenerVolumeSlider.cpp @@ -62,6 +62,8 @@ void ListenerVolumeSlider::on_VolumeSlider_changeCompleted() { Global::get().channelListenerManager->setListenerVolumeAdjustment(Global::get().uiSession, m_channel->iId, adjustment); } + + emit dbAdjustmentChanged(adjustment.dbAdjustment); } void ListenerVolumeSlider::sendToServer() { diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 6d5fa95fca7..9494b7d55a5 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -199,6 +199,20 @@ MainWindow::MainWindow(QWidget *p) QObject::connect(this, &MainWindow::serverSynchronized, Global::get().pluginManager, &PluginManager::on_serverSynchronized); + // Sadly, QWidgetActions have a poor accessibility as of Qt 5.15.10 + // The slider value will not be read under any circumstances, so we use the label + // above it to communicate that to the user. + // This is not pretty, but it seems to be the only option, if we want to keep + // the inline slider... + connect(m_userLocalVolumeSlider.get(), &VolumeSliderWidgetAction::dbAdjustmentChanged, this, + &MainWindow::on_volumeSlider_dbAdjustmentChanged); + connect(m_listenerVolumeSlider.get(), &VolumeSliderWidgetAction::dbAdjustmentChanged, this, + &MainWindow::on_volumeSlider_dbAdjustmentChanged); + on_volumeSlider_dbAdjustmentChanged(0); + m_localVolumeLabel->setAccessibleDescription( + tr("The next element in this menu is a slider to adjust the volume of the selected client. " + "Focus this label to get the updated adjustment value.")); + QAccessible::installFactory(AccessibleSlider::semanticSliderFactory); } @@ -3858,6 +3872,16 @@ void MainWindow::on_qteLog_highlighted(const QUrl &url) { } } +void MainWindow::on_volumeSlider_dbAdjustmentChanged(int value) { + QString newName = QString("%1 %2%3 %4"); + newName = newName.arg(tr("Local Volume Adjustment")).arg(value > 0 ? QString("+") : QString("")).arg(value).arg(tr("decibels")); + m_localVolumeLabel->setAccessibleName(newName); + + QString newText = QString("%1: (%2%3 dB)"); + newText = newText.arg(tr("Local Volume Adjustment")).arg(value > 0 ? QString("+") : QString("")).arg(value); + m_localVolumeLabel->setText(newText); +} + void MainWindow::context_triggered() { QAction *a = qobject_cast< QAction * >(sender()); diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index 18f160d48e3..7401cac6e8d 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -299,6 +299,7 @@ public slots: void on_qteLog_customContextMenuRequested(const QPoint &pos); void on_qteLog_anchorClicked(const QUrl &); void on_qteLog_highlighted(const QUrl &link); + void on_volumeSlider_dbAdjustmentChanged(int value); void on_PushToTalk_triggered(bool, QVariant); void on_PushToMute_triggered(bool, QVariant); void on_VolumeUp_triggered(bool, QVariant); diff --git a/src/mumble/MenuLabel.cpp b/src/mumble/MenuLabel.cpp index 1655a5f5156..7dd4d7cbb14 100644 --- a/src/mumble/MenuLabel.cpp +++ b/src/mumble/MenuLabel.cpp @@ -6,8 +6,10 @@ #include "MenuLabel.h" #include +#include -MenuLabel::MenuLabel(const QString &text, QObject *parent) : QWidgetAction(parent), m_text(text) { +MenuLabel::MenuLabel(const QString &text, QObject *parent) + : QWidgetAction(parent), m_text(text), m_accessibleName(""), m_accessibleDescription("") { setMenuRole(QAction::NoRole); } @@ -15,5 +17,39 @@ QWidget *MenuLabel::createWidget(QWidget *parent) { QLabel *label = new QLabel(m_text, parent); label->setFocusPolicy(Qt::TabFocus); + label->setAccessibleName(m_accessibleName); + label->setAccessibleDescription(m_accessibleDescription); + return label; } + +void MenuLabel::setText(const QString &text) { + m_text = text; + + QLabel *label = qobject_cast< QLabel * >(defaultWidget()); + if (label) { + label->setText(text); + label->update(); + } +} + +void MenuLabel::setAccessibleName(const QString &name) { + m_accessibleName = name; + + QLabel *label = qobject_cast< QLabel * >(defaultWidget()); + if (label) { + label->setAccessibleName(m_accessibleName); + label->update(); + qDebug() << "Set to " << m_accessibleName; + } +} + +void MenuLabel::setAccessibleDescription(const QString &description) { + m_accessibleDescription = description; + + QLabel *label = qobject_cast< QLabel * >(defaultWidget()); + if (label) { + label->setAccessibleDescription(m_accessibleDescription); + label->update(); + } +} diff --git a/src/mumble/MenuLabel.h b/src/mumble/MenuLabel.h index 22aa6225659..19b2dfc8adc 100644 --- a/src/mumble/MenuLabel.h +++ b/src/mumble/MenuLabel.h @@ -17,11 +17,17 @@ class MenuLabel : public QWidgetAction { public: MenuLabel(const QString &text, QObject *parent = nullptr); + void setText(const QString &name); + void setAccessibleName(const QString &name); + void setAccessibleDescription(const QString &description); + protected: QWidget *createWidget(QWidget *parent) override; private: - const QString m_text; + QString m_text; + QString m_accessibleName; + QString m_accessibleDescription; }; #endif diff --git a/src/mumble/UserLocalVolumeSlider.cpp b/src/mumble/UserLocalVolumeSlider.cpp index ea3f23fa4a3..fa28a27733e 100644 --- a/src/mumble/UserLocalVolumeSlider.cpp +++ b/src/mumble/UserLocalVolumeSlider.cpp @@ -43,5 +43,7 @@ void UserLocalVolumeSlider::on_VolumeSlider_changeCompleted() { } else { Global::get().mw->logChangeNotPermanent(QObject::tr("Local Volume Adjustment..."), user); } + + emit dbAdjustmentChanged(VolumeAdjustment::toDBAdjustment(user->getLocalVolumeAdjustments())); } } diff --git a/src/mumble/VolumeSliderWidgetAction.cpp b/src/mumble/VolumeSliderWidgetAction.cpp index 7553ae68b9f..004dc7d4480 100644 --- a/src/mumble/VolumeSliderWidgetAction.cpp +++ b/src/mumble/VolumeSliderWidgetAction.cpp @@ -19,7 +19,7 @@ VolumeSliderWidgetAction::VolumeSliderWidgetAction(QWidget *parent) m_volumeSlider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); KeyEventObserver *keyEventFilter = new KeyEventObserver(this, QEvent::KeyRelease, false, - { Qt::Key_Left, Qt::Key_Right, Qt::Key_Up, Qt::Key_Down }); + { Qt::Key_Left, Qt::Key_Right }); m_volumeSlider->installEventFilter(keyEventFilter); // The list of wheel events observed seems odd at first. We have to check for multiple @@ -54,6 +54,8 @@ void VolumeSliderWidgetAction::updateSliderValue(float value) { int dbShift = VolumeAdjustment::toIntegerDBAdjustment(value); m_volumeSlider->setValue(dbShift); updateTooltip(dbShift); + + emit dbAdjustmentChanged(dbShift); } void VolumeSliderWidgetAction::updateTooltip(int value) { diff --git a/src/mumble/VolumeSliderWidgetAction.h b/src/mumble/VolumeSliderWidgetAction.h index 25bb408670f..e776241887c 100644 --- a/src/mumble/VolumeSliderWidgetAction.h +++ b/src/mumble/VolumeSliderWidgetAction.h @@ -25,6 +25,9 @@ class VolumeSliderWidgetAction : public QWidgetAction { void displayTooltip(int value); void updateTooltip(int value); +signals: + void dbAdjustmentChanged(int value); + protected slots: virtual void on_VolumeSlider_valueChanged(int){}; virtual void on_VolumeSlider_changeCompleted(){};