From 75010f09089462049cec800ae0865a43a9f82e82 Mon Sep 17 00:00:00 2001 From: SeeLook <seelook@gmail.com> Date: Mon, 22 Feb 2021 22:33:05 +0100 Subject: [PATCH] Set clef either from score or instrument tuning page - also increase minimal note duration when bass is set - so keep instrument and clef variables above pages - change instrument image dynamically --- src/qml/settings/InstrumentPage.qml | 59 +++++++++++++++------------- src/qml/settings/ScorePage.qml | 12 +++--- src/qml/settings/SoundPage.qml | 3 +- src/qml/settings/TsettingsDialog.qml | 11 ++++++ 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/src/qml/settings/InstrumentPage.qml b/src/qml/settings/InstrumentPage.qml index 1a3ae0e27..d2e76e6ea 100644 --- a/src/qml/settings/InstrumentPage.qml +++ b/src/qml/settings/InstrumentPage.qml @@ -18,7 +18,7 @@ Flickable { contentHeight: instrCol.height + NOO.factor() * 2 contentWidth: Math.max(width, NOO.factor() * 35) - property bool first: true // read props first time from GLOB but when instrument changed then from its profile + property bool first: true // read props first time from GLOB but when instrument changes then from its profile ScrollBar.vertical: ScrollBar { active: false; visible: active } @@ -36,19 +36,20 @@ Flickable { if (first) { transp.shift = GLOB.transposition prefFlatRadio.checked = GLOB.preferFlats - first = false } else { + settings.instrument = instrument var ins = NOO.instr(instrument) + settings,clef = ins.clef transp.shift = ins.transposition prefFlatRadio.checked = ins.isSax ? true : false prefSharpRadio.checked = ins.isSax ? false : true tuningCombo.model = instrument === Tinstrument.BassGuitar ? NOO.bassTunings() : NOO.guitarTunings() if (ins.isGuitar) { - score.clef = ins.clef if (instrument === Tinstrument.BassGuitar) setTuning(NOO.tuning(Ttune.Bass4_EADG)) else setTuning(NOO.tuning(Ttune.Standard_EADGBE)) + fretsNrSpin.value = ins.fretNumber } else if (ins.type === Tinstrument.NoInstrument) { setTuning(NOO.tuning(score.scoreObj.lowestNote(), score.scoreObj.highestNote(), NOO.emptyNote(), NOO.emptyNote(), NOO.emptyNote(), NOO.emptyNote())) } @@ -57,29 +58,29 @@ Flickable { } } - Grid { - visible: NOO.instr(instrSel.instrument).isGuitar - anchors.horizontalCenter: parent.horizontalCenter - spacing: NOO.factor() - columns: parent.width < NOO.factor() * 50 ? 1 : 2 - horizontalItemAlignment: Grid.AlignHCenter - Row { - spacing: NOO.factor() - Text { text: qsTr("number of frets:"); anchors.verticalCenter: parent.verticalCenter; color: activPal.text } - TspinBox { id: fretsNrSpin; from: 15; to: 24; value: GLOB.fretNumber } - } - Row { - spacing: NOO.factor() - Text { text: qsTr("number of strings:"); anchors.verticalCenter: parent.verticalCenter; color: activPal.text } - TspinBox { id: stringNrSpin; from: 3; to: 6; value: GLOB.stringNumber() } - } - } - Tile { visible: instrSel.instrument <= Tinstrument.BassGuitar Column { spacing: NOO.factor() width: parent.width + Grid { + visible: NOO.instr(instrSel.instrument).isGuitar + anchors.horizontalCenter: parent.horizontalCenter + spacing: NOO.factor() + columns: parent.width < NOO.factor() * 50 ? 1 : 2 + horizontalItemAlignment: Grid.AlignHCenter + Row { + spacing: NOO.factor() + Text { text: qsTr("number of frets:"); anchors.verticalCenter: parent.verticalCenter; color: activPal.text } + TspinBox { id: fretsNrSpin; from: 15; to: 24; value: GLOB.fretNumber } + } + Row { + spacing: NOO.factor() + Text { text: qsTr("number of strings:"); anchors.verticalCenter: parent.verticalCenter; color: activPal.text } + TspinBox { id: stringNrSpin; from: 3; to: 6; value: GLOB.stringNumber() } + } + } + Item { width: NOO.factor(); height: NOO.factor() } Row { spacing: NOO.factor() anchors.horizontalCenter: parent.horizontalCenter @@ -104,6 +105,8 @@ Flickable { meter: Tmeter.NoMeter scoreObj.onClicked: tuningCombo.currentIndex = tuningCombo.count - 1 scoreObj.editMode: true + clef: settings.clef + onClefChanged: settings.clef = clef Component.onCompleted: { stringNrSpin.valueModified.connect(strNrChanged) tuningCombo.activated.connect(tuningSelected) @@ -204,16 +207,17 @@ Flickable { showOtherPosChB.checked = GLOB.showOtherPos fretDots.text = GLOB.markedFrets var tmpTrans = GLOB.transposition - instrSel.instrument = GLOB.instrument.type - (GLOB.instrument.type === 0 ? -1 : 1) // FIXME: workaround for Qt 5.10.1 and above - score.clef = GLOB.clefType instrSel.instrument = GLOB.instrument.type transp.shift = tmpTrans if (GLOB.instrument.isGuitar) { - if (GLOB.tuning.type === Ttune.Custom) - tuningCombo.currentIndex = tuningCombo.count - 1 - else - tuningCombo.currentIndex = GLOB.tuning.type - (GLOB.instrument.type === Tinstrument.BassGuitar ? 100 : 0) + if (GLOB.tuning.type === Ttune.Custom) { + setTuning(NOO.tuning(GLOB.tuning.string(1), GLOB.tuning.string(2), GLOB.tuning.string(3), + GLOB.tuning.string(4), GLOB.tuning.string(5), GLOB.tuning.string(6))) + tuningCombo.currentIndex = tuningCombo.count - 1 + } else + tuningCombo.currentIndex = GLOB.tuning.type - (GLOB.instrument.type === Tinstrument.BassGuitar ? 100 : 0) } + first = false } } @@ -230,6 +234,7 @@ Flickable { score.deleteLast() } } + stringNrSpin.value = t.stringNumber } function save() { diff --git a/src/qml/settings/ScorePage.qml b/src/qml/settings/ScorePage.qml index db6ecb009..55916e083 100644 --- a/src/qml/settings/ScorePage.qml +++ b/src/qml/settings/ScorePage.qml @@ -23,7 +23,7 @@ Column { StackLayout { id: swipePages - height: parent.height - headList.height - NOO.factor() / 2 + height: parent.height - headList.height width: parent.width Tflickable { // 1st page (general) @@ -174,6 +174,7 @@ Column { width: parent.width spacing: NOO.isAndroid() ? 2 : NOO.factor() / 2 Text { + id: clefText text: qsTr("Select default clef for the application.") + "<br><b>" + qsTr("Remember! Not all clefs are suitable for some possible tunings or instrument types!") + "<b>" textFormat: Text.StyledText @@ -184,8 +185,9 @@ Column { } ClefMenu { id: clefs - width: parent.width; height: swipePages.height - NOO.factor() * 5 - Component.onCompleted: selClef = GLOB.clefType + width: parent.width; height: swipePages.height - parent.spacing - clefText.height + selClef: settings.clef + onSelClefChanged: settings.clef = selClef } } @@ -296,7 +298,7 @@ Column { GLOB.seventhIsB = is7BSelector.is7B GLOB.namesOnScore = namesOnScoreChB.checked GLOB.nameColor = nameColorButt.color - GLOB.clefType = clefs.selClef + // GLOB.clefType saved in TsettingsDialog.qml if (GLOB.keySignatureEnabled) { GLOB.showKeyName = showKeyNamesChB.checked if (GLOB.showKeyName) { @@ -314,7 +316,7 @@ Column { enharmNoteColor.color = Qt.rgba(0, 0.6352941176470588, 0.6352941176470588, 1) doubleAccidsChB.checked = false pointerColorButt.color = "pink" - clefs.selClef = GLOB.instrument.clef + settings.clef = GLOB.instrument.clef enableKeyChB.checked = false musicalRadio.checked = true diff --git a/src/qml/settings/SoundPage.qml b/src/qml/settings/SoundPage.qml index 00d8805b4..3b920d50d 100644 --- a/src/qml/settings/SoundPage.qml +++ b/src/qml/settings/SoundPage.qml @@ -81,7 +81,8 @@ Column { TlabelText { text: qsTr("minimum note duration") } TspinBox { id: minDurSpin - from: 80; to: 1000 + from: settings.instrument !== 3 ? 80 : 160 // longer note if bass + to: 1000 stepSize: 10 editable: true } diff --git a/src/qml/settings/TsettingsDialog.qml b/src/qml/settings/TsettingsDialog.qml index 29e9aed42..dc14a34be 100644 --- a/src/qml/settings/TsettingsDialog.qml +++ b/src/qml/settings/TsettingsDialog.qml @@ -7,6 +7,16 @@ import QtQuick.Controls 2.2 Item { + id: settings + + property int clef: GLOB.clefType + property int instrument: GLOB.instrument.typeINT + + onInstrumentChanged: { + if (pages.buttons.length > 2) + pages.buttons[2].pixmap = NOO.pix("pane/i-0" + instrument) + } + width: parent.width height: parent.height @@ -28,6 +38,7 @@ Item { } function apply() { + GLOB.clefType = clef // it can be changed either by score or instrument page for (var i = 0; i < pages.pages.length; ++i) { if (typeof(pages.pages[i]) === 'object') pages.pages[i].save() -- GitLab