Skip to content

Commit

Permalink
fix #25882
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed May 28, 2014
1 parent 2b832e8 commit 957d375
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 47 deletions.
2 changes: 1 addition & 1 deletion libmscore/edit.cpp
Expand Up @@ -1111,7 +1111,7 @@ void Score::deleteItem(Element* el)
{
if (!el)
return;
qDebug("deleteItem %s", el->name());
// qDebug("deleteItem %s", el->name());
switch (el->type()) {
case Element::ElementType::INSTRUMENT_NAME: {
Part* part = el->staff()->part();
Expand Down
2 changes: 0 additions & 2 deletions libmscore/pedal.cpp
Expand Up @@ -112,8 +112,6 @@ void PedalSegment::styleChanged()
Pedal::Pedal(Score* s)
: TextLine(s)
{
setBeginHook(true);
setEndHook(true);
setBeginHookHeight(Spatium(-1.2));
setEndHookHeight(Spatium(-1.2));

Expand Down
16 changes: 8 additions & 8 deletions libmscore/stafftype.cpp
Expand Up @@ -274,7 +274,7 @@ void StaffType::read(XmlReader& e)
else if (tag == "ledgerlines")
_showLedgerLines = e.readInt();
else if (tag == "durations")
setGenDurations(e.readInt() != 0);
setGenDurations(e.readBool());
else if (tag == "durationFontName")
setDurationFontName(e.readElementText());
else if (tag == "durationFontSize")
Expand All @@ -288,21 +288,21 @@ void StaffType::read(XmlReader& e)
else if (tag == "fretFontY")
setFretFontUserY(e.readDouble());
else if (tag == "linesThrough")
setLinesThrough(e.readInt() != 0);
setLinesThrough(e.readBool());
else if (tag == "minimStyle")
setMinimStyle( (TablatureMinimStyle) e.readInt() );
else if (tag == "onLines")
setOnLines(e.readInt() != 0);
setOnLines(e.readBool());
else if (tag == "showRests")
setShowRests(e.readInt() != 0);
setShowRests(e.readBool());
else if (tag == "stemsDown")
setStemsDown(e.readInt() != 0);
setStemsDown(e.readBool());
else if (tag == "stemsThrough")
setStemsThrough(e.readInt() != 0);
setStemsThrough(e.readBool());
else if (tag == "upsideDown")
setUpsideDown(e.readInt() != 0);
setUpsideDown(e.readBool());
else if (tag == "useNumbers")
setUseNumbers(e.readInt() != 0);
setUseNumbers(e.readBool());
else
e.unknown();
}
Expand Down
64 changes: 48 additions & 16 deletions libmscore/textline.cpp
Expand Up @@ -409,6 +409,45 @@ TextLine::~TextLine()
delete _endText;
}

//---------------------------------------------------------
// createBeginTextElement
//---------------------------------------------------------

void TextLine::createBeginTextElement()
{
if (!_beginText) {
_beginText = new Text(score());
_beginText->setParent(this);
_beginText->setTextStyleType(TEXT_STYLE_TEXTLINE);
}
}

//---------------------------------------------------------
// createContinueTextElement
//---------------------------------------------------------

void TextLine::createContinueTextElement()
{
if (!_continueText) {
_continueText = new Text(score());
_continueText->setParent(this);
_continueText->setTextStyleType(TEXT_STYLE_TEXTLINE);
}
}

//---------------------------------------------------------
// createEndTextElement
//---------------------------------------------------------

void TextLine::createEndTextElement()
{
if (!_endText) {
_endText = new Text(score());
_endText->setParent(this);
_endText->setTextStyleType(TEXT_STYLE_TEXTLINE);
}
}

//---------------------------------------------------------
// setBeginText
//---------------------------------------------------------
Expand All @@ -430,11 +469,7 @@ void TextLine::setBeginText(const QString& s)
_beginText = 0;
return;
}
if (!_beginText) {
_beginText = new Text(score());
_beginText->setParent(this);
_beginText->setTextStyleType(TEXT_STYLE_TEXTLINE);
}
createBeginTextElement();
_beginText->setText(s);
}

