From 9c7e98145c127c94f66236de10ba67bffeaf7d23 Mon Sep 17 00:00:00 2001 From: Howard-C Date: Sun, 15 Dec 2019 18:10:22 +0800 Subject: [PATCH 1/2] fix #297738: "generate key signatures" in staff type change does not work `staff()->genKeySig()` always checks for `Fraction(0, 1)` while `staff()->staffType(tick())->genKeysig()` checks for the property at the exact tick. The patch also fixes the `StaffType` generation of tablature staves, making `genKeysig` default (and always) to false. --- libmscore/keysig.cpp | 2 +- libmscore/stafftype.cpp | 6 +++++- mscore/editstafftype.cpp | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libmscore/keysig.cpp b/libmscore/keysig.cpp index bfd263816628e..58f672697e288 100644 --- a/libmscore/keysig.cpp +++ b/libmscore/keysig.cpp @@ -101,7 +101,7 @@ void KeySig::layout() } _sig.keySymbols().clear(); - if (staff() && !staff()->genKeySig()) // no key sigs on TAB staves + if (staff() && !staff()->staffType(tick())->genKeysig()) return; // determine current clef for this staff diff --git a/libmscore/stafftype.cpp b/libmscore/stafftype.cpp index ef813d597b1b9..15276a44fc22d 100644 --- a/libmscore/stafftype.cpp +++ b/libmscore/stafftype.cpp @@ -87,6 +87,7 @@ StaffType::StaffType(StaffGroup sg, const QString& xml, const QString& name, int setShowBarlines(showBarLines); setStemless(stemless); setGenTimesig(genTimesig); + setGenKeysig(sg != StaffGroup::TAB); setDurationFontName(durFontName); setDurationFontSize(durFontSize); setDurationFontUserY(durFontUserY); @@ -273,6 +274,9 @@ void StaffType::read(XmlReader& e) _group = StaffGroup::STANDARD; } + if (_group == StaffGroup::TAB) + setGenKeysig(false); + while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "name") @@ -314,7 +318,7 @@ void StaffType::read(XmlReader& e) setDurationFontSize(e.readDouble()); else if (tag == "durationFontY") setDurationFontUserY(e.readDouble()); - else if (tag == "fretFontName") + else if (tag == "fretFontName") setFretFontName(e.readElementText()); else if (tag == "fretFontSize") setFretFontSize(e.readDouble()); diff --git a/mscore/editstafftype.cpp b/mscore/editstafftype.cpp index 5d138b848c8ca..8af11946051b0 100644 --- a/mscore/editstafftype.cpp +++ b/mscore/editstafftype.cpp @@ -412,6 +412,7 @@ void EditStaffType::setFromDlg() staffType.setStemsDown(stemBelowRadio->isChecked()); staffType.setStemsThrough(stemThroughRadio->isChecked()); if (staffType.group() == StaffGroup::TAB) { + staffType.setGenKeysig(false); staffType.setStemless(true); // assume no note values staffType.setGenDurations(false); // " " if (noteValuesSymb->isChecked()) From 406566c0f9c534f5ac7861e6882f9394394bdb8c Mon Sep 17 00:00:00 2001 From: Howard-C Date: Wed, 25 Dec 2019 21:10:43 +0800 Subject: [PATCH 2/2] disable "Generate key signatures" button for staff type change applied to tablature staff --- mscore/inspector/inspector.cpp | 27 +++++++++++++++++++++++++++ mscore/inspector/inspector.h | 1 + 2 files changed, 28 insertions(+) diff --git a/mscore/inspector/inspector.cpp b/mscore/inspector/inspector.cpp index 385fc5bfb5348..11dc61cd1cd49 100644 --- a/mscore/inspector/inspector.cpp +++ b/mscore/inspector/inspector.cpp @@ -72,6 +72,8 @@ #include "libmscore/accidental.h" #include "libmscore/articulation.h" #include "libmscore/fermata.h" +#include "libmscore/stafftypechange.h" +#include "libmscore/mscore.h" #include "libmscore/stafftextbase.h" namespace Ms { @@ -502,6 +504,31 @@ InspectorStaffTypeChange::InspectorStaffTypeChange(QWidget* parent) mapSignals(); } +//--------------------------------------------------------- +// setElement +//--------------------------------------------------------- + +void InspectorStaffTypeChange::setElement() + { + InspectorBase::setElement(); + bool hasTabStaff = false; + bool hasNonTabStaff = false; + for (Element* el : *(inspector->el())) { + StaffTypeChange* stc = toStaffTypeChange(el); + // tab staff shouldn't have key signature + if (stc->staffType()->group() == StaffGroup::TAB) { + hasTabStaff = true; + sl.genKeysig->setEnabled(false); + sl.resetGenKeysig->setEnabled(false); + } + else { + hasNonTabStaff = true; + } + } + if (hasTabStaff && !hasNonTabStaff) + sl.genKeysig->setChecked(false); + } + //--------------------------------------------------------- // InspectorVBox //--------------------------------------------------------- diff --git a/mscore/inspector/inspector.h b/mscore/inspector/inspector.h index 8cbe9ed041c43..bb2709d891b7c 100644 --- a/mscore/inspector/inspector.h +++ b/mscore/inspector/inspector.h @@ -104,6 +104,7 @@ class InspectorStaffTypeChange : public InspectorBase { public: InspectorStaffTypeChange(QWidget* parent); + virtual void setElement() override; }; //---------------------------------------------------------