From ede65963ea1d6131944679a131641c18b97bce0b Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Wed, 10 Jan 2024 18:19:49 +0100 Subject: [PATCH] Improve mixer channel update for mute events Improve the mixer channel update for mute events by not delegating to `MixerView` like for the solo case. Instead the `MixerChannelView` now has its own `toggledMute` slot which simply updates the widget on changes to the mute model. Also fix `MixerChannelView::setChannelIndex` by disconnecting from the signals of the previous mixer channel and connecting to the signals for the new one. Remove `toggledMute` from `MixerView`. The solo implementation is kept as is because it also triggers changes to the core model. So the chain seems to be: * Solo button clicked in mixer channel view * Button changes solo model * Solo model signals to mixer view which was connected via the mixer channel view * Mixer view performs changes in the other core models * All mixer channels are updated. Are better chain would first update the core models and then update the GUI from the changes: * Solo button clicked in mixer channel view * Button changes solo model * Solo model signals to core mixer, i.e. not a view! * Mixer view performs changes in the other core models * Changed models emit signal to GUI elements --- include/MixerChannelView.h | 1 + include/MixerView.h | 1 - src/gui/MixerChannelView.cpp | 24 +++++++++++++++++++++--- src/gui/MixerView.cpp | 5 ----- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/MixerChannelView.h b/include/MixerChannelView.h index 8d2306f91..86c7f247d 100644 --- a/include/MixerChannelView.h +++ b/include/MixerChannelView.h @@ -97,6 +97,7 @@ namespace lmms::gui void removeUnusedChannels(); void moveChannelLeft(); void moveChannelRight(); + void toggledMute(); private: QString elideName(const QString& name); diff --git a/include/MixerView.h b/include/MixerView.h index bc99a3340..251becb27 100644 --- a/include/MixerView.h +++ b/include/MixerView.h @@ -98,7 +98,6 @@ protected: private slots: void updateFaders(); void toggledSolo(); - void toggledMute(); private: void updateAllMixerChannels(); diff --git a/src/gui/MixerChannelView.cpp b/src/gui/MixerChannelView.cpp index cbd9019f1..a2edc5c5f 100644 --- a/src/gui/MixerChannelView.cpp +++ b/src/gui/MixerChannelView.cpp @@ -104,7 +104,7 @@ namespace lmms::gui m_muteButton->setInactiveGraphic(embed::getIconPixmap("led_green")); m_muteButton->setCheckable(true); m_muteButton->setToolTip(tr("Mute this channel")); - connect(&mixerChannel->m_muteModel, &BoolModel::dataChanged, mixerView, &MixerView::toggledMute, Qt::DirectConnection); + connect(&mixerChannel->m_muteModel, &BoolModel::dataChanged, this, &MixerChannelView::toggledMute, Qt::DirectConnection); m_soloButton = new PixmapButton(this, tr("Solo")); m_soloButton->setModel(&mixerChannel->m_soloModel); @@ -274,11 +274,24 @@ namespace lmms::gui void MixerChannelView::setChannelIndex(int index) { + // First disconnect the signals of the previous mixer channel + auto * currentMixerChannel = Engine::mixer()->mixerChannel(m_channelIndex); + disconnect(¤tMixerChannel->m_muteModel, &BoolModel::dataChanged, this, &MixerChannelView::toggledMute); + disconnect(¤tMixerChannel->m_soloModel, &BoolModel::dataChanged, m_mixerView, &MixerView::toggledSolo); + MixerChannel* mixerChannel = Engine::mixer()->mixerChannel(index); m_fader->setModel(&mixerChannel->m_volumeModel); - m_muteButton->setModel(&mixerChannel->m_muteModel); - m_soloButton->setModel(&mixerChannel->m_soloModel); + + auto * muteModel = &mixerChannel->m_muteModel; + m_muteButton->setModel(muteModel); + connect(muteModel, &BoolModel::dataChanged, this, &MixerChannelView::toggledMute, Qt::DirectConnection); + + auto * soloModel = &mixerChannel->m_soloModel; + m_soloButton->setModel(soloModel); + connect(soloModel, &BoolModel::dataChanged, m_mixerView, &MixerView::toggledSolo, Qt::DirectConnection); + m_effectRackView->setModel(&mixerChannel->m_fxChain); + m_channelIndex = index; } @@ -437,6 +450,11 @@ namespace lmms::gui mix->moveChannelRight(m_channelIndex); } + void MixerChannelView::toggledMute() + { + update(); + } + QString MixerChannelView::elideName(const QString& name) { const auto maxTextHeight = m_renameLineEdit->width(); diff --git a/src/gui/MixerView.cpp b/src/gui/MixerView.cpp index ea6a28948..62d436fed 100644 --- a/src/gui/MixerView.cpp +++ b/src/gui/MixerView.cpp @@ -288,11 +288,6 @@ void MixerView::toggledSolo() } -void MixerView::toggledMute() -{ - updateAllMixerChannels(); -} - void MixerView::updateAllMixerChannels() { for (int i = 0; i < m_mixerChannelViews.size(); ++i)