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