Add comments to a score (Changelog, notes etc...)
Last weekend I sat down with a french music teacher, composer, and MuseScore user @skunt. He asked me if it would be possible to have a dialog where he could write some text notes. He would use this dialog to write down the current state of the score, TODOs, things to be worked on. With his students, he would use it to add some comments about the state of learning process of the piece etc...
So I wrote a plugin: https://musescore.org/en/project/scorecomments
Once installed and activate, go to Plugins > Comments and a dialog will pop up. Enter some text, save your score, and next time you open it, this dialog will show the same text.
Comments
works well. thank you.
works well. thank you.
Awesome work and great plugin !
With a shortcut to call it, it's perfect !
Thanks lasconic !!
In reply to Awesome work and great plugin by skunt
Now working with this plugin :)
To launch it with a shortcut (ALT- works well), it's ok. But to close the window I must leave my keyboard and take the mouse, it's not very useful.
Is there a way to close by pressing ESC key e.g. ?
In reply to Now working with this plugin by skunt
Alt+F4? Certainly does work on Windows.
In reply to Alt+F4? Certainly does work by Jojo-Schmitz
Thanks, I will try with this OS. Actually, I use a macbook, it doesn't work. I try with cmd+W but it close the current file.
In reply to Thanks, I will try with this by skunt
Alt+F4 is the generic Windows shortcut to close a window. I don't know whether macOS or Linux provides one too
As per Google ⌘+W should close the top window, ⌘+⌥+ should close all windows of the current app
In reply to Alt+F4 is the generic Windows by Jojo-Schmitz
Thanks for your proposal.
I thought rather add to the plugin code a function like Qt.qui(); when I press esc key, but my skills in code are extremely limited !
In reply to Thanks for your proposal. I by skunt
I updated the plugin. It will now focus in the TextArea by default and pressing Escape when in the TextArea will quit the plugin.
In reply to I updated the plugin. It will by [DELETED] 5
My hero :-D !
This is going to cost me in wine bottles...
In reply to I updated the plugin. It will by [DELETED] 5
Hmm, is it useful that you can open that plugin without a current score?
In reply to Hmm, is it useful that you by Jojo-Schmitz
Exact. But without current score, there is any metaTags record, also no action.
In reply to Exact. But without current by skunt
It doesn't really harm, but doesn't do any good either, and should get prevenddt. Unfortunatly the requiresScore property is not available in 2.0, but what about `if (currentScore === 'undefined' ) Qt.quit()` Not sure this works with "pluginType: Dialog" though
In reply to It doesn't really harm, but by Jojo-Schmitz
You're right for the expected behavior.
Maybe this condition will work only if cur.Score is defined before, right ?
In reply to It doesn't really harm, but by Jojo-Schmitz
Can't we have 09e268ed cherry picked for 2.0.4?
In reply to It doesn't really harm, but by Jojo-Schmitz
@Jojo: Qt.quit() indeed works for dialog.
See https://github.com/jeetee/MuseScore_TempoChanges/blob/master/TempoChang…
In reply to @Jojo: Qt.quit() indeed works by jeetee
OK, tried with `if (!curScore)` and it seems to work, sort of (the dialog shows up very briefly still),
it didn't work at all with `if (typeof curScore === 'undefined' )` though.
PR created and sent ;-)
BTW: the problem with the short flashing dialog exists with my Batch convert plugin too, here at MuseScore start and only visible if the computer is quite slow or pretty busy with some other stuff. And hints how to avoid that are appreciated...
In reply to OK, tried with `if by Jojo-Schmitz
With some minor changes the flashing dialog can be removed.
Use a window object and only display it if a score is open.
You need to import the window type with
{syntaxhighlighter class="brush: js"}
import QtQuick.Window 2.2
{/syntaxhighlighter}
The top of the code then should look like this:
{syntaxhighlighter class="brush: js"}
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.2
import MuseScore 1.0
MuseScore {
menuPath : "Plugins.Comments"
version : "2.0"
description : qsTr("This plugin adds comments to your score")
pluginType : "Dialog"
//requiresScore: true // needs MuseScore > 2.0.3
onRun : {
if (!curScore) {
Qt.quit();
} else {
window.visible = true;
}
}
Window {
id : window
width : 400;
height : 300;
visible : false
Label {
{/syntaxhighlighter}
And to save the text if the window is closed by clicking the windows X tool at the end of the Window object (still within it) add:
{syntaxhighlighter class="brush: js"}
onClosing : {
if (curScore)
curScore.setMetaTag("comments", abcText.text)
Qt.quit()
}
{/syntaxhighlighter}
I also like the plugins to remember where I left the window last time I used it, and by using window we can.
At the end of the window object (still within the window object) add :
{syntaxhighlighter class="brush: js"}
Component.onCompleted : {
if (curScore) {
var metrics = curScore.metaTag("metrics");
if (metrics) {
metrics = JSON.parse(metrics);
window.x = metrics.x;
window.y = metrics.y;
window.width = metrics.width;
window.height = metrics.height;
}
}
}
{/syntaxhighlighter}
And change the on closing to:
{syntaxhighlighter class="brush: js"}
onClosing : {
if (curScore) {
var metrics = {
x : window.x,
y : window.y,
width : window.width,
height : window.height
}
curScore.setMetaTag("comments", abcText.text)
curScore.setMetaTag("metrics", JSON.stringify(metrics));
}
Qt.quit()
}
{/syntaxhighlighter}
I initially missed the mod to close the window on escape, we need to modify the key handler to:
{syntaxhighlighter class="brush: js"}
Keys.onPressed : {
if (event.key == Qt.Key_Escape) {
if (curScore) {
curScore.setMetaTag("comments", text)
var metrics = {
x : window.x,
y : window.y,
width : window.width,
height : window.height
}
curScore.setMetaTag("metrics", JSON.stringify(metrics));
}
window.close();
Qt.quit()
}
}
{/syntaxhighlighter}
Full code with these mods is available here:
https://docs.google.com/document/d/1VsWhX7ThMM693D7e_tggjuDBndC8sIpqXWV…
Copy and paste it to a new plugin.
I can't find out what pluginType : "Dialog" actually does, but as it runs with it there, I left it in.
There is an awful lot of functionality in the QML environment, I'm just getting to grips with some of it.
Hope it helps.
In reply to With some minor changes the by stevel05
Awesome ideas to improve this plugin ! Thanks guys !
@Stevel05: Your code works very well ! Thank you for the explanations and your contribution.
My question is : what happen if the user modify or delete metrics informations in Score Properties ? The window dialog seems to use its default centered position.
In reply to Awesome ideas to improve this by skunt
Yes, if there is no metrics (first time it's run) it will use the default centered position. If it's changed to something that can't be parsed via JSON, it will ignore it and use the default until saved again by exiting the plugin.
In reply to With some minor changes the by stevel05
You could just as well wrap into another Dialog iso a Window, similar setup, slightly different visual effect.
As for saving settings for/from a plugin, you're better off using the actual settings provision rather than storing it in the score (what you're doing now). See https://github.com/jeetee/MuseScore_Plugin_Examples for an example using both techniques.
@steve: pluginType: "dialog" and "dock" results in a different wrapping structure when the plugin is loaded, see https://github.com/musescore/MuseScore/blob/522e84dfb196ac7a61830c4666f…
In reply to You could just as well wrap by jeetee
Thanks jeetee I will check that out. For my own plugin I do use a different approach as it is storing a lot of data.
In reply to Thanks jeetee I will check by stevel05
It appears that I can no longer modify the post with the code above, but the full code version incorporates jeetee's suggestion.
Available here:
https://docs.google.com/document/d/1VsWhX7ThMM693D7e_tggjuDBndC8sIpqXWV…
In reply to It appears that I can no by stevel05
Pull requests welcome. https://github.com/lasconic/musescore_comments
I'm not a fan at all of saving the dialog metrics in the score properties... If you use different computers or share your files with others, the dialog might be completely out of screen.
Probably better to use Qt.labs.settings
Regarding requireScore in 2.0.4/2.1, I don't think it's a good idea either (sorry). It would mean that plugin made for this version would not work with 2.0.X, and that would be a pity.
In reply to Pull requests welcome. by [DELETED] 5
Thanks lasconic,
I'm not yet completely familiar with github and pull requests, but now seems like a good time to learn.
Steve
In reply to Pull requests welcome. by [DELETED] 5
Can we check for requireScore in a portable manner?
In reply to Can we check for requireScore by Jojo-Schmitz
@Jojo: No is the short answer.
The plugin code in the older/current released versions is very strict of which members/children appear at the 1st level of the plugin. Having requireScore in your plugin means the plugin itself can't get instantiated in 2.0.x
That's all water under the bridge unfortunately.
In reply to You could just as well wrap by jeetee
@stevel05 did a pull request, and it's now merged. Give it a try.
In reply to @stevel05 did a pull request, by [DELETED] 5
On my macOS Sierra and musescore 2.0.3.1 :
It works, but there is two problems :
1/ There are tow windows that appears when I launch le plugin : the second window is grey :
2/ If the window is open : I type some text but I don't press esc key : I click on the save icon : the window plugin closes and the comments is not saved in the metaTag.
In reply to On my macOS Sierra and by skunt
Missing text should now be fixed, I will try to look at the double window, which doesn't happen on my version of windows (10), if I can get an old Mac up and running.
In reply to Missing text should now be by stevel05
@skunt
Double window should now be fixed, please test it when you have time.
In reply to @skunt Double window should by stevel05
1/ the second window has disappeared. This bug is fixed.
2/ if save without quit the plugin dialog, the text is correctly saved. Bug fixed.
3/ I saw that the position of the dialog is saved too.
4/ Without current score opened, laughing the plugin does not do anything. So, ok.
Now, this plugin seems to have a great behavior. Thanks @stevel05, great work !
https://musescore.org/en/comment/reply/node/142446/comment_forum#page-t…