Skip to content

Commit c79dea1

Browse files
Merge pull request #27092 from mike-spa/dontAllowDragByCopyOntoTuplet
Don't allow copy-by-drag onto tuplets
1 parent 8864b44 commit c79dea1

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

src/engraving/dom/segment.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,25 @@ void Segment::setXPosInSystemCoords(double x)
10951095
mutldata()->setPosX(x - measure()->x());
10961096
}
10971097

1098+
bool Segment::isInsideTuplet() const
1099+
{
1100+
if (!isChordRestType()) {
1101+
return false;
1102+
}
1103+
1104+
for (EngravingItem* item : m_elist) {
1105+
if (!item) {
1106+
continue;
1107+
}
1108+
ChordRest* chordRest = toChordRest(item);
1109+
if (chordRest->tuplet() && chordRest->tick() != chordRest->topTuplet()->tick()) {
1110+
return true;
1111+
}
1112+
}
1113+
1114+
return false;
1115+
}
1116+
10981117
//---------------------------------------------------------
10991118
// swapElements
11001119
//---------------------------------------------------------

src/engraving/dom/segment.h

+2
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ class Segment final : public EngravingItem
320320
double xPosInSystemCoords() const;
321321
void setXPosInSystemCoords(double x);
322322

323+
bool isInsideTuplet() const;
324+
323325
private:
324326

325327
friend class Factory;

src/notation/internal/notationinteraction.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,16 @@ bool NotationInteraction::dropRange(const QByteArray& data, const PointF& pos, b
19711971
return false;
19721972
}
19731973

1974+
if (segment->isInsideTuplet()) {
1975+
endDrop();
1976+
notifyAboutDropChanged();
1977+
//MScore::setError(MsError::DEST_TUPLET);
1978+
//MScoreErrorsController(iocContext()).checkAndShowMScoreError();
1979+
// NOTE: if we show the error popup here it seems that the mouse-release event is missed
1980+
// so the dragged region stays sticked to the mouse and move around. Don't know how to fix it. [M.S.]
1981+
return false;
1982+
}
1983+
19741984
rdd.targetSegment = segment;
19751985
rdd.targetStaffIdx = staffIdx;
19761986

@@ -2005,8 +2015,8 @@ bool NotationInteraction::dropRange(const QByteArray& data, const PointF& pos, b
20052015
XmlReader e(data);
20062016
score()->pasteStaff(e, segment, staffIdx);
20072017

2008-
apply();
20092018
endDrop();
2019+
apply();
20102020

20112021
MScoreErrorsController(iocContext()).checkAndShowMScoreError();
20122022

0 commit comments

Comments
 (0)