From 8f52179912bbebf5a3d78a53eb228626386eb69d Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 20 Jan 2019 00:51:22 -0800 Subject: [PATCH] UI: Fix accessibility/narration text on sources list Fixes the narration reading (for the blind) for items in the sources list; previously they would not be read due to the new custom model. This issue is solved by returning the name of item in the form of a QVariant of a QString returned from the QAbstractItemModel::data virtual function when the Qt::AccessibleTextRole role is used. --- UI/source-tree.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/UI/source-tree.cpp b/UI/source-tree.cpp index c86aea9cb..0fbce074a 100644 --- a/UI/source-tree.cpp +++ b/UI/source-tree.cpp @@ -695,8 +695,14 @@ int SourceTreeModel::rowCount(const QModelIndex &parent) const return parent.isValid() ? 0 : items.count(); } -QVariant SourceTreeModel::data(const QModelIndex &, int) const +QVariant SourceTreeModel::data(const QModelIndex &index, int role) const { + if (role == Qt::AccessibleTextRole) { + OBSSceneItem item = items[index.row()]; + obs_source_t *source = obs_sceneitem_get_source(item); + return QVariant(QT_UTF8(obs_source_get_name(source))); + } + return QVariant(); }