Disable notation accessibility if notation paint view is not focused
This commit is contained in:
parent
1bf748dd74
commit
236187292f
7 changed files with 35 additions and 4 deletions
|
@ -311,13 +311,15 @@ bool AccessibleItem::accessibleState(State st) const
|
|||
return false;
|
||||
}
|
||||
|
||||
auto root = accessibleRoot();
|
||||
if (!root || !root->enabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (st) {
|
||||
case IAccessible::State::Enabled: return true;
|
||||
case IAccessible::State::Active: return true;
|
||||
case IAccessible::State::Focused: {
|
||||
auto root = accessibleRoot();
|
||||
return root ? root->focusedElement() == this : false;
|
||||
}
|
||||
case IAccessible::State::Focused: return root->focusedElement() == this;
|
||||
case IAccessible::State::Selected: return m_element->selected();
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -91,6 +91,16 @@ QString AccessibleRoot::accessibleName() const
|
|||
return element()->score()->name();
|
||||
}
|
||||
|
||||
bool AccessibleRoot::enabled() const
|
||||
{
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
void AccessibleRoot::setEnabled(bool enabled)
|
||||
{
|
||||
m_enabled = enabled;
|
||||
}
|
||||
|
||||
void AccessibleRoot::setMapToScreenFunc(const AccessibleMapToScreenFunc& func)
|
||||
{
|
||||
m_accessibleMapToScreenFunc = func;
|
||||
|
|
|
@ -44,7 +44,12 @@ public:
|
|||
accessibility::IAccessible::Role accessibleRole() const override;
|
||||
QString accessibleName() const override;
|
||||
|
||||
bool enabled() const;
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
bool m_enabled = false;
|
||||
|
||||
AccessibleItem* m_focusedElement = nullptr;
|
||||
|
||||
AccessibleMapToScreenFunc m_accessibleMapToScreenFunc;
|
||||
|
|
|
@ -37,6 +37,8 @@ public:
|
|||
virtual ValCh<std::string> accessibilityInfo() const = 0;
|
||||
|
||||
virtual void setMapToScreenFunc(const mu::engraving::AccessibleMapToScreenFunc& func) = 0;
|
||||
|
||||
virtual void setEnabled(bool enabled) = 0;
|
||||
};
|
||||
|
||||
using INotationAccessibilityPtr = std::shared_ptr<INotationAccessibility>;
|
||||
|
|
|
@ -74,6 +74,12 @@ void NotationAccessibility::setMapToScreenFunc(const AccessibleMapToScreenFunc&
|
|||
score()->dummy()->rootItem()->accessible()->accessibleRoot()->setMapToScreenFunc(func);
|
||||
}
|
||||
|
||||
void NotationAccessibility::setEnabled(bool enabled)
|
||||
{
|
||||
score()->rootItem()->accessible()->accessibleRoot()->setEnabled(enabled);
|
||||
score()->dummy()->rootItem()->accessible()->accessibleRoot()->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void NotationAccessibility::updateAccessibilityInfo()
|
||||
{
|
||||
if (!score()) {
|
||||
|
|
|
@ -46,6 +46,8 @@ public:
|
|||
|
||||
void setMapToScreenFunc(const mu::engraving::AccessibleMapToScreenFunc& func) override;
|
||||
|
||||
void setEnabled(bool enabled) override;
|
||||
|
||||
private:
|
||||
const Ms::Score* score() const;
|
||||
const Ms::Selection* selection() const;
|
||||
|
|
|
@ -245,6 +245,10 @@ void NotationPaintView::onCurrentNotationChanged()
|
|||
return res;
|
||||
});
|
||||
|
||||
connect(this, &QQuickPaintedItem::focusChanged, this, [this](bool focused) {
|
||||
notation()->accessibility()->setEnabled(focused);
|
||||
});
|
||||
|
||||
forceFocusIn();
|
||||
update();
|
||||
|
||||
|
|
Loading…
Reference in a new issue