CuteLogger
Fast and simple logging solution for Qt based applications
audiometerwidget.h
1/*
2 * Copyright (c) 2015 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef AUDIOMETERWIDGET_H
19#define AUDIOMETERWIDGET_H
20
21#include <QLinearGradient>
22#include <QStringList>
23#include <QVector>
24#include <QWidget>
25
26#include <stdint.h>
27
28class QLabel;
29
30class AudioMeterWidget : public QWidget
31{
32 Q_OBJECT
33public:
34 AudioMeterWidget(QWidget *parent = 0);
35 void setDbLabels(const QVector<int> &labels);
36 void setChannelLabels(const QStringList &labels);
37 void setChannelLabelUnits(const QString &units);
38 void setOrientation(Qt::Orientation orientation);
39
40public slots:
41 void showAudio(const QVector<double> &dbLevels);
42
43protected:
44 void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
45 void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
46 void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
47
48private:
49 void calcGraphRect();
50 void drawDbLabels(QPainter &);
51 void drawChanLabels(QPainter &);
52 void drawBars(QPainter &);
53 void drawPeaks(QPainter &);
54 void updateToolTip();
55 QRectF m_graphRect;
56 QSizeF m_barSize;
57 Qt::Orientation m_orient;
58 QVector<double> m_levels;
59 QVector<double> m_peaks;
60 QVector<int> m_dbLabels;
61 QStringList m_chanLabels;
62 QLinearGradient m_gradient;
63 double m_maxDb;
64 QString m_chanLabelUnits;
65};
66
67#endif