Browse Source

„PianoKeyBoard.cpp“ löschen

master
Lars Mewes 2 years ago
parent
commit
9d3db194fb
1 changed files with 0 additions and 63 deletions
  1. 0
    63
      PianoKeyBoard.cpp

+ 0
- 63
PianoKeyBoard.cpp View File

@@ -1,63 +0,0 @@
#include "PianoKeyBoard.h"
#include "MainWindow.h"
#include <QGraphicsSceneMouseEvent>
#include <QColorDialog>

PianoKeyBoard::PianoKeyBoard(qreal x, qreal y, qreal w, qreal h, MainWindow *parent): QGraphicsScene(x,y,w,h){

addItem(keys[0] = new PianoKey(parent->colorScale.getToneByName("C")));
addItem(keys[1] = new PianoKey(parent->colorScale.getToneByName("Cis")));
addItem(keys[2] = new PianoKey(parent->colorScale.getToneByName("D")));
addItem(keys[3] = new PianoKey(parent->colorScale.getToneByName("Dis")));
addItem(keys[4] = new PianoKey(parent->colorScale.getToneByName("E")));
addItem(keys[5] = new PianoKey(parent->colorScale.getToneByName("F")));
addItem(keys[6] = new PianoKey(parent->colorScale.getToneByName("Fis")));
addItem(keys[7] = new PianoKey(parent->colorScale.getToneByName("G")));
addItem(keys[8] = new PianoKey(parent->colorScale.getToneByName("Gis")));
addItem(keys[9] = new PianoKey(parent->colorScale.getToneByName("A")));
addItem(keys[10] = new PianoKey(parent->colorScale.getToneByName("Ais")));
addItem(keys[11] = new PianoKey(parent->colorScale.getToneByName("H")));

for(int i=0; i<12; i++)
QObject::connect(keys[i]->getTone(), &Tone::colorchanged, keys[i], &PianoKey::redraw);

};

void PianoKeyBoard::mousePressEvent(QGraphicsSceneMouseEvent *event){
QString title = "Bitte Farbe wählen für Ton ";
if(event->button() == Qt::LeftButton){
//first check "black" Piano keys as they are in foreground
for(int i=6; i<12; i++){
if(keys[i]->sceneBoundingRect().contains(event->scenePos())){
keys[i]->getTone()->setColor(
QColorDialog::getColor(
keys[i]->getTone()->getColor(),
nullptr,
title.append(keys[i]->getTone()->getName()),
QColorDialog::DontUseNativeDialog
)
);
return;
}
}
for(int i=0; i<6; i++){
if(keys[i]->sceneBoundingRect().contains(event->scenePos())){
keys[i]->getTone()->setColor(
QColorDialog::getColor(
keys[i]->getTone()->getColor(),
nullptr,
title.append(keys[i]->getTone()->getName()),
QColorDialog::DontUseNativeDialog
)
);
return;
}
}
}
};
PianoKey * PianoKeyBoard::getKey(int number)const{
return keys[number];
};
PianoKeyBoard::~PianoKeyBoard(){

};

Loading…
Cancel
Save