Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/notation/inotationinteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ class INotationInteraction
virtual muse::async::Channel<ShowItemRequest> showItemRequested() const = 0;

virtual void setGetViewRectFunc(const std::function<muse::RectF()>& func) = 0;
virtual void checkAndShowError() = 0;
};

using INotationInteractionPtr = std::shared_ptr<INotationInteraction>;
Expand Down
33 changes: 21 additions & 12 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
#include "engraving/rw/xmlreader.h"
#include "engraving/rw/rwregister.h"

#include "mscoreerrorscontroller.h"
#include "notationerrors.h"
#include "notation.h"
#include "notationnoteinput.h"
Expand Down Expand Up @@ -234,6 +233,8 @@ NotationInteraction::NotationInteraction(Notation* notation, INotationUndoStackP
notifyAboutSelectionChangedIfNeed();
});

m_errorsController = std::make_shared<MScoreErrorsController>(iocContext());

m_noteInput->stateChanged().onNotify(this, [this]() {
if (!m_noteInput->isNoteInputMode()) {
hideShadowNote();
Expand Down Expand Up @@ -1342,8 +1343,7 @@ void NotationInteraction::endDrag()
}

notifyAboutDragChanged();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
}

muse::async::Notification NotationInteraction::dragChanged() const
Expand Down Expand Up @@ -2047,7 +2047,7 @@ bool NotationInteraction::dropSingle(const PointF& pos, Qt::KeyboardModifiers mo
notifyAboutDropChanged();
}

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();

return accepted;
}
Expand Down Expand Up @@ -2172,7 +2172,7 @@ bool NotationInteraction::dropRange(const QByteArray& data, const PointF& pos, b
endDrop();
notifyAboutDropChanged();
//MScore::setError(MsError::DEST_TUPLET);
//MScoreErrorsController(iocContext()).checkAndShowMScoreError();
// checkAndShowError();
// NOTE: if we show the error popup here it seems that the mouse-release event is missed
// so the dragged region stays sticked to the mouse and move around. Don't know how to fix it. [M.S.]
return false;
Expand Down Expand Up @@ -2207,7 +2207,7 @@ bool NotationInteraction::dropRange(const QByteArray& data, const PointF& pos, b
endDrop();
apply();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();

return true;
}
Expand Down Expand Up @@ -2336,7 +2336,7 @@ bool NotationInteraction::applyPaletteElement(mu::engraving::EngravingItem* elem

setDropTarget(nullptr);

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();

return true;
}
Expand Down Expand Up @@ -4909,7 +4909,7 @@ void NotationInteraction::splitSelectedMeasure()
score()->cmdSplitMeasure(chordRest);
apply();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
}

void NotationInteraction::joinSelectedMeasures()
Expand All @@ -4924,7 +4924,7 @@ void NotationInteraction::joinSelectedMeasures()
score()->cmdJoinMeasure(measureRange.startMeasure, measureRange.endMeasure);
apply();

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
}

Ret NotationInteraction::canAddBoxes() const
Expand Down Expand Up @@ -5116,6 +5116,7 @@ void NotationInteraction::addBoxes(BoxType boxType, int count, int beforeBoxInde
void NotationInteraction::copySelection()
{
if (!selection()->canCopy()) {
checkAndShowError();
return;
}

Expand Down Expand Up @@ -5241,7 +5242,7 @@ void NotationInteraction::pasteSelection(const Fraction& scale)
selectAndStartEditIfNeeded(pastedElement);
}

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
}

void NotationInteraction::swapSelection()
Expand Down Expand Up @@ -5284,7 +5285,7 @@ void NotationInteraction::deleteSelection()
score()->cmdDeleteSelection();
}

MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
apply();
resetHitElementContext();
}
Expand Down Expand Up @@ -5889,7 +5890,7 @@ void NotationInteraction::addIntervalToSelectedNotes(int interval)

if (notes.empty()) {
MScore::setError(MsError::NO_NOTE_SELECTED);
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
checkAndShowError();
return;
}

Expand Down Expand Up @@ -8201,3 +8202,11 @@ void NotationInteraction::setGetViewRectFunc(const std::function<RectF()>& func)
{
static_cast<NotationNoteInput*>(m_noteInput.get())->setGetViewRectFunc(func);
}

void NotationInteraction::checkAndShowError()
{
IF_ASSERT_FAILED(m_errorsController) {
return;
}
m_errorsController->checkAndShowMScoreError();
}
5 changes: 5 additions & 0 deletions src/notation/internal/notationinteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "../iselectinstrumentscenario.h"
#include "inotationundostack.h"

#include "mscoreerrorscontroller.h"

#include "engraving/dom/engravingitem.h"
#include "engraving/dom/elementgroup.h"
#include "engraving/types/symid.h"
Expand Down Expand Up @@ -333,6 +335,7 @@ class NotationInteraction : public INotationInteraction, public muse::Injectable
muse::async::Channel<ShowItemRequest> showItemRequested() const override;

void setGetViewRectFunc(const std::function<muse::RectF()>& func) override;
void checkAndShowError() override;

private:
mu::engraving::Score* score() const;
Expand Down Expand Up @@ -520,6 +523,8 @@ class NotationInteraction : public INotationInteraction, public muse::Injectable

std::shared_ptr<NotationSelectionFilter> m_selectionFilter = nullptr;

std::shared_ptr<MScoreErrorsController> m_errorsController = nullptr;

DragData m_dragData;
muse::async::Notification m_dragChanged;
std::vector<muse::LineF> m_anchorLines;
Expand Down
1 change: 1 addition & 0 deletions src/notation/tests/mocks/notationinteractionmock.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,5 +286,6 @@ class NotationInteractionMock : public INotationInteraction
MOCK_METHOD(muse::async::Channel<ShowItemRequest>, showItemRequested, (), (const, override));

MOCK_METHOD(void, setGetViewRectFunc, (const std::function<muse::RectF()>&), (override));
MOCK_METHOD(void, checkAndShowError, (), (override));
};
}
Loading