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 <QWidget>
23#include <QVector>
24#include <QStringList>
25#include <QLinearGradient>
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