Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include "qmlpluginapi.h"
24 :
25 : #include <QQmlEngine>
26 : #include <QJSValueIterator>
27 :
28 : #include "engraving/compat/scoreaccess.h"
29 : #include "engraving/dom/factory.h"
30 : #include "engraving/dom/interval.h"
31 : #include "engraving/dom/masterscore.h"
32 : #include "engraving/types/types.h"
33 :
34 : #include "notation/inotation.h"
35 : #include "notation/inotationelements.h" // IWYU pragma: keep
36 : #include "notationscene/notationcommands.h"
37 :
38 : // api
39 : #include "engravingapiv1.h"
40 : #include "rcommand/commandtypes.h"
41 : #include "score.h"
42 : #include "instrument.h"
43 : #include "cursor.h"
44 : #include "elements.h"
45 : #include "selection.h"
46 : #include "util.h"
47 :
48 : #include "log.h"
49 :
50 : using namespace mu::engraving;
51 : using namespace mu::engraving::apiv1;
52 :
53 : Enum* PluginAPI::elementTypeEnum = nullptr;
54 : Enum* PluginAPI::accidentalTypeEnum = nullptr;
55 : Enum* PluginAPI::accidentalBracketEnum = nullptr;
56 : Enum* PluginAPI::ornamentStyleEnum = nullptr;
57 : Enum* PluginAPI::alignEnum = nullptr;
58 : Enum* PluginAPI::placementEnum = nullptr;
59 : Enum* PluginAPI::placementHEnum = nullptr;
60 : Enum* PluginAPI::textPlaceEnum = nullptr;
61 : Enum* PluginAPI::directionEnum = nullptr;
62 : Enum* PluginAPI::directionHEnum = nullptr;
63 : Enum* PluginAPI::orientationEnum = nullptr;
64 : Enum* PluginAPI::autoOnOffEnum = nullptr;
65 : Enum* PluginAPI::autoCustomHideEnum = nullptr;
66 : Enum* PluginAPI::voiceAssignmentEnum = nullptr;
67 : Enum* PluginAPI::spacerTypeEnum = nullptr;
68 : Enum* PluginAPI::layoutBreakTypeEnum = nullptr;
69 : Enum* PluginAPI::durationTypeEnum = nullptr;
70 : Enum* PluginAPI::noteValueTypeEnum = nullptr;
71 : Enum* PluginAPI::beamModeEnum = nullptr;
72 : Enum* PluginAPI::glissandoTypeEnum = nullptr;
73 : Enum* PluginAPI::glissandoStyleEnum = nullptr;
74 : Enum* PluginAPI::harmonyTypeEnum = nullptr;
75 : Enum* PluginAPI::harmonyVoicingEnum = nullptr;
76 : Enum* PluginAPI::hDurationEnum = nullptr;
77 : Enum* PluginAPI::frameTypeEnum = nullptr;
78 : Enum* PluginAPI::verticalAlignmentEnum = nullptr;
79 : Enum* PluginAPI::tremoloBarTypeEnum = nullptr;
80 : Enum* PluginAPI::preferSharpFlatEnum = nullptr;
81 : Enum* PluginAPI::noteHeadTypeEnum = nullptr;
82 : Enum* PluginAPI::noteHeadSchemeEnum = nullptr;
83 : Enum* PluginAPI::noteHeadGroupEnum = nullptr;
84 : Enum* PluginAPI::noteTypeEnum = nullptr;
85 : Enum* PluginAPI::playEventTypeEnum = nullptr;
86 : Enum* PluginAPI::segmentTypeEnum = nullptr;
87 : Enum* PluginAPI::barLineTypeEnum = nullptr;
88 : Enum* PluginAPI::tidEnum = nullptr;
89 : Enum* PluginAPI::lyricsSyllabicEnum = nullptr;
90 : Enum* PluginAPI::spannerAnchorEnum = nullptr;
91 : Enum* PluginAPI::mMRestRangeBracketTypeEnum = nullptr;
92 : Enum* PluginAPI::tupletNumberTypeEnum = nullptr;
93 : Enum* PluginAPI::tupletBracketTypeEnum = nullptr;
94 : Enum* PluginAPI::tripletFeelTypeEnum = nullptr;
95 : Enum* PluginAPI::guitarBendTypeEnum = nullptr;
96 : Enum* PluginAPI::guitarBendShowHoldLineEnum = nullptr;
97 : Enum* PluginAPI::clefTypeEnum = nullptr;
98 : Enum* PluginAPI::clefToBarlinePositionEnum = nullptr;
99 : Enum* PluginAPI::dynamicTypeEnum = nullptr;
100 : Enum* PluginAPI::dynamicSpeedEnum = nullptr;
101 : Enum* PluginAPI::lineTypeEnum = nullptr;
102 : Enum* PluginAPI::hookTypeEnum = nullptr;
103 : Enum* PluginAPI::keyModeEnum = nullptr;
104 : Enum* PluginAPI::arpeggioTypeEnum = nullptr;
105 : Enum* PluginAPI::intervalStepEnum = nullptr;
106 : Enum* PluginAPI::intervalTypeEnum = nullptr;
107 : Enum* PluginAPI::instrumentLabelVisibilityEnum = nullptr;
108 : Enum* PluginAPI::ornamentShowAccidentalEnum = nullptr;
109 : Enum* PluginAPI::partialSpannerDirectionEnum = nullptr;
110 : Enum* PluginAPI::chordStylePresetEnum = nullptr;
111 : Enum* PluginAPI::playingTechniqueTypeEnum = nullptr;
112 : Enum* PluginAPI::gradualTempoChangeTypeEnum = nullptr;
113 : Enum* PluginAPI::changeMethodEnum = nullptr;
114 : Enum* PluginAPI::changeDirectionEnum = nullptr;
115 : Enum* PluginAPI::accidentalRoleEnum = nullptr;
116 : Enum* PluginAPI::accidentalValEnum = nullptr;
117 : Enum* PluginAPI::fermataTypeEnum = nullptr;
118 : Enum* PluginAPI::chordLineTypeEnum = nullptr;
119 : Enum* PluginAPI::slurStyleTypeEnum = nullptr;
120 : Enum* PluginAPI::tremoloTypeEnum = nullptr;
121 : Enum* PluginAPI::tremoloChordTypeEnum = nullptr;
122 : Enum* PluginAPI::bracketTypeEnum = nullptr;
123 : Enum* PluginAPI::jumpTypeEnum = nullptr;
124 : Enum* PluginAPI::markerTypeEnum = nullptr;
125 : Enum* PluginAPI::measureNumberModeEnum = nullptr;
126 : Enum* PluginAPI::staffGroupEnum = nullptr;
127 : Enum* PluginAPI::ottavaTypeEnum = nullptr;
128 : Enum* PluginAPI::hairpinTypeEnum = nullptr;
129 : Enum* PluginAPI::trillTypeEnum = nullptr;
130 : Enum* PluginAPI::vibratoTypeEnum = nullptr;
131 : Enum* PluginAPI::articulationTextTypeEnum = nullptr;
132 : Enum* PluginAPI::lyricsDashSystemStartEnum = nullptr;
133 : Enum* PluginAPI::noteLineEndPlacementEnum = nullptr;
134 : Enum* PluginAPI::spannerSegmentTypeEnum = nullptr;
135 : Enum* PluginAPI::tiePlacementEnum = nullptr;
136 : Enum* PluginAPI::tieDotsPlacementEnum = nullptr;
137 : Enum* PluginAPI::timeSigTypeEnum = nullptr;
138 : Enum* PluginAPI::timeSigPlacementEnum = nullptr;
139 : Enum* PluginAPI::timeSigStyleEnum = nullptr;
140 : Enum* PluginAPI::timeSigVSMarginEnum = nullptr;
141 : Enum* PluginAPI::noteSpellingTypeEnum = nullptr;
142 : Enum* PluginAPI::keyEnum = nullptr;
143 : Enum* PluginAPI::updateModeEnum = nullptr;
144 : Enum* PluginAPI::layoutFlagEnum = nullptr;
145 : Enum* PluginAPI::layoutModeEnum = nullptr;
146 : Enum* PluginAPI::tappingHandEnum = nullptr;
147 : Enum* PluginAPI::lHTappingSymbolEnum = nullptr;
148 : Enum* PluginAPI::rHTappingSymbolEnum = nullptr;
149 : Enum* PluginAPI::lHTappingShowItemsEnum = nullptr;
150 : Enum* PluginAPI::parenthesesModeEnum = nullptr;
151 : Enum* PluginAPI::repeatPlayCountPresetEnum = nullptr;
152 : Enum* PluginAPI::measureNumberPlacementEnum = nullptr;
153 : Enum* PluginAPI::symIdEnum = nullptr;
154 : Enum* PluginAPI::cursorEnum = nullptr;
155 :
156 : //---------------------------------------------------------
157 : // PluginAPI::registerQmlTypes
158 : //---------------------------------------------------------
159 :
160 0 : void PluginAPI::registerQmlTypes()
161 : {
162 : static bool qmlTypesRegistered = false;
163 0 : if (qmlTypesRegistered) {
164 0 : return;
165 : }
166 :
167 0 : if (-1 == qmlRegisterType<PluginAPI>("MuseScore", 3, 0, "MuseScore")) {
168 0 : LOGW("qmlRegisterType failed: MuseScore");
169 : }
170 :
171 0 : qmlRegisterUncreatableType<Enum>("MuseScore", 3, 0, "MuseScoreEnum", "Cannot create an enumeration");
172 :
173 : //qmlRegisterType<ScoreView>("MuseScore", 3, 0, "ScoreView");
174 :
175 0 : qmlRegisterType<Cursor>("MuseScore", 3, 0, "Cursor");
176 0 : qmlRegisterAnonymousType<ScoreElement>("MuseScore", 3);
177 0 : qmlRegisterAnonymousType<Score>("MuseScore", 3);
178 0 : qmlRegisterAnonymousType<EngravingItem>("MuseScore", 3);
179 0 : qmlRegisterAnonymousType<Chord>("MuseScore", 3);
180 0 : qmlRegisterAnonymousType<Note>("MuseScore", 3);
181 0 : qmlRegisterAnonymousType<Tuplet>("MuseScore", 3);
182 0 : qmlRegisterAnonymousType<DurationElement>("MuseScore", 3);
183 0 : qmlRegisterAnonymousType<Segment>("MuseScore", 3);
184 0 : qmlRegisterAnonymousType<Measure>("MuseScore", 3);
185 0 : qmlRegisterAnonymousType<Part>("MuseScore", 3);
186 0 : qmlRegisterAnonymousType<Staff>("MuseScore", 3);
187 0 : qmlRegisterAnonymousType<Instrument>("MuseScore", 3);
188 0 : qmlRegisterAnonymousType<Channel>("MuseScore", 3);
189 0 : qmlRegisterAnonymousType<StringData>("MuseScore", 3);
190 0 : qmlRegisterAnonymousType<Excerpt>("MuseScore", 3);
191 0 : qmlRegisterAnonymousType<Selection>("MuseScore", 3);
192 0 : qmlRegisterAnonymousType<Tie>("MuseScore", 3);
193 0 : qmlRegisterAnonymousType<Harmony>("MuseScore", 3);
194 0 : qmlRegisterAnonymousType<FretDiagram>("MuseScore", 3);
195 0 : qmlRegisterAnonymousType<Drumset>("MuseScore", 3);
196 0 : qmlRegisterAnonymousType<MeasureBase>("MuseScore", 3);
197 0 : qmlRegisterAnonymousType<System>("MuseScore", 3);
198 0 : qmlRegisterAnonymousType<Spanner>("MuseScore", 3);
199 0 : qmlRegisterAnonymousType<SpannerSegment>("MuseScore", 3);
200 0 : qmlRegisterAnonymousType<Ornament>("MuseScore", 3);
201 0 : qmlRegisterType<PlayEvent>("MuseScore", 3, 0, "PlayEvent");
202 :
203 0 : qmlRegisterAnonymousType<Fraction>("MuseScore", 3);
204 0 : qRegisterMetaType<Fraction*>("Fraction*");
205 0 : qmlRegisterAnonymousType<IntervalWrapper>("MuseScore", 3);
206 0 : qRegisterMetaType<IntervalWrapper*>("IntervalWrapper*");
207 0 : qmlRegisterAnonymousType<OrnamentIntervalWrapper>("MuseScore", 3);
208 0 : qRegisterMetaType<OrnamentIntervalWrapper*>("OrnamentIntervalWrapper*");
209 :
210 : #ifdef QT_QPROCESS_SUPPORTED
211 0 : qmlRegisterType<MsProcess>("MuseScore", 3, 0, "QProcess");
212 : #endif
213 0 : qmlRegisterType<FileIO, 1>("FileIO", 3, 0, "FileIO");
214 :
215 0 : qmlTypesRegistered = true;
216 : }
217 :
218 0 : void PluginAPI::setup(QQmlEngine* e)
219 : {
220 : // Sync PluginAPI and EngravingApiV1
221 :
222 0 : QJSValue apiVal = e->globalObject().property("api");
223 0 : if (apiVal.isNull()) {
224 0 : LOGE() << "not found api object";
225 0 : return;
226 : }
227 :
228 0 : QJSValue engravingApiVal = apiVal.property("engraving");
229 0 : QObject* engravingApiObj = engravingApiVal.toQObject();
230 0 : if (!engravingApiObj) {
231 0 : LOGE() << "not found api.engraving object";
232 0 : return;
233 : }
234 :
235 0 : EngravingApiV1* engravingApi = dynamic_cast<EngravingApiV1*>(engravingApiObj);
236 0 : if (!engravingApi) {
237 0 : LOGE() << "api.engraving object not EngravingApiV1";
238 0 : return;
239 : }
240 :
241 0 : engravingApi->setApi(this);
242 0 : m_engine = engravingApi->engine();
243 0 : }
244 :
245 0 : PluginAPI::PluginAPI(QQuickItem* parent)
246 0 : : QQuickItem(parent), muse::Contextable(muse::iocCtxForQmlObject(this))
247 : {
248 0 : setRequiresScore(true); // by default plugins require a score to work
249 0 : }
250 :
251 0 : PluginAPI::PluginAPI(const muse::modularity::ContextPtr& ctx)
252 0 : : muse::Contextable(ctx)
253 : {
254 0 : setRequiresScore(true); // by default plugins require a score to work
255 0 : }
256 :
257 0 : apiv1::Score* PluginAPI::curScore() const
258 : {
259 0 : if (currentScore()) {
260 0 : return wrap<apiv1::Score>(currentScore(), Ownership::SCORE);
261 : }
262 :
263 0 : return nullptr;
264 : }
265 :
266 0 : QQmlListProperty<apiv1::Score> PluginAPI::scores()
267 : {
268 0 : NOT_IMPLEMENTED;
269 :
270 0 : static std::vector<mu::engraving::Score*> scores;
271 :
272 0 : return wrapContainerProperty<Score>(this, scores);
273 : }
274 :
275 : //---------------------------------------------------------
276 : // writeScore
277 : /// Writes a score to a file.
278 : /// \param s The score which should be saved.
279 : /// \param name Path where to save the score, with or
280 : /// without the filename extension (the extension is
281 : /// determined by \p ext parameter).
282 : /// \param ext Filename extension \b without the dot,
283 : /// e.g. \p "mscz" or \p "pdf". Determines the file
284 : /// format to be used.
285 : //---------------------------------------------------------
286 :
287 0 : bool PluginAPI::writeScore(Score* s, const QString& name, const QString& ext)
288 : {
289 0 : if (!s || !s->score()) {
290 0 : LOGW() << "No score provided";
291 0 : return false;
292 : }
293 :
294 0 : if (s->score() != currentScore()) {
295 0 : LOGW() << "Only writing the selected score is currently supported";
296 0 : return false;
297 : }
298 :
299 0 : return helper()->writeScore(name, ext);
300 : }
301 :
302 : //---------------------------------------------------------
303 : // readScore
304 : /// Reads the score from a file and opens it in a new tab
305 : /// \param name Path to the file to be opened.
306 : /// \param noninteractive Can be used to avoid a "save
307 : /// changes" dialog on closing a score that is either
308 : /// imported or was created with an older version of
309 : /// MuseScore.
310 : //---------------------------------------------------------
311 :
312 0 : apiv1::Score* PluginAPI::readScore(const QString& name, bool noninteractive)
313 : {
314 0 : const bool hadScoreOpened = currentScore();
315 :
316 0 : if (hadScoreOpened) {
317 0 : LOGW() << "Will open a score in a new window";
318 : }
319 :
320 0 : if (noninteractive) {
321 0 : LOGW() << "Noninteractive flag is not yet implemented";
322 0 : return nullptr;
323 : }
324 :
325 0 : mu::engraving::Score* score = helper()->readScore(name);
326 0 : if (score) {
327 0 : return wrap<apiv1::Score>(score, Ownership::SCORE);
328 : }
329 0 : return nullptr;
330 : }
331 :
332 : //---------------------------------------------------------
333 : // closeScore
334 : //---------------------------------------------------------
335 :
336 0 : void PluginAPI::closeScore()
337 : {
338 0 : return closeScore(curScore());
339 : }
340 :
341 0 : void PluginAPI::closeScore(apiv1::Score* score)
342 : {
343 0 : if (!score || !score->score()) {
344 0 : LOGW() << "No score provided";
345 0 : return;
346 : }
347 :
348 0 : if (score->score() != currentScore()) {
349 0 : LOGW() << "Only closing the selected score is currently supported";
350 0 : return;
351 : }
352 :
353 0 : helper()->closeScore();
354 : }
355 :
356 : //---------------------------------------------------------
357 : // newElement
358 : /// Creates a new element with the given type. The
359 : /// element can be then added to a score via Cursor::add.
360 : /// \param elementType EngravingItem type, should be the value
361 : /// from PluginAPI::PluginAPI::EngravingItem enumeration.
362 : //---------------------------------------------------------
363 :
364 0 : apiv1::EngravingItem* PluginAPI::newElement(int elementType)
365 : {
366 0 : mu::engraving::Score* score = currentScore();
367 :
368 0 : if (!score) {
369 0 : return nullptr;
370 : }
371 :
372 0 : if (elementType <= int(ElementType::INVALID) || elementType >= int(ElementType::ROOT_ITEM)) {
373 0 : LOGW("PluginAPI::newElement: Wrong type ID: %d", elementType);
374 0 : return nullptr;
375 : }
376 :
377 0 : const ElementType type = ElementType(elementType);
378 0 : mu::engraving::EngravingItem* e = Factory::createItem(type, score->dummy());
379 0 : return wrap(e, Ownership::PLUGIN);
380 : }
381 :
382 : //---------------------------------------------------------
383 : // removeElement
384 : /// Disposes of an EngravingItem and its children.
385 : /// \param EngravingItem type.
386 : /// \since MuseScore 3.3
387 : //---------------------------------------------------------
388 :
389 0 : void PluginAPI::removeElement(apiv1::EngravingItem* wrapped)
390 : {
391 0 : mu::engraving::Score* score = wrapped->element()->score();
392 0 : score->deleteItem(wrapped->element());
393 0 : }
394 :
395 : //---------------------------------------------------------
396 : // newScore
397 : //---------------------------------------------------------
398 :
399 0 : apiv1::Score* PluginAPI::newScore(const QString& /*name*/, const QString& part, int measures)
400 : {
401 0 : if (currentScore()) {
402 0 : currentScore()->endCmd();
403 : }
404 :
405 0 : MasterScore* score = mu::engraving::compat::ScoreAccess::createMasterScoreWithDefaultStyle(iocContext());
406 :
407 : // TODO: Set path/filename
408 0 : NOT_IMPLEMENTED << "setting path/filename";
409 :
410 0 : score->appendPart(Score::instrTemplateFromName(part));
411 0 : score->appendMeasures(measures);
412 0 : score->doLayout();
413 :
414 : // TODO: Open score
415 0 : NOT_IMPLEMENTED << "opening the newly created score";
416 :
417 0 : qApp->processEvents();
418 0 : Q_ASSERT(currentScore() == score);
419 0 : score->startCmd(TranslatableString("undoableAction", "New score"));
420 0 : return wrap<Score>(score, Ownership::SCORE);
421 : }
422 :
423 0 : void PluginAPI::cmd(const QString& s)
424 : {
425 : static const QMap<QString, muse::rcommand::Command> COMPAT_CMD_MAP = {
426 : { "escape", notation::CancelCommand::id },
427 : { "cut", notation::CutCommand::id },
428 : { "copy", notation::CopyCommand::id },
429 : { "paste", notation::PasteDefaultCommand::id },
430 : { "paste-half", notation::PasteHalfCommand::id },
431 : { "paste-double", notation::PasteDoubleCommand::id },
432 : { "select-all", notation::SelectAllCommand::id },
433 : { "delete", notation::DeleteCommand::id },
434 : { "next-chord", notation::MOVE_RIGHT_COMMAND },
435 : { "prev-chord", notation::MOVE_LEFT_COMMAND },
436 : { "prev-measure", notation::MOVE_LEFT_QUICKLY_COMMAND }
437 0 : };
438 :
439 0 : commandDispatcher()->dispatch(COMPAT_CMD_MAP.value(s, muse::rcommand::Command(s.toStdString())));
440 0 : }
441 :
442 0 : void PluginAPI::openLog(const QString&)
443 : {
444 0 : DEPRECATED;
445 0 : }
446 :
447 0 : void PluginAPI::closeLog()
448 : {
449 0 : DEPRECATED;
450 0 : }
451 :
452 0 : void PluginAPI::log(const QString& txt)
453 : {
454 0 : LOGD() << txt;
455 0 : }
456 :
457 0 : void PluginAPI::logn(const QString& txt)
458 : {
459 0 : LOGD() << txt;
460 0 : }
461 :
462 0 : void PluginAPI::log2(const QString& txt, const QString& txt2)
463 : {
464 0 : LOGD() << txt << txt2;
465 0 : }
466 :
467 : //---------------------------------------------------------
468 : // newQProcess
469 : /// Not enabled currently (so excluded from plugin docs)
470 : //---------------------------------------------------------
471 :
472 0 : MsProcess* PluginAPI::newQProcess()
473 : {
474 0 : NOT_IMPLEMENTED;
475 0 : return nullptr;
476 : }
477 :
478 : //---------------------------------------------------------
479 : // PluginAPI::fraction
480 : /// Creates a new fraction with the given numerator and
481 : /// denominator
482 : //---------------------------------------------------------
483 :
484 0 : apiv1::Fraction* PluginAPI::fraction(int num, int den) const
485 : {
486 0 : return wrap(mu::engraving::Fraction(num, den));
487 : }
488 :
489 : //---------------------------------------------------------
490 : // PluginAPI::fractionFromTicks
491 : /// Converts an integer tick value to an equivalent fraction.
492 : /// \since MuseScore 4.6
493 : //---------------------------------------------------------
494 :
495 0 : apiv1::Fraction* PluginAPI::fractionFromTicks(int ticks) const
496 : {
497 0 : return wrap(mu::engraving::Fraction::fromTicks(ticks));
498 : }
499 :
500 0 : void PluginAPI::quit()
501 : {
502 0 : emit closeRequested();
503 0 : m_closeRequested.notify();
504 0 : }
505 :
506 0 : mu::engraving::Score* PluginAPI::currentScore() const
507 : {
508 0 : if (notation::INotationPtr notation = context()->currentNotation()) {
509 0 : return notation->elements()->msScore();
510 0 : }
511 :
512 0 : return nullptr;
513 : }
514 :
515 0 : QString PluginAPI::pluginType() const
516 : {
517 0 : return m_pluginType;
518 : }
519 :
520 0 : void PluginAPI::setPluginType(const QString& newPluginType)
521 : {
522 0 : m_pluginType = newPluginType;
523 0 : }
524 :
525 0 : QString PluginAPI::menuPath() const
526 : {
527 0 : return QString();
528 : }
529 :
530 0 : void PluginAPI::setMenuPath(const QString&)
531 : {
532 0 : DEPRECATED;
533 0 : }
534 :
535 0 : QString PluginAPI::title() const
536 : {
537 0 : return m_title;
538 : }
539 :
540 0 : void PluginAPI::setTitle(const QString& newTitle)
541 : {
542 0 : m_title = newTitle;
543 0 : }
544 :
545 0 : QString PluginAPI::version() const
546 : {
547 0 : return m_version;
548 : }
549 :
550 0 : void PluginAPI::setVersion(const QString& newVersion)
551 : {
552 0 : m_version = newVersion;
553 0 : }
554 :
555 0 : QString PluginAPI::description() const
556 : {
557 0 : return m_description;
558 : }
559 :
560 0 : void PluginAPI::setDescription(const QString& newDescription)
561 : {
562 0 : m_description = newDescription;
563 0 : }
564 :
565 0 : QString PluginAPI::dockArea() const
566 : {
567 0 : return QString();
568 : }
569 :
570 0 : void PluginAPI::setDockArea(const QString&)
571 : {
572 0 : DEPRECATED;
573 0 : }
574 :
575 0 : bool PluginAPI::requiresScore() const
576 : {
577 0 : return m_requiresScore;
578 : }
579 :
580 0 : void PluginAPI::setRequiresScore(bool newRequiresScore)
581 : {
582 0 : m_requiresScore = newRequiresScore;
583 0 : }
584 :
585 0 : QString PluginAPI::thumbnailName() const
586 : {
587 0 : return m_thumbnailName;
588 : }
589 :
590 0 : void PluginAPI::setThumbnailName(const QString& newThumbnailName)
591 : {
592 0 : m_thumbnailName = newThumbnailName;
593 0 : }
594 :
595 0 : QString PluginAPI::categoryCode() const
596 : {
597 0 : return m_categoryCode;
598 : }
599 :
600 0 : void PluginAPI::setCategoryCode(const QString& newCategoryCode)
601 : {
602 0 : m_categoryCode = newCategoryCode;
603 0 : }
604 :
605 0 : int PluginAPI::division() const
606 : {
607 0 : return engraving::Constants::DIVISION;
608 : }
609 :
610 0 : int PluginAPI::mscoreVersion() const
611 : {
612 0 : return mscoreMajorVersion() * 10000 + mscoreMinorVersion() * 100 + mscoreUpdateVersion();
613 : }
614 :
615 0 : int PluginAPI::mscoreMajorVersion() const
616 : {
617 0 : return application()->version().major();
618 : }
619 :
620 0 : int PluginAPI::mscoreMinorVersion() const
621 : {
622 0 : return application()->version().minor();
623 : }
624 :
625 0 : int PluginAPI::mscoreUpdateVersion() const
626 : {
627 0 : return application()->version().patch();
628 : }
629 :
630 0 : qreal PluginAPI::mscoreDPI() const
631 : {
632 0 : return engraving::DPI;
633 : }
634 :
635 0 : OrnamentIntervalWrapper* PluginAPI::defaultOrnamentInterval() const
636 : {
637 0 : return wrap(mu::engraving::DEFAULT_ORNAMENT_INTERVAL);
638 : }
639 :
640 : //---------------------------------------------------------
641 : // PluginAPI::ornamentInterval
642 : /// Creates a new ornament interval with the given step and type
643 : //---------------------------------------------------------
644 :
645 0 : OrnamentIntervalWrapper* PluginAPI::ornamentInterval(int step, int type) const
646 : {
647 0 : return wrap(mu::engraving::OrnamentInterval(mu::engraving::IntervalStep(step), mu::engraving::IntervalType(type)));
648 : }
649 :
650 : //---------------------------------------------------------
651 : // PluginAPI::interval
652 : /// Creates a new interval with the given chromatic and diatonic steps
653 : //---------------------------------------------------------
654 :
655 0 : IntervalWrapper* PluginAPI::interval(int diatonic, int chromatic) const
656 : {
657 0 : return wrap(mu::engraving::Interval(diatonic, chromatic));
658 : }
659 :
660 : //---------------------------------------------------------
661 : // PluginAPI::intervalFromOrnamentInterval
662 : /// Creates a new interval from a given ornament interval
663 : //---------------------------------------------------------
664 :
665 0 : IntervalWrapper* PluginAPI::intervalFromOrnamentInterval(OrnamentIntervalWrapper* o) const
666 : {
667 0 : return wrap(mu::engraving::Interval::fromOrnamentInterval(o->ornamentInterval()));
668 : }
|