Merge pull request #1996 from lasconic/scoreparts
command line option to export score and parts
This commit is contained in:
commit
33c959a43b
5 changed files with 128 additions and 30 deletions
|
@ -903,5 +903,34 @@ void cloneStaff2(Staff* srcStaff, Staff* dstStaff, int stick, int etick)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
QList<Excerpt*> Excerpt::createAllExcerpt(Score *score) {
|
||||
QList<Excerpt*> all;
|
||||
for (Part* part : score->parts()) {
|
||||
Excerpt* e = new Excerpt(score);
|
||||
e->parts().append(part);
|
||||
QString name = createName(part->partName(), all);
|
||||
e->setTitle(name);
|
||||
all.append(e);
|
||||
}
|
||||
return all;
|
||||
}
|
||||
|
||||
QString Excerpt::createName(const QString& partName, QList<Excerpt*> excerptList) {
|
||||
QString n = partName.simplified();
|
||||
QString name;
|
||||
int count = excerptList.count();
|
||||
for (int i = 0;; ++i) {
|
||||
name = i ? QString("%1-%2").arg(n).arg(i) : QString("%1").arg(n);
|
||||
Excerpt* ee = 0;
|
||||
for (int k = 0; k < count; ++k) {
|
||||
ee = excerptList[k];
|
||||
if (ee->title() == name)
|
||||
break;
|
||||
}
|
||||
if ((ee == 0) || (ee->title() != name))
|
||||
break;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,6 +51,9 @@ class Excerpt : public QObject {
|
|||
bool operator!=(const Excerpt&) const;
|
||||
QString title() const { return _title; }
|
||||
void setTitle(const QString& s) { _title = s; }
|
||||
|
||||
static QList<Excerpt*> createAllExcerpt(Score* score);
|
||||
static QString createName(const QString& partName, QList<Excerpt*>);
|
||||
};
|
||||
|
||||
extern void createExcerpt(Excerpt*);
|
||||
|
|
|
@ -146,21 +146,13 @@ void ExcerptsDialog::deleteClicked()
|
|||
|
||||
QString ExcerptsDialog::createName(const QString& partName)
|
||||
{
|
||||
QString n = partName.simplified();
|
||||
QString name;
|
||||
for (int i = 0;; ++i) {
|
||||
name = i ? QString("%1-%2").arg(n).arg(i) : QString("%1").arg(n);
|
||||
Excerpt* ee = 0;
|
||||
int n = excerptList->count();
|
||||
for (int k = 0; k < n; ++k) {
|
||||
ee = static_cast<ExcerptItem*>(excerptList->item(k))->excerpt();
|
||||
if (ee->title() == name)
|
||||
break;
|
||||
}
|
||||
if ((ee == 0) || (ee->title() != name))
|
||||
break;
|
||||
int count = excerptList->count();
|
||||
QList<Excerpt*> excerpts;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
Excerpt* ee = static_cast<ExcerptItem*>(excerptList->item(i))->excerpt();
|
||||
excerpts.append(ee);
|
||||
}
|
||||
return name;
|
||||
return Excerpt::createName(partName, excerpts);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -184,15 +176,11 @@ void ExcerptsDialog::newClicked()
|
|||
|
||||
void ExcerptsDialog::newAllClicked()
|
||||
{
|
||||
int n = partList->count();
|
||||
QList<Excerpt*> excerpts = Excerpt::createAllExcerpt(score);
|
||||
ExcerptItem* ei = 0;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
Excerpt* e = new Excerpt(score);
|
||||
PartItem* pi = static_cast<PartItem*>(partList->item(i));
|
||||
e->parts().append(pi->part());
|
||||
QString name = createName(pi->part()->partName());
|
||||
e->setTitle(name);
|
||||
excerptList->addItem(new ExcerptItem(e));
|
||||
for (Excerpt* e : excerpts) {
|
||||
ei = new ExcerptItem(e);
|
||||
excerptList->addItem(ei);
|
||||
}
|
||||
if (ei) {
|
||||
excerptList->selectionModel()->clearSelection();
|
||||
|
|
|
@ -1942,14 +1942,50 @@ bool MuseScore::savePdf(QList<Score*> cs, const QString& saveName)
|
|||
s->doLayout();
|
||||
}
|
||||
s->setPrinting(true);
|
||||
//
|
||||
// here we ignore the configured page offset
|
||||
//
|
||||
|
||||
// we ignore the configured page offset
|
||||
// we display page footer on all pages
|
||||
// we display page number on all pages
|
||||
int oldPageOffset = s->pageNumberOffset();
|
||||
s->setPageNumberOffset(pageOffset);
|
||||
bool oldFirstPageNumber = s->style(StyleIdx::footerFirstPage).toBool();
|
||||
bool footerFirstPage = s->style(StyleIdx::footerFirstPage).toBool();
|
||||
s->style()->set(StyleIdx::footerFirstPage, true);
|
||||
|
||||
QString evenFooterL = s->style()->value(StyleIdx::evenFooterL).toString();
|
||||
QString tmp = evenFooterL;
|
||||
tmp.replace("$p", "$P");
|
||||
s->style()->set(StyleIdx::evenFooterL, tmp);
|
||||
|
||||
QString evenFooterC = s->style()->value(StyleIdx::evenFooterC).toString();
|
||||
tmp = evenFooterC;
|
||||
tmp.replace("$p", "$P");
|
||||
s->style()->set(StyleIdx::evenFooterC, tmp);
|
||||
|
||||
QString evenFooterR = s->style()->value(StyleIdx::evenFooterR).toString();
|
||||
tmp = evenFooterR;
|
||||
tmp.replace("$p", "$P");
|
||||
s->style()->set(StyleIdx::evenFooterR, tmp);
|
||||
|
||||
QString oddFooterL = s->style()->value(StyleIdx::oddFooterL).toString();
|
||||
tmp = oddFooterL;
|
||||
tmp.replace("$p", "$P");
|
||||
s->style()->set(StyleIdx::oddFooterL, tmp);
|
||||
|
||||
QString oddFooterC = s->style()->value(StyleIdx::oddFooterC).toString();
|
||||
tmp = oddFooterC;
|
||||
tmp.replace("$p", "$P");
|
||||
s->style()->set(StyleIdx::oddFooterC, tmp);
|
||||
|
||||
QString oddFooterR = s->style()->value(StyleIdx::oddFooterR).toString();
|
||||
tmp = oddFooterR;
|
||||
tmp.replace("$p", "$P");
|
||||
s->style()->set(StyleIdx::oddFooterR, tmp);
|
||||
|
||||
if (layoutMode == LayoutMode::PAGE)
|
||||
s->startCmd();
|
||||
s->doLayout();
|
||||
if (layoutMode == LayoutMode::PAGE)
|
||||
s->endCmd(true);
|
||||
|
||||
const PageFormat* pf = s->pageFormat();
|
||||
printerDev.setPaperSize(pf->size(), QPrinter::Inch);
|
||||
|
@ -1967,8 +2003,19 @@ bool MuseScore::savePdf(QList<Score*> cs, const QString& saveName)
|
|||
//reset score
|
||||
s->setPrinting(false);
|
||||
s->setPageNumberOffset(oldPageOffset);
|
||||
s->style()->set(StyleIdx::footerFirstPage, oldFirstPageNumber);
|
||||
s->style()->set(StyleIdx::footerFirstPage, footerFirstPage);
|
||||
s->style()->set(StyleIdx::evenFooterL, evenFooterL);
|
||||
s->style()->set(StyleIdx::evenFooterC, evenFooterC);
|
||||
s->style()->set(StyleIdx::evenFooterR, evenFooterR);
|
||||
s->style()->set(StyleIdx::oddFooterL, oddFooterL);
|
||||
s->style()->set(StyleIdx::oddFooterC, oddFooterC);
|
||||
s->style()->set(StyleIdx::oddFooterR, oddFooterR);
|
||||
|
||||
if (layoutMode == LayoutMode::PAGE)
|
||||
s->startCmd();
|
||||
s->doLayout();
|
||||
if (layoutMode == LayoutMode::PAGE)
|
||||
s->endCmd(true);
|
||||
if (layoutMode != s->layoutMode())
|
||||
s->endCmd(true); // rollback
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@
|
|||
#include "libmscore/chordlist.h"
|
||||
#include "libmscore/volta.h"
|
||||
#include "libmscore/lasso.h"
|
||||
#include "libmscore/excerpt.h"
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
|
@ -131,6 +132,7 @@ double converterDpi = 0;
|
|||
double guiScaling = 1.0;
|
||||
int trimMargin = -1;
|
||||
bool noWebView = false;
|
||||
bool exportScoreParts = false;
|
||||
|
||||
QString mscoreGlobalShare;
|
||||
|
||||
|
@ -2088,8 +2090,31 @@ static bool processNonGui()
|
|||
return saveMxl(cs, fn);
|
||||
if (fn.endsWith(".mid"))
|
||||
return mscore->saveMidi(cs, fn);
|
||||
if (fn.endsWith(".pdf"))
|
||||
return mscore->savePdf(fn);
|
||||
if (fn.endsWith(".pdf")) {
|
||||
if (!exportScoreParts)
|
||||
return mscore->savePdf(fn);
|
||||
else {
|
||||
if (cs->excerpts().size() == 0) {
|
||||
QList<Excerpt*> exceprts = Excerpt::createAllExcerpt(cs);
|
||||
|
||||
foreach(Excerpt* e, exceprts) {
|
||||
Score* nscore = new Score(e->oscore());
|
||||
e->setPartScore(nscore);
|
||||
nscore->setName(e->title()); // needed before AddExcerpt
|
||||
nscore->style()->set(StyleIdx::createMultiMeasureRests, true);
|
||||
cs->startCmd();
|
||||
cs->undo(new AddExcerpt(nscore));
|
||||
createExcerpt(e);
|
||||
cs->endCmd();
|
||||
}
|
||||
}
|
||||
QList<Score*> scores;
|
||||
scores.append(cs);
|
||||
foreach(Excerpt* e, cs->excerpts())
|
||||
scores.append(e->partScore());
|
||||
return mscore->savePdf(scores, fn);
|
||||
}
|
||||
}
|
||||
if (fn.endsWith(".png"))
|
||||
return mscore->savePng(cs, fn);
|
||||
if (fn.endsWith(".svg"))
|
||||
|
@ -4510,6 +4535,7 @@ int main(int argc, char* av[])
|
|||
|
||||
parser.addHelpOption(); // -?, -h, --help
|
||||
parser.addVersionOption(); // -v, --version
|
||||
|
||||
//parser.addOption(QCommandLineOption({"v", "version"}, "Print version")); // see above
|
||||
parser.addOption(QCommandLineOption( "long-version", "Print detailed version information"));
|
||||
parser.addOption(QCommandLineOption({"d", "debug"}, "Debug mode"));
|
||||
|
@ -4535,6 +4561,8 @@ int main(int argc, char* av[])
|
|||
parser.addOption(QCommandLineOption({"t", "test-mode"}, "Set testMode flag for all files"));
|
||||
parser.addOption(QCommandLineOption({"M", "midi-operations"}, "Specify MIDI import operations file", "file"));
|
||||
parser.addOption(QCommandLineOption({"w", "no-webview"}, "No web view in start center"));
|
||||
parser.addOption(QCommandLineOption({"P", "export-score-parts"}, "used with -o <file>.pdf, export score + parts"));
|
||||
|
||||
parser.addPositionalArgument("scorefiles", "The files to open", "[scorefile...]");
|
||||
|
||||
parser.process(QCoreApplication::arguments());
|
||||
|
@ -4615,6 +4643,9 @@ int main(int argc, char* av[])
|
|||
preferences.midiImportOperations.setOperationsFile(temp);
|
||||
}
|
||||
noWebView = parser.isSet("w");
|
||||
exportScoreParts = parser.isSet("export-score-parts");
|
||||
if (exportScoreParts && !converterMode)
|
||||
parser.showHelp(EXIT_FAILURE);
|
||||
|
||||
QStringList argv = parser.positionalArguments();
|
||||
|
||||
|
|
Loading…
Reference in a new issue