Skip to content

Commit

Permalink
Merge pull request #13383 from Eism/accessibility_score_command
Browse files Browse the repository at this point in the history
fixed #12966: Toggle note input / normal modes does not read the change
  • Loading branch information
RomanPudashkin authored Sep 22, 2022
2 parents 3920500 + 19f3e41 commit cfc7f04
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/engraving/accessibility/accessibleitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,14 @@ QString AccessibleItem::accessibleName() const
}

AccessibleRoot* root = accessibleRoot();
QString commandInfo = root ? root->commandInfo() : "";
QString staffInfo = root ? root->staffInfo() : "";
QString barsAndBeats = m_element->formatBarsAndBeats();

barsAndBeats.remove(u';'); // Too many pauses in speech

QString name = QString("%1%2%3%4")
QString name = QString("%1%2%3%4%5")
.arg(!commandInfo.isEmpty() ? (commandInfo + "; ") : "")
.arg(!staffInfo.isEmpty() ? (staffInfo + "; ") : "")
.arg(m_element->screenReaderInfo().toQString())
.arg(m_element->visible() ? "" : " " + qtrc("engraving", "invisible"))
Expand Down
14 changes: 14 additions & 0 deletions src/engraving/accessibility/accessibleroot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ void AccessibleRoot::updateStaffInfo(const AccessibleItemWeakPtr newAccessibleIt
}
}

QString AccessibleRoot::commandInfo() const
{
return m_commandInfo;
}

void AccessibleRoot::setCommandInfo(const QString& command)
{
m_commandInfo = command;

if (!m_commandInfo.isEmpty()) {
notifyAboutFocusedElementNameChanged();
}
}

void AccessibleRoot::setMapToScreenFunc(const AccessibleMapToScreenFunc& func)
{
m_accessibleMapToScreenFunc = func;
Expand Down
4 changes: 4 additions & 0 deletions src/engraving/accessibility/accessibleroot.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class AccessibleRoot : public AccessibleItem
void updateStaffInfo(const AccessibleItemWeakPtr newAccessibleItem, const AccessibleItemWeakPtr oldAccessibleItem,
bool voiceStaffInfoChange = true);

QString commandInfo() const;
void setCommandInfo(const QString& command);

private:

bool m_enabled = false;
Expand All @@ -63,6 +66,7 @@ class AccessibleRoot : public AccessibleItem
AccessibleMapToScreenFunc m_accessibleMapToScreenFunc;

QString m_staffInfo;
QString m_commandInfo;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,15 @@ void AccessibilityController::triggerRevoicingOfChangedName(IAccessible* item)
return;
}

const IAccessible* itemPanel = panel(item);
if (!itemPanel) {
return;
}

m_ignorePanelChangingVoice = true;

item->setState(State::Focused, false);

const IAccessible* itemPanel = panel(item);
IAccessible* tmpFocusedItem = findSiblingItem(itemPanel, item);
if (!tmpFocusedItem) {
tmpFocusedItem = const_cast<IAccessible*>(itemPanel);
Expand Down
2 changes: 2 additions & 0 deletions src/notation/inotationaccessibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class INotationAccessibility
virtual void setMapToScreenFunc(const mu::engraving::AccessibleMapToScreenFunc& func) = 0;

virtual void setEnabled(bool enabled) = 0;

virtual void setTriggeredCommand(const std::string& command) = 0;
};

using INotationAccessibilityPtr = std::shared_ptr<INotationAccessibility>;
Expand Down
11 changes: 11 additions & 0 deletions src/notation/internal/notationaccessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ NotationAccessibility::NotationAccessibility(const Notation* notation)
: m_getScore(notation)
{
notation->interaction()->selectionChanged().onNotify(this, [this]() {
setTriggeredCommand("");
updateAccessibilityInfo();
});

Expand Down Expand Up @@ -111,6 +112,16 @@ void NotationAccessibility::setEnabled(bool enabled)
#endif
}

void NotationAccessibility::setTriggeredCommand(const std::string& command)
{
#ifndef ENGRAVING_NO_ACCESSIBILITY
score()->rootItem()->accessible()->accessibleRoot()->setCommandInfo(QString::fromStdString(command));
score()->dummy()->rootItem()->accessible()->accessibleRoot()->setCommandInfo(QString::fromStdString(command));
#else
UNUSED(command)
#endif
}

