Skip to content

Commit 2ad0ba8

Browse files
committed
Code quality improvements
1 parent 774ac8f commit 2ad0ba8

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

src/notation/internal/notationinteraction.cpp

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5282,17 +5282,11 @@ void NotationInteraction::autoFlipHairpinsType(Dynamic* selDyn)
52825282

52835283
void NotationInteraction::toggleDynamicPopup()
52845284
{
5285-
if (selection()->isNone()) {
5286-
return;
5287-
}
5288-
5289-
// If multiple selected selection()->element() returns null
5290-
if (!selection()->element()) {
5285+
EngravingItem* el = selection()->element();
5286+
if (!el) {
52915287
return;
52925288
}
52935289

5294-
EngravingItem* el = selection()->element();
5295-
52965290
if (el->isHairpinSegment()) {
52975291
HairpinSegment* hairpinSeg = toHairpinSegment(el);
52985292
Hairpin* hairpin = hairpinSeg->hairpin();
@@ -5311,37 +5305,37 @@ void NotationInteraction::toggleDynamicPopup()
53115305
};
53125306

53135307
switch (m_editData.curGrip) {
5314-
case Grip::START: {
5308+
case Grip::START:
53155309
if (EngravingItem* startDynOrExp = hairpinSeg->findElementToSnapBefore()) {
5316-
select({ startDynOrExp }); // If there is already a dynamic select it instead of opening an empty popup
5310+
// If there is already a dynamic, select it instead of opening an empty popup
5311+
select({ startDynOrExp });
53175312
if (startDynOrExp->isDynamic()) {
53185313
startEditElement(startDynOrExp, false);
53195314
autoFlipHairpinsType(toDynamic(startDynOrExp));
53205315
}
53215316
} else {
53225317
addDynamic(hairpin->tick(), hairpin->track(), hairpin->voiceAssignment());
53235318
}
5324-
}
5325-
return;
5326-
case Grip::END: {
5327-
EngravingItem* endDynOrExp = hairpinSeg->findElementToSnapAfter();
5328-
if (endDynOrExp != nullptr) {
5329-
select({ endDynOrExp }); // If there is already a dynamic select it instead of opening an empty popup
5319+
break;
5320+
case Grip::END:
5321+
if (EngravingItem* endDynOrExp = hairpinSeg->findElementToSnapAfter()) {
5322+
// If there is already a dynamic, select it instead of opening an empty popup
5323+
select({ endDynOrExp });
53305324
if (endDynOrExp->isDynamic()) {
53315325
startEditElement(endDynOrExp, false);
53325326
autoFlipHairpinsType(toDynamic(endDynOrExp));
53335327
}
53345328
} else {
53355329
addDynamic(hairpin->tick2(), hairpin->track2(), hairpin->voiceAssignment());
53365330
}
5337-
}
5338-
return;
5331+
break;
53395332
default:
5340-
return;
5333+
break;
53415334
}
5342-
} else {
5343-
addTextToItem(TextStyleType::DYNAMICS, el);
5335+
return;
53445336
}
5337+
5338+
addTextToItem(TextStyleType::DYNAMICS, el);
53455339
}
53465340

53475341
bool NotationInteraction::toggleLayoutBreakAvailable() const

0 commit comments

Comments
 (0)