Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync 3.5_backend branch with 3.x branch #6484

Merged
merged 5 commits into from
Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions build/Linux+BSD/mscore.1.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.\" New manual page for MuseScore 3
.\" Copyright (c) 2018, 2019
.\" Copyright (c) 2018, 2019, 2020
.\" mirabilos <m@mirbsd.org>
.\" Published under the same terms as MuseScore itself.
.\"-
.Dd June 18, 2019
.Dd Septemper 06, 2020
.Dt @MAN_MSCORE_UPPER@ 1
.Os MuseScore
.Sh NAME@Variables_substituted_by_CMAKE_on_installation@
Expand Down Expand Up @@ -47,8 +47,11 @@
.Op Fl \-revert\-settings
.Op Fl \-run\-test\-script
.Op Fl \-score\-media
.Op Fl \-highlight\-config
.Op Fl \-score\-mp3
.Op Fl \-score\-parts
.Op Fl \-score\-parts\-pdf
.Op Fl \-score\-transpose
.Op Fl \-template\-mode
.Op Fl \-test\-mode
.Op Fl \-version
Expand Down Expand Up @@ -247,12 +250,20 @@ Run script tests listed in the command line arguments
.It Fl \-score\-media
Export all media (except MP3) for a given score
as a single JSON document to stdout
.It Fl \-highlight\-config
Set highlight to svg, generated from a given score
.It Fl \-score\-mp3
Generates an MP3 for the given score and exports it
Generate an MP3 for the given score and export it
as a single JSON document to stdout
.It Fl \-score\-parts
Generate parts data for the given score and save them
to separate mscz files
.It Fl \-score\-parts\-pdf
Generates parts data for the given score and exports it
Generate parts data for the given score and export it
as a single JSON document to stdout
.It Fl \-score\-transpose
Transpose the given score and export the data to
a single JSON file, print it to stdout
.It Fl \-template\-mode
Save files in template mode (e.g. without page sizes)
.El
Expand Down Expand Up @@ -511,7 +522,7 @@ SMuFL (Standard Music Font Layout 1.20)
MuseScore was split off the MusE sequencer in 2002 and has since
become the foremost Open Source notation software.
.Sh AUTHORS
MuseScore is developed by Werner Schweer and others.
MuseScore is developed by MuseScore BVBA and others.
.Pp
This manual page was written by
.An mirabilos Aq tg@debian.org .
Expand Down
2 changes: 1 addition & 1 deletion libmscore/glissando.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NICE-TO-HAVE TODO:
and SlurSegment::changeAnchor() in slur.cpp as models)
*/

#include "log.h"
#include "global/log.h"

#include "arpeggio.h"
#include "glissando.h"
Expand Down
2 changes: 1 addition & 1 deletion libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Implementation of most part of class Measure.
*/

#include "log.h"
#include "global/log.h"

#include "measure.h"
#include "accidental.h"
Expand Down
2 changes: 1 addition & 1 deletion libmscore/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <assert.h>

#include "log.h"
#include "global/log.h"

#include "note.h"
#include "score.h"
Expand Down
2 changes: 1 addition & 1 deletion libmscore/rendermidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include "utils.h"
#include "sym.h"
#include "synthesizerstate.h"
#include "log.h"
#include "global/log.h"

#include "audio/midi/event.h"
#include "mscore/preferences.h"
Expand Down
2 changes: 1 addition & 1 deletion libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ class Score : public QObject, public ScoreElement {
bool saveFile(QFileInfo& info);
bool saveFile(QIODevice* f, bool msczFormat, bool onlySelection = false);
bool saveCompressedFile(QFileInfo&, bool onlySelection, bool createThumbnail = true);
bool saveCompressedFile(QIODevice *, const QFileInfo &, bool onlySelection, bool createThumbnail = true);
bool saveCompressedFile(QIODevice*, const QString& fileName, bool onlySelection, bool createThumbnail = true);

void print(QPainter* printer, int page);
ChordRest* getSelectedChordRest() const;
Expand Down
10 changes: 6 additions & 4 deletions libmscore/scorefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ bool MasterScore::saveFile(bool generateBackup)
}
#endif
else {
rv = Score::saveCompressedFile(&temp, info, false);
QString fileName = info.completeBaseName() + ".mscx";
rv = Score::saveCompressedFile(&temp, fileName, false);
}

