Break every X measures plugin for 2.0
import QtQuick 2.0
import MuseScore 1.0
import QtQuick.Controls 1.1
MuseScore {
menuPath: "Plugins.Break every X measures"
description: qsTr("This plugin will add a line break every X measures in the selection or in in the full score if no selection.")
pluginType: "dialog"
width: 230
height: 50
id: window
onRun: {}
function make() {
var m = curScore.firstMeasure
var nNum = 1
while (m) {
if (nNum == input.text){
m.lineBreak = true
nNum = 0
} else {
m.lineBreak = false
}
m = m.nextMeasure
nNum++
}
Qt.quit()
}
TextInput {
id: input
maximumLength: 3
text: "4"
inputMask: "000"
focus: true
anchors.top: window.top
anchors.topMargin: 10
anchors.left: window.left
anchors.leftMargin: 100
font.bold: true
font.pointSize: 15
smooth: false
}
Button {
id : buttonCancel
text: qsTr("Cancel")
anchors.bottom: window.bottom
anchors.right: window.right
anchors.topMargin: 10
anchors.bottomMargin: 0
onClicked: { Qt.quit() }
}
Button {
id : buttonOK
text: qsTr("OK")
anchors.bottom: window.bottom
anchors.left: window.left
anchors.topMargin: 10
anchors.bottomMargin: 0
onClicked: { make() }
}
}
1) TextInput is broken...
2) Score is not updated...
(Sorry, I do not speak in English. I use Google translate.)
Comments
That plugin is no longer needed (and not distributed with 2.0 any longer either, so where did you get it from?), its functionality is now built-in and you'd find it in the Tools menu. See https://musescore.org/en/node/42631#line-breaks
In reply to That plugin is no longer by Jojo-Schmitz
Thank you!
I wrote this plugin itself.
Now, still wondering why it does not work.
In reply to Thank you! I wrote this by martin.ludenhoff
Wrote it yourself? It looks remarkably similar to what used to get distributed... and that version too had a problem with the input field, I guess that was one of the reason to fully integrate it.
In reply to Wrote it yourself? It looks by Jojo-Schmitz
Yes, itself.
Still but why not updated score?
In reply to Yes, itself. Still but why by martin.ludenhoff
The problem is, you don't use any documented (or implemented) method to change the score. I don't know where m.lineBreak comes from. But it is neither documented nor implemented and won't do anything.
In reply to The problem is, you don't use by heuchi
m.lineBreak is inside the guide! (MeasureBase class)
>> ...any documented (or implemented) method to change the score...
For example?
That can be called after set m.linebreak?
In reply to The problem is, you don't use by heuchi
m.lineBreak is inside the guide! (MeasureBase class)
>> ...any documented (or implemented) method to change the score...
For example?
That can be called after set m.linebreak?
In reply to The problem is, you don't use by heuchi
?? This is documented and should work. And it did, back when that plugin got distributed (i.e. before the implementation of the corresponding tool)
In reply to ?? This is documented and by Jojo-Schmitz
It "works" if you hit then Ctrl + S.
In reply to It "works" if you hit then by martin.ludenhoff
Yeah, sorry, it works, I just looked at Measure and didn't find it there...
In reply to Yeah, sorry, it works, I just by heuchi
The second thing about your code is:
pluginType: "dialog"
I wouldn't use that. But instead create a real dialog (using QtQuick.Dialogs 1.2 for example).
It should work then.
In reply to ?? This is documented and by Jojo-Schmitz
>> This is documented and should work.
Have you tried to run my code?
In reply to >> This is documented and by martin.ludenhoff
No, but if i read the code correctly, it would create exactly one line break
Dig up the original version from the Git repository to see how that did it, there should at least be some modulo operation
In reply to No, but if i read the code by Jojo-Schmitz
>> but if i read the code correctly, it would create exactly one line break
No.
Run the code, then press Ctrl+S.
In reply to >> but if i read the code by martin.ludenhoff
double post
In reply to double post by Jojo-Schmitz
>> Ctrl-S is Save Score
Yes.
Code only problem is that breaks appear only after that.
In reply to >> Ctrl-S is Save by martin.ludenhoff
Here's the last version of the official breaks plugin, as you may see it does change the score without saving
I guess it is the curCursor.startCmd() and ...endCmd() that is missing in your's?
In reply to Here's the last version of by Jojo-Schmitz
>> Here's the last version of the official breaks plugin...
Thank you! It works fine!
It works better than the built-in function.
For example, select two measure and try to insert a break every 1 measure.
In reply to >> Here's the last version of by martin.ludenhoff
You mean that it does not add a line break to the 2nd selected measure?
Reported in #56536: "Break every X measures" tool does not operate on the last measure in selection
In reply to You mean that it does not add by Jojo-Schmitz
>> You mean that it does not add a line break to the 2nd selected measure?
Yes.
In reply to >> You mean that it does not by martin.ludenhoff
Looks like some of-by-one error
In reply to >> but if i read the code by martin.ludenhoff
Ctrl-S is Save Score, why should I want to do that?
Ah, I see, it does indeed add those line breaks every 4 measure, but only after saving the score, very strange.
This means however that the "m.lineBreak = true" does work like documented
In reply to Ctrl-S is Save Score, why by Jojo-Schmitz
>> very strange.
>> This means however that the "m.lineBreak = true" does work like documented
That this question :)
In reply to >> very strange. >> This by martin.ludenhoff
Well, that part definitely does work...
In reply to Well, that part definitely by Jojo-Schmitz
I tried your code and I don't understand your 1) problem. TextInput works fine for me.
About the other things:
This will not call Score.cmdStart() and Score.cmdEnd() automatically and therefore:
If you use pluginType: "dialog" you will need to include the calls to curScore.startCmd() and curScore.endCmd() as Jojo-Schmitz said.
In reply to I tried your code and I don't by heuchi
as I guessed actually :-) so thanks for the confirmation...
In reply to I tried your code and I don't by heuchi
Thanks!