Fix mixer channel updates on solo/mute (#7055)
* Fix mixer channel updates on solo/mute
Fix the update of the mixer channels whenever a channel is soloed or muted.
The solution is rather "brutal" as it updates all mixer channel views when one of the models changes.
Introduce private helper method `MixerView::updateAllMixerChannels`. It calls the `update` method on each `MixerChannelView` so that they can get repainted.
Call `updateAllMixerChannels` at the end of the existing method `toggledSolo`.
Introduce a new method `MixerView::toggledMute` which is called whenever the mute model of a channel changes. It also updates all mixer channels.
Fixes #7054.
* 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
* Revert "Improve mixer channel update for mute events"
This reverts commit ede65963ea.
* Add comment
After the revert done with commit the code is more consistent again but not in a good way. Hence a comment is added which indicates that an inprovement is needed.
* Abstract mixer retrieval
Abstract the retrieval of the mixer behind the new method `getMixer`. This is done in preparation for some dependency injection so that the `MixerView` does not have to ask the `Engine` for the mixer but gets it injected, a.k.a. the "Hollywood principle": "Don't call us, we'll call you."
It's called `getMixer` and not just mixer because it allows for locale variables to be called `mixer` without confusing it with the method.
* Let MixerView connect directly to models
Let the `MixerView` connect directly to the solo and mute models it is connected with.
Remove the connections that are made in `MixerChannelView` which acted as a proxy which only complicated things.
Add `connectToSoloAndMute` which connects the `MixerView` to the solo and mute models of a given channel. Call it whenever a new channel is created.
Add `disconnectFromSoloAndMute` which disconnects the `MixerView` from the solo and mute models of a given channel. Call it when a channel is deleted.
* Code cleanup
Cleanup code related to the creation of the master channel view.
* Inject the Mixer into the MixerView
Inject the `Mixer` into the `MixerView` via the constructor. This makes it more explicit that the `Mixer` is the model of the view. It also implements the "Dependency Inversion Principle" in that the `MIxerView` does not have to ask the `Engine` for the `Mixer` anymore.
The current changes should be safe in that the `Mixer` instance is static and does not change.
* Fix connections on song load
Disconnect and reconnect in `MixerView::refreshDisplay` which is called when a song is loaded.
This commit is contained in:
committed by
GitHub
parent
5fdf611357
commit
629ba0362b
@@ -38,6 +38,11 @@
|
||||
#include "embed.h"
|
||||
#include "EffectRackView.h"
|
||||
|
||||
namespace lmms
|
||||
{
|
||||
class Mixer;
|
||||
}
|
||||
|
||||
namespace lmms::gui
|
||||
{
|
||||
class LMMS_EXPORT MixerView : public QWidget, public ModelView,
|
||||
@@ -45,7 +50,7 @@ class LMMS_EXPORT MixerView : public QWidget, public ModelView,
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MixerView();
|
||||
MixerView(Mixer* mixer);
|
||||
void keyPressEvent(QKeyEvent* e) override;
|
||||
|
||||
void saveSettings(QDomDocument& doc, QDomElement& domElement) override;
|
||||
@@ -97,7 +102,17 @@ protected:
|
||||
|
||||
private slots:
|
||||
void updateFaders();
|
||||
// TODO This should be improved. Currently the solo and mute models are connected via
|
||||
// the MixerChannelView's constructor with the MixerView. It would already be an improvement
|
||||
// if the MixerView connected itself to each new MixerChannel that it creates/handles.
|
||||
void toggledSolo();
|
||||
void toggledMute();
|
||||
|
||||
private:
|
||||
Mixer* getMixer() const;
|
||||
void updateAllMixerChannels();
|
||||
void connectToSoloAndMute(int channelIndex);
|
||||
void disconnectFromSoloAndMute(int channelIndex);
|
||||
|
||||
private:
|
||||
QVector<MixerChannelView*> m_mixerChannelViews;
|
||||
@@ -109,6 +124,7 @@ private:
|
||||
QWidget* m_channelAreaWidget;
|
||||
QStackedLayout* m_racksLayout;
|
||||
QWidget* m_racksWidget;
|
||||
Mixer* m_mixer;
|
||||
|
||||
void updateMaxChannelSelector();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user