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
This commit is contained in:
Michael Gregorius
2024-01-10 18:19:49 +01:00
parent 2658751255
commit ede65963ea
4 changed files with 22 additions and 9 deletions

View File

@@ -97,6 +97,7 @@ namespace lmms::gui
void removeUnusedChannels();
void moveChannelLeft();
void moveChannelRight();
void toggledMute();
private:
QString elideName(const QString& name);

View File

@@ -98,7 +98,6 @@ protected:
private slots:
void updateFaders();
void toggledSolo();
void toggledMute();
private:
void updateAllMixerChannels();

View File

@@ -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(&currentMixerChannel->m_muteModel, &BoolModel::dataChanged, this, &MixerChannelView::toggledMute);
disconnect(&currentMixerChannel->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();

View File

@@ -288,11 +288,6 @@ void MixerView::toggledSolo()
}
void MixerView::toggledMute()
{
updateAllMixerChannels();
}
void MixerView::updateAllMixerChannels()
{
for (int i = 0; i < m_mixerChannelViews.size(); ++i)