Skip to content

Commit 3342fd9

Browse files
Reuse OpenParams
1 parent 6f182ab commit 3342fd9

File tree

9 files changed

+74
-93
lines changed

9 files changed

+74
-93
lines changed

src/converter/convertertypes.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,9 @@
2121
*/
2222
#pragma once
2323

24-
#include "global/containers.h"
25-
#include "global/io/path.h"
24+
#include "project/types/projecttypes.h"
2625

2726
namespace mu::converter {
28-
struct OpenParams {
29-
OpenParams() {}
30-
31-
muse::io::path_t stylePath;
32-
bool forceMode = false;
33-
bool unrollRepeats = false;
34-
};
35-
3627
struct ConvertRegion {
3728
struct Position {
3829
size_t staffIdx = muse::nidx;
@@ -45,4 +36,5 @@ struct ConvertRegion {
4536
using ConvertRegionJson = std::string;
4637
using page_num_t = size_t;
4738
using ConvertTarget = std::variant<ConvertRegionJson, page_num_t>;
39+
using OpenParams = project::OpenParams;
4840
}

src/converter/internal/compat/backendapi.cpp

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ static const std::string META_DATA_NAME = "metadata";
6767
static const std::string DEV_INFO_NAME = "devinfo";
6868

6969
static constexpr bool ADD_SEPARATOR = true;
70-
static constexpr auto NO_STYLE = "";
7170

7271
static ScoreElementScanner::Options parseScoreElementScannerOptions(const std::string& json)
7372
{
@@ -104,13 +103,11 @@ static ScoreElementScanner::Options parseScoreElementScannerOptions(const std::s
104103
}
105104

106105
Ret BackendApi::exportScoreMedia(const muse::io::path_t& in, const muse::io::path_t& out, const muse::io::path_t& highlightConfigPath,
107-
const muse::io::path_t& stylePath,
108-
bool forceMode,
109-
bool unrollRepeats)
106+
const OpenParams& openParams)
110107
{
111108
TRACEFUNC
112109

113-
RetVal<INotationProjectPtr> prj = openProject(in, stylePath, forceMode, unrollRepeats);
110+
RetVal<INotationProjectPtr> prj = openProject(in, openParams);
114111
if (!prj.ret) {
115112
return prj.ret;
116113
}
@@ -139,12 +136,11 @@ Ret BackendApi::exportScoreMedia(const muse::io::path_t& in, const muse::io::pat
139136
return result ? make_ret(Ret::Code::Ok) : make_ret(Ret::Code::InternalError);
140137
}
141138

142-
Ret BackendApi::exportScoreMeta(const muse::io::path_t& in, const muse::io::path_t& out, const muse::io::path_t& stylePath,
143-
bool forceMode, bool unrollRepeats)
139+
Ret BackendApi::exportScoreMeta(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams)
144140
{
145141
TRACEFUNC
146142

147-
RetVal<INotationProjectPtr> prj = openProject(in, stylePath, forceMode, unrollRepeats);
143+
RetVal<INotationProjectPtr> prj = openProject(in, openParams);
148144
if (!prj.ret) {
149145
return prj.ret;
150146
}
@@ -161,12 +157,11 @@ Ret BackendApi::exportScoreMeta(const muse::io::path_t& in, const muse::io::path
161157
return result ? make_ret(Ret::Code::Ok) : make_ret(Ret::Code::InternalError);
162158
}
163159

164-
Ret BackendApi::exportScoreParts(const muse::io::path_t& in, const muse::io::path_t& out, const muse::io::path_t& stylePath,
165-
bool forceMode, bool unrollRepeats)
160+
Ret BackendApi::exportScoreParts(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams)
166161
{
167162
TRACEFUNC
168163

169-
RetVal<INotationProjectPtr> prj = openProject(in, stylePath, forceMode, unrollRepeats);
164+
RetVal<INotationProjectPtr> prj = openProject(in, openParams);
170165
if (!prj.ret) {
171166
return prj.ret;
172167
}
@@ -181,12 +176,11 @@ Ret BackendApi::exportScoreParts(const muse::io::path_t& in, const muse::io::pat
181176
return ret;
182177
}
183178

184-
Ret BackendApi::exportScorePartsPdfs(const muse::io::path_t& in, const muse::io::path_t& out, const muse::io::path_t& stylePath,
185-
bool forceMode, bool unrollRepeats)
179+
Ret BackendApi::exportScorePartsPdfs(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams)
186180
{
187181
TRACEFUNC
188182

189-
RetVal<INotationProjectPtr> prj = openProject(in, stylePath, forceMode, unrollRepeats);
183+
RetVal<INotationProjectPtr> prj = openProject(in, openParams);
190184
if (!prj.ret) {
191185
return prj.ret;
192186
}
@@ -204,12 +198,11 @@ Ret BackendApi::exportScorePartsPdfs(const muse::io::path_t& in, const muse::io:
204198
}
205199

206200
Ret BackendApi::exportScoreTranspose(const muse::io::path_t& in, const muse::io::path_t& out, const std::string& optionsJson,
207-
const muse::io::path_t& stylePath,
208-
bool forceMode, bool unrollRepeats)
201+
const OpenParams& openParams)
209202
{
210203
TRACEFUNC
211204

212-
RetVal<INotationProjectPtr> prj = openProject(in, stylePath, forceMode, unrollRepeats);
205+
RetVal<INotationProjectPtr> prj = openProject(in, openParams);
213206
if (!prj.ret) {
214207
return prj.ret;
215208
}
@@ -232,11 +225,11 @@ Ret BackendApi::exportScoreTranspose(const muse::io::path_t& in, const muse::io:
232225
}
233226

234227
Ret BackendApi::exportScoreElements(const muse::io::path_t& in, const muse::io::path_t& out, const std::string& optionsJson,
235-
const muse::io::path_t& stylePath, bool forceMode)
228+
const OpenParams& openParams)
236229
{
237230
TRACEFUNC;
238231

239-
RetVal<INotationProjectPtr> prj = openProject(in, stylePath, forceMode);
232+
RetVal<INotationProjectPtr> prj = openProject(in, openParams);
240233
if (!prj.ret) {
241234
return prj.ret;
242235
}
@@ -262,10 +255,7 @@ Ret BackendApi::openOutputFile(QFile& file, const muse::io::path_t& out)
262255
return ok ? make_ret(Ret::Code::Ok) : make_ret(Ret::Code::InternalError);
263256
}
264257

265-
RetVal<project::INotationProjectPtr> BackendApi::openProject(const muse::io::path_t& path,
266-
const muse::io::path_t& stylePath,
267-
bool forceMode,
268-
bool unrollRepeats)
258+
RetVal<project::INotationProjectPtr> BackendApi::openProject(const muse::io::path_t& path, const OpenParams& params)
269259
{
270260
TRACEFUNC
271261

@@ -274,7 +264,7 @@ RetVal<project::INotationProjectPtr> BackendApi::openProject(const muse::io::pat
274264
return make_ret(Ret::Code::InternalError);
275265
}
276266

277-
Ret ret = notationProject->load(path, stylePath, forceMode, unrollRepeats);
267+
Ret ret = notationProject->load(path, params);
278268
if (!ret) {
279269
LOGE() << "failed load: " << path << ", ret: " << ret.toString();
280270
return make_ret(Ret::Code::InternalError);
@@ -840,7 +830,10 @@ void BackendApi::initPotentialExcerpts(notation::IMasterNotationPtr masterNotati
840830

841831
Ret BackendApi::updateSource(const muse::io::path_t& in, const std::string& newSource, bool forceMode)
842832
{
843-
RetVal<INotationProjectPtr> project = openProject(in, NO_STYLE, forceMode);
833+
OpenParams openParams;
834+
openParams.forceMode = forceMode;
835+
836+
RetVal<INotationProjectPtr> project = openProject(in, openParams);
844837
if (!project.ret) {
845838
return project.ret;
846839
}

src/converter/internal/compat/backendapi.h

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* MuseScore Studio
66
* Music Composition & Notation
77
*
8-
* Copyright (C) 2021 MuseScore Limited
8+
* Copyright (C) 2025 MuseScore Limited
99
*
1010
* This program is free software: you can redistribute it and/or modify
1111
* it under the terms of the GNU General Public License version 3 as
@@ -19,8 +19,8 @@
1919
* You should have received a copy of the GNU General Public License
2020
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2121
*/
22-
#ifndef MU_CONVERTER_BACKENDAPI_H
23-
#define MU_CONVERTER_BACKENDAPI_H
22+
23+
#pragma once
2424

2525
#include <QFile>
2626

@@ -34,6 +34,8 @@
3434
#include "project/iprojectcreator.h"
3535
#include "project/inotationwritersregister.h"
3636

37+
#include "converter/convertertypes.h"
38+
3739
namespace mu::engraving {
3840
class Score;
3941
}
@@ -49,26 +51,22 @@ class BackendApi
4951

5052
public:
5153
static muse::Ret exportScoreMedia(const muse::io::path_t& in, const muse::io::path_t& out, const muse::io::path_t& highlightConfigPath,
52-
const muse::io::path_t& stylePath = "", bool forceMode = false, bool unrollRepeats = false);
53-
static muse::Ret exportScoreMeta(const muse::io::path_t& in, const muse::io::path_t& out, const muse::io::path_t& stylePath,
54-
bool forceMode = false, bool unrollRepeats = false);
55-
static muse::Ret exportScoreParts(const muse::io::path_t& in, const muse::io::path_t& out, const muse::io::path_t& stylePath,
56-
bool forceMode = false, bool unrollRepeats = false);
57-
static muse::Ret exportScorePartsPdfs(const muse::io::path_t& in, const muse::io::path_t& out, const muse::io::path_t& stylePath,
58-
bool forceMode = false, bool unrollRepeats = false);
54+
const OpenParams& openParams = {});
55+
static muse::Ret exportScoreMeta(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {});
56+
static muse::Ret exportScoreParts(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {});
57+
static muse::Ret exportScorePartsPdfs(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams = {});
5958
static muse::Ret exportScoreTranspose(const muse::io::path_t& in, const muse::io::path_t& out, const std::string& optionsJson,
60-
const muse::io::path_t& stylePath, bool forceMode = false, bool unrollRepeats = false);
59+
const OpenParams& openParams = {});
6160

6261
static muse::Ret exportScoreElements(const muse::io::path_t& in, const muse::io::path_t& out, const std::string& optionsJson,
63-
const muse::io::path_t& stylePath, bool forceMode = false);
62+
const OpenParams& openParams = {});
6463

6564
static muse::Ret updateSource(const muse::io::path_t& in, const std::string& newSource, bool forceMode = false);
6665

6766
private:
6867
static muse::Ret openOutputFile(QFile& file, const muse::io::path_t& out);
6968

70-
static muse::RetVal<project::INotationProjectPtr> openProject(const muse::io::path_t& path,
71-
const muse::io::path_t& stylePath = muse::io::path_t(), bool forceMode = false, bool unrollRepeats = false);
69+
static muse::RetVal<project::INotationProjectPtr> openProject(const muse::io::path_t& path, const OpenParams& params = {});
7270

7371
static QVariantMap readBeatsColors(const muse::io::path_t& filePath);
7472

@@ -106,5 +104,3 @@ class BackendApi
106104
static void initPotentialExcerpts(notation::IMasterNotationPtr masterNotation);
107105
};
108106
}
109-
110-
#endif // MU_CONVERTER_BACKENDAPI_H

src/converter/internal/convertercontroller.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Ret ConverterController::fileConvert(const muse::io::path_t& in, const muse::io:
147147
return make_ret(Err::UnknownError);
148148
}
149149

150-
Ret ret = notationProject->load(in, openParams.stylePath, openParams.forceMode, openParams.unrollRepeats);
150+
Ret ret = notationProject->load(in, openParams);
151151
if (!ret) {
152152
LOGE() << "failed load notation, err: " << ret.toString() << ", path: " << in;
153153
return make_ret(Err::InFileFailedLoad);
@@ -251,7 +251,7 @@ Ret ConverterController::convertScoreParts(const muse::io::path_t& in, const mus
251251
return make_ret(Err::ConvertTypeUnknown);
252252
}
253253

254-
Ret ret = notationProject->load(in, openParams.stylePath, openParams.forceMode, openParams.unrollRepeats);
254+
Ret ret = notationProject->load(in, openParams);
255255
if (!ret) {
256256
LOGE() << "failed load notation, err: " << ret.toString() << ", path: " << in;
257257
return make_ret(Err::InFileFailedLoad);
@@ -622,44 +622,44 @@ Ret ConverterController::exportScoreMedia(const muse::io::path_t& in, const muse
622622
{
623623
TRACEFUNC;
624624

625-
return BackendApi::exportScoreMedia(in, out, highlightConfigPath, openParams.stylePath, openParams.forceMode, openParams.unrollRepeats);
625+
return BackendApi::exportScoreMedia(in, out, highlightConfigPath, openParams);
626626
}
627627

628628
Ret ConverterController::exportScoreMeta(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams)
629629
{
630630
TRACEFUNC;
631631

632-
return BackendApi::exportScoreMeta(in, out, openParams.stylePath, openParams.forceMode, openParams.unrollRepeats);
632+
return BackendApi::exportScoreMeta(in, out, openParams);
633633
}
634634

635635
Ret ConverterController::exportScoreParts(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams)
636636
{
637637
TRACEFUNC;
638638

639-
return BackendApi::exportScoreParts(in, out, openParams.stylePath, openParams.forceMode, openParams.unrollRepeats);
639+
return BackendApi::exportScoreParts(in, out, openParams);
640640
}
641641

642642
Ret ConverterController::exportScorePartsPdfs(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams)
643643
{
644644
TRACEFUNC;
645645

646-
return BackendApi::exportScorePartsPdfs(in, out, openParams.stylePath, openParams.forceMode, openParams.unrollRepeats);
646+
return BackendApi::exportScorePartsPdfs(in, out, openParams);
647647
}
648648

649649
Ret ConverterController::exportScoreTranspose(const muse::io::path_t& in, const muse::io::path_t& out, const std::string& optionsJson,
650650
const OpenParams& openParams)
651651
{
652652
TRACEFUNC;
653653

654-
return BackendApi::exportScoreTranspose(in, out, optionsJson, openParams.stylePath, openParams.forceMode, openParams.unrollRepeats);
654+
return BackendApi::exportScoreTranspose(in, out, optionsJson, openParams);
655655
}
656656

657657
Ret ConverterController::exportScoreElements(const muse::io::path_t& in, const muse::io::path_t& out, const std::string& optionsJson,
658658
const OpenParams& openParams)
659659
{
660660
TRACEFUNC;
661661

662-
return BackendApi::exportScoreElements(in, out, optionsJson, openParams.stylePath, openParams.forceMode);
662+
return BackendApi::exportScoreElements(in, out, optionsJson, openParams);
663663
}
664664

665665
Ret ConverterController::exportScoreVideo(const muse::io::path_t& in, const muse::io::path_t& out, const OpenParams& openParams)
@@ -677,7 +677,7 @@ Ret ConverterController::exportScoreVideo(const muse::io::path_t& in, const muse
677677
return make_ret(Err::ConvertTypeUnknown);
678678
}
679679

680-
Ret ret = notationProject->load(in, openParams.stylePath, openParams.forceMode, openParams.unrollRepeats);
680+
Ret ret = notationProject->load(in, openParams);
681681
if (!ret) {
682682
LOGE() << "failed load notation, err: " << ret.toString() << ", path: " << in;
683683
return make_ret(Err::InFileFailedLoad);

src/project/inotationproject.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ class INotationProject
4545
virtual QString displayName() const = 0;
4646
virtual muse::async::Notification displayNameChanged() const = 0;
4747

48-
virtual muse::Ret load(const muse::io::path_t& path,
49-
const muse::io::path_t& stylePath = muse::io::path_t(), bool forceMode = false, bool unrollRepeats = false,
50-
const std::string& format = "") = 0;
51-
48+
virtual muse::Ret load(const muse::io::path_t& path, const OpenParams& params = {}, const std::string& format = "") = 0;
5249
virtual muse::Ret createNew(const ProjectCreateOptions& projectInfo) = 0;
5350

5451
virtual bool isCloudProject() const = 0;

0 commit comments

Comments
 (0)