From bf4b923d9450f387c440bfcc7e258ba75f32d887 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 2 Jan 2023 14:49:15 +0100 Subject: [PATCH 1/6] Update for MuseScore 4: replace Qt.quit() with quit() --- tin_whistle_tablature.qml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tin_whistle_tablature.qml b/tin_whistle_tablature.qml index 6c882e9..ca561e9 100644 --- a/tin_whistle_tablature.qml +++ b/tin_whistle_tablature.qml @@ -49,7 +49,7 @@ MuseScore { "This is due to a quirk in the QT framework that MuseScore uses to implement the program.\n" + "Note that you will also need to restart MuseScore for it to recognize the new font." onAccepted: { - Qt.quit() + quit() } } @@ -61,7 +61,7 @@ MuseScore { text: "No selected staff in the current score uses a tin whistle instrument.\n" + "Use menu command \"Edit -> Instruments\" to select your instrument." onAccepted: { - Qt.quit() + quit() } } @@ -387,14 +387,14 @@ MuseScore { cursor.next() } // end while segment } // end for staff - Qt.quit() + quit() } onRun: { console.log("Hello tin whistle tablature") if (typeof curScore === 'undefined') - Qt.quit() + quit() if (Qt.fontFamilies().indexOf("Tin Whistle Tab") >= 0) { renderTinWhistleTablature() @@ -403,6 +403,6 @@ MuseScore { } else fontMissingDialog.open() - Qt.quit() + quit() } // end onRun } From 95cba1fcd706120336ff2502b6fe1394f295ce87 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 2 Jan 2023 14:52:15 +0100 Subject: [PATCH 2/6] Don't try to use staff index for parts list Parts and staves are different things. A part may have multiple staves. Therefore, it is invalid to use a staff index to obtain a part from the parts list. Instead, we should take the staff from the staves list and then take the part for that staff. --- tin_whistle_tablature.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tin_whistle_tablature.qml b/tin_whistle_tablature.qml index ca561e9..357e98f 100644 --- a/tin_whistle_tablature.qml +++ b/tin_whistle_tablature.qml @@ -138,9 +138,9 @@ MuseScore { for (var staff = startStaff; staff <= endStaff; staff++) { // check that it is for a tin whistle var instrument; - var hasInstrumentId = curScore.parts[staff].instrumentId !== undefined; + var hasInstrumentId = curScore.staves[staff].part.instrumentId !== undefined; if (hasInstrumentId) { - instrument = curScore.parts[staff].instrumentId + instrument = curScore.staves[staff].part.instrumentId } else { // Assume a D whistle if currently running MuseScore version is missing // the instrumentId property. From 59c2d55ed01dfa6eaac972adb21c733af888b945 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 2 Jan 2023 16:24:16 +0100 Subject: [PATCH 3/6] Update for MuseScore 4: add missing start/endCmd calls --- tin_whistle_tablature.qml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tin_whistle_tablature.qml b/tin_whistle_tablature.qml index 357e98f..973ef1c 100644 --- a/tin_whistle_tablature.qml +++ b/tin_whistle_tablature.qml @@ -103,6 +103,8 @@ MuseScore { } function renderTinWhistleTablature() { + curScore.startCmd(); + // select either the full score or just the selected staves var cursor = curScore.newCursor(); var startStaff; @@ -387,6 +389,8 @@ MuseScore { cursor.next() } // end while segment } // end for staff + + curScore.endCmd(); quit() } From 16a9ef1b43b5df3708d61dd18e101e9f8d51e8a5 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 2 Jan 2023 16:36:04 +0100 Subject: [PATCH 4/6] Update for MuseScore 4: recognize MuseScore's own instrument IDs MuseScore 3 returned the MusicXML instrument ID, MuseScore 4 returns its own instrument ID. This change might be reverted in MuseScore 4.0.1, but we will just make sure we recognize MuseScore's own instrument IDs too. --- tin_whistle_tablature.qml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tin_whistle_tablature.qml b/tin_whistle_tablature.qml index 973ef1c..c2d79f0 100644 --- a/tin_whistle_tablature.qml +++ b/tin_whistle_tablature.qml @@ -149,7 +149,8 @@ MuseScore { instrument = "wind.flutes.whistle.tin.d" } - if (instrument == "wind.flutes.whistle.tin") { + // MuseScore 3 returned the MusicXML instrument ID, MuseScore 4 returns its own instrument ID + if (instrument == "wind.flutes.whistle.tin" || instrument === "c-tin-whistle") { basePitch = 72 // default is C tuning (even though D is the most common) tabOffsetY = 3.3 whistleFound = true; @@ -157,11 +158,11 @@ MuseScore { basePitch = 72 // C tuning tabOffsetY = 3.3 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.tin.bflat") { + } else if (instrument == "wind.flutes.whistle.tin.bflat" || instrument === "bflat-tin-whistle") { basePitch = 70 // B flat tuning tabOffsetY = 3.6 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.tin.d") { + } else if (instrument == "wind.flutes.whistle.tin.d" || instrument === "d-tin-whistle") { basePitch = 74 // D tuning tabOffsetY = 3 whistleFound = true; From 50a6f195627335cb690bce1ba598b9631dbc8059 Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 2 Jan 2023 16:39:13 +0100 Subject: [PATCH 5/6] Fix some Qt Creator QML warnings --- tin_whistle_tablature.qml | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tin_whistle_tablature.qml b/tin_whistle_tablature.qml index c2d79f0..9509ede 100644 --- a/tin_whistle_tablature.qml +++ b/tin_whistle_tablature.qml @@ -30,8 +30,8 @@ MuseScore { description: qsTr("This plugin provides fingering diagrams for the tin whistle. Ensure font `TinWhistleTab.ttf` is installed") menuPath: "Plugins.Tin Whistle.Add tablature" - property var tabFontName: "Tin Whistle Tab" - property var whistleFound: false + property string tabFontName: "Tin Whistle Tab" + property bool whistleFound: false // The notes from the "Tin Whistle Tab" font, using key of D as standard property variant tabs : ["d", "i", "e", "j", "f", "g", "h", "a", "n", "b", "m", "c", "D", "I", "E", "J", "F", "G", "H", "A", "N", "B", "M", "C", '\u00CE'] @@ -95,7 +95,7 @@ MuseScore { function dumpObjectEntries(obj, showUndefinedVals, title) { console.log("VV -------- " + title + " ---------- VV") for (var key in obj) { - if (showUndefinedVals || (obj[key] != null)) { + if (showUndefinedVals || (obj[key])) { console.log(key + "=" + obj[key]); } } @@ -120,7 +120,7 @@ MuseScore { } else { startStaff = cursor.staffIdx cursor.rewind(2) - if (cursor.tick == 0) { + if (cursor.tick === 0) { // when the selection includes the last measure of the score: // rewind(2) goes behind the last segment (where there's none) // and sets tick=0. Need to fix up tick @@ -150,47 +150,47 @@ MuseScore { } // MuseScore 3 returned the MusicXML instrument ID, MuseScore 4 returns its own instrument ID - if (instrument == "wind.flutes.whistle.tin" || instrument === "c-tin-whistle") { + if (instrument === "wind.flutes.whistle.tin" || instrument === "c-tin-whistle") { basePitch = 72 // default is C tuning (even though D is the most common) tabOffsetY = 3.3 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.tin.c") { + } else if (instrument === "wind.flutes.whistle.tin.c") { basePitch = 72 // C tuning tabOffsetY = 3.3 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.tin.bflat" || instrument === "bflat-tin-whistle") { + } else if (instrument === "wind.flutes.whistle.tin.bflat" || instrument === "bflat-tin-whistle") { basePitch = 70 // B flat tuning tabOffsetY = 3.6 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.tin.d" || instrument === "d-tin-whistle") { + } else if (instrument === "wind.flutes.whistle.tin.d" || instrument === "d-tin-whistle") { basePitch = 74 // D tuning tabOffsetY = 3 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.tin.common") { + } else if (instrument === "wind.flutes.whistle.tin.common") { basePitch = 74 // D tuning (the most common) tabOffsetY = 3 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.tin.eflat") { + } else if (instrument === "wind.flutes.whistle.tin.eflat") { basePitch = 75 // E flat tuning tabOffsetY = 3 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.tin.f") { + } else if (instrument === "wind.flutes.whistle.tin.f") { basePitch = 77 // F tuning tabOffsetY = 3 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.tin.g") { + } else if (instrument === "wind.flutes.whistle.tin.g") { basePitch = 79 // G tuning tabOffsetY = 3 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.low.d") { + } else if (instrument === "wind.flutes.whistle.low.d") { basePitch = 62 // D tuning for low whistle tabOffsetY = 5.6 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.low.f") { + } else if (instrument === "wind.flutes.whistle.low.f") { basePitch = 65 // F tuning for low whistle tabOffsetY = 4.9 whistleFound = true; - } else if (instrument == "wind.flutes.whistle.low.g") { + } else if (instrument === "wind.flutes.whistle.low.g") { basePitch = 67 // G tuning for low whistle tabOffsetY = 4.0 whistleFound = true; @@ -230,12 +230,12 @@ MuseScore { var tabFontSizeGrace = 25 // Size of grace note sized whistle tab image while (cursor.segment && (fullScore || cursor.tick < endTick)) { - if (cursor.element && cursor.element.type == Element.CHORD) { + if (cursor.element && cursor.element.type === Element.CHORD) { var text = newElement(Element.STAFF_TEXT); // Scan grace notes for existence and add to appropriate lists... - var leadingLifo = new Array(); - var trailingFifo = new Array(); + var leadingLifo = []; + var trailingFifo = []; var graceChords = cursor.element.graceNotes; // Determine if Element.posX and Element.posY is supported. (MuseScore 3.3+) var hasElementPos = cursor.element.posX !== undefined; @@ -247,8 +247,8 @@ MuseScore { if (hasNoteType) { for (var chordNum = 0; chordNum < graceChords.length; chordNum++) { var noteType = graceChords[chordNum].notes[0].noteType - if (noteType == NoteType.GRACE8_AFTER || noteType == NoteType.GRACE16_AFTER || - noteType == NoteType.GRACE32_AFTER) { + if (noteType === NoteType.GRACE8_AFTER || noteType === NoteType.GRACE16_AFTER || + noteType === NoteType.GRACE32_AFTER) { trailingFifo.unshift(graceChords[chordNum]) } else { leadingLifo.push(graceChords[chordNum]) @@ -300,7 +300,7 @@ MuseScore { } // Next process the parent note... - if (cursor.element.notes[0].tieBack != null) { + if (cursor.element.notes[0].tieBack) { // don't add tab if parent note is tied to previous note console.log("Skipped tied parent note, pitches : " + pitch + ", " + lastPitch) } @@ -309,7 +309,7 @@ MuseScore { var chord = cursor.element; pitch = chord.notes[0].pitch; - if (pitch == lastPitch) { + if (pitch === lastPitch) { // don't add tab if parent note is same pitch as previous note console.log("Skipped repeated parent note, pitches : " + pitch + ", " + lastPitch) } From 9ade23c0d7f377a9e09568e919b1d4a23b0b31fd Mon Sep 17 00:00:00 2001 From: jon gadsden Date: Sun, 8 Jan 2023 18:59:57 +0000 Subject: [PATCH 6/6] add category code --- tin_whistle_tablature.qml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tin_whistle_tablature.qml b/tin_whistle_tablature.qml index 9509ede..62375a5 100644 --- a/tin_whistle_tablature.qml +++ b/tin_whistle_tablature.qml @@ -17,18 +17,19 @@ // 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 +// the file LICENCE //============================================================================= -import QtQuick 2.2 -import QtQuick.Dialogs 1.1 +import QtQuick 2.15 +import QtQuick.Dialogs 1.3 import MuseScore 3.0 MuseScore { - version: "3.4" - description: qsTr("This plugin provides fingering diagrams for the tin whistle. Ensure font `TinWhistleTab.ttf` is installed") - menuPath: "Plugins.Tin Whistle.Add tablature" + version: "4.0" + description: "This plugin provides fingering diagrams for the tin whistles, requires `TinWhistleTab.ttf` font" + title: "Tin Whistle Tablature" + categoryCode: "composing-arranging-tools" property string tabFontName: "Tin Whistle Tab" property bool whistleFound: false @@ -59,7 +60,7 @@ MuseScore { standardButtons: StandardButton.Ok title: "No Staffs use a Tin Whistle" text: "No selected staff in the current score uses a tin whistle instrument.\n" + - "Use menu command \"Edit -> Instruments\" to select your instrument." + "Use menu command \"View -> Instruments\" to select instruments" onAccepted: { quit() } @@ -78,7 +79,7 @@ MuseScore { } tabText = tabs[index] return tabText - } + } // end selectTinTabCharacter function setTinTabCharacterFont (text, tabSize) { text.fontFace = tabFontName @@ -89,10 +90,10 @@ MuseScore { text.placement = Placement.BELOW // Turn off note relative placement text.autoplace = false - } + } // end setTinTabCharacterFont // For diagnostic use. - function dumpObjectEntries(obj, showUndefinedVals, title) { + function dumpObjectEntries (obj, showUndefinedVals, title) { console.log("VV -------- " + title + " ---------- VV") for (var key in obj) { if (showUndefinedVals || (obj[key])) { @@ -100,9 +101,9 @@ MuseScore { } } console.log("^^ -------- " + title + " ---------- ^^") - } + } // end dumpObjectEntries - function renderTinWhistleTablature() { + function renderTinWhistleTablature () { curScore.startCmd(); // select either the full score or just the selected staves @@ -393,7 +394,7 @@ MuseScore { curScore.endCmd(); quit() - } + } // end renderTinWhistleTablature onRun: { console.log("Hello tin whistle tablature") @@ -410,4 +411,4 @@ MuseScore { fontMissingDialog.open() quit() } // end onRun -} +} // end MuseScore