MuseScore Plugins 3.2.3
Plugins API for MuseScore
Loading...
Searching...
No Matches
qmlpluginapi.h
1//=============================================================================
2// MuseScore
3// Music Composition & Notation
4//
5// Copyright (C) 2012 Werner Schweer
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License version 2
9// as published by the Free Software Foundation and appearing in
10// the file LICENCE.GPL
11//=============================================================================
12
13#ifndef __QMLPLUGINAPI_H__
14#define __QMLPLUGINAPI_H__
15
16#include "config.h"
17
18#include "../qmlplugin.h"
19#include "enums.h"
20#include "libmscore/mscore.h"
21#include "libmscore/utils.h"
22
23namespace Ms {
24
25class Element;
26class MScore;
27
33namespace PluginAPI {
34
35class Element;
36class FractionWrapper;
37class MsProcess;
38class Score;
39
40#define DECLARE_API_ENUM(qmlName, cppName) \
41 Q_PROPERTY(Ms::PluginAPI::Enum* qmlName READ get_##cppName CONSTANT) \
42 static Enum* cppName; \
43 static Enum* get_##cppName() { return cppName; }
44
45//---------------------------------------------------------
52// @P scores array[Ms::Score] all currently open scores (read only)
53//---------------------------------------------------------
54
55class PluginAPI : public Ms::QmlPlugin {
56 Q_OBJECT
58 Q_PROPERTY(QString menuPath READ menuPath WRITE setMenuPath)
60 Q_PROPERTY(QString filePath READ filePath)
62 Q_PROPERTY(QString version READ version WRITE setVersion)
64 Q_PROPERTY(QString description READ description WRITE setDescription)
66 Q_PROPERTY(QString pluginType READ pluginType WRITE setPluginType)
68 Q_PROPERTY(QString dockArea READ dockArea WRITE setDockArea)
70 Q_PROPERTY(bool requiresScore READ requiresScore WRITE setRequiresScore)
72 Q_PROPERTY(int division READ division)
74 Q_PROPERTY(int mscoreVersion READ mscoreVersion CONSTANT)
76 Q_PROPERTY(int mscoreMajorVersion READ mscoreMajorVersion CONSTANT)
78 Q_PROPERTY(int mscoreMinorVersion READ mscoreMinorVersion CONSTANT)
80 Q_PROPERTY(int mscoreUpdateVersion READ mscoreUpdateVersion CONSTANT)
82 Q_PROPERTY(qreal mscoreDPI READ mscoreDPI)
84 Q_PROPERTY(Ms::PluginAPI::Score* curScore READ curScore)
86 Q_PROPERTY(QQmlListProperty<Ms::PluginAPI::Score> scores READ scores)
87
88 // Should be initialized in qmlpluginapi.cpp
90 DECLARE_API_ENUM( Element, elementTypeEnum )
92 DECLARE_API_ENUM( Accidental, accidentalTypeEnum )
94 DECLARE_API_ENUM( Beam, beamModeEnum )
98 DECLARE_API_ENUM( Placement, placementEnum )
100 DECLARE_API_ENUM( Glissando, glissandoTypeEnum ) // was probably absent in 2.X
102 DECLARE_API_ENUM( LayoutBreak, layoutBreakTypeEnum )
104 DECLARE_API_ENUM( Lyrics, lyricsSyllabicEnum )
108 DECLARE_API_ENUM( Direction, directionEnum )
112 DECLARE_API_ENUM( DirectionH, directionHEnum )
116 DECLARE_API_ENUM( OrnamentStyle, ornamentStyleEnum )
121 DECLARE_API_ENUM( GlissandoStyle, glissandoStyleEnum )
125 DECLARE_API_ENUM( Tid, tidEnum )
128 DECLARE_API_ENUM( NoteType, noteTypeEnum )
132 DECLARE_API_ENUM( NoteHeadType, noteHeadTypeEnum )
136 DECLARE_API_ENUM( NoteHeadGroup, noteHeadGroupEnum )
140 DECLARE_API_ENUM( NoteValueType, noteValueTypeEnum )
142 DECLARE_API_ENUM( Segment, segmentTypeEnum )
143 DECLARE_API_ENUM( Spanner, spannerAnchorEnum ) // probably unavailable in 2.X
144
145 QFile logFile;
146
147 static void initEnums();
148
149 signals:
152 void run();
153
154 public:
156 PluginAPI(QQuickItem* parent = 0);
157
158 static void registerQmlTypes();
159
160 void runPlugin() override { emit run(); }
161
162 Score* curScore() const;
163 QQmlListProperty<Score> scores();
165
166 Q_INVOKABLE Ms::PluginAPI::Score* newScore(const QString& name, const QString& part, int measures);
167 Q_INVOKABLE Ms::PluginAPI::Element* newElement(int);
168 Q_INVOKABLE void removeElement(Ms::PluginAPI::Element* wrapped);
169 Q_INVOKABLE void cmd(const QString&);
171 Q_INVOKABLE Ms::PluginAPI::MsProcess* newQProcess();
172 Q_INVOKABLE bool writeScore(Ms::PluginAPI::Score*, const QString& name, const QString& ext);
173 Q_INVOKABLE Ms::PluginAPI::Score* readScore(const QString& name, bool noninteractive = false);
174 Q_INVOKABLE void closeScore(Ms::PluginAPI::Score*);
175
176 Q_INVOKABLE void log(const QString&);
177 Q_INVOKABLE void logn(const QString&);
178 Q_INVOKABLE void log2(const QString&, const QString&);
179 Q_INVOKABLE void openLog(const QString&);
180 Q_INVOKABLE void closeLog();
181
182 Q_INVOKABLE Ms::PluginAPI::FractionWrapper* fraction(int numerator, int denominator) const;
183 };
184
185#undef DECLARE_API_ENUM
186} // namespace PluginAPI
187} // namespace Ms
188#endif
Definition beam.h:36
symbols for line break, page break etc.
Definition layoutbreak.h:27
Definition lyrics.h:27
Definition elements.h:69
Fraction object available to QML plugins.
Definition fraction.h:32
Start an external program. Available in QML as QProcess.
Definition util.h:116
Main class of the plugins framework. Named as MuseScore in QML.
Definition qmlpluginapi.h:55
void run()
Indicates that the plugin was launched.
Ms::PluginAPI::Enum * DirectionH
Contains Ms::MScore::DirectionH enumeration values.
Definition qmlpluginapi.h:112
int mscoreMajorVersion
1st part of the MuseScore version (read only)
Definition qmlpluginapi.h:76
bool requiresScore
Whether the plugin requires an existing score to run, default is true
Definition qmlpluginapi.h:70
Ms::PluginAPI::Enum * Glissando
Contains Ms::GlissandoType enumeration values.
Definition qmlpluginapi.h:100
int division
Number of MIDI ticks for 1/4 note (read only)
Definition qmlpluginapi.h:72
Q_INVOKABLE Ms::PluginAPI::Element * newElement(int)
Creates a new element with the given type.
Definition qmlpluginapi.cpp:168
QQmlListProperty< Ms::PluginAPI::Score > scores
List of currently open scores (read only).
Definition qmlpluginapi.h:86
qreal mscoreDPI
(read-only)
Definition qmlpluginapi.h:82
Q_INVOKABLE void removeElement(Ms::PluginAPI::Element *wrapped)
Disposes of an Element and its children.
Definition qmlpluginapi.cpp:189
QString pluginType
Type may be dialog, dock, or not defined.
Definition qmlpluginapi.h:66
Q_INVOKABLE Ms::PluginAPI::Score * readScore(const QString &name, bool noninteractive=false)
Reads the score from a file and opens it in a new tab.
Definition qmlpluginapi.cpp:141
Q_INVOKABLE Ms::PluginAPI::FractionWrapper * fraction(int numerator, int denominator) const
Creates a new fraction with the given numerator and denominator.
Definition qmlpluginapi.cpp:308
Ms::PluginAPI::Enum * NoteValueType
Contains Ms::Note::ValueType enumeration values.
Definition qmlpluginapi.h:140
QString description
Human-readable plugin description, displayed in Plugin Manager.
Definition qmlpluginapi.h:64
QString dockArea
Where to dock on main screen.
Definition qmlpluginapi.h:68
Ms::PluginAPI::Enum * OrnamentStyle
Contains Ms::MScore::OrnamentStyle enumeration values.
Definition qmlpluginapi.h:116
int mscoreVersion
Complete version number of MuseScore in the form: MMmmuu (read only)
Definition qmlpluginapi.h:74
Ms::PluginAPI::Enum * Accidental
Contains Ms::AccidentalType enumeration values.
Definition qmlpluginapi.h:92
Ms::PluginAPI::Enum * NoteHeadType
Contains Ms::NoteHead::Type enumeration values.
Definition qmlpluginapi.h:132
QString version
Version of this plugin.
Definition qmlpluginapi.h:62
Ms::PluginAPI::Score * curScore
Current score, if any (read only)
Definition qmlpluginapi.h:84
int mscoreUpdateVersion
3rd part of the MuseScore version (read only)
Definition qmlpluginapi.h:80
Ms::PluginAPI::Enum * NoteHeadGroup
Contains Ms::NoteHead::Group enumeration values.
Definition qmlpluginapi.h:136
QString filePath
Source file path, without the file name (read only)
Definition qmlpluginapi.h:60
Q_INVOKABLE bool writeScore(Ms::PluginAPI::Score *, const QString &name, const QString &ext)
Writes a score to a file.
Definition qmlpluginapi.cpp:124
QString menuPath
Path where the plugin is placed in menu.
Definition qmlpluginapi.h:58
int mscoreMinorVersion
2nd part of the MuseScore version (read only)
Definition qmlpluginapi.h:78
Definition score.h:36
Definition elements.h:474
Definition cursor.cpp:29
NoteType
Definition types.h:254
Direction
Definition types.h:281
Placement
Definition types.h:311
Tid
Enumerates the list of built-in text substyles.
Definition types.h:370
GlissandoStyle
Definition types.h:301