Palette* MuseScore::newKeySigPalette(bool basic) { Palette* sp = new Palette; sp->setName(QT_TRANSLATE_NOOP("Palette", "Key Signatures")); sp->setMag(1.0); sp->setGrid(56, 64); sp->setYOffset(0.0); for (int i = 0; i < 7; ++i) { KeySig* k = new KeySig(gscore); k->setKey(Key(i + 1)); sp->append(k, qApp->translate("MuseScore", keyNames[i*2])); } for (int i = -7; i < 0; ++i) { KeySig* k = new KeySig(gscore); k->setKey(Key(i)); sp->append(k, qApp->translate("MuseScore", keyNames[(7 + i) * 2 + 1])); } KeySig* k = new KeySig(gscore); k->setKey(Key::C); sp->append(k, qApp->translate("MuseScore", keyNames[14])); if (!basic) { // atonal key signature KeySigEvent nke; nke.setKey(Key::C); nke.setCustom(true); nke.setMode(KeyMode::NONE); KeySig* nk = new KeySig(gscore); nk->setKeySigEvent(nke); sp->append(nk, qApp->translate("MuseScore", keyNames[15])); } return sp; }
void MCursor::addKeySig(Key key) { createMeasures(); Measure* measure = _score->tick2measure(_tick); Segment* segment = measure->getSegment(Segment::Type::KeySig, _tick); int n = _score->nstaves(); for (int i = 0; i < n; ++i) { KeySig* ks = new KeySig(_score); ks->setKey(key); ks->setTrack(i * VOICES); segment->add(ks); } }
Palette* MuseScore::newKeySigPalette() { Palette* sp = new Palette; sp->setName(QT_TRANSLATE_NOOP("Palette", "Key Signatures")); sp->setMag(1.0); sp->setGrid(56, 45); sp->setYOffset(1.0); for (int i = 0; i < 7; ++i) { KeySig* k = new KeySig(gscore); k->setKey(Key(i + 1)); sp->append(k, keyNames[i*2]); } for (int i = -7; i < 0; ++i) { KeySig* k = new KeySig(gscore); k->setKey(Key(i)); sp->append(k, keyNames[(7 + i) * 2 + 1]); } KeySig* k = new KeySig(gscore); k->setKey(Key::C); sp->append(k, keyNames[14]); return sp; }
void assignKeyListToStaff(const KeyList &kl, Staff *staff) { Score* score = staff->score(); const int track = staff->idx() * VOICES; Key pkey = Key::C; for (auto it = kl.begin(); it != kl.end(); ++it) { const int tick = it->first; Key key = it->second.key(); if ((key == Key::C) && (key == pkey)) // dont insert uneccessary C key continue; pkey = key; KeySig* ks = new KeySig(score); ks->setTrack(track); ks->setGenerated(false); ks->setKey(key); ks->setMag(staff->mag()); Measure* m = score->tick2measure(tick); Segment* seg = m->getSegment(ks, tick); seg->add(ks); } }