if (!rv) {
Expand Down Expand Up @@ -528,7 +529,9 @@ bool Score::saveCompressedFile(QFileInfo& info, bool onlySelection, bool createT
MScore::lastError = tr("Open File\n%1\nfailed: %2").arg(info.filePath(), strerror(errno));
return false;
}
return saveCompressedFile(&fp, info, onlySelection, createThumbnail);

QString fileName = info.completeBaseName() + ".mscx";
return saveCompressedFile(&fp, fileName, onlySelection, createThumbnail);
}

//---------------------------------------------------------
Expand Down Expand Up @@ -578,11 +581,10 @@ QImage Score::createThumbnail()
// file is already opened
//---------------------------------------------------------

bool Score::saveCompressedFile(QIODevice* f, const QFileInfo& info, bool onlySelection, bool doCreateThumbnail)
bool Score::saveCompressedFile(QIODevice* f, const QString& fn, bool onlySelection, bool doCreateThumbnail)
{
MQZipWriter uz(f);

QString fn = info.completeBaseName() + ".mscx";
QBuffer cbuf;
cbuf.open(QIODevice::ReadWrite);
XmlWriter xml(this, &cbuf);
Expand Down
2 changes: 1 addition & 1 deletion libmscore/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Implementation of class Selection plus other selection related functions.
*/

#include "log.h"
#include "global/log.h"

#include "mscore.h"
#include "arpeggio.h"
Expand Down
2 changes: 1 addition & 1 deletion libmscore/slurtie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// the file LICENCE.GPL
//=============================================================================

#include "log.h"
#include "global/log.h"

#include "measure.h"
#include "score.h"
Expand Down
2 changes: 1 addition & 1 deletion libmscore/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include "textframe.h"
#include "stafflines.h"
#include "bracketItem.h"
#include "log.h"
#include "global/log.h"

namespace Ms {

Expand Down
2 changes: 1 addition & 1 deletion libmscore/textedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// the file LICENCE.GPL
//=============================================================================

#include "log.h"
#include "global/log.h"
#include "textedit.h"
#include "score.h"

Expand Down
2 changes: 2 additions & 0 deletions libmscore/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,6 @@ Q_DECLARE_METATYPE(Ms::PlayEventType);

Q_DECLARE_METATYPE(Ms::AccidentalType);

Q_DECLARE_METATYPE(Ms::HPlacement);

#endif
2 changes: 1 addition & 1 deletion libmscore/undo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
between startUndo() and endUndo().
*/

#include "log.h"
#include "global/log.h"
#include "undo.h"
#include "element.h"
#include "note.h"
Expand Down
2 changes: 1 addition & 1 deletion libmscore/xml.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class XmlWriter : public QTextStream {

int assignLocalIndex(const Location& mainElementLocation);
void setLidLocalIndex(int lid, int localIndex) { _lidLocalIndices.insert(lid, localIndex); }
int lidLocalIndex(int lid) const { Q_ASSERT(_lidLocalIndices.contains(lid)); return _lidLocalIndices[lid]; }
int lidLocalIndex(int lid) const { return _lidLocalIndices[lid]; }

const std::vector<std::pair<const ScoreElement*, QString>>& elements() const { return _elements; }
void setRecordElements(bool record) { _recordElements = record; }
Expand Down
80 changes: 72 additions & 8 deletions mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2943,7 +2943,7 @@ QString MuseScore::getWallpaper(const QString& caption)
// [This file is currently undergoing a bunch of changes, and that's the kind
// [of edit that must be coordinated with the MuseScore master code base.
//
bool MuseScore::saveSvg(Score* score, const QString& saveName)
bool MuseScore::saveSvg(Score* score, const QString& saveName, const NotesColors& notesColors)
{
const QList<Page*>& pl = score->pages();
int pages = pl.size();
Expand Down Expand Up @@ -2982,19 +2982,56 @@ bool MuseScore::saveSvg(Score* score, const QString& saveName)
QFile f(fileName);
if (!f.open(QIODevice::WriteOnly))
return false;
bool rv = saveSvg(score, &f, pageNumber);
bool rv = saveSvg(score, &f, pageNumber, /* drawPageBackground */ false, notesColors);

if (!rv)
return false;
}
return true;
}

//---------------------------------------------------------
// MuseScore::readNotesColors
/// Read notes colors from json file
//---------------------------------------------------------

NotesColors MuseScore::readNotesColors(const QString& filePath) const
{
if (filePath.isEmpty()) {
return NotesColors();
}

QFile file;
file.setFileName(filePath);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QString content = file.readAll();
file.close();

QJsonDocument document = QJsonDocument::fromJson(content.toUtf8());
QJsonObject obj = document.object();
QJsonArray colors = obj.value("highlight").toArray();

NotesColors result;

for (const QJsonValue& colorObj: colors) {
QJsonObject obj = colorObj.toObject();
QJsonArray notesIndexes = obj.value("notes").toArray();
QColor notesColor = QColor(obj.value("color").toString());

for (const QJsonValue& index: notesIndexes) {
result.insert(index.toInt(), notesColor);
}
}

return result;
}

//---------------------------------------------------------
// MuseScore::saveSvg
/// Save a single page
//---------------------------------------------------------

bool MuseScore::saveSvg(Score* score, QIODevice* device, int pageNumber, bool drawPageBackground)
bool MuseScore::saveSvg(Score* score, QIODevice* device, int pageNumber, bool drawPageBackground, const NotesColors& notesColors)
{
QString title(score->title());
score->setPrinting(true);
Expand Down Expand Up @@ -3089,6 +3126,16 @@ bool MuseScore::saveSvg(Score* score, QIODevice* device, int pageNumber, bool dr
QList<Element*> pel = page->elements();
qStableSort(pel.begin(), pel.end(), elementLessThan);
ElementType eType;

int lastNoteIndex = -1;
for (int i = 0; i < pageNumber; ++i) {
for (const Element* element: score->pages()[i]->elements()) {
if (element->type() == ElementType::NOTE) {
lastNoteIndex++;
}
}
}

for (const Element* e : pel) {
// Always exclude invisible elements
if (!e->visible())
Expand All @@ -3107,7 +3154,21 @@ bool MuseScore::saveSvg(Score* score, QIODevice* device, int pageNumber, bool dr
printer.setElement(e);

// Paint it
paintElement(p, e);
if (e->type() == ElementType::NOTE) {
QColor color = e->color();
int currentNoteIndex = (++lastNoteIndex);

if (notesColors.contains(currentNoteIndex)) {
color = notesColors[currentNoteIndex];
}

Element *note = dynamic_cast<const Note*>(e)->clone();
note->setColor(color);
paintElement(p, note);
delete note;
} else {
paintElement(p, e);
}
}
p.end(); // Writes MuseScore SVG file to disk, finally

Expand Down Expand Up @@ -3431,7 +3492,7 @@ QByteArray MuseScore::exportPdfAsJSON(Score* score)
// exportAllMediaFiles
//---------------------------------------------------------

bool MuseScore::exportAllMediaFiles(const QString& inFilePath, const QString& outFilePath)
bool MuseScore::exportAllMediaFiles(const QString& inFilePath, const QString& highlightConfigPath, const QString& outFilePath)
{
std::unique_ptr<MasterScore> score(mscore->readScore(inFilePath));
if (!score)
Expand Down Expand Up @@ -3471,7 +3532,10 @@ bool MuseScore::exportAllMediaFiles(const QString& inFilePath, const QString& ou
QByteArray svgData;
QBuffer svgDevice(&svgData);
svgDevice.open(QIODevice::ReadWrite);
res &= mscore->saveSvg(score.get(), &svgDevice, i, /* drawPageBackground */ true);

NotesColors notesColors = readNotesColors(highlightConfigPath);
res &= mscore->saveSvg(score.get(), &svgDevice, i, /* drawPageBackground */ true, notesColors);

bool lastArrayValue = ((score->pages().size() - 1) == i);
jsonWriter.addValue(svgData.toBase64(), lastArrayValue);
}
Expand Down Expand Up @@ -3640,8 +3704,8 @@ bool MuseScore::exportTransposedScoreToJSON(const QString& inFilePath, const QSt
bool saved = false;
QTemporaryFile tmpFile(QString("%1_transposed.XXXXXX.mscz").arg(score->title()));
if (tmpFile.open()) {
QFileInfo fi(tmpFile.fileName());
saved = score->Score::saveCompressedFile(&tmpFile, fi, /* onlySelection */ false);
QString fileName = QFileInfo(tmpFile.fileName()).completeBaseName() + + ".mscx";
saved = score->Score::saveCompressedFile(&tmpFile, fileName, /* onlySelection */ false);
tmpFile.close();
tmpFile.open();
jsonWriter.addValue(tmpFile.readAll().toBase64());
Expand Down
Loading