spectrogram: Disable tuner when nothing subscribes to sample output

This commit is contained in:
Mike Walters
2016-04-23 18:47:33 +01:00
parent a4dd942bcb
commit 377fe33204
2 changed files with 12 additions and 2 deletions

View File

@@ -60,7 +60,8 @@ SpectrogramPlot::SpectrogramPlot(std::shared_ptr<SampleSource<std::complex<float
void SpectrogramPlot::paintFront(QPainter &painter, QRect &rect, range_t<off_t> sampleRange)
{
tuner.paintFront(painter, rect, sampleRange);
if (tunerEnabled())
tuner.paintFront(painter, rect, sampleRange);
}
void SpectrogramPlot::paintMid(QPainter &painter, QRect &rect, range_t<off_t> sampleRange)
@@ -175,7 +176,10 @@ int SpectrogramPlot::linesPerTile()
bool SpectrogramPlot::mouseEvent(QEvent::Type type, QMouseEvent event)
{
return tuner.mouseEvent(type, event);
if (tunerEnabled())
return tuner.mouseEvent(type, event);
return false;
}
std::shared_ptr<AbstractSampleSource> SpectrogramPlot::output()
@@ -213,6 +217,11 @@ void SpectrogramPlot::setZoomLevel(int zoom)
zoomLevel = zoom;
}
bool SpectrogramPlot::tunerEnabled()
{
return (tunerOutput->subscriberCount() > 0);
}
void SpectrogramPlot::tunerMoved()
{
tunerFilter->set_center_freq(getTunerCentre());