21 #include "../core/messages/messagenewfftcalculated.h"
22 #include "../core/messages/messagemodechanged.h"
29 : QGraphicsView(parent),
32 setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
33 setWhatsThis(tr(
"This item displays the status of the recorder. A red circle indicates that the audio signal is currently recorded. A blue rotating circle is shown when the program processes the recorded signal. A green pause symbol is displayed if you can record the next key."));
36 setStyleSheet(
"background: transparent; border: none");
41 mRecordItems.push_back(
mScene.addEllipse(-44, -42, 91, 91, QPen(Qt::darkRed), QBrush(Qt::darkRed)));
45 mPauseItems.push_back(
mScene.addRect(-45, -45, 35, 90, QPen(Qt::darkGreen), QBrush(Qt::darkGreen)));
46 mPauseItems.push_back(
mScene.addRect(-45, -45, 31, 87, QPen(Qt::lightGray), QBrush(Qt::green)));
47 mPauseItems.push_back(
mScene.addRect(10, -45, 35, 90, QPen(Qt::darkGreen), QBrush(Qt::darkGreen)));
48 mPauseItems.push_back(
mScene.addRect(10, -45, 31, 87, QPen(Qt::lightGray), QBrush(Qt::green)));
53 path.arcMoveTo(-45, -45, 90, 90, 0);
54 path.arcTo(-45, -45, 90, 90, 0, 360);
55 QConicalGradient gradient(0, 0, 0);
56 gradient.setColorAt(0, QColor(0, 0, 0, 255));
57 gradient.setColorAt(1, QColor(0, 0, 0, 0));
58 mProgressItems.push_back(
mScene.addPath(path, QPen(QBrush(gradient), 10, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)));
60 path = QPainterPath();
61 path.arcMoveTo(-45, -45, 90, 90, 0);
62 path.arcTo(-45, -45, 90, 90, 0, 360);
63 gradient = QConicalGradient(0, 0, 0);
64 gradient.setColorAt(0, QColor(50, 50, 255, 255));
65 gradient.setColorAt(1, QColor(50, 50, 255, 0));
66 mProgressItems.push_back(
mScene.addPath(path, QPen(QBrush(gradient), 8, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)));
88 QGraphicsView::showEvent(event);
94 QGraphicsView::resizeEvent(event);
98 switch (m->getType()) {
100 qDebug() <<
"Analysis started";
107 qDebug() <<
"Analysis ended";
114 qDebug() <<
"Recording started";
126 for (
auto item : items) {
127 item->setVisible(visible);
133 item->setRotation(item->rotation() + 5);
RecordingStatusGraphicsView(QWidget *parent)
Default constructor.
std::shared_ptr< Message > MessagePtr
Global type of a shared message pointer.
virtual ~RecordingStatusGraphicsView()
Emptry virtual destructor.
void handleMessage(MessagePtr m) overridefinal
Message handling.
static const QRectF SCENE_RECT
The scene rect of the QGraphicsScene.
QGraphicsScene mScene
The graphics scene.
void onProcess()
Called by the timer to rotate the blue circle.
std::vector< QGraphicsItem * > mPauseItems
Items that are used to draw the pause state.
QTimer mProgressTimer
Timer to shoot a onProgress() at a fixed time intervall.
void showEvent(QShowEvent *event) override
Reimplemented show event that will fit the SCENE_RECT into the view.
void setItemVisible(const std::vector< QGraphicsItem * > &items, bool visible)
Function to show or hide a group of items.
analysis of the signal started
void resizeEvent(QResizeEvent *event) override
Reimplemented resize event that will fit the SCENE_RECT into the view.
std::vector< QGraphicsItem * > mRecordItems
Items that are used to draw the recording state.
std::vector< QGraphicsItem * > mProgressItems
Items that are used to draw the analysing state.
analysis of the signal ended
keystroke recognized and recording started
virtual QSize sizeHint() const overridefinal