MuseScore/mscore/qmlplugin.h

137 lines
5.9 KiB
C
Raw Normal View History

2012-12-10 09:15:50 +01:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2012 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#ifndef __QMLPLUGIN_H__
#define __QMLPLUGIN_H__
#include "config.h"
#ifdef SCRIPT_INTERFACE
#include "libmscore/mscore.h"
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-12-10 09:15:50 +01:00
class MsProcess;
class Score;
class Element;
class MScore;
class MuseScoreCore;
extern int version();
extern int majorVersion();
extern int minorVersion();
extern int updateVersion();
//---------------------------------------------------------
// QmlPlugin
// @@ MuseScore
// @P menuPath QString where the plugin is placed in menu
// @P filePath QString source file path, without the file name (read only)
// @P version QString version of this plugin
// @P description QString human readable description, displayed in Plugin Manager
// @P pluginType QString type may be dialog, dock, or not defined.
// @P dockArea QString where to dock on main screen. left,top,bottom, right(default)
// @P requiresScore bool whether the plugin requires an existing score to run
// @P division int number of MIDI ticks for 1/4 note (read only)
// @P mscoreVersion int complete version number of MuseScore in the form: MMmmuu (read only)
// @P mscoreMajorVersion int 1st part of the MuseScore version (read only)
// @P mscoreMinorVersion int 2nd part of the MuseScore version (read only)
// @P mscoreUpdateVersion int 3rd part of the MuseScore version (read only)
// @P mscoreDPI qreal (read only)
// @P curScore Ms::Score* current score, if any (read only)
// @P scores array[Ms::Score] all currently open scores (read only)
2012-12-10 09:15:50 +01:00
//---------------------------------------------------------
2013-05-16 17:06:31 +02:00
class QmlPlugin : public QQuickItem {
2012-12-10 09:15:50 +01:00
Q_OBJECT
Q_PROPERTY(QString menuPath READ menuPath WRITE setMenuPath)
Q_PROPERTY(QString filePath READ filePath)
2012-12-10 09:15:50 +01:00
Q_PROPERTY(QString version READ version WRITE setVersion)
Q_PROPERTY(QString description READ description WRITE setDescription)
Q_PROPERTY(QString pluginType READ pluginType WRITE setPluginType)
Q_PROPERTY(QString dockArea READ dockArea WRITE setDockArea)
Q_PROPERTY(bool requiresScore READ requiresScore WRITE setRequiresScore)
2012-12-10 09:15:50 +01:00
Q_PROPERTY(int division READ division)
Q_PROPERTY(int mscoreVersion READ mscoreVersion)
Q_PROPERTY(int mscoreMajorVersion READ mscoreMajorVersion)
Q_PROPERTY(int mscoreMinorVersion READ mscoreMinorVersion)
Q_PROPERTY(int mscoreUpdateVersion READ mscoreUpdateVersion)
Q_PROPERTY(qreal mscoreDPI READ mscoreDPI)
2013-05-16 17:06:31 +02:00
Q_PROPERTY(Ms::Score* curScore READ curScore)
2016-03-11 12:18:46 +01:00
//TODO-ws Q_PROPERTY(QQmlListProperty<Ms::Score> scores READ scores)
2012-12-10 09:15:50 +01:00
MuseScoreCore* msc;
QString _menuPath;
QString _pluginType;
QString _dockArea;
bool _requiresScore;
2012-12-10 09:15:50 +01:00
QString _version;
QString _description;
2015-04-03 18:23:51 +02:00
QFile logFile;
2012-12-10 09:15:50 +01:00
protected:
QString _filePath; // the path of the source file, without file name
2012-12-10 09:15:50 +01:00
signals:
void run();
public:
2013-05-16 17:06:31 +02:00
QmlPlugin(QQuickItem* parent = 0);
2012-12-10 09:15:50 +01:00
~QmlPlugin();
void setMenuPath(const QString& s) { _menuPath = s; }
QString menuPath() const { return _menuPath; }
void setVersion(const QString& s) { _version = s; }
QString version() const { return _version; }
void setDescription(const QString& s) { _description = s; }
QString description() const { return _description; }
void setFilePath(const QString s) { _filePath = s; }
QString filePath() const { return _filePath; }
2012-12-10 09:15:50 +01:00
void setPluginType(const QString& s) { _pluginType = s; }
QString pluginType() const { return _pluginType; }
void setDockArea(const QString& s) { _dockArea = s; }
QString dockArea() const { return _dockArea; }
void runPlugin() { emit run(); }
void setRequiresScore(bool b) { _requiresScore = b; }
bool requiresScore() const { return _requiresScore; }
2012-12-10 09:15:50 +01:00
int division() const { return MScore::division; }
2013-05-13 18:49:17 +02:00
int mscoreVersion() const { return Ms::version(); }
2012-12-10 09:15:50 +01:00
int mscoreMajorVersion() const { return majorVersion(); }
int mscoreMinorVersion() const { return minorVersion(); }
int mscoreUpdateVersion() const { return updateVersion(); }
2015-11-16 14:24:47 +01:00
qreal mscoreDPI() const { return DPI; }
2012-12-10 09:15:50 +01:00
Score* curScore() const;
2013-05-16 17:06:31 +02:00
QQmlListProperty<Score> scores();
2012-12-10 09:15:50 +01:00
Q_INVOKABLE Ms::Score* newScore(const QString& name, const QString& part, int measures);
Q_INVOKABLE Ms::Element* newElement(int);
2012-12-10 09:15:50 +01:00
Q_INVOKABLE void cmd(const QString&);
Q_INVOKABLE Ms::MsProcess* newQProcess();
Q_INVOKABLE bool writeScore(Ms::Score*, const QString& name, const QString& ext);
Q_INVOKABLE Ms::Score* readScore(const QString& name, bool noninteractive = false);
Q_INVOKABLE void closeScore(Ms::Score*);
2015-04-03 18:23:51 +02:00
Q_INVOKABLE void log(const QString&);
Q_INVOKABLE void logn(const QString&);
Q_INVOKABLE void log2(const QString&, const QString&);
Q_INVOKABLE void openLog(const QString&);
Q_INVOKABLE void closeLog();
2012-12-10 09:15:50 +01:00
};
2013-05-13 18:49:17 +02:00
} // namespace Ms
2012-12-10 09:15:50 +01:00
#endif
2014-12-09 09:12:42 +01:00
#endif