Skip to content

Commit

Permalink
add screenreader info for text and dynamics
Browse files Browse the repository at this point in the history
  • Loading branch information
lasconic committed Jun 15, 2017
1 parent 49fc82c commit 0c05902
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 10 deletions.
9 changes: 0 additions & 9 deletions libmscore/ambitus.cpp
Expand Up @@ -732,14 +732,5 @@ QString Ambitus::accessibleInfo()
.arg(tpc2name(bottomTpc(), NoteSpellingType::STANDARD, NoteCaseType::AUTO, false))
.arg(QString::number(bottomOctave()));
}

//---------------------------------------------------------
// screenReaderInfo
//---------------------------------------------------------

QString Ambitus::screenReaderInfo()
{
return accessibleInfo();
}
}

1 change: 0 additions & 1 deletion libmscore/ambitus.h
Expand Up @@ -89,7 +89,6 @@ class Ambitus : public Element {
virtual Space space() const override;
virtual void write(Xml&) const override;
virtual QString accessibleInfo() override;
virtual QString screenReaderInfo() override;

// properties
QVariant getProperty(P_ID ) const;
Expand Down
16 changes: 16 additions & 0 deletions libmscore/dynamic.cpp
Expand Up @@ -445,5 +445,21 @@ QString Dynamic::accessibleInfo()
return QString("%1: %2").arg(Element::accessibleInfo()).arg(s);
}

//---------------------------------------------------------
// screenReaderInfo
//---------------------------------------------------------

QString Dynamic::screenReaderInfo()
{
QString s;

if (dynamicType() == Dynamic::Type::OTHER)
s = plainText().simplified();
else {
s = dynamicTypeName();
}
return QString("%1: %2").arg(Element::accessibleInfo()).arg(s);
}

}

1 change: 1 addition & 0 deletions libmscore/dynamic.h
Expand Up @@ -113,6 +113,7 @@ class Dynamic : public Text {
virtual QVariant propertyDefault(P_ID id) const override;

virtual QString accessibleInfo() override;
virtual QString screenReaderInfo() override;
};

} // namespace Ms
Expand Down
28 changes: 28 additions & 0 deletions libmscore/text.cpp
Expand Up @@ -3044,6 +3044,34 @@ QString Text::accessibleInfo()
return QString("%1: %2").arg(rez).arg(s);
}

//---------------------------------------------------------
// screenReaderInfo
//---------------------------------------------------------

QString Text::screenReaderInfo()
{
QString rez;
const QList<TextStyle>& ts = score()->style()->textStyles();
switch (textStyleType()) {
case TextStyleType::TITLE:
case TextStyleType::SUBTITLE:
case TextStyleType::COMPOSER:
case TextStyleType::POET:
case TextStyleType::TRANSLATOR:
case TextStyleType::MEASURE_NUMBER:
rez = qApp->translate("TextStyle",ts.at(int(textStyleType())).name().toUtf8());
break;
default:
if ((type() == Element::Type::STAFF_TEXT) && systemFlag())
rez = tr("System Text");
else
rez = Element::accessibleInfo();
break;
}
QString s = plainText(true).simplified();
return QString("%1: %2").arg(rez).arg(s);
}

//---------------------------------------------------------
// subtype
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/text.h
Expand Up @@ -336,6 +336,7 @@ class Text : public Element {

void undoSetText(const QString& s) { undoChangeProperty(P_ID::TEXT, s); }
virtual QString accessibleInfo() override;
virtual QString screenReaderInfo() override;

virtual int subtype() const;
virtual QString subtypeName() const;
Expand Down

0 comments on commit 0c05902

Please sign in to comment.