diff --git a/include/FxMixer.h b/include/FxMixer.h index 920d4e27bc3..e7af1d50e1c 100644 --- a/include/FxMixer.h +++ b/include/FxMixer.h @@ -73,7 +73,13 @@ class FxChannel : public ThreadableJob void unmuteForSolo(); - // TODO C++17 and above: use std::optional insteads + void setColor (QColor newColor) + { + m_color = newColor; + m_hasColor = true; + } + + // TODO C++17 and above: use std::optional instead QColor m_color; bool m_hasColor; diff --git a/src/gui/widgets/FxLine.cpp b/src/gui/widgets/FxLine.cpp index 476d8773b2b..254e4068d94 100644 --- a/src/gui/widgets/FxLine.cpp +++ b/src/gui/widgets/FxLine.cpp @@ -418,11 +418,9 @@ void FxLine::setStrokeInnerInactive( const QColor & c ) void FxLine::changeColor() { auto channel = Engine::fxMixer()->effectChannel( m_channelIndex ); - auto new_color = ColorChooser( this ).withPalette( ColorChooser::Palette::Mixer )->getColor( channel->m_color ); - if( ! new_color.isValid() ) - { return; } - channel->m_color = new_color; - channel->m_hasColor = true; + auto new_color = ColorChooser(this).withPalette(ColorChooser::Palette::Mixer)->getColor(channel->m_color); + if(!new_color.isValid()) { return; } + channel->setColor (new_color); update(); } @@ -439,7 +437,6 @@ void FxLine::resetColor() void FxLine::randomColor() { auto channel = Engine::fxMixer()->effectChannel( m_channelIndex ); - channel->m_color = ColorChooser::getPalette( ColorChooser::Palette::Mixer )[ rand() % 48 ]; - channel->m_hasColor = true; + channel->setColor (ColorChooser::getPalette(ColorChooser::Palette::Mixer)[rand() % 48]); update(); } diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index c61999a0ee7..5c75245f39e 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -1098,8 +1098,10 @@ InstrumentTrackWindow * InstrumentTrackView::topLevelInstrumentTrackWindow() void InstrumentTrackView::createFxLine() { int channelIndex = gui->fxMixerView()->addNewChannel(); + auto channel = Engine::fxMixer()->effectChannel(channelIndex); - Engine::fxMixer()->effectChannel( channelIndex )->m_name = getTrack()->name(); + channel->m_name = getTrack()->name(); + if (getTrack()->useColor()) { channel->setColor (getTrack()->color()); } assignFxLine(channelIndex); } diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index b84d2980311..398fbd28a2e 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -1169,8 +1169,10 @@ void SampleTrackWindow::modelChanged() void SampleTrackView::createFxLine() { int channelIndex = gui->fxMixerView()->addNewChannel(); + auto channel = Engine::fxMixer()->effectChannel(channelIndex); - Engine::fxMixer()->effectChannel(channelIndex)->m_name = getTrack()->name(); + channel->m_name = getTrack()->name(); + if (getTrack()->useColor()) { channel->setColor (getTrack()->color()); } assignFxLine(channelIndex); }