Added ability to delete whistle tabs from score. Also added confirm dialog to reset button

This commit is contained in:
Stephan Roos
2026-03-01 14:21:19 +02:00
parent 9220b0d439
commit 1afece90d9

View File

@ -31,8 +31,8 @@ import MuseScore 3.0
MuseScore { MuseScore {
id: mscore id: mscore
version: "4.2" version: "4.3"
title: "ASCII Whistle Fingering" title: "ASCII Whistle Tabs"
description: "Inserts ASCII fingering diagrams using numerical dictionary" description: "Inserts ASCII fingering diagrams using numerical dictionary"
pluginType: "dialog" pluginType: "dialog"
categoryCode: "composing-arranging-tools" categoryCode: "composing-arranging-tools"
@ -815,9 +815,12 @@ MuseScore {
function removeExistingAnnotations() { function removeExistingAnnotations() {
if (typeof curScore === "undefined") { if (typeof curScore === "undefined") {
errorDialog.open("Couldn't remove annotations, score undefined.")
return 0 return 0
} }
curScore.startCmd()
var cursor = curScore.newCursor() var cursor = curScore.newCursor()
var removed = 0 var removed = 0
@ -854,6 +857,8 @@ MuseScore {
} }
} }
console.log("Removed", removed, "existing annotations") console.log("Removed", removed, "existing annotations")
curScore.endCmd()
return removed return removed
} }
@ -1483,17 +1488,45 @@ MuseScore {
// MIDDLE ROW - Undo/Redo/Reset Buttons // MIDDLE ROW - Undo/Redo/Reset Buttons
RowLayout { RowLayout {
Layout.columnSpan: 2 Layout.columnSpan: 2
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignLeft
Layout.fillWidth: true
spacing: 10 spacing: 10
Layout.topMargin: 10 Layout.topMargin: 10
Layout.bottomMargin: 10 Layout.bottomMargin: 10
Button {
id: removeButton
text: "Remove Tabs"
ToolTip.visible: hovered
ToolTip.delay: 500
ToolTip.text: "Remove all whistle tabs from the score"
background: Rectangle {
color: sysPal.button
border.color: textColor
}
contentItem: Text {
text: removeButton.text
color: textColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
onClicked: {deleteDialog.open()}
}
//Spacer to right-align reset button
Item {
Layout.fillWidth: true
}
Button { Button {
id: resetButton id: resetButton
text: "Reset to Defaults" text: "Reset to Defaults"
ToolTip.visible: hovered
ToolTip.delay: 500
ToolTip.text: "Reset all settings to default values"
contentItem: Text { contentItem: Text {
text: resetButton.text text: resetButton.text
color: sysPal.buttonText color: textColor
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -1502,7 +1535,7 @@ MuseScore {
border.color: textColor border.color: textColor
} }
onClicked: { onClicked: {
resetToDefaults() resetDialog.open()
} }
} }
} }
@ -1707,6 +1740,33 @@ MuseScore {
overwriteDialog.close() overwriteDialog.close()
} }
} }
MessageDialog {
id: deleteDialog
title: "Confirm"
text: "This will delete all whistle annotations, continue?"
standardButtons: [StandardButton.Ok, StandardButton.Cancel]
onAccepted: {
removeExistingAnnotations()
quit()
}
onRejected: {
deleteDialog.close()
}
}
MessageDialog {
id: resetDialog
title: "Confirm"
text: "This will refresh and reset all text configurations, whistle dictionaries and format strings. Continue?"
standardButtons: [StandardButton.Ok, StandardButton.Cancel]
onAccepted: {
resetToDefaults()
}
onRejected: {
resetDialog.close()
}
}
//--------------------------------------------------------- //---------------------------------------------------------
// Command pattern for undo/redo (unchanged) // Command pattern for undo/redo (unchanged)