Expand All @@ -459,11 +494,7 @@ void TextLine::setContinueText(const QString& s)
_continueText = 0;
return;
}
if (!_continueText) {
_continueText = new Text(score());
_continueText->setParent(this);
_continueText->setTextStyleType(TEXT_STYLE_TEXTLINE);
}
createContinueTextElement();
_continueText->setText(s);
}

Expand All @@ -488,11 +519,12 @@ void TextLine::setEndText(const QString& s, int textStyle)

void TextLine::setEndText(const QString& s)
{
if (!_endText) {
_endText = new Text(score());
_endText->setParent(this);
_endText->setTextStyleType(TEXT_STYLE_TEXTLINE);
if (s.isEmpty()) {
delete _endText;
_endText = 0;
return;
}
createEndTextElement();
_endText->setText(s);
}

Expand Down Expand Up @@ -672,15 +704,15 @@ bool TextLine::readProperties(XmlReader& e)
const QStringRef& tag(e.name());

if (tag == "beginHook")
_beginHook = (e.readInt() != 0);
_beginHook = e.readBool();
else if (tag == "beginHookHeight") {
_beginHookHeight = Spatium(e.readDouble());
_beginHook = true;
}
else if (tag == "beginHookType")
_beginHookType = HookType(e.readInt());
else if (tag == "endHook")
_endHook = (e.readInt() != 0);
_endHook = e.readBool();
else if (tag == "endHookHeight" || tag == "hookHeight") { // hookHeight is obsolete
_endHookHeight = Spatium(e.readDouble());
_endHook = true;
Expand Down
5 changes: 5 additions & 0 deletions libmscore/textline.h
Expand Up @@ -108,13 +108,18 @@ class TextLine : public SLine {
Text* continueTextElement() const { return _continueText; }
Text* endTextElement() const { return _endText; }

void createBeginTextElement();
void createContinueTextElement();
void createEndTextElement();

void setBeginText(const QString& s, int style);
void setContinueText(const QString& s, int style);
void setEndText(const QString& s, int style);

void setBeginText(const QString&);
void setContinueText(const QString&);
void setEndText(const QString&);

QString beginText() const;
QString continueText() const;
QString endText() const;
Expand Down
1 change: 1 addition & 0 deletions libmscore/xml.h
Expand Up @@ -77,6 +77,7 @@ class XmlReader : public XmlStreamReader {
int readInt() { return readElementText().toInt(); }
int readInt(bool* ok) { return readElementText().toInt(ok); }
double readDouble() { return readElementText().toDouble(); }
bool readBool() { return readElementText().toInt() != 0; }
QPointF readPoint();
QSizeF readSize();
QRectF readRect();
Expand Down
44 changes: 25 additions & 19 deletions mscore/lineproperties.cpp
Expand Up @@ -136,27 +136,36 @@ void LineProperties::accept()
if (pt != otl->endTextPlace())
otl->undoChangeProperty(P_ID::END_TEXT_PLACE, int(pt));

if ((tl->beginTextElement() && !tl->beginTextElement()) || (beginText->text() != otl->beginText()))
if (beginText->text() != otl->beginText())
otl->undoChangeProperty(P_ID::BEGIN_TEXT, beginText->text());
if ((tl->continueTextElement() && !tl->continueTextElement()) || (continueText->text() != otl->continueText()))
else if (otl->beginText().isEmpty())
otl->setBeginText("");
if (continueText->text() != otl->continueText())
otl->undoChangeProperty(P_ID::CONTINUE_TEXT, continueText->text());
if ((tl->endTextElement() && !tl->endTextElement()) || (endText->text() != otl->endText()))
else if (otl->continueText().isEmpty())
otl->setContinueText("");
if (endText->text() != otl->endText())
otl->undoChangeProperty(P_ID::END_TEXT, endText->text());
else if (otl->endText().isEmpty())
otl->setEndText("");

// TODO: apply text style changes

Text* t = tl->beginTextElement();
if (t) {
Text* ot = otl->beginTextElement();
if (t->textStyleType() != ot->textStyleType())
ot->undoChangeProperty(P_ID::TEXT_STYLE_TYPE, t->textStyleType());
// TODO: only save style difference
if (t->textStyle() != ot->textStyle())
ot->undoChangeProperty(P_ID::TEXT_STYLE, QVariant::fromValue(t->textStyle()));
if (otl->beginTextElement()) {
otl->beginTextElement()->undoChangeProperty(P_ID::TEXT_STYLE_TYPE, tl->beginTextElement()->textStyleType());
otl->beginTextElement()->undoChangeProperty(P_ID::TEXT_STYLE, QVariant::fromValue(tl->beginTextElement()->textStyle()));
}

// ...
if (otl->continueTextElement()) {
otl->continueTextElement()->undoChangeProperty(P_ID::TEXT_STYLE_TYPE, tl->continueTextElement()->textStyleType());
otl->continueTextElement()->undoChangeProperty(P_ID::TEXT_STYLE, QVariant::fromValue(tl->continueTextElement()->textStyle()));
}

if (otl->endTextElement()) {
otl->endTextElement()->undoChangeProperty(P_ID::TEXT_STYLE_TYPE, tl->endTextElement()->textStyleType());
otl->endTextElement()->undoChangeProperty(P_ID::TEXT_STYLE, QVariant::fromValue(tl->endTextElement()->textStyle()));
}

// ...
QDialog::accept();
}

Expand All @@ -166,8 +175,7 @@ void LineProperties::accept()

void LineProperties::beginTextProperties()
{
if (!tl->beginTextElement())
tl->setBeginText(""); // create text element
tl->createBeginTextElement();
TextProperties t(tl->beginTextElement(), this);
t.exec();
}
Expand All @@ -178,8 +186,7 @@ void LineProperties::beginTextProperties()

void LineProperties::continueTextProperties()
{
if (!tl->continueTextElement())
tl->setContinueText(""); // create Text element
tl->createContinueTextElement();
TextProperties t(tl->continueTextElement(), this);
t.exec();
}
Expand All @@ -190,8 +197,7 @@ void LineProperties::continueTextProperties()

void LineProperties::endTextProperties()
{
if (!tl->endTextElement())
tl->setEndText(""); // create Text element
tl->createEndTextElement();
TextProperties t(tl->endTextElement(), this);
t.exec();
}
Expand Down
9 changes: 8 additions & 1 deletion mscore/menus.cpp
Expand Up @@ -812,28 +812,35 @@ Palette* MuseScore::newLinesPalette()
Pedal* pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setBeginText("<sym>keyboardPedalPed</sym>");
pedal->setBeginHook(false);
sp->append(pedal, QT_TRANSLATE_NOOP("Palette", "Pedal"));
pedal->setEndHook(true);

pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setBeginHook(true);
pedal->setEndHook(true);
sp->append(pedal, QT_TRANSLATE_NOOP("Palette", "Pedal"));

pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setBeginHook(true);
pedal->setEndHook(true);
pedal->setEndHookType(HookType::HOOK_45);
sp->append(pedal, QT_TRANSLATE_NOOP("Palette", "Pedal"));

pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setBeginHook(true);
pedal->setBeginHookType(HookType::HOOK_45);
pedal->setEndHook(true);
pedal->setEndHookType(HookType::HOOK_45);
sp->append(pedal, QT_TRANSLATE_NOOP("Palette", "Pedal"));

pedal = new Pedal(gscore);
pedal->setLen(w);
pedal->setBeginHook(true);
pedal->setBeginHookType(HookType::HOOK_45);
pedal->setEndHook(true);
sp->append(pedal, QT_TRANSLATE_NOOP("Palette", "Pedal"));

Trill* trill = new Trill(gscore);
Expand Down

0 comments on commit 957d375

Please sign in to comment.