diff --git a/spectrogramplot.cpp b/spectrogramplot.cpp index 7bee274..03afcc1 100644 --- a/spectrogramplot.cpp +++ b/spectrogramplot.cpp @@ -60,7 +60,8 @@ SpectrogramPlot::SpectrogramPlot(std::shared_ptr sampleRange) { - tuner.paintFront(painter, rect, sampleRange); + if (tunerEnabled()) + tuner.paintFront(painter, rect, sampleRange); } void SpectrogramPlot::paintMid(QPainter &painter, QRect &rect, range_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 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()); diff --git a/spectrogramplot.h b/spectrogramplot.h index f474171..7cdf2a2 100644 --- a/spectrogramplot.h +++ b/spectrogramplot.h @@ -80,6 +80,7 @@ private: float getTunerCentre(); std::vector getTunerTaps(); int linesPerTile(); + bool tunerEnabled(); }; class TileCacheKey