Skip to content

Commit 3182e2d

Browse files
authored
Merge pull request #13 from lasconic/revert-12-master
Revert "Port to MuseScore 3.x"
2 parents 475561a + e4d9b5d commit 3182e2d

File tree

2 files changed

+73
-23
lines changed

2 files changed

+73
-23
lines changed

blacknotes.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//=============================================================================
2+
// Black notes : Paint all notes in black
3+
// http://musescore.org/en/project/blacknotes
4+
//
5+
// Copyright (C)2010 Nicolas Froment (lasconic)
6+
//
7+
// This program is free software; you can redistribute it and/or modify
8+
// it under the terms of the GNU General Public License version 2.
9+
//
10+
// This program is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with this program; if not, write to the Free Software
17+
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18+
//=============================================================================
19+
20+
//---------------------------------------------------------
21+
// init
22+
//---------------------------------------------------------
23+
24+
function init()
25+
{
26+
}
27+
28+
//-------------------------------------------------------------------
29+
// run
30+
//-------------------------------------------------------------------
31+
32+
function run()
33+
{
34+
if (typeof curScore === 'undefined')
35+
return;
36+
37+
var black = new QColor(0, 0, 0);
38+
var cursor = new Cursor(curScore);
39+
for (var staff = 0; staff < curScore.staves; ++staff) {
40+
cursor.staff = staff;
41+
for (var v = 0; v < 4; v++) {
42+
cursor.voice = v;
43+
cursor.rewind(); // set cursor to first chord/rest
44+
45+
while (!cursor.eos()) {
46+
if (cursor.isChord()) {
47+
var chord = cursor.chord();
48+
var n = chord.notes;
49+
for (var i = 0; i < n; i++) {
50+
var note = chord.note(i);
51+
if (note.color != black)
52+
note.color = black;
53+
}
54+
}
55+
cursor.next();
56+
}
57+
}
58+
}
59+
}
60+
61+
var mscorePlugin = {
62+
menu: 'Plugins.Notes.Color notes in black',
63+
init: init,
64+
run: run
65+
};
66+
67+
mscorePlugin;

blacknotes.qml

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// Copyright (C)2010 Nicolas Froment (lasconic)
66
// Copyright (C)2014 Jörn Eichler (heuchi)
7-
// Copyright (C)2012-2019 Joachim Schmitz (Jojo-Schmitz)
7+
// Copyright (C)2012-2015 Joachim Schmitz (Jojo-Schmitz)
88
//
99
// This program is free software; you can redistribute it and/or modify
1010
// it under the terms of the GNU General Public License version 2.
@@ -19,25 +19,14 @@
1919
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2020
//=============================================================================
2121

22-
import QtQuick 2.9
23-
import QtQuick.Dialogs 1.2
24-
import MuseScore 3.0
22+
import QtQuick 2.2
23+
import MuseScore 1.0
2524

2625
MuseScore {
27-
version: "3.0"
26+
version: "1.0"
2827
description: "This plugin paints all chords and rests in black"
2928
menuPath: "Plugins.Notes.Color Notes in Black"
3029

31-
MessageDialog {
32-
id: versionError
33-
visible: false
34-
title: qsTr("Unsupported MuseScore Version")
35-
text: qsTr("This plugin needs MuseScore 3.0.2 or later")
36-
onAccepted: {
37-
Qt.quit()
38-
}
39-
}
40-
4130
function blackenElement(element) {
4231
if (element.type == Element.REST)
4332
element.color = "black"
@@ -51,7 +40,7 @@ MuseScore {
5140
if (element.stemSlash)
5241
element.stemSlash.color = "black"
5342
}
54-
else if (element.type == Element.NOTE) {
43+
else if (element.type == Element.NOTE) {
5544
element.color = "black"
5645
if (element.accidental)
5746
element.accidental.color = "black"
@@ -60,8 +49,6 @@ MuseScore {
6049
element.dots[i].color = "black"
6150
}
6251
}
63-
else
64-
console.log("Unknown element type: " + element.type)
6552
}
6653

6754
// Apply the given function to all chords and rests in selection
@@ -129,11 +116,7 @@ MuseScore {
129116
}
130117

131118
onRun: {
132-
console.log("Hello, Black Notes")
133-
// check MuseScore version
134-
if (mscoreMajorVersion == 3 && mscoreMinorVersion == 0 && mscoreUpdateVersion <= 1)
135-
versionError.open()
136-
else
119+
if (typeof curScore !== 'undefined')
137120
applyToChordsAndRestsInSelection(blackenElement)
138121
Qt.quit();
139122
}

0 commit comments

Comments
 (0)