Skip to content

Commit

Permalink
Merge pull request #4000 from Jojo-Schmitz/plugins
Browse files Browse the repository at this point in the history
fix #175726: first step at getting plugins to work in master
  • Loading branch information
anatoly-os committed Oct 25, 2018
2 parents 2efabba + 98207a4 commit 44b28b7
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 55 deletions.
13 changes: 7 additions & 6 deletions libmscore/score.h
Expand Up @@ -316,10 +316,10 @@ class Movements : public std::vector<MasterScore*> {

//---------------------------------------------------------------------------------------
// @@ Score
// @P composer string composer of the score (read only)
//// @P composer string composer of the score (read only)
// @P duration int duration of score in seconds (read only)
// @P excerpts array[Excerpt] the list of the excerpts (linked parts)
// @P firstMeasure Measure the first measure of the score (read only)
//// @P excerpts array[Excerpt] the list of the excerpts (linked parts)
//// @P firstMeasure Measure the first measure of the score (read only)
// @P firstMeasureMM Measure the first multi-measure rest measure of the score (read only)
// @P harmonyCount int number of harmony items (read only)
// @P hasHarmonies bool score has chord symbols (read only)
Expand All @@ -329,13 +329,14 @@ class Movements : public std::vector<MasterScore*> {
// @P lastMeasureMM Measure the last multi-measure rest measure of the score (read only)
// @P lastSegment Segment the last score segment (read-only)
// @P lyricCount int number of lyric items (read only)
// @P name string name of the score
//// @P name string name of the score
// @P nmeasures int number of measures (read only)
// @P npages int number of pages (read only)
// @P nstaves int number of staves (read only)
// @P ntracks int number of tracks (staves * 4) (read only)
// not to be documented?
// @P parts array[Part] the list of parts (read only)
//// @P parts array[Part] the list of parts (read only)
// @P mscoreVersion QString MuseScore version the score was last saved with (read only)
// @P mscoreRevision QString MuseScore revision the score was last saved with (read only)
//
// a Score has always an associated MasterScore
//---------------------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions share/plugins/abc_import.qml
Expand Up @@ -20,12 +20,12 @@
import QtQuick 2.1
import QtQuick.Dialogs 1.0
import QtQuick.Controls 1.0
import MuseScore 1.0
import FileIO 1.0
import MuseScore 3.0
import FileIO 3.0

MuseScore {
menuPath: "Plugins.ABC Import"
version: "2.0"
version: "3.0"
description: qsTr("This plugin imports ABC text from a file or the clipboard. Internet connection is required.")
requiresScore: false
pluginType: "dialog"
Expand Down
34 changes: 17 additions & 17 deletions share/plugins/colornotes.qml
Expand Up @@ -16,7 +16,7 @@ import QtQuick 2.2
import MuseScore 3.0

MuseScore {
version: "1.0"
version: "3.0"
description: qsTr("This plugin colors notes in the selection depending on their pitch as per the Boomwhackers convention")
menuPath: "Plugins.Notes.Color Notes"

Expand Down Expand Up @@ -46,7 +46,7 @@ MuseScore {
var endStaff;
var endTick;
var fullScore = false;
if (!cursor.segment) { // no selection
if (!cursor.segment()) { // no selection
fullScore = true;
startStaff = 0; // start with 1st staff
endStaff = curScore.nstaves - 1; // and end with last
Expand Down Expand Up @@ -74,16 +74,16 @@ MuseScore {
if (fullScore)
cursor.rewind(0) // if no selection, beginning of score

while (cursor.segment && (fullScore || cursor.tick < endTick)) {
if (cursor.element && cursor.element.type === Element.CHORD) {
var graceChords = cursor.element.graceNotes;
while (cursor.segment() && (fullScore || cursor.tick < endTick)) {
if (cursor.element() && cursor.element().type === Ms.CHORD) {
var graceChords = cursor.element().graceNotes;
for (var i = 0; i < graceChords.length; i++) {
// iterate through all grace chords
var graceNotes = graceChords[i].notes;
for (var j = 0; j < graceNotes.length; j++)
func(graceNotes[j]);
}
var notes = cursor.element.notes;
var notes = cursor.element().notes;
for (var k = 0; k < notes.length; k++) {
var note = notes[k];
func(note);
Expand All @@ -96,24 +96,24 @@ MuseScore {
}

function colorNote(note) {
if (note.color == black)
note.color = colors[note.pitch % 12];
if (note.get("color") === black)
note.set("color", colors[note.pitch % 12]);
else
note.color = black;
note.set("color", black);

if (note.accidental) {
if (note.accidental.color == black)
note.accidental.color = colors[note.pitch % 12];
else
note.accidental.color = black;
//if (note.accidental.get("color") === black)
//note.accidental.set("color", colors[note.pitch % 12]);
//else
note.accidental.set("color", black);
}

for (var i = 0; i < note.dots.length; i++) {
if (note.dots[i]) {
if (note.dots[i].color == black)
note.dots[i].color = colors[note.pitch % 12];
else
note.dots[i].color = black;
//if (note.dots[i].get("color") === black)
//note.dots[i].set("color", colors[note.pitch % 12]);
//else
note.dots[i].set("color", black);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions share/plugins/createscore.qml
@@ -1,8 +1,8 @@
import QtQuick 2.0
import MuseScore 1.0
import MuseScore 3.0

MuseScore {
version: "2.0"
version: "3.0"
description: "This demo plugin creates a new score."
menuPath: "Plugins.createscore"
requiresScore: false
Expand Down
10 changes: 5 additions & 5 deletions share/plugins/helloqml/helloqml.qml
@@ -1,10 +1,10 @@
import QtQuick 2.0
import MuseScore 1.0
import MuseScore 3.0


MuseScore {
menuPath: "Plugins.helloQml"
version: "2.0"
version: "3.0"
description: qsTr("This demo plugin shows some basic tasks.")
pluginType: "dialog"

Expand All @@ -26,10 +26,10 @@ MuseScore {
while (segment) {
var element
element = segment.elementAt(0)
if (element && element.type == Element.CHORD) {
if (element() && element().type == Ms.CHORD) {
console.log(qsTr(" element"))
console.log(element.beamMode)
if (element.beamMode == BeamMode.NO)
console.log(element().beamMode)
if (element().beamMode == BeamMode.NO)
console.log(" beam no")
}
segment = segment.next()
Expand Down
18 changes: 9 additions & 9 deletions share/plugins/notenames.qml
Expand Up @@ -15,10 +15,10 @@
//=============================================================================

import QtQuick 2.0
import MuseScore 1.0
import MuseScore 3.0

MuseScore {
version: "2.0"
version: "3.0"
description: qsTr("This plugin names notes as per your language setting")
menuPath: "Plugins.Notes." + qsTr("Note Names") // this does not work, why?

Expand Down Expand Up @@ -124,7 +124,7 @@ MuseScore {
var endTick;
var fullScore = false;
cursor.rewind(1);
if (!cursor.segment) { // no selection
if (!cursor.segment()) { // no selection
fullScore = true;
startStaff = 0; // start with 1st staff
endStaff = curScore.nstaves - 1; // and end with last
Expand Down Expand Up @@ -153,11 +153,11 @@ MuseScore {
if (fullScore) // no selection
cursor.rewind(0); // beginning of score

while (cursor.segment && (fullScore || cursor.tick < endTick)) {
if (cursor.element && cursor.element.type === Element.CHORD) {
var text = newElement(Element.STAFF_TEXT);
while (cursor.segment() && (fullScore || cursor.tick < endTick)) {
if (cursor.element() && cursor.element().type === Ms.CHORD) {
var text = newElement(Ms.STAFF_TEXT);

var graceChords = cursor.element.graceNotes;
var graceChords = cursor.element().graceNotes;
for (var i = 0; i < graceChords.length; i++) {
// iterate through all grace chords
var graceNotes = graceChords[i].notes;
Expand All @@ -174,10 +174,10 @@ MuseScore {

cursor.add(text);
// new text for next element
text = newElement(Element.STAFF_TEXT);
text = newElement(Ms.STAFF_TEXT);
}

var notes = cursor.element.notes;
var notes = cursor.element().notes;
nameChord(notes, text);

switch (voice) {
Expand Down
4 changes: 2 additions & 2 deletions share/plugins/panel.qml
@@ -1,10 +1,10 @@
import QtQuick 2.0
import MuseScore 1.0
import MuseScore 3.0


MuseScore {
menuPath: "Plugins.panel"
version: "2.0"
version: "3.0"
description: "This demo plugin creates a GUI panel."
requiresScore: false

Expand Down
4 changes: 2 additions & 2 deletions share/plugins/random.qml
@@ -1,8 +1,8 @@
import QtQuick 2.1
import MuseScore 1.0
import MuseScore 3.0

MuseScore {
version: "2.1"
version: "3.0"
description: "Create random score."
menuPath: "Plugins.random"
requiresScore: false
Expand Down
4 changes: 2 additions & 2 deletions share/plugins/random2.qml
@@ -1,10 +1,10 @@
import QtQuick 2.1
import MuseScore 1.0
import MuseScore 3.0
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0

MuseScore {
version: "2.1"
version: "3.0"
description: "Create random score."
menuPath: "Plugins.random2"
requiresScore: false
Expand Down
4 changes: 2 additions & 2 deletions share/plugins/run.qml
Expand Up @@ -23,11 +23,11 @@
//=============================================================================

import QtQuick 2.0
import MuseScore 1.0
import MuseScore 3.0

MuseScore {
menuPath: "Plugins.run"
version: "2.0"
version: "3.0"
description: "This demo plugin runs an external command. Probably this will only work on Linux."
requiresScore: false

Expand Down
4 changes: 2 additions & 2 deletions share/plugins/scorelist.qml
@@ -1,10 +1,10 @@
import QtQuick 2.0
import MuseScore 1.0
import MuseScore 3.0


MuseScore {
menuPath: "Plugins.scorelist"
version: "2.0"
version: "3.0"
description: "This test plugin iterates through the score list."
pluginType: "dialog"

Expand Down
4 changes: 2 additions & 2 deletions share/plugins/view.qml
@@ -1,8 +1,8 @@
import QtQuick 2.0
import MuseScore 1.0
import MuseScore 3.0

MuseScore {
version: "1.0"
version: "3.0"
description: "Demo plugin to demonstrate the use of a ScoreView"
menuPath: "Plugins.ScoreView"
pluginType: "dialog"
Expand Down
2 changes: 1 addition & 1 deletion share/plugins/walk.qml
Expand Up @@ -34,7 +34,7 @@ MuseScore {
var e = cursor.element();
if (e) {
console.log("type: " + e.name + " (" + e.type + ") at tick: " + e.tick + " color " + e.get("color"));
if (e.type == Ms.REST) {
if (e.type === Ms.REST) {
var d = e.get("duration");
console.log(" duration " + d.numerator + "/" + d.denominator);
}
Expand Down

0 comments on commit 44b28b7

Please sign in to comment.