forked from mumble-voip/mumble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX(a11y): Add semantic description to sliders in Settings
- Loading branch information
Showing
7 changed files
with
170 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2023-2024 The Mumble Developers. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file at the root of the | ||
// Mumble source tree or at <https://www.mumble.info/LICENSE>. | ||
|
||
#include "SemanticSlider.h" | ||
|
||
#include <QDebug> | ||
|
||
AccessibleAbstractSlider::AccessibleAbstractSlider(QWidget *w, QAccessible::Role r) | ||
: QAccessibleWidget(w, r) | ||
{ | ||
Q_ASSERT(qobject_cast<QAbstractSlider *>(w)); | ||
} | ||
|
||
void *AccessibleAbstractSlider::interface_cast(QAccessible::InterfaceType t) | ||
{ | ||
return QAccessibleWidget::interface_cast(t); | ||
} | ||
|
||
QAbstractSlider *AccessibleAbstractSlider::abstractSlider() const | ||
{ | ||
return static_cast<QAbstractSlider *>(object()); | ||
} | ||
|
||
AccessibleSlider::AccessibleSlider(QWidget *w) | ||
: AccessibleAbstractSlider(w) | ||
{ | ||
Q_ASSERT(slider()); | ||
addControllingSignal(QLatin1String("valueChanged(int)")); | ||
} | ||
|
||
SemanticSlider *AccessibleSlider::slider() const | ||
{ | ||
return qobject_cast<SemanticSlider*>(object()); | ||
} | ||
|
||
QString AccessibleSlider::text(QAccessible::Text t) const | ||
{ | ||
qDebug() << "text method" << t; | ||
if (t == QAccessible::Name) { | ||
qDebug() << "send text"; | ||
qDebug() << (AccessibleAbstractSlider::text(t) + " " + slider()->m_semanticValue); | ||
return AccessibleAbstractSlider::text(t) + " " + slider()->m_semanticValue; | ||
} | ||
|
||
return AccessibleAbstractSlider::text(t); | ||
} | ||
|
||
QAccessibleInterface *AccessibleSlider::semanticSliderFactory(const QString &classname, QObject *object) { | ||
QAccessibleInterface *interface = nullptr; | ||
|
||
if(object && object->isWidgetType()) { | ||
if (classname == QLatin1String("SemanticSlider")) { | ||
interface = new AccessibleSlider(static_cast<QWidget *>(object)); | ||
qDebug() << "created interface"; | ||
} else { | ||
qDebug() << "not interfaced"; | ||
} | ||
} | ||
|
||
return interface; | ||
} | ||
|
||
SemanticSlider::SemanticSlider(QWidget *parent) | ||
: QSlider(parent), m_semanticValue("test 1.56 milliseconds") | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2023-2024 The Mumble Developers. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file at the root of the | ||
// Mumble source tree or at <https://www.mumble.info/LICENSE>. | ||
|
||
#ifndef MUMBLE_MUMBLE_WIDGETS_SEMANTICSLIDER_H_ | ||
#define MUMBLE_MUMBLE_WIDGETS_SEMANTICSLIDER_H_ | ||
|
||
#include <QAccessible> | ||
#include <QAccessibleValueInterface> | ||
#include <QAccessibleWidget> | ||
|
||
#include <QString> | ||
#include <QWidget> | ||
#include <QObject> | ||
#include <QVariant> | ||
|
||
#include <QtWidgets/QAbstractSlider> | ||
#include <QtWidgets/QSlider> | ||
|
||
class AccessibleAbstractSlider: public QAccessibleWidget | ||
{ | ||
public: | ||
explicit AccessibleAbstractSlider(QWidget *w, QAccessible::Role r = QAccessible::Slider); | ||
void *interface_cast(QAccessible::InterfaceType t) override; | ||
|
||
protected: | ||
QAbstractSlider *abstractSlider() const; | ||
}; | ||
|
||
class AccessibleSlider : public AccessibleAbstractSlider | ||
{ | ||
public: | ||
explicit AccessibleSlider(QWidget *w); | ||
QString text(QAccessible::Text t) const override; | ||
|
||
static QAccessibleInterface *semanticSliderFactory(const QString &classname, QObject *object); | ||
|
||
protected: | ||
SemanticSlider *slider() const; | ||
}; | ||
|
||
class SemanticSlider: public QSlider | ||
{ | ||
public: | ||
SemanticSlider(QWidget *parent = nullptr); | ||
|
||
QString m_semanticValue; | ||
} | ||
|
||
#endif |