1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

Allow several classes of Level Meters sharing the same base algorithms. Initiate with the VU meter

This commit is contained in:
f4exb 2016-12-04 06:40:57 +01:00
parent 95f9a03a7b
commit 373a99e575
4 changed files with 29 additions and 10 deletions

View File

@ -357,7 +357,7 @@
</widget>
</item>
<item>
<widget class="LevelMeter" name="volumeMeter" native="true">
<widget class="LevelMeterVU" name="volumeMeter" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -662,7 +662,7 @@
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>LevelMeter</class>
<class>LevelMeterVU</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>

View File

@ -381,7 +381,7 @@
</widget>
</item>
<item>
<widget class="LevelMeter" name="volumeMeter" native="true">
<widget class="LevelMeterVU" name="volumeMeter" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -686,7 +686,7 @@
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>LevelMeter</class>
<class>LevelMeterVU</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>

View File

@ -132,7 +132,16 @@ void LevelMeter::paintEvent(QPaintEvent *event)
render(&painter);
}
void LevelMeter::render(QPainter *painter)
LevelMeterVU::LevelMeterVU(QWidget *parent) :
LevelMeter(parent)
{
}
LevelMeterVU::~LevelMeterVU()
{
}
void LevelMeterVU::render(QPainter *painter)
{
painter->fillRect(rect(), QColor(42, 42, 42, 255));

View File

@ -60,8 +60,8 @@ class LevelMeter : public QWidget
Q_OBJECT
public:
explicit LevelMeter(QWidget *parent = 0);
~LevelMeter();
LevelMeter(QWidget *parent = 0);
virtual ~LevelMeter();
void paintEvent(QPaintEvent *event);
@ -69,10 +69,10 @@ public slots:
void reset();
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples);
private slots:
protected slots:
void redrawTimerExpired();
private:
protected:
/**
* Height of RMS level bar.
* Range 0.0 - 1.0.
@ -120,7 +120,17 @@ private:
QColor m_peakColor;
QColor m_decayedPeakColor;
void render(QPainter *painter);
virtual void render(QPainter *painter) = 0;
};
class LevelMeterVU : public LevelMeter
{
public:
LevelMeterVU(QWidget *parent = 0);
virtual ~LevelMeterVU();
protected:
virtual void render(QPainter *painter);
};
#endif /* SDRBASE_GUI_LEVELMETER_H_ */