MuseScore/libmscore/keysig.cpp

605 lines
22 KiB
C++
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2002-2011 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#include "sym.h"
#include "staff.h"
#include "clef.h"
#include "keysig.h"
#include "measure.h"
2012-05-26 14:26:10 +02:00
#include "segment.h"
#include "score.h"
#include "undo.h"
2014-04-09 16:09:21 +02:00
#include "xml.h"
2012-05-26 14:26:10 +02:00
2013-05-13 18:49:17 +02:00
namespace Ms {
const char* keyNames[] = {
2012-05-26 14:26:10 +02:00
QT_TRANSLATE_NOOP("MuseScore", "G major, E minor"),
QT_TRANSLATE_NOOP("MuseScore", "Cb major, Ab minor"),
2012-05-26 14:26:10 +02:00
QT_TRANSLATE_NOOP("MuseScore", "D major, B minor"),
QT_TRANSLATE_NOOP("MuseScore", "Gb major, Eb minor"),
QT_TRANSLATE_NOOP("MuseScore", "A major, F# minor"),
QT_TRANSLATE_NOOP("MuseScore", "Db major, Bb minor"),
QT_TRANSLATE_NOOP("MuseScore", "E major, C# minor"),
QT_TRANSLATE_NOOP("MuseScore", "Ab major, F minor"),
QT_TRANSLATE_NOOP("MuseScore", "B major, G# minor"),
QT_TRANSLATE_NOOP("MuseScore", "Eb major, C minor"),
QT_TRANSLATE_NOOP("MuseScore", "F# major, D# minor"),
QT_TRANSLATE_NOOP("MuseScore", "Bb major, G minor"),
QT_TRANSLATE_NOOP("MuseScore", "C# major, A# minor"),
QT_TRANSLATE_NOOP("MuseScore", "F major, D minor"),
2015-02-08 22:22:28 +01:00
QT_TRANSLATE_NOOP("MuseScore", "C major, A minor"),
2015-02-09 16:19:17 +01:00
QT_TRANSLATE_NOOP("MuseScore", "Open/Atonal")
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
// KeySig
//---------------------------------------------------------
KeySig::KeySig(Score* s)
: Element(s)
{
setFlags(ElementFlag::SELECTABLE | ElementFlag::ON_STAFF);
2012-07-27 18:01:15 +02:00
_showCourtesy = true;
2014-06-26 23:17:25 +02:00
_hideNaturals = false;
2012-05-26 14:26:10 +02:00
}
KeySig::KeySig(const KeySig& k)
: Element(k)
{
_showCourtesy = k._showCourtesy;
_sig = k._sig;
2014-06-26 23:17:25 +02:00
_hideNaturals = false;
2012-05-26 14:26:10 +02:00
}
2013-05-28 15:42:02 +02:00
//---------------------------------------------------------
// mag
//---------------------------------------------------------
qreal KeySig::mag() const
{
2016-12-23 12:05:18 +01:00
return staff() ? staff()->mag(tick()) : 1.0;
2013-05-28 15:42:02 +02:00
}
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// add
//---------------------------------------------------------
2013-11-06 15:58:05 +01:00
void KeySig::addLayout(SymId sym, qreal x, int line)
2012-05-26 14:26:10 +02:00
{
2016-12-23 12:05:18 +01:00
qreal stepDistance = staff() ? staff()->lineDistance(tick()) * 0.5 : 0.5;
2014-09-06 11:03:25 +02:00
KeySym ks;
ks.sym = sym;
2015-08-06 23:29:55 +02:00
ks.spos = QPointF(x, qreal(line) * stepDistance);
_sig.keySymbols().append(ks);
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// layout
//---------------------------------------------------------
void KeySig::layout()
{
qreal _spatium = spatium();
setbbox(QRectF());
if (isCustom() && !isAtonal()) {
for (KeySym& ks: _sig.keySymbols()) {
2014-09-06 11:03:25 +02:00
ks.pos = ks.spos * _spatium;
addbbox(symBbox(ks.sym).translated(ks.pos));
2012-05-26 14:26:10 +02:00
}
return;
}
_sig.keySymbols().clear();
if (staff() && !staff()->genKeySig()) // no key sigs on TAB staves
return;
2012-05-26 14:26:10 +02:00
// determine current clef for this staff
2013-09-05 16:37:49 +02:00
ClefType clef = ClefType::G;
2012-05-26 14:26:10 +02:00
if (staff())
2014-05-08 17:59:24 +02:00
clef = staff()->clef(segment()->tick());
2012-05-26 14:26:10 +02:00
int accidentals = 0, naturals = 0;
2014-06-20 17:07:22 +02:00
int t1 = int(_sig.key());
2013-05-06 14:20:31 +02:00
switch (qAbs(t1)) {
2012-05-26 14:26:10 +02:00
case 7: accidentals = 0x7f; break;
case 6: accidentals = 0x3f; break;
case 5: accidentals = 0x1f; break;
case 4: accidentals = 0xf; break;
case 3: accidentals = 0x7; break;
case 2: accidentals = 0x3; break;
case 1: accidentals = 0x1; break;
case 0: accidentals = 0; break;
default:
2014-06-03 15:28:10 +02:00
qDebug("illegal t1 key %d", t1);
2012-05-26 14:26:10 +02:00
break;
}
// manage display of naturals:
// naturals are shown if there is some natural AND prev. measure has no section break
// AND style says they are not off
// OR key sig is CMaj/Amin (in which case they are always shown)
2014-06-03 15:28:10 +02:00
2014-06-26 23:17:25 +02:00
bool naturalsOn = false;
Measure* prevMeasure = measure() ? measure()->prevMeasure() : 0;
2014-06-26 23:17:25 +02:00
// If we're not force hiding naturals (Continuous panel), use score style settings
if (!_hideNaturals)
naturalsOn = (prevMeasure && !prevMeasure->sectionBreak()
&& (score()->styleI(StyleIdx::keySigNaturals) != int(KeySigNatural::NONE))) || (t1 == 0);
2014-06-03 15:28:10 +02:00
// Don't repeat naturals if shown in courtesy
2017-03-08 13:12:26 +01:00
if (prevMeasure && prevMeasure->findSegment(SegmentType::KeySigAnnounce, segment()->tick())
2016-03-02 13:20:19 +01:00
&& !segment()->isKeySigAnnounceType())
naturalsOn = false;
if (track() == -1)
naturalsOn = false;
2014-06-03 15:28:10 +02:00
int coffset = 0;
2014-06-20 17:07:22 +02:00
Key t2 = Key::C;
2014-06-03 15:28:10 +02:00
if (naturalsOn) {
2014-06-30 16:21:10 +02:00
t2 = staff()->key(segment()->tick() - 1);
2014-06-20 17:07:22 +02:00
if (t2 == Key::C)
2014-06-03 15:28:10 +02:00
naturalsOn = false;
else {
2014-06-20 17:07:22 +02:00
switch (qAbs(int(t2))) {
2014-06-03 15:28:10 +02:00
case 7: naturals = 0x7f; break;
case 6: naturals = 0x3f; break;
case 5: naturals = 0x1f; break;
case 4: naturals = 0xf; break;
case 3: naturals = 0x7; break;
case 2: naturals = 0x3; break;
case 1: naturals = 0x1; break;
case 0: naturals = 0; break;
default:
2015-10-27 11:30:09 +01:00
qDebug("illegal t2 key %d", int(t2));
2014-06-03 15:28:10 +02:00
break;
}
// remove redundant naturals
if (!((t1 > 0) ^ (t2 > 0)))
naturals &= ~accidentals;
if (t2 < 0)
coffset = 7;
}
}
// naturals should go BEFORE accidentals if style says so
// OR going from sharps to flats or vice versa (i.e. t1 & t2 have opposite signs)
bool prefixNaturals =
naturalsOn
2014-06-20 17:07:22 +02:00
&& (score()->styleI(StyleIdx::keySigNaturals) == int(KeySigNatural::BEFORE) || t1 * int(t2) < 0);
2014-06-03 15:28:10 +02:00
// naturals should go AFTER accidentals if they should not go before!
bool suffixNaturals = naturalsOn && !prefixNaturals;
const signed char* lines = ClefInfo::lines(clef);
2013-09-05 16:37:49 +02:00
// add prefixed naturals, if any
2014-06-03 15:28:10 +02:00
qreal xo = 0.0;
if (prefixNaturals) {
for (int i = 0; i < 7; ++i) {
2012-05-26 14:26:10 +02:00
if (naturals & (1 << i)) {
2013-11-06 15:58:05 +01:00
addLayout(SymId::accidentalNatural, xo, lines[i + coffset]);
xo += 1.0;
}
2012-05-26 14:26:10 +02:00
}
}
// add accidentals
2013-05-27 14:03:49 +02:00
static const qreal sspread = 1.0;
2013-05-27 11:48:05 +02:00
static const qreal fspread = 1.0;
2013-09-05 16:37:49 +02:00
2012-05-26 14:26:10 +02:00
switch(t1) {
2013-11-06 15:58:05 +01:00
case 7: addLayout(SymId::accidentalSharp, xo + 6.0 * sspread, lines[6]);
// fall through
2013-11-06 15:58:05 +01:00
case 6: addLayout(SymId::accidentalSharp, xo + 5.0 * sspread, lines[5]);
// fall through
2013-11-06 15:58:05 +01:00
case 5: addLayout(SymId::accidentalSharp, xo + 4.0 * sspread, lines[4]);
// fall through
2013-11-06 15:58:05 +01:00
case 4: addLayout(SymId::accidentalSharp, xo + 3.0 * sspread, lines[3]);
// fall through
2013-11-06 15:58:05 +01:00
case 3: addLayout(SymId::accidentalSharp, xo + 2.0 * sspread, lines[2]);
// fall through
2013-11-06 15:58:05 +01:00
case 2: addLayout(SymId::accidentalSharp, xo + 1.0 * sspread, lines[1]);
// fall through
2013-11-06 15:58:05 +01:00
case 1: addLayout(SymId::accidentalSharp, xo, lines[0]);
2012-05-26 14:26:10 +02:00
break;
2013-11-06 15:58:05 +01:00
case -7: addLayout(SymId::accidentalFlat, xo + 6.0 * fspread, lines[13]);
// fall through
2013-11-06 15:58:05 +01:00
case -6: addLayout(SymId::accidentalFlat, xo + 5.0 * fspread, lines[12]);
// fall through
2013-11-06 15:58:05 +01:00
case -5: addLayout(SymId::accidentalFlat, xo + 4.0 * fspread, lines[11]);
// fall through
2013-11-06 15:58:05 +01:00
case -4: addLayout(SymId::accidentalFlat, xo + 3.0 * fspread, lines[10]);
// fall through
2013-11-06 15:58:05 +01:00
case -3: addLayout(SymId::accidentalFlat, xo + 2.0 * fspread, lines[9]);
// fall through
2013-11-06 15:58:05 +01:00
case -2: addLayout(SymId::accidentalFlat, xo + 1.0 * fspread, lines[8]);
// fall through
2013-11-06 15:58:05 +01:00
case -1: addLayout(SymId::accidentalFlat, xo, lines[7]);
2012-05-26 14:26:10 +02:00
case 0:
break;
default:
2014-06-03 15:28:10 +02:00
qDebug("illegal t1 key %d", t1);
2012-05-26 14:26:10 +02:00
break;
}
// add suffixed naturals, if any
if (suffixNaturals) {
xo += qAbs(t1); // skip accidentals
2014-06-03 15:28:10 +02:00
if (t1 > 0) { // after sharps, add a little more space
xo += 0.15;
// if last sharp (t1) is above next natural (t1+1)...
2013-09-05 16:37:49 +02:00
if (lines[t1] < lines[t1+1])
xo += 0.2; // ... add more space
}
for (int i = 0; i < 7; ++i) {
if (naturals & (1 << i)) {
2013-11-06 15:58:05 +01:00
addLayout(SymId::accidentalNatural, xo, lines[i + coffset]);
xo += 1.0;
}
}
}
2012-05-26 14:26:10 +02:00
// compute bbox
for (KeySym& ks : _sig.keySymbols()) {
2014-09-06 11:03:25 +02:00
ks.pos = ks.spos * _spatium;
addbbox(symBbox(ks.sym).translated(ks.pos));
2012-05-26 14:26:10 +02:00
}
}
//---------------------------------------------------------
// set
//---------------------------------------------------------
void KeySig::draw(QPainter* p) const
{
p->setPen(curColor());
for (const KeySym& ks: _sig.keySymbols())
2014-09-06 11:03:25 +02:00
drawSymbol(ks.sym, p, QPointF(ks.pos.x(), ks.pos.y()));
2016-02-06 22:03:43 +01:00
if (!parent() && (isAtonal() || isCustom()) && _sig.keySymbols().empty()) {
// empty custom or atonal key signature - draw something for palette
2015-02-08 22:22:28 +01:00
p->setPen(Qt::gray);
drawSymbol(SymId::timeSigX, p, QPointF(symWidth(SymId::timeSigX) * -0.5, 2.0 * spatium()));
}
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// acceptDrop
//---------------------------------------------------------
2017-03-31 13:03:15 +02:00
bool KeySig::acceptDrop(EditData& data) const
2012-05-26 14:26:10 +02:00
{
2017-01-18 14:16:33 +01:00
return data.element->type() == ElementType::KEYSIG;
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// drop
//---------------------------------------------------------
2017-03-31 13:03:15 +02:00
Element* KeySig::drop(EditData& data)
2012-05-26 14:26:10 +02:00
{
2014-08-24 10:20:01 +02:00
KeySig* ks = static_cast<KeySig*>(data.element);
2017-01-18 14:16:33 +01:00
if (ks->type() != ElementType::KEYSIG) {
2014-08-24 10:20:01 +02:00
delete ks;
2012-05-26 14:26:10 +02:00
return 0;
}
KeySigEvent k = ks->keySigEvent();
delete ks;
2012-05-26 14:26:10 +02:00
if (data.modifiers & Qt::ControlModifier) {
// apply only to this stave
if (!(k == keySigEvent()))
score()->undoChangeKeySig(staff(), tick(), k);
2012-05-26 14:26:10 +02:00
}
else {
// apply to all staves:
2016-03-10 10:41:31 +01:00
foreach(Staff* s, score()->masterScore()->staves())
score()->undoChangeKeySig(s, tick(), k);
2012-05-26 14:26:10 +02:00
}
return this;
}
//---------------------------------------------------------
2014-06-03 15:28:10 +02:00
// setKey
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
2014-06-20 17:07:22 +02:00
void KeySig::setKey(Key key)
2012-05-26 14:26:10 +02:00
{
2014-06-05 11:37:21 +02:00
KeySigEvent e;
2014-06-20 17:07:22 +02:00
e.setKey(key);
2014-06-05 11:37:21 +02:00
setKeySigEvent(e);
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// write
//---------------------------------------------------------
2016-11-19 11:51:21 +01:00
void KeySig::write(XmlWriter& xml) const
2012-05-26 14:26:10 +02:00
{
xml.stag(name());
Element::writeProperties(xml);
if (_sig.isAtonal()) {
xml.tag("custom", 1);
}
else if (_sig.custom()) {
xml.tag("custom", 1);
for (const KeySym& ks : _sig.keySymbols()) {
2013-06-04 18:29:14 +02:00
xml.stag("KeySym");
2014-10-23 17:00:23 +02:00
xml.tag("sym", Sym::id2name(ks.sym));
2014-09-06 11:03:25 +02:00
xml.tag("pos", ks.spos);
2013-06-04 18:29:14 +02:00
xml.etag();
}
2012-05-26 14:26:10 +02:00
}
else {
2014-06-20 17:07:22 +02:00
xml.tag("accidental", int(_sig.key()));
2012-05-26 14:26:10 +02:00
}
switch (_sig.mode()) {
case KeyMode::NONE: xml.tag("mode", "none"); break;
case KeyMode::MAJOR: xml.tag("mode", "major"); break;
case KeyMode::MINOR: xml.tag("mode", "minor"); break;
case KeyMode::UNKNOWN:
default:
;
}
2013-06-04 18:29:14 +02:00
if (!_showCourtesy)
xml.tag("showCourtesySig", _showCourtesy);
xml.etag();
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// read
//---------------------------------------------------------
2013-01-11 18:10:18 +01:00
void KeySig::read(XmlReader& e)
2012-05-26 14:26:10 +02:00
{
_sig = KeySigEvent(); // invalidate _sig
int subtype = 0;
2013-01-11 18:10:18 +01:00
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
2012-05-26 14:26:10 +02:00
if (tag == "KeySym") {
2014-09-06 11:03:25 +02:00
KeySym ks;
2013-01-11 18:10:18 +01:00
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
2014-10-23 17:00:23 +02:00
if (tag == "sym") {
QString val(e.readElementText());
bool valid;
SymId id = SymId(val.toInt(&valid));
if (!valid)
id = Sym::name2id(val);
if (score()->mscVersion() <= 114) {
if (valid)
id = KeySig::convertFromOldId(val.toInt(&valid));
else
id = Sym::oldName2id(val);
}
2014-10-23 17:00:23 +02:00
ks.sym = id;
}
2012-05-26 14:26:10 +02:00
else if (tag == "pos")
2014-09-06 11:03:25 +02:00
ks.spos = e.readPoint();
2012-05-26 14:26:10 +02:00
else
2013-01-11 18:10:18 +01:00
e.unknown();
2012-05-26 14:26:10 +02:00
}
_sig.keySymbols().append(ks);
2012-05-26 14:26:10 +02:00
}
else if (tag == "showCourtesySig")
_showCourtesy = e.readInt();
else if (tag == "showNaturals") // obsolete
e.readInt();
2012-05-26 14:26:10 +02:00
else if (tag == "accidental")
2014-06-20 17:07:22 +02:00
_sig.setKey(Key(e.readInt()));
2014-06-03 15:28:10 +02:00
else if (tag == "natural") // obsolete
e.readInt();
else if (tag == "custom") {
e.readInt();
_sig.setCustom(true);
}
else if (tag == "mode") {
QString m(e.readElementText());
if (m == "none")
_sig.setMode(KeyMode::NONE);
else if (m == "major")
_sig.setMode(KeyMode::MAJOR);
else if (m == "minor")
_sig.setMode(KeyMode::MINOR);
else
_sig.setMode(KeyMode::UNKNOWN);
}
2012-05-26 14:26:10 +02:00
else if (tag == "subtype")
2013-01-11 18:10:18 +01:00
subtype = e.readInt();
2012-05-26 14:26:10 +02:00
else if (!Element::readProperties(e))
2013-01-11 18:10:18 +01:00
e.unknown();
2012-05-26 14:26:10 +02:00
}
// for backward compatibility
if (!_sig.isValid())
_sig.initFromSubtype(subtype);
2016-02-06 22:03:43 +01:00
if (_sig.custom() && _sig.keySymbols().empty())
_sig.setMode(KeyMode::NONE);
2012-05-26 14:26:10 +02:00
}
//---------------------------------------------------------
// convertFromOldId
//
// for import of 1.3 scores
//---------------------------------------------------------
SymId KeySig::convertFromOldId(int val) const
{
SymId symId = SymId::noSym;
switch (val) {
case 32: symId = SymId::accidentalSharp; break;
case 33: symId = SymId::accidentalThreeQuarterTonesSharpArrowUp; break;
case 34: symId = SymId::accidentalQuarterToneSharpArrowDown; break;
// case 35: // "sharp arrow both" missing in SMuFL
case 36: symId = SymId::accidentalQuarterToneSharpStein; break;
case 37: symId = SymId::accidentalBuyukMucennebSharp; break;
case 38: symId = SymId::accidentalKomaSharp; break;
case 39: symId = SymId::accidentalThreeQuarterTonesSharpStein; break;
case 40: symId = SymId::accidentalNatural; break;
case 41: symId = SymId::accidentalQuarterToneSharpNaturalArrowUp; break;
case 42: symId = SymId::accidentalQuarterToneFlatNaturalArrowDown; break;
// case 43: // "natural arrow both" missing in SMuFL
case 44: symId = SymId::accidentalFlat; break;
case 45: symId = SymId::accidentalQuarterToneFlatArrowUp; break;
case 46: symId = SymId::accidentalThreeQuarterTonesFlatArrowDown; break;
// case 47: // "flat arrow both" missing in SMuFL
case 48: symId = SymId::accidentalBakiyeFlat; break;
case 49: symId = SymId::accidentalBuyukMucennebFlat; break;
case 50: symId = SymId::accidentalThreeQuarterTonesFlatZimmermann; break;
case 51: symId = SymId::accidentalQuarterToneFlatStein; break;
// case 52: // "mirrored flat slash" missing in SMuFL
case 53: symId = SymId::accidentalDoubleFlat; break;
// case 54: // "flat flat slash" missing in SMuFL
case 55: symId = SymId::accidentalDoubleSharp; break;
case 56: symId = SymId::accidentalSori; break;
case 57: symId = SymId::accidentalKoron; break;
default:
qDebug("MuseScore 1.3 symbol id corresponding to <%d> not found", val);
symId = SymId::noSym;
break;
}
return symId;
}
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
// operator==
//---------------------------------------------------------
bool KeySig::operator==(const KeySig& k) const
{
return _sig == k._sig;
}
//---------------------------------------------------------
// changeKeySigEvent
//---------------------------------------------------------
void KeySig::changeKeySigEvent(const KeySigEvent& t)
{
if (_sig == t)
return;
setKeySigEvent(t);
}
//---------------------------------------------------------
// tick
//---------------------------------------------------------
int KeySig::tick() const
{
return segment() ? segment()->tick() : 0;
}
2012-07-27 18:01:15 +02:00
//---------------------------------------------------------
// undoSetShowCourtesy
//---------------------------------------------------------
void KeySig::undoSetShowCourtesy(bool v)
{
2016-06-09 09:26:13 +02:00
undoChangeProperty(P_ID::SHOW_COURTESY, v);
2012-07-27 18:01:15 +02:00
}
//---------------------------------------------------------
// getProperty
//---------------------------------------------------------
QVariant KeySig::getProperty(P_ID propertyId) const
{
2016-06-09 09:26:13 +02:00
switch (propertyId) {
2014-05-26 18:18:01 +02:00
case P_ID::SHOW_COURTESY: return int(showCourtesy());
2012-07-27 18:01:15 +02:00
default:
return Element::getProperty(propertyId);
}
}
//---------------------------------------------------------
// setProperty
//---------------------------------------------------------
bool KeySig::setProperty(P_ID propertyId, const QVariant& v)
{
2016-06-09 09:26:13 +02:00
switch (propertyId) {
2014-05-26 18:18:01 +02:00
case P_ID::SHOW_COURTESY:
if (generated())
return false;
2012-07-27 18:01:15 +02:00
setShowCourtesy(v.toBool());
break;
default:
if (!Element::setProperty(propertyId, v))
return false;
break;
}
2016-03-02 13:20:19 +01:00
score()->setLayoutAll();
2012-07-27 18:01:15 +02:00
setGenerated(false);
return true;
}
//---------------------------------------------------------
// propertyDefault
//---------------------------------------------------------
QVariant KeySig::propertyDefault(P_ID id) const
{
2016-06-09 09:26:13 +02:00
switch (id) {
case P_ID::SHOW_COURTESY: return true;
default:
return Element::propertyDefault(id);
2012-07-27 18:01:15 +02:00
}
}
//---------------------------------------------------------
// nextElement
//---------------------------------------------------------
Element* KeySig::nextElement()
{
return segment()->firstInNextSegments(staffIdx());
}
//---------------------------------------------------------
// prevElement
//---------------------------------------------------------
Element* KeySig::prevElement()
{
return segment()->lastInPrevSegments(staffIdx());
}
//---------------------------------------------------------
// accessibleInfo
//---------------------------------------------------------
2016-02-04 17:06:32 +01:00
QString KeySig::accessibleInfo() const
{
QString keySigType;
if (isAtonal())
return QString("%1: %2").arg(Element::accessibleInfo()).arg(qApp->translate("MuseScore", keyNames[15]));
else if (isCustom())
return QObject::tr("%1: Custom").arg(Element::accessibleInfo());
if (key() == Key::C)
return QString("%1: %2").arg(Element::accessibleInfo()).arg(qApp->translate("MuseScore", keyNames[14]));
int keyInt = static_cast<int>(key());
if (keyInt < 0)
keySigType = qApp->translate("MuseScore", keyNames[(7 + keyInt) * 2 + 1]);
else
keySigType = qApp->translate("MuseScore", keyNames[(keyInt - 1) * 2]);
return QString("%1: %2").arg(Element::accessibleInfo()).arg(keySigType);
}
2013-05-13 18:49:17 +02:00
}
2012-07-27 18:01:15 +02:00