MuseScore Plugins
3.2.3
Plugins API for MuseScore
Toggle main menu visibility
Loading...
Searching...
No Matches
mscore
plugin
api
util.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 __PLUGIN_API_UTIL_H__
14
#define __PLUGIN_API_UTIL_H__
15
16
#include "config.h"
17
18
#include "libmscore/element.h"
19
#include "libmscore/mscoreview.h"
20
#include "libmscore/score.h"
21
#include "libmscore/utils.h"
22
23
namespace
Ms
{
24
namespace
PluginAPI
{
25
26
class
Score
;
27
28
//---------------------------------------------------------
50
//---------------------------------------------------------
51
52
class
FileIO :
public
QObject {
53
Q_OBJECT
54
55
public
:
57
Q_PROPERTY(QString
source
58
READ
source
59
WRITE setSource
60
)
62
explicit
FileIO(QObject *parent = 0);
63
69
Q_INVOKABLE QString
read
();
71
Q_INVOKABLE
bool
exists
();
78
Q_INVOKABLE
bool
write
(
const
QString& data);
80
Q_INVOKABLE
bool
remove
();
82
Q_INVOKABLE QString
homePath
() {QDir dir;
return
dir.homePath();}
84
Q_INVOKABLE QString
tempPath
() {QDir dir;
return
dir.tempPath();}
86
Q_INVOKABLE
int
modifiedTime
();
87
89
QString
source
() {
return
mSource; }
90
91
public
slots:
92
void
setSource(
const
QString&
source
) { mSource =
source
; }
94
95
signals:
101
void
error
(
const
QString& msg);
102
103
private
:
104
QString mSource;
105
};
106
107
//---------------------------------------------------------
108
// MsProcess
109
// @@ QProcess
114
//---------------------------------------------------------
115
116
class
MsProcess :
public
QProcess {
117
Q_OBJECT
118
119
public
:
120
MsProcess(QObject* parent = 0) : QProcess(parent) {}
121
122
public
slots:
123
//@ --
124
Q_INVOKABLE
void
start(
const
QString& program) { QProcess::start(program); }
125
//@ --
126
Q_INVOKABLE
bool
waitForFinished(
int
msecs = 30000) {
return
QProcess::waitForFinished(msecs); }
127
//@ --
128
Q_INVOKABLE QByteArray readAllStandardOutput() {
return
QProcess::readAllStandardOutput(); }
129
};
130
131
//---------------------------------------------------------
132
// @@ ScoreView
134
//---------------------------------------------------------
135
136
class
ScoreView
:
public
QQuickPaintedItem,
public
MuseScoreView {
137
Q_OBJECT
139
Q_PROPERTY(QColor
color
READ
color
WRITE setColor)
141
Q_PROPERTY(qreal
scale
READ
scale
WRITE setScale)
142
143
Ms
::
Score
* score;
144
int
_currentPage;
145
QColor _color;
146
qreal mag;
147
int
playPos;
148
QRectF _boundingRect;
149
150
QNetworkAccessManager* networkManager;
151
152
virtual
void
setScore(
Ms
::
Score
*) override;
153
154
virtual
void
dataChanged(const QRectF&)
override
{ update(); }
155
virtual
void
updateAll()
override
{ update(); }
156
157
virtual
void
paint(QPainter*)
override
;
158
159
virtual
QRectF boundingRect()
const override
{
return
_boundingRect; }
160
virtual
void
drawBackground(QPainter*,
const
QRectF&)
const override
{}
161
162
public
slots:
163
//@ --
164
Q_INVOKABLE
void
setScore(Ms::PluginAPI::Score*);
165
//@ --
166
Q_INVOKABLE
void
setCurrentPage(
int
n);
167
//@ --
168
Q_INVOKABLE
void
nextPage();
169
//@ --
170
Q_INVOKABLE
void
prevPage();
171
172
public
:
174
ScoreView(QQuickItem* parent = 0);
175
virtual
~ScoreView() {}
176
QColor
color
()
const
{
return
_color; }
177
void
setColor(
const
QColor& c) { _color = c; }
178
qreal
scale
()
const
{
return
mag; }
179
void
setScale(qreal v) { mag = v; }
180
virtual
const
QRect geometry()
const override
{
return
QRect(QQuickPaintedItem::x(), y(), width(), height()); }
182
};
183
}
// namespace PluginAPI
184
}
// namespace Ms
185
#endif
Ms::PluginAPI::FileIO::remove
Q_INVOKABLE bool remove()
Removes the file.
Definition
util.cpp:102
Ms::PluginAPI::FileIO::tempPath
Q_INVOKABLE QString tempPath()
Returns a path suitable for a temporary file.
Definition
util.h:82
Ms::PluginAPI::FileIO::write
Q_INVOKABLE bool write(const QString &data)
Writes a string to the file.
Definition
util.cpp:83
Ms::PluginAPI::FileIO::read
Q_INVOKABLE QString read()
Reads file contents and returns a string.
Definition
util.cpp:54
Ms::PluginAPI::FileIO::homePath
Q_INVOKABLE QString homePath()
Returns user's home directory.
Definition
util.h:80
Ms::PluginAPI::FileIO::error
void error(const QString &msg)
Emitted on file operations errors.
Ms::PluginAPI::FileIO::exists
Q_INVOKABLE bool exists()
Returns true if the file exists.
Definition
util.cpp:111
Ms::PluginAPI::FileIO::source
QString source
Path to the file which is operated on.
Definition
util.h:58
Ms::PluginAPI::FileIO::modifiedTime
Q_INVOKABLE int modifiedTime()
Returns the file's last modification time.
Definition
util.cpp:117
Ms::PluginAPI::Score
Definition
score.h:36
Ms::PluginAPI::ScoreView
This is an GUI element to show a score.
Definition
util.h:136
Ms::PluginAPI::ScoreView::color
QColor color
Background color.
Definition
util.h:139
Ms::PluginAPI::ScoreView::scale
qreal scale
Scaling factor.
Definition
util.h:141
Ms::PluginAPI
Contains items exposed to the QML plugins framework.
Definition
cursor.cpp:30
Ms
Definition
cursor.cpp:29
Generated by
1.17.0