diff --git a/src/libs/core/instruments/tpianobg.cpp b/src/libs/core/instruments/tpianobg.cpp index d1e71e8fe8bf5953380697c3d2bd2208df0fcaa7..d170a03ba312fa607feba8f0ede576c923bccad0 100644 --- a/src/libs/core/instruments/tpianobg.cpp +++ b/src/libs/core/instruments/tpianobg.cpp @@ -29,6 +29,10 @@ #include "checktime.h" +const char* const octaveNames[8] = { QT_TR_NOOP("Subcontra"), QT_TR_NOOP("Contra"), QT_TR_NOOP("Great"), QT_TR_NOOP("Small"), + QT_TR_NOOP("One-line"), QT_TR_NOOP("Two-line"), QT_TR_NOOP("Three-line"), QT_TR_NOOP("Four-line") }; + + TpianoBg::TpianoBg(QQuickItem* parent) : QQuickPaintedItem(parent), m_keyWidth(32.0), @@ -95,6 +99,15 @@ CHECKTIME ( painter->drawRect(0, kw, m_margin, height() - kw); painter->drawRect(width() - m_margin, kw, m_margin, height() - kw); } + painter->setPen(Qt::white); + QFont f; + f.setPixelSize(qRound(m_keyWidth * 0.6)); + painter->setFont(f); + for (int k = 0; k < m_keysNumber / 7; ++k) { + painter->drawText(QRect(m_margin + k * 7 * kw, 0, 7 * kw, m_keyWidth), Qt::AlignCenter, octaveNames[m_firstOctave + 2 + k]); + int xx = m_margin + (k + 1) * 7 * kw; + painter->drawLine(xx, qRound(m_keyWidth / 2.0), xx, qRound(m_keyWidth - 1.0)); + } ) } diff --git a/src/qml/instruments/Instrument.qml b/src/qml/instruments/Instrument.qml index 8240452da0f902b5e0790115975886ac4d5107cd..24954693fcd006fe94890d5378548ff6b8d8cb97 100644 --- a/src/qml/instruments/Instrument.qml +++ b/src/qml/instruments/Instrument.qml @@ -4,17 +4,21 @@ import QtQuick 2.7 +import Nootka 1.0 + + Item { id: root property Item instrument: null signal note(var n) - height: nootkaWindow.height / 4 //5 for piano + height: nootkaWindow.height / (GLOB.instrument.type === Tinstrument.Piano ? 5 : 4) width: nootkaWindow.width Component.onCompleted: { - var c = Qt.createComponent("qrc:/Guitar.qml") + var i = GLOB.instrument.type === Tinstrument.Piano ? "Piano" : "Guitar" + var c = Qt.createComponent("qrc:/" + i + ".qml") instrument = c.createObject(root, {"anchors.fill": root}) instrument.onNoteChanged.connect(callNote) }