void NotationAccessibility::updateAccessibilityInfo()
{
if (!score()) {
Expand Down
2 changes: 2 additions & 0 deletions src/notation/internal/notationaccessibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class NotationAccessibility : public INotationAccessibility, public async::Async

void setEnabled(bool enabled) override;

void setTriggeredCommand(const std::string& command) override;

private:
const engraving::Score* score() const;
const engraving::Selection* selection() const;
Expand Down
24 changes: 22 additions & 2 deletions src/notation/internal/notationactioncontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "libmscore/note.h"
#include "libmscore/text.h"

#include "translation.h"
#include "log.h"

using namespace mu::io;
Expand Down Expand Up @@ -589,6 +590,16 @@ mu::async::Notification NotationActionController::currentNotationStyleChanged()
return currentNotationStyle() ? currentNotationStyle()->styleChanged() : async::Notification();
}

INotationAccessibilityPtr NotationActionController::currentNotationAccessibility() const
{
auto notation = currentNotation();
if (!notation) {
return nullptr;
}

return notation->accessibility();
}

void NotationActionController::resetState()
{
TRACEFUNC;
Expand All @@ -603,7 +614,7 @@ void NotationActionController::resetState()
}

if (noteInput->isNoteInputMode()) {
noteInput->endNoteInput();
toggleNoteInput();
return;
}

Expand Down Expand Up @@ -635,6 +646,15 @@ void NotationActionController::toggleNoteInput()
} else {
noteInput->startNoteInput();
}

auto notationAccessibility = currentNotationAccessibility();
if (!notationAccessibility) {
return;
}

ui::UiActionState state = actionRegister()->actionState("note-input");
std::string stateTitle = state.checked ? trc("notation", "Note input mode") : trc("notation", "Normal mode");
notationAccessibility->setTriggeredCommand(stateTitle);
}

void NotationActionController::toggleNoteInputMethod(NoteInputMethod method)
Expand All @@ -648,7 +668,7 @@ void NotationActionController::toggleNoteInputMethod(NoteInputMethod method)
if (!noteInput->isNoteInputMode()) {
noteInput->startNoteInput();
} else if (noteInput->state().method == method) {
noteInput->endNoteInput();
toggleNoteInput();
return;
}

Expand Down
18 changes: 12 additions & 6 deletions src/notation/internal/notationactioncontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,27 @@
#ifndef MU_NOTATION_NOTATIONACTIONCONTROLLER_H
#define MU_NOTATION_NOTATIONACTIONCONTROLLER_H

#include "modularity/ioc.h"
#include "actions/iactionsdispatcher.h"
#include "async/asyncable.h"
#include "actions/actionable.h"
#include "actions/actiontypes.h"
#include "async/asyncable.h"

#include "modularity/ioc.h"
#include "iinteractive.h"
#include "actions/iactionsdispatcher.h"
#include "ui/iuiactionsregister.h"
#include "context/iglobalcontext.h"
#include "context/iuicontextresolver.h"
#include "inotation.h"
#include "iinteractive.h"
#include "playback/iplaybackcontroller.h"
#include "inotationconfiguration.h"
#include "engraving/iengravingconfiguration.h"
#include "inotationconfiguration.h"

#include "inotation.h"

namespace mu::notation {
class NotationActionController : public actions::Actionable, public async::Asyncable
{
INJECT(notation, actions::IActionsDispatcher, dispatcher)
INJECT(notation, ui::IUiActionsRegister, actionRegister)
INJECT(notation, context::IGlobalContext, globalContext)
INJECT(notation, context::IUiContextResolver, uiContextResolver)
INJECT(notation, framework::IInteractive, interactive)
Expand All @@ -61,6 +65,8 @@ class NotationActionController : public actions::Actionable, public async::Async
INotationStylePtr currentNotationStyle() const;
async::Notification currentNotationStyleChanged() const;

INotationAccessibilityPtr currentNotationAccessibility() const;

using EngravingDebuggingOptions = engraving::IEngravingConfiguration::DebuggingOptions;
static const std::unordered_map<actions::ActionCode, bool EngravingDebuggingOptions::*> engravingDebuggingActions;

Expand Down

0 comments on commit cfc7f04

Please sign in to comment.