Skip to content

Commit

Permalink
make sure to be in page mode when converting to graphical format or c…
Browse files Browse the repository at this point in the history
…reating thumbnail
  • Loading branch information
lasconic committed Jul 8, 2015
1 parent e5f3119 commit 858ddb2
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 22 deletions.
8 changes: 8 additions & 0 deletions libmscore/scorefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,12 @@ void Score::saveCompressedFile(QFileInfo& info, bool onlySelection)

QImage Score::createThumbnail()
{
LayoutMode layoutMode = _layoutMode;
if (layoutMode != LayoutMode::PAGE) {
startCmd();
undo(new ChangeLayoutMode(this, LayoutMode::PAGE));
doLayout();
}
Page* page = pages().at(0);
QRectF fr = page->abbox();
qreal mag = 256.0 / qMax(fr.width(), fr.height());
Expand All @@ -489,6 +495,8 @@ QImage Score::createThumbnail()
p.scale(mag, mag);
print(&p, 0);
p.end();
if (layoutMode != _layoutMode)
endCmd(true); // rollback
return pm;
}

Expand Down
10 changes: 10 additions & 0 deletions mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1839,10 +1839,20 @@ bool MuseScore::saveAs(Score* cs, bool saveCopy, const QString& path, const QStr
rv = saveMp3(cs, fn);
#endif
else if (ext == "spos") {
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
// save positions of segments
rv = savePositions(cs, fn, true);
}
else if (ext == "mpos") {
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
// save positions of measures
rv = savePositions(cs, fn, false);
}
Expand Down
89 changes: 67 additions & 22 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2058,12 +2058,13 @@ static bool processNonGui()
if (!converterMode)
return res;
}

bool rv = true;
if (converterMode) {
QString fn(outFileName);
Score* cs = mscore->currentScore();
if (!cs)
return false;
LayoutMode layoutMode = cs->layoutMode();
if (!styleFile.isEmpty()) {
QFile f(styleFile);
if (f.open(QIODevice::ReadOnly)) {
Expand All @@ -2080,7 +2081,7 @@ static bool processNonGui()
}
return true;
}
if (fn.endsWith(".mscz")) {
else if (fn.endsWith(".mscz")) {
QFileInfo fi(fn);
try {
cs->saveCompressedFile(fi, false);
Expand All @@ -2090,15 +2091,33 @@ static bool processNonGui()
}
return true;
}
if (fn.endsWith(".xml"))
return saveXml(cs, fn);
if (fn.endsWith(".mxl"))
return saveMxl(cs, fn);
if (fn.endsWith(".mid"))
else if (fn.endsWith(".xml")) {
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
rv = saveXml(cs, fn);
}
else if (fn.endsWith(".mxl")) {
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
rv = saveMxl(cs, fn);
}
else if (fn.endsWith(".mid"))
return mscore->saveMidi(cs, fn);
if (fn.endsWith(".pdf")) {
if (!exportScoreParts)
return mscore->savePdf(fn);
else if (fn.endsWith(".pdf")) {
if (!exportScoreParts) {
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
rv = mscore->savePdf(fn);
}
else {
if (cs->excerpts().size() == 0) {
QList<Excerpt*> exceprts = Excerpt::createAllExcerpt(cs);
Expand All @@ -2121,30 +2140,56 @@ static bool processNonGui()
return mscore->savePdf(scores, fn);
}
}
if (fn.endsWith(".png"))
return mscore->savePng(cs, fn);
if (fn.endsWith(".svg"))
return mscore->saveSvg(cs, fn);
else if (fn.endsWith(".png")) {
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
rv = mscore->savePng(cs, fn);
}
else if (fn.endsWith(".svg")) {
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
rv = mscore->saveSvg(cs, fn);
}
#ifdef HAS_AUDIOFILE
if (fn.endsWith(".wav") || fn.endsWith(".ogg") || fn.endsWith(".flac"))
else if (fn.endsWith(".wav") || fn.endsWith(".ogg") || fn.endsWith(".flac"))
return mscore->saveAudio(cs, fn);
#endif
#ifdef USE_LAME
if (fn.endsWith(".mp3"))
else if (fn.endsWith(".mp3"))
return mscore->saveMp3(cs, fn);
#endif
if (fn.endsWith(".spos"))
return savePositions(cs, fn, true);
if (fn.endsWith(".mpos"))
return savePositions(cs, fn, false);
if (fn.endsWith(".mlog"))
else if (fn.endsWith(".spos")) {
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
rv = savePositions(cs, fn, true);
}
else if (fn.endsWith(".mpos")) {
if (layoutMode != LayoutMode::PAGE) {
cs->startCmd();
cs->undo(new ChangeLayoutMode(cs, LayoutMode::PAGE));
cs->doLayout();
}
rv = savePositions(cs, fn, false);
}
else if (fn.endsWith(".mlog"))
return cs->sanityCheck(fn);
else {
qDebug("dont know how to convert to %s", qPrintable(outFileName));
return false;
}
if (layoutMode != cs->layoutMode())
cs->endCmd(true); // rollback
}
return true;
return rv;
}

//---------------------------------------------------------
Expand Down

0 comments on commit 858ddb2

Please sign in to comment.