Skip to content
Snippets Groups Projects
Commit 741511a8 authored by SeeLook's avatar SeeLook
Browse files

Drawing octave names on piano, loading instrument depends on settings

parent f105d40b
Branches
Tags
No related merge requests found
......@@ -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));
}
)
}
......
......@@ -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)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment