当使用快捷键向乐谱中添加低八度(8vb)符号时,添加的符号显示结果为高八度符号。
调试找到,通过快捷键添加低八度符号时。依次通过一下接口。
ScoreView::cmd("add-8vb"); (scoreview.cpp,1980行)
Score::cmd(const QAction* a, EditData& ed); (cmd.cpp,360行)
Score::cmdAddOttava(OttavaType::OTTAVA_8VB); (edit.cpp,1322行)
cmdAddOttava
函数内容,其中注释有XXY ADD
的两行就是解决BUG的代码。需要在元素设置过属性以后再修改一下样式。
void Score::cmdAddOttava(OttavaType type)
{
const Selection sel = selection(); // copy selection state before the operation.
// add on each staff if possible
if (sel.isRange() && sel.staffStart() != sel.staffEnd() - 1) {
for (int staffIdx = sel.staffStart() ; staffIdx < sel.staffEnd(); ++staffIdx) {
ChordRest* cr1 = sel.firstChordRest(staffIdx * VOICES);
ChordRest* cr2 = sel.lastChordRest(staffIdx * VOICES);
if (!cr1)
continue;
if (cr2 == 0)
cr2 = cr1;
Ottava* ottava = new Ottava(this);
ottava->setOttavaType(type);
ottava->setTrack(cr1->track());
ottava->setTrack2(cr1->track());
ottava->setTick(cr1->tick());
ottava->setTick2(cr2->tick() + cr2->actualTicks());
ottava->styleChanged(); //XXY ADD 修改元素样式
undoAddElement(ottava);
}
}
else {
ChordRest* cr1;
ChordRest* cr2;
getSelectedChordRest2(&cr1, &cr2);
if (!cr1)
return;
if (cr2 == 0)
cr2 = cr1;
Ottava* ottava = new Ottava(this);
ottava->setOttavaType(type);
ottava->setTrack(cr1->track());
ottava->setTrack2(cr1->track());
ottava->setTick(cr1->tick());
ottava->setTick2(cr2->tick() + cr2->actualTicks());
ottava->styleChanged(); //XXY ADD 修改元素样式
undoAddElement(ottava);
if (!noteEntryMode())
select(ottava, SelectType::SINGLE, 0);
}
}