Skip to content
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
26 changes: 21 additions & 5 deletions src/converter/internal/convertercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "global/io/file.h"
#include "global/io/dir.h"

#include "engraving/dom/masterscore.h"
#include "engraving/infrastructure/mscio.h"

#include "convertercodes.h"
Expand Down Expand Up @@ -127,7 +128,7 @@ Ret ConverterController::fileConvert(const muse::io::path_t& in, const muse::io:
const muse::UriQuery& extensionUri,
const std::optional<notation::TransposeOptions>& transposeOptions,
const std::optional<size_t>& pageNum, const std::vector<size_t>& visibleParts,
const muse::String& copyright)
const CopyrightInfo& copyright)
{
TRACEFUNC;

Expand Down Expand Up @@ -168,9 +169,13 @@ Ret ConverterController::fileConvert(const muse::io::path_t& in, const muse::io:
ConverterUtils::setVisibleParts(notationProject->masterNotation()->notation(), visibleParts);
}

if (!copyright.isEmpty()) {
if (!copyright.text.isEmpty()) {
if (copyright.showOnAllPages) {
notationProject->masterNotation()->masterScore()->style().set(mu::engraving::Sid::oddFooterC, "$c");
notationProject->masterNotation()->masterScore()->style().set(mu::engraving::Sid::evenFooterC, "$c");
}
ProjectMeta meta = notationProject->metaInfo();
meta.copyright += copyright;
meta.copyright += copyright.text;
notationProject->setMetaInfo(meta);
}

Expand Down Expand Up @@ -329,8 +334,19 @@ RetVal<ConverterController::BatchJob> ConverterController::parseBatchJob(const m

QJsonValue copyright = obj[u"copyright"];
if (!copyright.isUndefined()) {
if (copyright.isString()) {
job.copyright = copyright.toString();
if (copyright.isObject()) {
QJsonValue copyrightText = copyright[u"text"];
if (copyrightText.isUndefined()) {
rv.ret = make_ret(Err::BatchJobFileFailedParse, err.errorString().toStdString());
return rv;
}

job.copyright.text = copyrightText.toString();

QJsonValue showOnAllPages = copyright[u"showOnAllPages"];
if (!showOnAllPages.isUndefined() && showOnAllPages.isBool()) {
job.copyright.showOnAllPages = showOnAllPages.toBool();
}
} else {
rv.ret = make_ret(Err::BatchJobFileFailedParse, err.errorString().toStdString());
return rv;
Expand Down
10 changes: 7 additions & 3 deletions src/converter/internal/convertercontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,18 @@ class ConverterController : public IConverterController, public muse::Injectable

private:

struct CopyrightInfo {
muse::String text = {};
bool showOnAllPages = false;
};

struct Job {
muse::io::path_t in;
muse::io::path_t out;
std::optional<notation::TransposeOptions> transposeOptions;
std::optional<size_t> pageNum;
std::vector<size_t> visibleParts;
muse::String copyright;
CopyrightInfo copyright;
};

using BatchJob = std::vector<Job>;
Expand All @@ -91,8 +96,7 @@ class ConverterController : public IConverterController, public muse::Injectable

muse::Ret fileConvert(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {},
const muse::String& soundProfile = muse::String(),
const muse::UriQuery& extensionUri = muse::UriQuery(), const TransposeOpts& transposeOptions = std::nullopt, const std::optional<size_t>& pageNum = std::nullopt, const std::vector<size_t>& visibleParts = std::vector<size_t>(),
const muse::String& copyright = muse::String());
const muse::UriQuery& extensionUri = muse::UriQuery(), const TransposeOpts& transposeOptions = std::nullopt, const std::optional<size_t>& pageNum = std::nullopt, const std::vector<size_t>& visibleParts = std::vector<size_t>(), const CopyrightInfo& copyright = { {}, false });

muse::Ret convertScoreParts(project::INotationWriterPtr writer, notation::IMasterNotationPtr masterNotation,
const muse::io::path_t& out);
Expand Down
Loading