diff --git a/importexport/musicxml/exportxml.cpp b/importexport/musicxml/exportxml.cpp index 62aa13c98862..eef4ccbce82c 100644 --- a/importexport/musicxml/exportxml.cpp +++ b/importexport/musicxml/exportxml.cpp @@ -6209,7 +6209,10 @@ void ExportMusicXml::findAndExportClef(const Measure* const m, const int staves, // exception: at tick=0, export clef anyway if ((tick.isZero() || !cle->generated()) && ((seg->measure() != m) || ((seg->segmentType() == SegmentType::HeaderClef) && !cle->otherClef()))) { clefDebug("exportxml: clef exported"); - clef(sstaff, cle->clefType(), color2xml(cle)); + QString clefAttr = color2xml(cle); + if (!cle->visible()) + clefAttr += " print-object=\"no\""; + clef(sstaff, cle->clefType(), clefAttr); } else { clefDebug("exportxml: clef not exported"); @@ -6433,14 +6436,15 @@ void ExportMusicXml::writeElement(Element* el, const Measure* m, int sstaff, boo // these will be output at the start of the next measure const auto cle = toClef(el); const auto ti = cle->segment()->tick(); + const QString visible = (!cle->visible()) ? " print-object=\"no\"" : ""; clefDebug("exportxml: clef in measure ti=%d ct=%d gen=%d", ti, int(cle->clefType()), el->generated()); if (el->generated()) { clefDebug("exportxml: generated clef not exported"); } else if (!el->generated() && tickIsInMiddleOfMeasure(ti, m)) - clef(sstaff, cle->clefType(), color2xml(cle)); + clef(sstaff, cle->clefType(), color2xml(cle) + visible); else if (!el->generated() && (ti == m->tick()) && (cle->segment()->segmentType() != SegmentType::HeaderClef)) - clef(sstaff, cle->clefType(), color2xml(cle) + QString(" after-barline=\"yes\"")); + clef(sstaff, cle->clefType(), color2xml(cle) + visible + QString(" after-barline=\"yes\"")); else clefDebug("exportxml: clef not exported"); } diff --git a/importexport/musicxml/importmxmlpass2.cpp b/importexport/musicxml/importmxmlpass2.cpp index 6c7c75fadf03..73860e68baf8 100644 --- a/importexport/musicxml/importmxmlpass2.cpp +++ b/importexport/musicxml/importmxmlpass2.cpp @@ -4826,8 +4826,9 @@ void MusicXMLParserPass2::clef(const QString& partId, Measure* measure, const Fr int i = 0; int line = -1; - QString strClefno = _e.attributes().value("number").toString(); + const QString strClefno = _e.attributes().value("number").toString(); const bool afterBarline = _e.attributes().value("after-barline") == "yes"; + const bool printObject = _e.attributes().value("print-object") != "no"; while (_e.readNextStartElement()) { if (_e.name() == "sign") @@ -4904,7 +4905,7 @@ void MusicXMLParserPass2::clef(const QString& partId, Measure* measure, const Fr } else if (c == "TAB") { clef = ClefType::TAB; - st= StaffTypes::TAB_DEFAULT; + st = StaffTypes::TAB_DEFAULT; } else qDebug("clef: unknown clef ", qPrintable(c), line, i); // TODO @@ -4932,6 +4933,7 @@ void MusicXMLParserPass2::clef(const QString& partId, Measure* measure, const Fr Clef* clefs = new Clef(_score); clefs->setClefType(clef); + clefs->setVisible(printObject); int track = _pass1.trackForPart(partId) + clefno * VOICES; clefs->setTrack(track); Segment* s; diff --git a/mtest/musicxml/io/testInvisibleElements.xml b/mtest/musicxml/io/testInvisibleElements.xml index ffe9266836b5..67c83362594c 100644 --- a/mtest/musicxml/io/testInvisibleElements.xml +++ b/mtest/musicxml/io/testInvisibleElements.xml @@ -43,7 +43,7 @@ 4 4 - + G 2