Don't fetch frame for audiospectrum if it is hidden

parent 31a5423f
......@@ -328,6 +328,9 @@ void MainWindow::init()
// Audio spectrum scope
m_audioSpectrum = new AudioGraphSpectrum(pCore->monitorManager());
QDockWidget *spectrumDock = addDock(i18n("Audio Spectrum"), QStringLiteral("audiospectrum"), m_audioSpectrum);
connect(spectrumDock, &QDockWidget::visibilityChanged, [&](bool visible) {
m_audioSpectrum->dockVisible(visible);
});
// Close library and audiospectrum on first run
screenGrabDock->close();
libraryDock->close();
......
......@@ -303,7 +303,7 @@ AudioGraphSpectrum::AudioGraphSpectrum(MonitorManager *manager, QWidget *parent)
QAction *a = new QAction(i18n("Enable Audio Spectrum"), this);
a->setCheckable(true);
a->setChecked(KdenliveSettings::enableaudiospectrum());
if (KdenliveSettings::enableaudiospectrum()) {
if (KdenliveSettings::enableaudiospectrum() && isVisible()) {
connect(m_manager, &MonitorManager::frameDisplayed, this, &ScopeWidget::onNewFrame, Qt::UniqueConnection);
}
connect(a, &QAction::triggered, this, &AudioGraphSpectrum::activate);
......@@ -317,6 +317,17 @@ AudioGraphSpectrum::~AudioGraphSpectrum()
delete m_filter;
}
void AudioGraphSpectrum::dockVisible(bool visible)
{
if (KdenliveSettings::enableaudiospectrum()) {
if (!visible) {
disconnect(m_manager, &MonitorManager::frameDisplayed, this, &ScopeWidget::onNewFrame);
} else {
connect(m_manager, &MonitorManager::frameDisplayed, this, &ScopeWidget::onNewFrame);
}
}
}
void AudioGraphSpectrum::activate(bool enable)
{
if (enable) {
......
......@@ -80,6 +80,7 @@ class AudioGraphSpectrum : public ScopeWidget
public:
AudioGraphSpectrum(MonitorManager *manager, QWidget *parent = nullptr);
~AudioGraphSpectrum() override;
void dockVisible(bool visible);
private:
MonitorManager *m_manager;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment