From 5182e799b66f980e51c5592437e51cc0f67a4d73 Mon Sep 17 00:00:00 2001 From: herrwagner Date: Fri, 19 Jan 2018 18:02:01 +0100 Subject: [PATCH] fix #267721, fix #268624: added iteration over all selected elements on preset click, changes resetClicked() to simply call valueChanged with second parameter (reset) =true --- mscore/inspector/inspectorBarline.cpp | 81 +++++++++++++++++---------- mscore/inspector/inspectorBase.cpp | 27 +++------ 2 files changed, 61 insertions(+), 47 deletions(-) diff --git a/mscore/inspector/inspectorBarline.cpp b/mscore/inspector/inspectorBarline.cpp index 048c25432647..4543a4e17f71 100644 --- a/mscore/inspector/inspectorBarline.cpp +++ b/mscore/inspector/inspectorBarline.cpp @@ -127,13 +127,18 @@ void InspectorBarLine::setElement() void InspectorBarLine::presetDefaultClicked() { - BarLine* bl = toBarLine(inspector->element()); - Score* score = bl->score(); + Score* score = inspector->element()->score(); score->startCmd(); - bl->undoResetProperty(P_ID::BARLINE_SPAN); - bl->undoResetProperty(P_ID::BARLINE_SPAN_FROM); - bl->undoResetProperty(P_ID::BARLINE_SPAN_TO); + BarLine* bl; + for (Element* e : *inspector->el()) { + if (e->isBarLine()) { + bl = toBarLine(e); + bl->undoResetProperty(P_ID::BARLINE_SPAN); + bl->undoResetProperty(P_ID::BARLINE_SPAN_FROM); + bl->undoResetProperty(P_ID::BARLINE_SPAN_TO); + } + } score->endCmd(); } @@ -144,13 +149,18 @@ void InspectorBarLine::presetDefaultClicked() void InspectorBarLine::presetTick1Clicked() { - BarLine* bl = toBarLine(inspector->element()); - Score* score = bl->score(); + Score* score = inspector->element()->score(); score->startCmd(); - bl->undoChangeProperty(P_ID::BARLINE_SPAN, false); - bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_TICK1_FROM); - bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_TICK1_TO); + BarLine* bl; + for (Element* e : *inspector->el()) { + if (e->isBarLine()) { + bl = toBarLine(e); + bl->undoChangeProperty(P_ID::BARLINE_SPAN, false); + bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_TICK1_FROM); + bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_TICK1_TO); + } + } score->endCmd(); } @@ -161,13 +171,18 @@ void InspectorBarLine::presetTick1Clicked() void InspectorBarLine::presetTick2Clicked() { - BarLine* bl = toBarLine(inspector->element()); - Score* score = bl->score(); + Score* score = inspector->element()->score(); score->startCmd(); - bl->undoChangeProperty(P_ID::BARLINE_SPAN, false); - bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_TICK2_FROM); - bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_TICK2_TO); + BarLine* bl; + for (Element* e : *inspector->el()) { + if (e->isBarLine()) { + bl = toBarLine(e); + bl->undoChangeProperty(P_ID::BARLINE_SPAN, false); + bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_TICK2_FROM); + bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_TICK2_TO); + } + } score->endCmd(); } @@ -178,15 +193,19 @@ void InspectorBarLine::presetTick2Clicked() void InspectorBarLine::presetShort1Clicked() { - BarLine* bl = toBarLine(inspector->element()); - Score* score = bl->score(); + Score* score = inspector->element()->score(); score->startCmd(); - bl->undoChangeProperty(P_ID::BARLINE_SPAN, false); - bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_SHORT1_FROM); - int shortDelta = bl->staff() ? (bl->staff()->lines(bl->tick()) - 5) * 2 : 0; - bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_SHORT1_TO + shortDelta); - + BarLine* bl; + for (Element* e : *inspector->el()) { + if (e->isBarLine()) { + bl = toBarLine(e); + bl->undoChangeProperty(P_ID::BARLINE_SPAN, false); + bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_SHORT1_FROM); + int shortDelta = bl->staff() ? (bl->staff()->lines(bl->tick()) - 5) * 2 : 0; + bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_SHORT1_TO + shortDelta); + } + } score->endCmd(); } @@ -196,15 +215,19 @@ void InspectorBarLine::presetShort1Clicked() void InspectorBarLine::presetShort2Clicked() { - BarLine* bl = toBarLine(inspector->element()); - Score* score = bl->score(); + Score* score = inspector->element()->score(); score->startCmd(); - bl->undoChangeProperty(P_ID::BARLINE_SPAN, false); - bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_SHORT2_FROM); - int shortDelta = bl->staff() ? (bl->staff()->lines(bl->tick()) - 5) * 2 : 0; - bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_SHORT2_TO + shortDelta); - + BarLine* bl; + for (Element* e : *inspector->el()) { + if (e->isBarLine()) { + bl = toBarLine(e); + bl->undoChangeProperty(P_ID::BARLINE_SPAN, false); + bl->undoChangeProperty(P_ID::BARLINE_SPAN_FROM, BARLINE_SPAN_SHORT2_FROM); + int shortDelta = bl->staff() ? (bl->staff()->lines(bl->tick()) - 5) * 2 : 0; + bl->undoChangeProperty(P_ID::BARLINE_SPAN_TO, BARLINE_SPAN_SHORT2_TO + shortDelta); + } + } score->endCmd(); } diff --git a/mscore/inspector/inspectorBase.cpp b/mscore/inspector/inspectorBase.cpp index 9cf24a1b7afb..16ca4c6fe5ca 100644 --- a/mscore/inspector/inspectorBase.cpp +++ b/mscore/inspector/inspectorBase.cpp @@ -357,7 +357,14 @@ void InspectorBase::valueChanged(int idx, bool reset) else if (ps == PropertyFlags::STYLED) ps = PropertyFlags::UNSTYLED; QVariant val1 = e->getProperty(id); - if (val1 != val2 || (reset && ps != PropertyFlags::NOSTYLE)) + if (reset) { + val2 = e->propertyDefault(id); + } + if (val2.isValid() && val1 != val2) + if (reset) { + val2 = e->propertyDefault(id); + setValue(ii, val2); + } e->undoChangeProperty(id, val2, ps); } inspector->setInspectorEdit(true); @@ -377,23 +384,7 @@ void InspectorBase::valueChanged(int idx, bool reset) void InspectorBase::resetClicked(int i) { - Element* e = inspector->element(); - const InspectorItem& ii = iList[i]; - P_ID id = ii.t; - for (int i = 0; i < ii.parent; ++i) - e = e->parent(); - QVariant def = e->propertyDefault(id); - if (!def.isValid()) { - qDebug("default value not valid"); - return; - } - Score* s = e->score(); - s->startCmd(); - e->undoResetProperty(id); - inspector->setInspectorEdit(true); - s->endCmd(); // this may remove element - inspector->setInspectorEdit(false); - inspector->update(s); + valueChanged(i, true); } //---------------------------------------------------------