From 6beca8019e4e3cc78d496009e032215a6d7f387a Mon Sep 17 00:00:00 2001 From: jeetee Date: Sun, 24 Nov 2019 22:47:40 +0100 Subject: [PATCH 1/7] Italian translation, courtesy of Shoichi (https://musescore.org/en/user/44016) --- TempoChanges.qml | 2 +- translations/generating these qm files.bat | 4 +- translations/generating these ts files.bat | 3 +- translations/locale_it.qm | Bin 0 -> 1116 bytes translations/locale_it.ts | 71 +++++++++++++++++++++ 5 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 translations/locale_it.qm create mode 100644 translations/locale_it.ts diff --git a/TempoChanges.qml b/TempoChanges.qml index 1c380da..7580b63 100644 --- a/TempoChanges.qml +++ b/TempoChanges.qml @@ -17,7 +17,7 @@ import MuseScore 3.0 MuseScore { menuPath: "Plugins.TempoChanges" - version: "3.1.3" + version: "3.1.4" description: qsTr("Creates hidden tempo markers.\nSee also: https://musescore.org/en/handbook/3/tempo#ritardando-accelerando") pluginType: "dialog" requiresScore: true diff --git a/translations/generating these qm files.bat b/translations/generating these qm files.bat index 9fdb9d7..2f2dd9a 100644 --- a/translations/generating these qm files.bat +++ b/translations/generating these qm files.bat @@ -1,3 +1,3 @@ -set PATH=%PATH%;C:\Qt\5.12.2\msvc2017_64\bin -lrelease.exe -nounfinished locale_nl.ts locale_de.ts locale_fr.ts locale_zh.ts +set PATH=%PATH%;C:\Qt\5.12.5\msvc2017_64\bin +lrelease.exe -nounfinished locale_nl.ts locale_de.ts locale_fr.ts locale_it.ts locale_zh.ts PAUSE \ No newline at end of file diff --git a/translations/generating these ts files.bat b/translations/generating these ts files.bat index dfeb80b..415e9cd 100644 --- a/translations/generating these ts files.bat +++ b/translations/generating these ts files.bat @@ -1,7 +1,8 @@ REM add more local_xx.ts files to this string when required -set PATH=%PATH%;C:\Qt\5.12.2\msvc2017_64\bin +set PATH=%PATH%;C:\Qt\5.12.5\msvc2017_64\bin lupdate.exe -locations relative -no-obsolete ../ -ts locale_de.ts lupdate.exe -locations relative -no-obsolete ../ -ts locale_fr.ts +lupdate.exe -locations relative -no-obsolete ../ -ts locale_it.ts lupdate.exe -locations relative -no-obsolete ../ -ts locale_nl.ts lupdate.exe -locations relative -no-obsolete ../ -ts locale_zh.ts PAUSE \ No newline at end of file diff --git a/translations/locale_it.qm b/translations/locale_it.qm new file mode 100644 index 0000000000000000000000000000000000000000..b73cd788fdbf127262291af6926639ea980a373a GIT binary patch literal 1116 zcmaJ=zi-n(6n<$-NezOvsybZhTsuy?5`&-S@tC{k>X0`+oB5(kwbL`yGL)T1+^*4LF+CvUL7zR+Sc&P)iqHgm(Err&ANfG8^l>#W}uFM3yx2 z2xQ4f;Xi_QjNL#_U{7)G;Ke5~WC6RR9Gb!3!QzughuAq<;4EuAL+CMl98KXHQh+a| z0NXBu7GAZlp&dvge3~X$_T1iJ z5l0q4=v>5!QaTfk!4RpmN80ATH_%$hNp3Sj}wYbF&F{;uo|@NoB^+HWgDSTwmNQcWAClz^>3 z8@Z7dO=Su*{c7^`XXF@E^s33>(LvMtXhx1PEIFdiX_-J*6+DwFTM7Bk>Rr&RgSCq& z9+vtR?8P^nRcbJb?qqo}of_-35`7S1z(f!wsFIk>_vR-_WLm3SlwH5$?+Rmu9GX)5 l-eQ0^Fr)==s7IEEi(k$+nj70RQB#v-i^lc|#&)UI`URj7^j-h} literal 0 HcmV?d00001 diff --git a/translations/locale_it.ts b/translations/locale_it.ts new file mode 100644 index 0000000..c27cd75 --- /dev/null +++ b/translations/locale_it.ts @@ -0,0 +1,71 @@ + + + + + Ms::MuseScore + + + Staff Text + + + + + PrefsDialogBase + + + Apply + + + + + TempoChanges + + + Creates hidden tempo markers. +See also: https://musescore.org/en/handbook/3/tempo#ritardando-accelerando + Handbook not yet translated into Italian. + Crea indicazioni metriche nascoste. +Vedi anche : https://musescore.org/en/handbook/3/tempo#ritardando-accelerando + + + + Unsupported MuseScore version. +TempoChanges needs v3.0.5 or above. + + Versione non supportata di MuseScore. +TempoChanges richiede la versione 3.0.5 o superiore. + + + + + BPM beat: + Battito BPM : + + + + Start BPM: + BPM iniziale : + + + + End BPM: + BPM finale : + + + + + Linear + Lineare + + + + Curved + Curva + + + + midpoint: + Punto medio : + + + From c7b1402d0406a4487e083c803196cc996938756b Mon Sep 17 00:00:00 2001 From: jeetee Date: Sun, 12 Apr 2020 00:25:48 +0200 Subject: [PATCH 2/7] resolve #12 - prefill start/end tempo --- TempoChanges.qml | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/TempoChanges.qml b/TempoChanges.qml index 7580b63..ea82d7c 100644 --- a/TempoChanges.qml +++ b/TempoChanges.qml @@ -32,6 +32,7 @@ MuseScore { console.log(qsTr("Unsupported MuseScore version.\nTempoChanges needs v3.0.5 or above.\n")); Qt.quit(); } + prefillSurroundingTempo(); } Settings { @@ -48,6 +49,36 @@ MuseScore { // //property var globalStyle //MS::MuseScoreStyleType - enum doesn't translate to a value in the plugin framework // } + function prefillSurroundingTempo() + { + var sel = getSelection(); + if (sel === null) { //no selection + console.log('No selection'); + return; + } + var beatBaseItem = beatBase.model.get(beatBase.currentIndex); + // Start Tempo + var foundTempo = undefined; + var segment = sel.startSeg; + while ((foundTempo === undefined) && (segment)) { + foundTempo = findExistingTempoElement(segment); + segment = segment.prev; + } + if (foundTempo !== undefined) { + startBPMvalue.placeholderText = Math.round(foundTempo.tempo * 60 / beatBaseItem.mult * 10) / 10; + } + // End Tempo + foundTempo = undefined + segment = sel.endSeg; + while ((foundTempo === undefined) && (segment)) { + foundTempo = findExistingTempoElement(segment); + segment = segment.next; + } + if (foundTempo !== undefined) { + endBPMvalue.placeholderText = Math.round(foundTempo.tempo * 60 / beatBaseItem.mult * 10) / 10; + } + } + function applyTempoChanges() { var sel = getSelection(); @@ -149,7 +180,9 @@ MuseScore { } selection = { start: cursor.tick, - end: null + startSeg: cursor.segment, + end: null, + endSeg: null }; cursor.rewind(2); //find end of selection if (cursor.tick == 0) { @@ -158,9 +191,11 @@ MuseScore { // rewind(2) goes behind the last segment (where // there's none) and sets tick=0 selection.end = curScore.lastSegment.tick + 1; + selection.endSeg = curScore.lastSegment; } else { selection.end = cursor.tick; + selection.endSeg = cursor.segment; } return selection; } From c9c7681e04adce0465156f87359a3be96093c928 Mon Sep 17 00:00:00 2001 From: jeetee Date: Sun, 12 Apr 2020 23:32:41 +0200 Subject: [PATCH 3/7] resolves #17 --- TempoChanges.qml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/TempoChanges.qml b/TempoChanges.qml index ea82d7c..dd5a598 100644 --- a/TempoChanges.qml +++ b/TempoChanges.qml @@ -511,4 +511,16 @@ MuseScore { } } + + Keys.onEscapePressed: { + Qt.quit(); + } + Keys.onReturnPressed: { + applyTempoChanges(); + Qt.quit(); + } + Keys.onEnterPressed: { + applyTempoChanges(); + Qt.quit(); + } } From 1f098be85ab3e8fd8edcd6bc2b25ed518e2d7b9d Mon Sep 17 00:00:00 2001 From: Maximilian Konrad Date: Mon, 13 Apr 2020 00:02:13 +0200 Subject: [PATCH 4/7] Added global enter and escape sequence --- TempoChanges.qml | 464 +++++++++++++++++++++++------------------------ 1 file changed, 232 insertions(+), 232 deletions(-) diff --git a/TempoChanges.qml b/TempoChanges.qml index dd5a598..c934205 100644 --- a/TempoChanges.qml +++ b/TempoChanges.qml @@ -65,7 +65,7 @@ MuseScore { segment = segment.prev; } if (foundTempo !== undefined) { - startBPMvalue.placeholderText = Math.round(foundTempo.tempo * 60 / beatBaseItem.mult * 10) / 10; + startBPMvalue.text = Math.round(foundTempo.tempo * 60 / beatBaseItem.mult * 10) / 10; } // End Tempo foundTempo = undefined @@ -75,7 +75,7 @@ MuseScore { segment = segment.next; } if (foundTempo !== undefined) { - endBPMvalue.placeholderText = Math.round(foundTempo.tempo * 60 / beatBaseItem.mult * 10) / 10; + endBPMvalue.text = Math.round(foundTempo.tempo * 60 / beatBaseItem.mult * 10) / 10; } } @@ -256,271 +256,271 @@ MuseScore { } } - GridLayout { + + Item { + focus: true + Keys.onEscapePressed: { + Qt.quit(); + } + + Keys.onReturnPressed: { + applyTempoChanges(); + Qt.quit(); + } + + GridLayout { id: 'mainLayout' anchors.fill: parent anchors.margins: 10 columns: 3 - Label { - text: qsTranslate("Ms::MuseScore", "Staff Text") + ":" - } - TextField { - id: startTextValue - placeholderText: 'rit. / accel.' - implicitHeight: 24 - } - Canvas { - id: canvas - Layout.rowSpan: 4 - Layout.minimumWidth: 102 - Layout.minimumHeight: 102 - Layout.fillWidth: true - Layout.fillHeight: true - - onPaint: { - var w = canvas.width; - var h = canvas.height; - var ctx = getContext("2d"); - - //square plot area - var length = (w > h) ? h : w; - var top = (h - length) / 2; - var left = (w - length) / 2; - ctx.clearRect(0, 0, w, h); - ctx.fillStyle = '#555555'; - ctx.fillRect(left, top, length, length); - ctx.strokeStyle = '#000000'; - ctx.lineWidth = 1; - ctx.strokeRect(left, top, length, length); - - //grid lines - ctx.strokeStyle = '#888888'; - ctx.beginPath(); - var divisions = 4; - for (var i = divisions - 1; i > 0; --i) { - //vertical - ctx.moveTo(left + ((i*length)/divisions), top); - ctx.lineTo(left + ((i*length)/divisions), top+length); - //horizontal - ctx.moveTo(left , top + ((i*length)/divisions)); - ctx.lineTo(left + length, top + ((i*length)/divisions)); + Label { + text: qsTranslate("Ms::MuseScore", "Staff Text") + ":" + } + TextField { + id: startTextValue + text: 'rit.' + implicitHeight: 24 + } + Canvas { + id: canvas + Layout.rowSpan: 4 + Layout.minimumWidth: 102 + Layout.minimumHeight: 102 + Layout.fillWidth: true + Layout.fillHeight: true + + onPaint: { + var w = canvas.width; + var h = canvas.height; + var ctx = getContext("2d"); + + //square plot area + var length = (w > h) ? h : w; + var top = (h - length) / 2; + var left = (w - length) / 2; + ctx.clearRect(0, 0, w, h); + ctx.fillStyle = '#555555'; + ctx.fillRect(left, top, length, length); + ctx.strokeStyle = '#000000'; + ctx.lineWidth = 1; + ctx.strokeRect(left, top, length, length); + + //grid lines + ctx.strokeStyle = '#888888'; + ctx.beginPath(); + var divisions = 4; + for (var i = divisions - 1; i > 0; --i) { + //vertical + ctx.moveTo(left + ((i*length)/divisions), top); + ctx.lineTo(left + ((i*length)/divisions), top+length); + //horizontal + ctx.moveTo(left , top + ((i*length)/divisions)); + ctx.lineTo(left + length, top + ((i*length)/divisions)); + } + ctx.stroke(); + + //graph + ctx.strokeStyle = '#abd3fb'; + ctx.lineWidth = 2; + var start = getFloatFromInput(startBPMvalue); + var end = getFloatFromInput(endBPMvalue); + var midPoint = ((curveType.isLinear) ? 50.0 : midpointSlider.value) / 100; + ctx.beginPath(); + ctx.moveTo(left + length, (start > end) ? top + length : top); + for (var x = length; x >= 0; --x) { + var outputPct = Math.pow((x / length), (Math.log(0.5) / Math.log(midPoint))); + var newY = (start > end) ? (top + (outputPct * length)) : (top + length - (outputPct * length)); + ctx.lineTo(left + x, newY); + } + ctx.stroke(); + + //write BPMs + canvasStartBPM.text = start; + canvasStartBPM.topPadding = (start > end) ? (top + 2) : (top + length - canvasStartBPM.contentHeight - 2); + canvasEndBPM.text = end; + canvasEndBPM.topPadding = (start > end) ? (top + length - canvasEndBPM.contentHeight - 2): (top + 2); + //keep them inside the grid or is there enough room next to it? + var longestBPMText = Math.max(canvasStartBPM.contentWidth, canvasEndBPM.contentWidth); + if ((longestBPMText + 2 + 2) < left) { + //outside + canvasStartBPM.leftPadding = left - 2 - canvasStartBPM.contentWidth; + canvasEndBPM.leftPadding = left - 2 - canvasEndBPM.contentWidth; + } + else { + //inside + canvasStartBPM.leftPadding = left + 2; + canvasEndBPM.leftPadding = left + 2; + } } - ctx.stroke(); - - //graph - ctx.strokeStyle = '#abd3fb'; - ctx.lineWidth = 2; - var start = getFloatFromInput(startBPMvalue); - var end = getFloatFromInput(endBPMvalue); - var midPoint = ((curveType.isLinear) ? 50.0 : midpointSlider.value) / 100; - ctx.beginPath(); - ctx.moveTo(left + length, (start > end) ? top + length : top); - for (var x = length; x >= 0; --x) { - var outputPct = Math.pow((x / length), (Math.log(0.5) / Math.log(midPoint))); - var newY = (start > end) ? (top + (outputPct * length)) : (top + length - (outputPct * length)); - ctx.lineTo(left + x, newY); + Label { + id: canvasStartBPM + color: '#d8d8d8' } - ctx.stroke(); - - //write BPMs - canvasStartBPM.text = start; - canvasStartBPM.topPadding = (start > end) ? (top + 2) : (top + length - canvasStartBPM.contentHeight - 2); - canvasEndBPM.text = end; - canvasEndBPM.topPadding = (start > end) ? (top + length - canvasEndBPM.contentHeight - 2): (top + 2); - //keep them inside the grid or is there enough room next to it? - var longestBPMText = Math.max(canvasStartBPM.contentWidth, canvasEndBPM.contentWidth); - if ((longestBPMText + 2 + 2) < left) { - //outside - canvasStartBPM.leftPadding = left - 2 - canvasStartBPM.contentWidth; - canvasEndBPM.leftPadding = left - 2 - canvasEndBPM.contentWidth; + Label { + id: canvasEndBPM + color: '#d8d8d8' } - else { - //inside - canvasStartBPM.leftPadding = left + 2; - canvasEndBPM.leftPadding = left + 2; + } //end of Canvas + + Label { + text: qsTr("BPM beat:") + } + ComboBox { + id: beatBase + model: ListModel { + id: beatBaseList + //mult is a tempo-multiplier compared to a crotchet + //ListElement { text: '\uECA0'; mult: 8 ; sym: 'metNoteDoubleWhole' } // 2/1 + ListElement { text: '\uECA2'; mult: 4 ; sym: 'metNoteWhole' } // 1/1 + //ListElement { text: '\uECA3 \uE1E7 \uE1E7'; mult: 3.5 ; sym: 'metNoteHalfUpmetAugmentationDotmetAugmentationDot' } // 1/2.. + ListElement { text: '\uECA3 \uECB7'; mult: 3 ; sym: 'metNoteHalfUpmetAugmentationDot' } // 1/2. + ListElement { text: '\uECA3'; mult: 2 ; sym: 'metNoteHalfUp' } // 1/2 + ListElement { text: '\uECA5 \uECB7 \uECB7'; mult: 1.75 ; sym: 'metNoteQuarterUpmetAugmentationDotmetAugmentationDot' } // 1/4.. + ListElement { text: '\uECA5 \uECB7'; mult: 1.5 ; sym: 'metNoteQuarterUpmetAugmentationDot' } // 1/4. + ListElement { text: '\uECA5'; mult: 1 ; sym: 'metNoteQuarterUp' } // 1/4 + ListElement { text: '\uECA7 \uECB7 \uECB7'; mult: 0.875 ; sym: 'metNote8thUpmetAugmentationDotmetAugmentationDot' } // 1/8.. + ListElement { text: '\uECA7 \uECB7'; mult: 0.75 ; sym: 'metNote8thUpmetAugmentationDot' } // 1/8. + ListElement { text: '\uECA7'; mult: 0.5 ; sym: 'metNote8thUp' } // 1/8 + ListElement { text: '\uECA9 \uECB7 \uECB7'; mult: 0.4375; sym: 'metNote16thUpmetAugmentationDotmetAugmentationDot' } //1/16.. + ListElement { text: '\uECA9 \uECB7'; mult: 0.375 ; sym: 'metNote16thUpmetAugmentationDot' } //1/16. + ListElement { text: '\uECA9'; mult: 0.25 ; sym: 'metNote16thUp' } //1/16 + } + currentIndex: 5 + implicitHeight: 42 + style: ComboBoxStyle { + textColor: '#000000' + selectedTextColor: '#000000' + font.family: 'MScore Text' + font.pointSize: 18 + padding.top: 5 + padding.bottom: 5 } } + Label { - id: canvasStartBPM - color: '#d8d8d8' + text: qsTr("Start BPM:") } - Label { - id: canvasEndBPM - color: '#d8d8d8' + TextField { + id: startBPMvalue + placeholderText: '120' + validator: DoubleValidator { bottom: 1;/* top: 512;*/ decimals: 1; notation: DoubleValidator.StandardNotation; } + implicitHeight: 24 + onTextChanged: { canvas.requestPaint(); } } - } //end of Canvas - Label { - text: qsTr("BPM beat:") - } - ComboBox { - id: beatBase - model: ListModel { - id: beatBaseList - //mult is a tempo-multiplier compared to a crotchet - //ListElement { text: '\uECA0'; mult: 8 ; sym: 'metNoteDoubleWhole' } // 2/1 - ListElement { text: '\uECA2'; mult: 4 ; sym: 'metNoteWhole' } // 1/1 - //ListElement { text: '\uECA3 \uE1E7 \uE1E7'; mult: 3.5 ; sym: 'metNoteHalfUpmetAugmentationDotmetAugmentationDot' } // 1/2.. - ListElement { text: '\uECA3 \uECB7'; mult: 3 ; sym: 'metNoteHalfUpmetAugmentationDot' } // 1/2. - ListElement { text: '\uECA3'; mult: 2 ; sym: 'metNoteHalfUp' } // 1/2 - ListElement { text: '\uECA5 \uECB7 \uECB7'; mult: 1.75 ; sym: 'metNoteQuarterUpmetAugmentationDotmetAugmentationDot' } // 1/4.. - ListElement { text: '\uECA5 \uECB7'; mult: 1.5 ; sym: 'metNoteQuarterUpmetAugmentationDot' } // 1/4. - ListElement { text: '\uECA5'; mult: 1 ; sym: 'metNoteQuarterUp' } // 1/4 - ListElement { text: '\uECA7 \uECB7 \uECB7'; mult: 0.875 ; sym: 'metNote8thUpmetAugmentationDotmetAugmentationDot' } // 1/8.. - ListElement { text: '\uECA7 \uECB7'; mult: 0.75 ; sym: 'metNote8thUpmetAugmentationDot' } // 1/8. - ListElement { text: '\uECA7'; mult: 0.5 ; sym: 'metNote8thUp' } // 1/8 - ListElement { text: '\uECA9 \uECB7 \uECB7'; mult: 0.4375; sym: 'metNote16thUpmetAugmentationDotmetAugmentationDot' } //1/16.. - ListElement { text: '\uECA9 \uECB7'; mult: 0.375 ; sym: 'metNote16thUpmetAugmentationDot' } //1/16. - ListElement { text: '\uECA9'; mult: 0.25 ; sym: 'metNote16thUp' } //1/16 + Label { + text: qsTr("End BPM:") } - currentIndex: 5 - implicitHeight: 42 - style: ComboBoxStyle { - textColor: '#000000' - selectedTextColor: '#000000' - font.family: 'MScore Text' - font.pointSize: 18 - padding.top: 5 - padding.bottom: 5 + TextField { + id: endBPMvalue + placeholderText: '60' + validator: DoubleValidator { bottom: 1;/* top: 512;*/ decimals: 1; notation: DoubleValidator.StandardNotation; } + implicitHeight: 24 + onTextChanged: { canvas.requestPaint(); } } - } - Label { - text: qsTr("Start BPM:") - } - TextField { - id: startBPMvalue - placeholderText: '120' - validator: DoubleValidator { bottom: 1;/* top: 512;*/ decimals: 1; notation: DoubleValidator.StandardNotation; } - implicitHeight: 24 - onTextChanged: { canvas.requestPaint(); } - } + ComboBox { + id: curveType + model: ListModel { + ListElement { text: qsTr("Linear") } + ListElement { text: qsTr("Curved") } + } + Layout.preferredWidth: 80 - Label { - text: qsTr("End BPM:") - } - TextField { - id: endBPMvalue - placeholderText: '60' - validator: DoubleValidator { bottom: 1;/* top: 512;*/ decimals: 1; notation: DoubleValidator.StandardNotation; } - implicitHeight: 24 - onTextChanged: { canvas.requestPaint(); } - } + property bool isLinear: { + return (curveType.currentText === qsTr("Linear")); + } - ComboBox { - id: curveType - model: ListModel { - ListElement { text: qsTr("Linear") } - ListElement { text: qsTr("Curved") } + onCurrentIndexChanged: { + canvas.requestPaint(); + } } - Layout.preferredWidth: 80 - - property bool isLinear: { - return (curveType.currentText === qsTr("Linear")); + Label { + text: qsTr("midpoint:") + Layout.alignment: Qt.AlignRight } + Slider { + id: midpointSlider + Layout.fillWidth: true - onCurrentIndexChanged: { - canvas.requestPaint(); - } - } - Label { - text: qsTr("midpoint:") - Layout.alignment: Qt.AlignRight - } - Slider { - id: midpointSlider - Layout.fillWidth: true - - minimumValue: 1 - maximumValue: 99 - value: 75.0 - stepSize: 0.1 - - enabled: !curveType.isLinear - - style: SliderStyle { - groove: Rectangle { //background - id: grooveRect - implicitHeight: 6 - color: (enabled) ? '#555555' : '#565656' - radius: implicitHeight - border { - color: '#888888' - width: 1 - } - - Rectangle { - //value fill - implicitHeight: grooveRect.implicitHeight - implicitWidth: styleData.handlePosition - color: (enabled) ? '#abd3fb' : '#567186' - radius: grooveRect.radius + minimumValue: 1 + maximumValue: 99 + value: 75.0 + stepSize: 0.1 + + enabled: !curveType.isLinear + + style: SliderStyle { + groove: Rectangle { //background + id: grooveRect + implicitHeight: 6 + color: (enabled) ? '#555555' : '#565656' + radius: implicitHeight border { color: '#888888' width: 1 } + + Rectangle { + //value fill + implicitHeight: grooveRect.implicitHeight + implicitWidth: styleData.handlePosition + color: (enabled) ? '#abd3fb' : '#567186' + radius: grooveRect.radius + border { + color: '#888888' + width: 1 + } + } + } + handle: Rectangle { + anchors.centerIn: parent + color: (enabled) ? (control.pressed ? '#ffffff': '#d8d8d8') : '#565656' + border.color: '#666666' + border.width: 1 + implicitWidth: 16 + implicitHeight: 16 + radius: 8 } - } - handle: Rectangle { - anchors.centerIn: parent - color: (enabled) ? (control.pressed ? '#ffffff': '#d8d8d8') : '#565656' - border.color: '#666666' - border.width: 1 - implicitWidth: 16 - implicitHeight: 16 - radius: 8 } } - } - Label { - Layout.columnSpan: 2 //just taking up two cells to make the next element align - } - RowLayout { - Layout.alignment: Qt.AlignHCenter - - SpinBox { - id: sliderValue - Layout.preferredWidth: 60 - - minimumValue: midpointSlider.minimumValue - maximumValue: midpointSlider.maximumValue - value: midpointSlider.value - decimals: 1 - stepSize: midpointSlider.stepSize + Label { + Layout.columnSpan: 2 //just taking up two cells to make the next element align + } + RowLayout { + Layout.alignment: Qt.AlignHCenter + + SpinBox { + id: sliderValue + Layout.preferredWidth: 60 + + minimumValue: midpointSlider.minimumValue + maximumValue: midpointSlider.maximumValue + value: midpointSlider.value + decimals: 1 + stepSize: midpointSlider.stepSize + + onValueChanged: { + midpointSlider.value = value; + canvas.requestPaint(); + } - onValueChanged: { - midpointSlider.value = value; - canvas.requestPaint(); + enabled: !curveType.isLinear } - - enabled: !curveType.isLinear + Label { text: '%' } } - Label { text: '%' } - } - Button { - id: applyButton - Layout.columnSpan: 3 - text: qsTranslate("PrefsDialogBase", "Apply") - onClicked: { - applyTempoChanges(); - Qt.quit(); + Button { + id: applyButton + Layout.columnSpan: 3 + text: qsTranslate("PrefsDialogBase", "Apply") + onClicked: { + applyTempoChanges(); + Qt.quit(); + } } } - - } - - Keys.onEscapePressed: { - Qt.quit(); - } - Keys.onReturnPressed: { - applyTempoChanges(); - Qt.quit(); - } - Keys.onEnterPressed: { - applyTempoChanges(); - Qt.quit(); } } From d9516cd47d23cbb99f34fdb24a3b40ba682b8dc3 Mon Sep 17 00:00:00 2001 From: jeetee Date: Wed, 15 Apr 2020 00:18:05 +0200 Subject: [PATCH 5/7] resolves #22 - adjust tempo to reference beat --- TempoChanges.qml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/TempoChanges.qml b/TempoChanges.qml index 9717f23..4148b24 100644 --- a/TempoChanges.qml +++ b/TempoChanges.qml @@ -23,6 +23,7 @@ MuseScore { requiresScore: true property int margin: 10 + property int previousBeatIndex: 5 width: 360 height: 240 @@ -386,6 +387,22 @@ MuseScore { padding.top: 5 padding.bottom: 5 } + onCurrentIndexChanged: { // update the value fields to match the new beatBase + var changeFactor = beatBase.model.get(currentIndex).mult / beatBase.model.get(previousBeatIndex).mult; + if (startBPMvalue.text == "") { + startBPMvalue.placeholderText = Math.round(getFloatFromInput(startBPMvalue) / changeFactor * 10) / 10; + } + else { + startBPMvalue.text = Math.round(getFloatFromInput(startBPMvalue) / changeFactor * 10) / 10; + } + if (endBPMvalue.text == "") { + endBPMvalue.placeholderText = Math.round(getFloatFromInput(endBPMvalue) / changeFactor * 10) / 10; + } + else { + endBPMvalue.text = Math.round(getFloatFromInput(endBPMvalue) / changeFactor * 10) / 10; + } + previousBeatIndex = currentIndex; // keep track reference for next change + } } Label { From 2fae394fea848f2447fa071b5dfbc0d8dd722537 Mon Sep 17 00:00:00 2001 From: jeetee Date: Wed, 15 Apr 2020 16:46:12 +0200 Subject: [PATCH 6/7] resolves #21 - detect beat base value from starttempo --- TempoChanges.qml | 58 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/TempoChanges.qml b/TempoChanges.qml index 4148b24..be5392b 100644 --- a/TempoChanges.qml +++ b/TempoChanges.qml @@ -66,6 +66,16 @@ MuseScore { segment = segment.prev; } if (foundTempo !== undefined) { + console.log('Found start tempo text = ' + foundTempo.text); + // Try to extract base beat + var targetBeatBaseIndex = findBeatBaseFromMarking(foundTempo); + if (targetBeatBaseIndex != -1) { + // Apply it + previousBeatIndex = targetBeatBaseIndex; + beatBase.currentIndex = targetBeatBaseIndex; + beatBaseItem = beatBase.model.get(targetBeatBaseIndex); + } + // Update input field according to the (detected) beat startBPMvalue.placeholderText = Math.round(foundTempo.tempo * 60 / beatBaseItem.mult * 10) / 10; } // End Tempo @@ -76,10 +86,56 @@ MuseScore { segment = segment.next; } if (foundTempo !== undefined) { + console.log('Found end tempo text = ' + foundTempo.text); endBPMvalue.placeholderText = Math.round(foundTempo.tempo * 60 / beatBaseItem.mult * 10) / 10; } } + /// Analyses tempo marking text to attempt to discover the base beat being used + /// If a beat is detected, returns the index in the beatBaseList matching the marking + /// @returns -1 if beat is not detected or not present in our beatBaseList + function findBeatBaseFromMarking(tempoMarking) + { + var metronomeMarkIndex = -1; + // First look for metronome marking symbols + var foundTempoText = tempoMarking.text.replace('space', ''); + var foundMetronomeSymbols = foundTempoText.match(/(met.*<\/sym>)+/g); + if (foundMetronomeSymbols !== null) { + // Locate the index in our dropdown matching the found beatString + for (metronomeMarkIndex = beatBase.model.count; --metronomeMarkIndex >= 0; ) { + if (beatBase.model.get(metronomeMarkIndex).sym == foundMetronomeSymbols[0]) { + break; // Found this marking in the dropdown at metronomeMarkIndex + } + } + } + else { + // Metronome marking symbols are substituted with their character entity if the text was edited + // UTF-16 range [\uECA0 - \uECB6] (double whole - 1024th) + for (var beatString, charidx = 0; charidx < foundTempoText.length; charidx++) { + beatString = foundTempoText[charidx]; + if ((beatString >= "\uECA2") && (beatString <= "\uECA9")) { + // Found base tempo - continue looking for augmentation dots + while (++charidx < foundTempoText.length) { + if (foundTempoText[charidx] == "\uECB7") { + beatString += " \uECB7"; + } + else if (foundTempoText[charidx] != ' ') { + break; // No longer augmentation dots or spaces + } + } + // Locate the index in our dropdown matching the found beatString + for (metronomeMarkIndex = beatBase.model.count; --metronomeMarkIndex >= 0; ) { + if (beatBase.model.get(metronomeMarkIndex).text == beatString) { + break; // Found this marking in the dropdown at metronomeMarkIndex + } + } + break; // Done processing base tempo + } + } + } + return metronomeMarkIndex; + } + function applyTempoChanges() { var sel = getSelection(); @@ -364,7 +420,7 @@ MuseScore { //mult is a tempo-multiplier compared to a crotchet //ListElement { text: '\uECA0'; mult: 8 ; sym: 'metNoteDoubleWhole' } // 2/1 ListElement { text: '\uECA2'; mult: 4 ; sym: 'metNoteWhole' } // 1/1 - //ListElement { text: '\uECA3 \uE1E7 \uE1E7'; mult: 3.5 ; sym: 'metNoteHalfUpmetAugmentationDotmetAugmentationDot' } // 1/2.. + //ListElement { text: '\uECA3 \uECB7 \uECB7'; mult: 3.5 ; sym: 'metNoteHalfUpmetAugmentationDotmetAugmentationDot' } // 1/2.. ListElement { text: '\uECA3 \uECB7'; mult: 3 ; sym: 'metNoteHalfUpmetAugmentationDot' } // 1/2. ListElement { text: '\uECA3'; mult: 2 ; sym: 'metNoteHalfUp' } // 1/2 ListElement { text: '\uECA5 \uECB7 \uECB7'; mult: 1.75 ; sym: 'metNoteQuarterUpmetAugmentationDotmetAugmentationDot' } // 1/4.. From 89fd5c8863b7b686de2522993dd9400d08ea85da Mon Sep 17 00:00:00 2001 From: jeetee Date: Wed, 15 Apr 2020 16:46:28 +0200 Subject: [PATCH 7/7] version++ --- TempoChanges.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TempoChanges.qml b/TempoChanges.qml index be5392b..5b06b80 100644 --- a/TempoChanges.qml +++ b/TempoChanges.qml @@ -17,7 +17,7 @@ import MuseScore 3.0 MuseScore { menuPath: "Plugins.TempoChanges" - version: "3.2.0" + version: "3.3.0" description: qsTr("Creates hidden tempo markers.\nSee also: https://musescore.org/en/handbook/3/tempo#ritardando-accelerando") pluginType: "dialog" requiresScore: true