scripting update

This commit is contained in:
Werner Schweer 2017-06-28 15:18:59 +02:00
parent 3f1312b25c
commit 3ab304d157
7 changed files with 28 additions and 28 deletions

View file

@ -420,18 +420,18 @@ QQmlEngine* MScore::qml()
_qml->setImportPathList(importPaths); _qml->setImportPathList(importPaths);
#endif #endif
const char* enumErr = "You can't create an enumeration"; const char* enumErr = "You can't create an enumeration";
qmlRegisterType<MsProcess> ("MuseScore", 1, 0, "QProcess"); qmlRegisterType<MsProcess> ("MuseScore", 3, 0, "QProcess");
qmlRegisterType<FileIO, 1> ("FileIO", 1, 0, "FileIO"); qmlRegisterType<FileIO, 1> ("FileIO", 3, 0, "FileIO");
//-----------mscore bindings //-----------mscore bindings
qmlRegisterUncreatableMetaObject(Ms::staticMetaObject, "MuseScore", 1, 0, "Ms", enumErr); qmlRegisterUncreatableMetaObject(Ms::staticMetaObject, "MuseScore", 3, 0, "Ms", enumErr);
// qmlRegisterUncreatableType<Direction>("MuseScore", 1, 0, "Direction", tr(enumErr)); // qmlRegisterUncreatableType<Direction>("MuseScore", 3, 0, "Direction", tr(enumErr));
qmlRegisterType<MScore> ("MuseScore", 1, 0, "MScore"); qmlRegisterType<MScore> ("MuseScore", 3, 0, "MScore");
qmlRegisterType<MsScoreView>("MuseScore", 1, 0, "ScoreView"); qmlRegisterType<MsScoreView>("MuseScore", 3, 0, "ScoreView");
qmlRegisterType<Score> ("MuseScore", 1, 0, "Score"); qmlRegisterType<Score> ("MuseScore", 3, 0, "Score");
qmlRegisterType<Cursor> ("MuseScore", 1, 0, "Cursor"); qmlRegisterType<Cursor> ("MuseScore", 3, 0, "Cursor");
qmlRegisterType<ElementW> ("MuseScore", 1, 0, "Element"); qmlRegisterType<ElementW> ("MuseScore", 3, 0, "Element");
qRegisterMetaType<ElementW*>("ElementWrapper*"); qRegisterMetaType<ElementW*>("ElementWrapper*");
#if 0 #if 0
qmlRegisterType<Segment> ("MuseScore", 1, 0, "Segment"); qmlRegisterType<Segment> ("MuseScore", 1, 0, "Segment");
@ -472,7 +472,7 @@ QQmlEngine* MScore::qml()
qmlRegisterType<SlurTie>(); qmlRegisterType<SlurTie>();
qmlRegisterType<Spanner>(); qmlRegisterType<Spanner>();
#endif #endif
qmlRegisterType<FractionWrapper> ("MuseScore", 1, 1, "Fraction"); qmlRegisterType<FractionWrapper> ("MuseScore", 3, 1, "Fraction");
qRegisterMetaType<FractionWrapper*>("FractionWrapper*"); qRegisterMetaType<FractionWrapper*>("FractionWrapper*");
} }
return _qml; return _qml;

View file

@ -5935,7 +5935,8 @@ int main(int argc, char* av[])
#endif #endif
#ifdef SCRIPT_INTERFACE #ifdef SCRIPT_INTERFACE
qmlRegisterType<QmlPlugin> ("MuseScore", 2, 0, "MuseScore"); if (-1 == qmlRegisterType<QmlPlugin> ("MuseScore", 3, 0, "MuseScore"))
qDebug("qmlRegisterType failed: MuseScore");
#endif #endif
if (MScore::debugMode) { if (MScore::debugMode) {
qDebug("DPI %f", DPI); qDebug("DPI %f", DPI);

View file

@ -1,5 +1,5 @@
import QtQuick 2.0 import QtQuick 2.0
import MuseScore 1.0 import MuseScore 3.0
MuseScore { MuseScore {
menuPath: "Plugins.p1" menuPath: "Plugins.p1"

View file

@ -1,9 +1,9 @@
import QtQuick 2.0 import QtQuick 2.0
import MuseScore 1.0 import MuseScore 3.0
MuseScore { MuseScore {
menuPath: "Plugins.test2" menuPath: "Plugins.test3"
version: "2.0" version: "3.0"
description: "Test Plugin" description: "Test Plugin"
width: 150 width: 150

View file

@ -91,7 +91,7 @@ void TestScripting::initTestCase()
{ {
initMTest(); initMTest();
qmlRegisterType<MScore> ("MuseScore", 1, 0, "MScore"); qmlRegisterType<MScore> ("MuseScore", 1, 0, "MScore");
qmlRegisterType<QmlPlugin> ("MuseScore", 1, 0, "MuseScore"); qmlRegisterType<QmlPlugin> ("MuseScore", 3, 0, "MuseScore");
MsQmlEngine = Ms::MScore::qml(); MsQmlEngine = Ms::MScore::qml();
} }

View file

@ -13,7 +13,7 @@
//============================================================================= //=============================================================================
import QtQuick 2.0 import QtQuick 2.0
import MuseScore 1.0 import MuseScore 3.0
MuseScore { MuseScore {
version: "1.0" version: "1.0"

View file

@ -2,7 +2,7 @@
// MuseScore // MuseScore
// Music Composition & Notation // Music Composition & Notation
// //
// Copyright (C) 2012 Werner Schweer // Copyright (C) 2012-2017 Werner Schweer
// //
// This program is free software; you can redistribute it and/or modify // This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 // it under the terms of the GNU General Public License version 2
@ -11,10 +11,10 @@
//============================================================================= //=============================================================================
import QtQuick 2.0 import QtQuick 2.0
import MuseScore 1.0 import MuseScore 3.0
MuseScore { MuseScore {
version: "1.0" version: "3.0"
description: "This test plugin walks through all elements in a score" description: "This test plugin walks through all elements in a score"
menuPath: "Plugins.Walk" menuPath: "Plugins.Walk"
@ -25,18 +25,17 @@ MuseScore {
Qt.quit(); Qt.quit();
var cursor = curScore.newCursor(); var cursor = curScore.newCursor();
cursor.rewind(0);
cursor.voice = 0; cursor.voice = 0;
cursor.staffIdx = 0; cursor.staffIdx = 0;
cursor.filter = -1;
cursor.rewind(0);
while (cursor.segment()) { while (cursor.segment()) {
var element = cursor.element(); var e = cursor.element();
if (element) { if (e) {
var type = element.type; console.log("type: " + e.name + " (" + e.type + ") at tick: " + e.tick + " color " + e.get("color"));
console.log("type: " + element.type + " tick: " + element.tick() + " color " + element.get("color")); if (e.type == Ms.REST) {
if (type == "Rest") { var d = e.get("duration");
var d = element.get("duration");
console.log(d);
console.log(" duration " + d.numerator + "/" + d.denominator); console.log(" duration " + d.numerator + "/" + d.denominator);
} }
} }