Skip to content

Commit

Permalink
Experiemental slider improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Jan 4, 2024
1 parent 8dc98c9 commit 04d0b29
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/mumble/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ 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...
m_localVolumeLabel->setAccessibleName(tr("Local Volume Adjustment"));
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);
}

Expand Down
24 changes: 23 additions & 1 deletion src/mumble/MenuLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,35 @@

#include <QLabel>

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);
}

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::setAccessibleName(const QString &name) {
m_accessibleName = name;

QLabel *label = qobject_cast< QLabel * >(defaultWidget());
if (label) {
label->setAccessibleName(m_accessibleName);
}
}

void MenuLabel::setAccessibleDescription(const QString &description) {
m_accessibleDescription = description;

QLabel *label = qobject_cast< QLabel * >(defaultWidget());
if (label) {
label->setAccessibleDescription(m_accessibleDescription);
}
}
5 changes: 5 additions & 0 deletions src/mumble/MenuLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ class MenuLabel : public QWidgetAction {
public:
MenuLabel(const QString &text, QObject *parent = nullptr);

void setAccessibleName(const QString &name);
void setAccessibleDescription(const QString &description);

protected:
QWidget *createWidget(QWidget *parent) override;

private:
const QString m_text;
QString m_accessibleName;
QString m_accessibleDescription;
};

#endif

0 comments on commit 04d0b29

Please sign in to comment.