diff --git a/TODO b/TODO index 93365ad1d4591007ff6e46c631a3b4762d2a5603..be13bb2d8086ccf34f35bbe01acfed76a74efa59 100644 --- a/TODO +++ b/TODO @@ -20,6 +20,9 @@ TRANSLATION CONTEXT CHANGES Einstrument - Tinstrument (or simply Instrument) TtoolBar - MainWindow + NameStyleSelector - text "Naming style of note. The main difference is the 7th note.<br>Is it B and B flat, or H and B?" has to go into ScorePage or its sub-page with name settings + TnoteNameSettings - ScorePage or its sub-page + ============================================================================ SCORE - rich text for key names (accidentals would be in Nootka symbols) diff --git a/src/libs/core/score/tnoteobject.cpp b/src/libs/core/score/tnoteobject.cpp index 0c9d016df59e799e27cd6d2df220def33dc9e5cd..0a749a87bc97f6f8a26d72b9809f06da07417cd8 100644 --- a/src/libs/core/score/tnoteobject.cpp +++ b/src/libs/core/score/tnoteobject.cpp @@ -247,11 +247,11 @@ void TnoteObject::setNote(const Tnote& n) { void TnoteObject::setX(qreal xx) { updateTieScale(); - QQuickItem::setX(xx + (/*m_accidText.isEmpty() ? 0.0 : */m_alter->width())); + QQuickItem::setX(xx + (m_alter->width())); if (m_wrapper->beam() && m_wrapper->beam()->last()->item() == this) m_wrapper->beam()->last()->beam()->drawBeam(); if (m_name) - m_name->setX(x()); + m_name->setX(x() - m_alter->width()); } @@ -610,7 +610,7 @@ void TnoteObject::updateNamePos() { m_name->setVisible(true); m_name->setY(m_notePosY + (m_note->rtm.stemDown() ? -5.0 : 1.0)); m_name->setProperty("text", m_note->toRichText()); - m_name->setX(x()); + m_name->setX(x() - m_alter->width()); } else { m_name->setVisible(false); } diff --git a/src/libs/core/score/tscoreobject.cpp b/src/libs/core/score/tscoreobject.cpp index 785b1051601d36e927751b2629bbb4f6056941f1..8fe2914c1fd3019dbe068be06b5148db16026717 100644 --- a/src/libs/core/score/tscoreobject.cpp +++ b/src/libs/core/score/tscoreobject.cpp @@ -44,7 +44,8 @@ TscoreObject::TscoreObject(QObject* parent) : m_enableDoubleAccids(false), m_showNoteNames(false), m_clefOffset(TclefOffset(3, 1)), - m_width(0.0), m_adjustInProgress(false) + m_width(0.0), m_adjustInProgress(false), + m_nameStyle(static_cast<int>(Tnote::defaultStyle)) { m_qmlEngine = new QQmlEngine; m_qmlComponent = new QQmlComponent(m_qmlEngine, this); @@ -279,7 +280,7 @@ void TscoreObject::setNote(int staffNr, int noteNr, const Tnote& n) { } -TnoteObject * TscoreObject::note(int noteId) { +TnoteObject* TscoreObject::note(int noteId) { return noteId > -1 && noteId < notesCount() ? m_segments[noteId]->item() : nullptr; } @@ -454,6 +455,19 @@ CHECKTIME( } +void TscoreObject::setNameStyle(int nameS) { +CHECKTIME( + if (m_nameStyle != nameS) { + m_nameStyle = nameS; + if (m_showNoteNames) { + for (int n = 0; n < notesCount(); ++n) // with hope that all items have name item created + m_segments[n]->item()->nameItem()->setProperty("text", m_notes[n].toRichText()); + } + } +) +} + + qreal TscoreObject::stavesHeight() { if (m_staves.isEmpty()) return 0.0; diff --git a/src/libs/core/score/tscoreobject.h b/src/libs/core/score/tscoreobject.h index 77d4c2c7ffffccb05dd392f6efbd307d3def5519..a14ee62d225b1ba4769edb757c775b8a7c0cb27f 100644 --- a/src/libs/core/score/tscoreobject.h +++ b/src/libs/core/score/tscoreobject.h @@ -73,6 +73,7 @@ class NOOTKACORE_EXPORT TscoreObject : public QObject Q_PROPERTY(bool enableDoubleAccidentals READ enableDoubleAccidentals WRITE setEnableDoubleAccids) Q_PROPERTY(bool showNoteNames READ showNoteNames WRITE setShowNoteNames) Q_PROPERTY(QColor nameColor READ nameColor WRITE setNameColor) + Q_PROPERTY(int nameStyle READ nameStyle WRITE setNameStyle) /* Helper variables */ Q_PROPERTY(qreal stavesHeight READ stavesHeight NOTIFY stavesHeightChanged) Q_PROPERTY(qreal width READ width WRITE setWidth) @@ -144,9 +145,12 @@ public: bool showNoteNames() { return m_showNoteNames; } void setShowNoteNames(bool showNames); - QColor nameColor() { return m_nameColor; } + QColor nameColor() const { return m_nameColor; } void setNameColor(const QColor& nameC); + int nameStyle() const { return m_nameStyle; } + void setNameStyle(int nameS); + /* ------------------ Lists with score content (staves, measures notes) ------------------ */ int notesCount() const { return m_notes.count(); } @@ -355,6 +359,7 @@ private: QQmlEngine *m_qmlEngine; QQmlComponent *m_qmlComponent; QColor m_nameColor; + int m_nameStyle; /* Note cursor */ TnoteObject *m_activeNote = nullptr; qreal m_activeYpos = 0.0; diff --git a/src/libs/core/tglobals.cpp b/src/libs/core/tglobals.cpp index 05daabc7f5a23ef0cb4cc4f844ceeb269a706144..75e817c94a26c4c4f196c70dc1765fcfa937a8be 100755 --- a/src/libs/core/tglobals.cpp +++ b/src/libs/core/tglobals.cpp @@ -132,12 +132,6 @@ void Tglobals::setNoteCursorColor(const QColor& c) { S->pointerColor = c; emit n bool Tglobals::isSingleNote() const { return S->isSingleNoteMode; } void Tglobals::setSingleNote(bool sn) { S->isSingleNoteMode = sn; } -bool Tglobals::namesOnScore() const { return S->namesOnScore; } -void Tglobals::setNamesOnScore(bool showNames) { S->namesOnScore = showNames; emit namesOnScoreChanged(); } - -QColor Tglobals::nameColor() const { return S->nameColor; } -void Tglobals::setNameColor(const QColor& nameC) { S->nameColor = nameC; emit nameColorChanged(); } - bool Tglobals::enableDoubleAccids() const { return S->doubleAccidentalsEnabled; } void Tglobals::setEnableDoubleAccids(bool dblAcc) { S->doubleAccidentalsEnabled = dblAcc; emit enableDoubleAccidsChanged(); } @@ -165,14 +159,49 @@ void Tglobals::updateKeySignatureNames() { emit keyNameChanged(); } +bool Tglobals::rhythmsEnabled() const { return S->rhythmsEnabled; } +void Tglobals::setRhythmsEnabled(bool enR) { S->rhythmsEnabled = enR; emit rhythmsEnabledChanged(); } +/* ------------------ Note name switches ------------------ */ bool Tglobals::seventhIsB() const { return S->seventhIs_B; } -void Tglobals::setSeventhIsB(bool isB) { S->seventhIs_B = isB; emit seventhIsBChanged(); } -bool Tglobals::rhythmsEnabled() const { return S->rhythmsEnabled; } -void Tglobals::setRhythmsEnabled(bool enR) { S->rhythmsEnabled = enR; emit rhythmsEnabledChanged(); } +void Tglobals::setSeventhIsB(bool isB) { + if (isB != S->seventhIs_B) { + S->seventhIs_B = isB; + emit seventhIsBChanged(); + } +} +int Tglobals::noteNameStyle() const { return static_cast<int>(S->nameStyleInNoteName); } + +void Tglobals::setNoteNameStyle(int nameStyle) { + Tnote::EnameStyle newNameStyle = static_cast<Tnote::EnameStyle>(nameStyle); + if (newNameStyle != S->nameStyleInNoteName) { + S->nameStyleInNoteName = static_cast<Tnote::EnameStyle>(nameStyle); + Tnote::defaultStyle = S->nameStyleInNoteName; + emit noteNameStyleChanged(); + } +} +bool Tglobals::namesOnScore() const { return S->namesOnScore; } + +void Tglobals::setNamesOnScore(bool showNames) { + if (showNames != S->namesOnScore) { + S->namesOnScore = showNames; + emit namesOnScoreChanged(); + } +} + +QColor Tglobals::nameColor() const { return S->nameColor; } + +void Tglobals::setNameColor(const QColor& nameC) { + if (nameC != S->nameColor) { + S->nameColor = nameC; + emit nameColorChanged(); + } +} + +/* ------------------ Instrument switches ------------------ */ void Tglobals::setInstrument(Tinstrument::Etype t) { m_instrument.setType(t); emit instrumentChanged(); } void Tglobals::setFingerColor(const QColor& fc) { GfingerColor = fc; emit fingerColorChanged(); } @@ -235,8 +264,21 @@ void Tglobals::loadSettings(QSettings* cfg) { S->namesOnScore = cfg->value(QStringLiteral("namesOnScore"), true).toBool(); S->nameColor = cfg->value(QStringLiteral("namesColor"), QColor(0, 225, 225)).value<QColor>(); cfg->endGroup(); +// Fix name style depending on 7th note is was set wrongly in configuration (naughty user) + if (S->seventhIs_B) { + if (S->nameStyleInNoteName == Tnote::e_norsk_Hb) + S->nameStyleInNoteName = Tnote::e_english_Bb; + else if (S->nameStyleInNoteName == Tnote::e_deutsch_His) + S->nameStyleInNoteName = Tnote::e_nederl_Bis; + } else { + if (S->nameStyleInNoteName == Tnote::e_english_Bb) + S->nameStyleInNoteName = Tnote::e_norsk_Hb; + else if (S->nameStyleInNoteName == Tnote::e_nederl_Bis) + S->nameStyleInNoteName = Tnote::e_deutsch_His; + } // Initialize name filter TnameStyleFilter::setStyleFilter(&S->seventhIs_B, &S->solfegeStyle); + Tnote::defaultStyle = S->nameStyleInNoteName; // guitar settings Ttune::prepareDefinedTunes(); diff --git a/src/libs/core/tglobals.h b/src/libs/core/tglobals.h index eae79ece8a00d788fcdcc745ec53202c4436d92a..1ddf3bb4084862d411a8effb5cdfcde7982c56ea 100644 --- a/src/libs/core/tglobals.h +++ b/src/libs/core/tglobals.h @@ -53,8 +53,6 @@ class NOOTKACORE_EXPORT Tglobals : public QObject Q_PROPERTY(QColor enharmNoteColor READ getEnharmNoteColor WRITE setEnharmNoteColor) Q_PROPERTY(QColor noteCursorColor READ getNoteCursorColor WRITE setNoteCursorColor NOTIFY noteCursorColorChanged) Q_PROPERTY(bool singleNoteMode READ isSingleNote WRITE setSingleNote) - Q_PROPERTY(qreal namesOnScore READ namesOnScore WRITE setNamesOnScore NOTIFY namesOnScoreChanged) - Q_PROPERTY(QColor nameColor READ nameColor WRITE setNameColor NOTIFY nameColorChanged) Q_PROPERTY(bool enableDoubleAccids READ enableDoubleAccids WRITE setEnableDoubleAccids NOTIFY enableDoubleAccidsChanged) Q_PROPERTY(bool keySignatureEnabled READ keySignatureEnabled WRITE setKeySignatureEnabled NOTIFY enableKeySignatureChanged) Q_PROPERTY(bool showKeyName READ showKeyName WRITE setShowKeyName NOTIFY showKeyNameChanged) @@ -64,8 +62,14 @@ class NOOTKACORE_EXPORT Tglobals : public QObject Q_PROPERTY(bool rhythmsEnabled READ rhythmsEnabled WRITE setRhythmsEnabled NOTIFY rhythmsEnabledChanged) Q_PROPERTY(int clefType READ clefType WRITE setClefType NOTIFY clefTypeChanged) + + /* Note name switches */ + Q_PROPERTY(qreal namesOnScore READ namesOnScore WRITE setNamesOnScore NOTIFY namesOnScoreChanged) + Q_PROPERTY(int noteNameStyle READ noteNameStyle WRITE setNoteNameStyle NOTIFY noteNameStyleChanged) Q_PROPERTY(bool seventhIsB READ seventhIsB WRITE setSeventhIsB NOTIFY seventhIsBChanged) + Q_PROPERTY(QColor nameColor READ nameColor WRITE setNameColor NOTIFY nameColorChanged) + /* Instrument switches */ Q_PROPERTY(Tinstrument instrument READ instrument NOTIFY instrumentChanged) Q_PROPERTY(TtuneObject* tuning READ tuning NOTIFY tuningChanged) @@ -124,9 +128,6 @@ public: int clefType() const; void setClefType(int clType); - bool seventhIsB() const; - void setSeventhIsB(bool isB); - bool showKeyName() const; void setShowKeyName(bool showKey); @@ -142,6 +143,14 @@ public: bool rhythmsEnabled() const; void setRhythmsEnabled(bool enR); + /* ------------------ Note name switches ------------------ */ + bool seventhIsB() const; + void setSeventhIsB(bool isB); + + int noteNameStyle() const; + void setNoteNameStyle(int nameStyle); + + /* ------------------ Instrument switches ------------------ */ QColor fingerColor() const { return GfingerColor; } void setFingerColor(const QColor& fc); @@ -232,6 +241,7 @@ signals: void enableKeySignatureChanged(); void clefTypeChanged(); void nameColorChanged(); + void noteNameStyleChanged(); void seventhIsBChanged(); void showKeyNameChanged(); void keyNameChanged(); diff --git a/src/nootka.qrc b/src/nootka.qrc index 7ab1723e1bd008c18baf06b8d6d3064c48ad8a27..6216053d42855c0286fbac834280963399e3bbc7 100644 --- a/src/nootka.qrc +++ b/src/nootka.qrc @@ -56,6 +56,7 @@ <file alias="InstrumentPage.qml">qml/settings/InstrumentPage.qml</file> <file alias="ColorButton.qml">qml/settings/ColorButton.qml</file> <file alias="KeySufixEdit.qml">qml/settings/KeySufixEdit.qml</file> + <file alias="Select7note.qml">qml/settings/Select7note.qml</file> <file alias="fakeTrans.js">qml/shared/fakeTrans.js</file> diff --git a/src/qml/MainScore.qml b/src/qml/MainScore.qml index aebf4d2e1671d3925873c00e8c4d83c243cc2825..eda603279ba311df305a3ad406f3c83cd8f4456b 100644 --- a/src/qml/MainScore.qml +++ b/src/qml/MainScore.qml @@ -29,8 +29,9 @@ Score { scoreObj.clefType: GLOB.clefType enableDoubleAccids: GLOB.enableDoubleAccids enableKeySign: GLOB.keySignatureEnabled - scoreObj.nameColor: GLOB.nameColor scoreObj.showNoteNames: GLOB.namesOnScore + scoreObj.nameColor: GLOB.nameColor + scoreObj.nameStyle: GLOB.noteNameStyle scoreObj.enableDoubleAccidentals: GLOB.enableDoubleAccids Text { @@ -41,7 +42,7 @@ Score { y: 5 color: activPal.text font.pointSize: 1.5 - text: getKeyNameText() // enableKeySign ? Noo.majAndMinKeyName(firstStaff.keySignature.key) : "" + text: getKeyNameText() Connections { target: GLOB onKeyNameChanged: keyName.text = Qt.binding(keyName.getKeyNameText) //Noo.majAndMinKeyName(firstStaff.keySignature.key) diff --git a/src/qml/settings/ScorePage.qml b/src/qml/settings/ScorePage.qml index a4046807da5959cb314202f2ff71eeac623551c2..bea288c89fe89bdccd9a2b2f20215197077c0011 100644 --- a/src/qml/settings/ScorePage.qml +++ b/src/qml/settings/ScorePage.qml @@ -216,12 +216,52 @@ Column { } } } - Flickable { // 3rd page (clefs) + Flickable { // 4rd page (note name calling) clip: true contentWidth: parent.width width: parent.width - NameStyleSelector { - + Column { + width: parent.width + spacing: nootkaWindow.fontSize / 2 + anchors.horizontalCenter: parent.horizontalCenter + Tile { + description: qsTranslate("NameStyleSelector", "Naming style of note. The main difference is the 7th note.<br>Is it B and B flat, or H and B?") + Column { + anchors.horizontalCenter: parent.horizontalCenter + spacing: nootkaWindow.fontSize * 2 + Select7note { + id: is7BSelector + anchors.horizontalCenter: parent.horizontalCenter + style: nameStyleSel.style + } + NameStyleSelector { + id: nameStyleSel + seventhIsB: is7BSelector.is7B + anchors.horizontalCenter: parent.horizontalCenter + } + } + } + Tile { + CheckBox { + id: namesOnScoreChB + text: qsTr("Show names of all notes on the score.") + anchors.horizontalCenter: parent.horizontalCenter + checked: GLOB.namesOnScore + } + } + Tile { + enabled: namesOnScoreChB.checked + Row { + spacing: nootkaWindow.fontSize + anchors.horizontalCenter: parent.horizontalCenter + Text { color: enabled ? activPal.text : disdPal.text; text: qsTr("names highlight color"); anchors.verticalCenter: parent.verticalCenter } + ColorButton { id: nameColorButt; color: GLOB.nameColor } + } + } + Component.onCompleted: { + nameStyleSel.style = GLOB.noteNameStyle + is7BSelector.is7B = GLOB.seventhIsB + } } } } @@ -241,6 +281,10 @@ Column { GLOB.updateKeySignatureNames() } } + GLOB.noteNameStyle = nameStyleSel.style + GLOB.seventhIsB = is7BSelector.is7B + GLOB.namesOnScore = namesOnScoreChB.checked + GLOB.nameColor = nameColorButt.color } function defaults() { diff --git a/src/qml/settings/Select7note.qml b/src/qml/settings/Select7note.qml new file mode 100644 index 0000000000000000000000000000000000000000..f3fc276e5b11d3a14fa9e4c44db45edb8ad32d2d --- /dev/null +++ b/src/qml/settings/Select7note.qml @@ -0,0 +1,43 @@ +/** This file is part of Nootka (http://nootka.sf.net) * + * Copyright (C) 2017 by Tomasz Bojczuk (seelook@gmail.com) * + * on the terms of GNU GPLv3 license (http://www.gnu.org/licenses) */ + +import QtQuick 2.7 +import QtQuick.Controls 2.1 + + +Item { + property alias is7B: bButt.checked + property int style: -1 //bButt.checked ? 1 : 3 + + width: mainLay.width + height: mainLay.height + + Grid { + id: mainLay + columns: 2 //width < nootkaWindow.fontSize * 40 ? 1 : 2 + spacing: nootkaWindow.fontSize + + Row { + spacing: nootkaWindow.fontSize / 2 + Text { text: qsTr("7th note is:"); color: enabled ? activPal.text : disdPal.text; anchors.verticalCenter: parent.verticalCenter } + RadioButton { id: bButt; text: "B" } + RadioButton { text: "H"; checked: !is7B } + } + + Text { + id: preview + font.pixelSize: nootkaWindow.fontSize * 2 + } + } + + onStyleChanged: { + if (style > -1) { + var sp = "" + for (var n = 1; n < 8; ++n) + sp += Noo.noteName(Noo.note(n, 1, 0), style, false) + " " + preview.text = sp + } + } +} + diff --git a/src/qml/shared/NameStyleSelector.qml b/src/qml/shared/NameStyleSelector.qml index d2eaf20e4f960998425346cb02fb613b9921c14f..59cbf393281e1c56c7c9fb79a217cc505a5a68a3 100644 --- a/src/qml/shared/NameStyleSelector.qml +++ b/src/qml/shared/NameStyleSelector.qml @@ -9,6 +9,7 @@ import Nootka 1.0 Item { + id: root property bool seventhIsB: true property int style: -1 @@ -42,31 +43,35 @@ Item { Column { id: styleColumn spacing: nootkaWindow.fontSize / 2 - RadioButton { + RadioButton { // 0 default property int style: Nootka.Norsk_Hb text: qsTr("Scandinavian") + " (C, C#, Db ... Hb, H)" visible: !seventhIsB + onVisibleChanged: if (!visible && checked) root.style = Nootka.English_Bb // fix when that name style is not supported when 7th is H } - RadioButton { - default property int style: Nootka.Italiano_Si - text: qsTr("Italian") + " (Do, Do#, Reb ... Sib, Si)" - } - RadioButton { + RadioButton { // 1 default property int style: Nootka.Deutsch_His text: qsTr("German") + " (C, Cis, Des ... B, H)" visible: !seventhIsB + onVisibleChanged: if (!visible && checked) root.style = Nootka.Nederl_Bis + } + RadioButton { // 2 + default property int style: Nootka.Italiano_Si + text: qsTr("Italian") + " (Do, Do#, Reb ... Sib, Si)" } - RadioButton { + RadioButton { // 3 default property int style: Nootka.English_Bb text: qsTr("English") + " (C, C#, Db ... Bb, B)" visible: seventhIsB + onVisibleChanged: if (!visible && checked) root.style = Nootka.Norsk_Hb } - RadioButton { + RadioButton { // 4 default property int style: Nootka.Nederl_Bis text: qsTr("Dutch") + " (C, Cis, Des ... Bes, B)" visible: seventhIsB + onVisibleChanged: if (!visible && checked) root.style = Nootka.Deutsch_His } - RadioButton { + RadioButton { // 5 default property int style: Nootka.Russian_Ci text: qsTr("Russian") + " (До, До# Реb ... Сиb, Си)" }