forked from BernardGreenberg/MuseScorePlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rednote.qml
75 lines (66 loc) · 2.28 KB
/
rednote.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2012 Werner Schweer
// Copyright (C) 2013-2017 Nicolas Froment, Joachim Schmitz
// Copyright (C) 2019 Bernard Greenberg
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//
// 3.1 6 Sept 2019 -- moved out of submenu to attempt to address selection prob.
// 3.2 3 Oct 2019 -- don't call Qt.Quit, closes dock plugins.
//=============================================================================
import QtQuick 2.2
import MuseScore 3.0
import QtQuick.Dialogs 1.1
MuseScore {
version: "3.2"
description: qsTr("This plugin colors the selected note(s) red.")
menuPath: "Plugins.Red Note"
property string red : "#ff0000"
function colorNote(note) {
note.color = red;
if (note.accidental) {
note.accidental.color = red;
}
for (var i = 0; i < note.dots.length; i++) {
if (note.dots[i]) {
note.dots[i].color = red;
}
}
}
onRun: {
console.log("hello red notes");
if ((mscoreMajorVersion < 3) || (mscoreMinorVersion < 3)) {
versionError.open()
Qt.quit();
return;
}
var selection = curScore.selection;
var elements = selection.elements;
if (elements.length > 0) { // We have a selection list to work with...
console.log(elements.length, "selections")
for (var idx = 0; idx < elements.length; idx++) {
var element = elements[idx]
//console.log("element.type=" + element.type)
if (element.type == Element.NOTE) {
console.log("We found a note! Paint it red!.")
colorNote(element);
}
}
}
}
MessageDialog {
id: versionError
visible: false
title: qsTr("Unsupported MuseScore Version")
text: qsTr("This plugin needs MuseScore 3.3 or later")
onAccepted: {
Qt.quit()
}
}
}