Skip to content

Commit

Permalink
Merge pull request #5326 from MarcSabatella/293228-palette-search
Browse files Browse the repository at this point in the history
fix #293228: accessibility for QML palettes
  • Loading branch information
anatoly-os committed Sep 17, 2019
1 parent 54107b2 commit b45221c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
12 changes: 5 additions & 7 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "palette.h"
#include "palettebox.h"
#include "palette/palettemodel.h"
#include "palette/palettewidget.h"
#include "palette/paletteworkspace.h"
#include "libmscore/part.h"
#include "libmscore/drumset.h"
Expand Down Expand Up @@ -5870,13 +5871,10 @@ void MuseScore::cmd(QAction* a)
return;
}
if (cmdn == "palette-search") {
PaletteBox* pb = getPaletteBox();
QLineEdit* sb = pb->searchBox();
sb->setFocus();
if (pb->noSelection())
pb->setKeyboardNavigation(false);
else
pb->setKeyboardNavigation(true);
// TODO: use new search box, or rename command to just "palette"
showPalette(true);
if (paletteWidget)
paletteWidget->setFocus();
return;
}
if (cmdn == "apply-current-palette-element") {
Expand Down
8 changes: 7 additions & 1 deletion mscore/palette/palettemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "libmscore/select.h"
#include "palettetree.h"
#include "preferences.h"
#include "scoreaccessibility.h"

namespace Ms {
//---------------------------------------------------------
Expand Down Expand Up @@ -250,8 +251,12 @@ QVariant PaletteTreeModel::data(const QModelIndex& index, int role) const
switch (role) {
case Qt::DisplayRole: // TODO don't display cell names in palettes
case Qt::ToolTipRole:
case Qt::AccessibleTextRole:
return qApp->translate("Palette", cell->name.toUtf8());
case Qt::AccessibleTextRole: {
QString name = qApp->translate("Palette", cell->name.toUtf8());
ScoreAccessibility::makeReadable(name);
return name;
}
case Qt::DecorationRole: {
qreal extraMag = 1.0;
if (const PalettePanel* pp = iptrToPalettePanel(index.internalPointer()))
Expand Down Expand Up @@ -455,6 +460,7 @@ QHash<int, QByteArray> PaletteTreeModel::roleNames() const
roles[EditableRole] = "editable";
roles[PaletteExpandedRole] = "expanded";
roles[CellActiveRole] = "cellActive";
roles[Qt::AccessibleTextRole] = "accessibleText";
return roles;
}

Expand Down
5 changes: 4 additions & 1 deletion mscore/qml/palettes/Palette.qml
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,10 @@ GridView {
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
ToolTip.text: toolTip ? toolTip : ""

text: toolTip ? toolTip : ""
text: model.accessibleText
// TODO: these may be needed for support of other screenreaders
//Accessible.name: model.accessibleText
//Accessible.description: model.accessibleText

onClicked: {
forceActiveFocus();
Expand Down
3 changes: 3 additions & 0 deletions mscore/qml/palettes/PalettesWidgetHeader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Item {
anchors.right: parent.right

placeholderText: qsTr("Search")
//TODO: in the future we may wish these values to differ
//Accessible.name: qsTr("Search")
Accessible.name: placeholderText
font: globalStyle.font

color: globalStyle.text
Expand Down

0 comments on commit b45221c

Please sign in to comment.