Skip to content

Commit ecd17fe

Browse files
authored
Merge pull request #31111 from mathesoncalum/31074-dont_show_again-464
Fix #31074: Ensure "don't show again" option is honoured in error dialogs [4.6.4 port]
2 parents 1c11ce9 + 6ccbcee commit ecd17fe

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

src/notation/inotationinteraction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ class INotationInteraction
333333
virtual muse::async::Channel<ShowItemRequest> showItemRequested() const = 0;
334334

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

338339
using INotationInteractionPtr = std::shared_ptr<INotationInteraction>;

src/notation/internal/notationinteraction.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
#include "engraving/rw/xmlreader.h"
9494
#include "engraving/rw/rwregister.h"
9595

96-
#include "mscoreerrorscontroller.h"
9796
#include "notationerrors.h"
9897
#include "notation.h"
9998
#include "notationnoteinput.h"
@@ -234,6 +233,8 @@ NotationInteraction::NotationInteraction(Notation* notation, INotationUndoStackP
234233
notifyAboutSelectionChangedIfNeed();
235234
});
236235

236+
m_errorsController = std::make_shared<MScoreErrorsController>(iocContext());
237+
237238
m_noteInput->stateChanged().onNotify(this, [this]() {
238239
if (!m_noteInput->isNoteInputMode()) {
239240
hideShadowNote();
@@ -1342,8 +1343,7 @@ void NotationInteraction::endDrag()
13421343
}
13431344

13441345
notifyAboutDragChanged();
1345-
1346-
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
1346+
checkAndShowError();
13471347
}
13481348

13491349
muse::async::Notification NotationInteraction::dragChanged() const
@@ -2047,7 +2047,7 @@ bool NotationInteraction::dropSingle(const PointF& pos, Qt::KeyboardModifiers mo
20472047
notifyAboutDropChanged();
20482048
}
20492049

2050-
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
2050+
checkAndShowError();
20512051

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

2210-
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
2210+
checkAndShowError();
22112211

22122212
return true;
22132213
}
@@ -2336,7 +2336,7 @@ bool NotationInteraction::applyPaletteElement(mu::engraving::EngravingItem* elem
23362336

23372337
setDropTarget(nullptr);
23382338

2339-
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
2339+
checkAndShowError();
23402340

23412341
return true;
23422342
}
@@ -4909,7 +4909,7 @@ void NotationInteraction::splitSelectedMeasure()
49094909
score()->cmdSplitMeasure(chordRest);
49104910
apply();
49114911

4912-
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
4912+
checkAndShowError();
49134913
}
49144914

49154915
void NotationInteraction::joinSelectedMeasures()
@@ -4924,7 +4924,7 @@ void NotationInteraction::joinSelectedMeasures()
49244924
score()->cmdJoinMeasure(measureRange.startMeasure, measureRange.endMeasure);
49254925
apply();
49264926

4927-
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
4927+
checkAndShowError();
49284928
}
49294929

49304930
Ret NotationInteraction::canAddBoxes() const
@@ -5116,6 +5116,7 @@ void NotationInteraction::addBoxes(BoxType boxType, int count, int beforeBoxInde
51165116
void NotationInteraction::copySelection()
51175117
{
51185118
if (!selection()->canCopy()) {
5119+
checkAndShowError();
51195120
return;
51205121
}
51215122

@@ -5241,7 +5242,7 @@ void NotationInteraction::pasteSelection(const Fraction& scale)
52415242
selectAndStartEditIfNeeded(pastedElement);
52425243
}
52435244

5244-
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
5245+
checkAndShowError();
52455246
}
52465247

52475248
void NotationInteraction::swapSelection()
@@ -5284,7 +5285,7 @@ void NotationInteraction::deleteSelection()
52845285
score()->cmdDeleteSelection();
52855286
}
52865287

5287-
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
5288+
checkAndShowError();
52885289
apply();
52895290
resetHitElementContext();
52905291
}
@@ -5889,7 +5890,7 @@ void NotationInteraction::addIntervalToSelectedNotes(int interval)
58895890

58905891
if (notes.empty()) {
58915892
MScore::setError(MsError::NO_NOTE_SELECTED);
5892-
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
5893+
checkAndShowError();
58935894
return;
58945895
}
58955896

@@ -8201,3 +8202,11 @@ void NotationInteraction::setGetViewRectFunc(const std::function<RectF()>& func)
82018202
{
82028203
static_cast<NotationNoteInput*>(m_noteInput.get())->setGetViewRectFunc(func);
82038204
}
8205+
8206+
void NotationInteraction::checkAndShowError()
8207+
{
8208+
IF_ASSERT_FAILED(m_errorsController) {
8209+
return;
8210+
}
8211+
m_errorsController->checkAndShowMScoreError();
8212+
}

src/notation/internal/notationinteraction.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include "../iselectinstrumentscenario.h"
3636
#include "inotationundostack.h"
3737

38+
#include "mscoreerrorscontroller.h"
39+
3840
#include "engraving/dom/engravingitem.h"
3941
#include "engraving/dom/elementgroup.h"
4042
#include "engraving/types/symid.h"
@@ -333,6 +335,7 @@ class NotationInteraction : public INotationInteraction, public muse::Injectable
333335
muse::async::Channel<ShowItemRequest> showItemRequested() const override;
334336

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

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

521524
std::shared_ptr<NotationSelectionFilter> m_selectionFilter = nullptr;
522525

526+
std::shared_ptr<MScoreErrorsController> m_errorsController = nullptr;
527+
523528
DragData m_dragData;
524529
muse::async::Notification m_dragChanged;
525530
std::vector<muse::LineF> m_anchorLines;

src/notation/tests/mocks/notationinteractionmock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,5 +286,6 @@ class NotationInteractionMock : public INotationInteraction
286286
MOCK_METHOD(muse::async::Channel<ShowItemRequest>, showItemRequested, (), (const, override));
287287

288288
MOCK_METHOD(void, setGetViewRectFunc, (const std::function<muse::RectF()>&), (override));
289+
MOCK_METHOD(void, checkAndShowError, (), (override));
289290
};
290291
}

0 commit comments

Comments
 (0)