import QtQuick 2.0 import QtQuick.Dialogs 1.2 import QtQuick.Controls 1.0 import MuseScore 3.0 MuseScore { menuPath: "Plugins.break" version: "3.0" description: qsTr("This plugin inserts line breaks.") requiresScore: true pluginType: "dialog" // pluginType: "dock" // dockArea: "right" onRun: { // setLineBreaks(parseInt(4)); } function setLineBreaks(ai_no) { var cursor; var lbreak; var li_measure; if (!curScore) {Qt.quit();} lbreak = newElement (Element.LAYOUT_BREAK); lbreak.layoutBreakType = LayoutBreak.LINE; cursor = curScore.newCursor(); cursor.rewind(0); // cursor.rewind(Cursor.SCORE_START); li_measure = 0; while (cursor.measure) { li_measure++; if (li_measure % ai_no == 0) { lbreak.score = curScore; cursor.add (lbreak.clone ()); } cursor.nextMeasure(); } cursor.rewind(0); return; } id:window width: 200; height: 100; Label { id: textLabel wrapMode: Text.WordWrap text: qsTr("Select measures/line") font.pointSize:10 anchors.left: window.left anchors.top: window.top anchors.leftMargin: 20 anchors.topMargin: 5 } TextField { id:myText anchors.top: textLabel.bottom anchors.left: window.left anchors.right: window.right anchors.topMargin: 30 anchors.bottomMargin: 10 anchors.leftMargin: 10 anchors.rightMargin: 100 maximumLength: 5 width:20 height:20 } SpinBox { id:spinNo value: 4 minimumValue : 2 maximumValue : 12 anchors.top: textLabel.bottom anchors.right: window.right anchors.leftMargin: 100 anchors.rightMargin: 10 width:50 height:20 } Button { id : buttonOK text: qsTr("Set Line Breaks") anchors.top: textLabel.bottom anchors.left: window.left anchors.right: window.right anchors.topMargin: 10 anchors.bottomMargin: 10 anchors.leftMargin: 10 anchors.rightMargin: 100 onClicked: { myText.text = spinNo.value + ""; setLineBreaks(parseInt(spinNo.value)); // Qt.quit(); } } }