From e0abff10d0c9e4ac9606f076c8fc7a66094acef0 Mon Sep 17 00:00:00 2001 From: Hussam Eddin Alhomsi Date: Tue, 24 Apr 2018 11:25:49 +0300 Subject: [PATCH] Responsive "Effects chain" & "User controller" LEDs (#4297) --- include/ControllerConnectionDialog.h | 1 + include/EffectChain.h | 5 ----- src/core/EffectChain.cpp | 11 ++++++++++- src/gui/ControllerConnectionDialog.cpp | 14 ++++++++++++-- src/gui/widgets/EffectRackView.cpp | 1 - 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/ControllerConnectionDialog.h b/include/ControllerConnectionDialog.h index d3fa11cbc32..95e55ce79d8 100644 --- a/include/ControllerConnectionDialog.h +++ b/include/ControllerConnectionDialog.h @@ -66,6 +66,7 @@ public slots: void selectController(); void midiToggled(); void userToggled(); + void userSelected(); void autoDetectToggled(); void enableAutoDetect( QAction * _a ); diff --git a/include/EffectChain.h b/include/EffectChain.h index fe6f2f92427..5397fe81ca1 100644 --- a/include/EffectChain.h +++ b/include/EffectChain.h @@ -57,11 +57,6 @@ class EXPORT EffectChain : public Model, public SerializingObject void clear(); - void setEnabled( bool _on ) - { - m_enabledModel.setValue( _on ); - } - private: typedef QVector EffectList; diff --git a/src/core/EffectChain.cpp b/src/core/EffectChain.cpp index a1aea9d3a74..b47267e8fab 100644 --- a/src/core/EffectChain.cpp +++ b/src/core/EffectChain.cpp @@ -125,6 +125,8 @@ void EffectChain::appendEffect( Effect * _effect ) m_effects.append( _effect ); Engine::mixer()->doneChangeInModel(); + m_enabledModel.setValue( true ); + emit dataChanged(); } @@ -144,6 +146,12 @@ void EffectChain::removeEffect( Effect * _effect ) m_effects.erase( found ); Engine::mixer()->doneChangeInModel(); + + if( m_effects.isEmpty() ) + { + m_enabledModel.setValue( false ); + } + emit dataChanged(); } @@ -250,7 +258,6 @@ void EffectChain::clear() Engine::mixer()->requestChangeInModel(); - m_enabledModel.setValue( false ); while( m_effects.count() ) { Effect * e = m_effects[m_effects.count() - 1]; @@ -259,4 +266,6 @@ void EffectChain::clear() } Engine::mixer()->doneChangeInModel(); + + m_enabledModel.setValue( false ); } diff --git a/src/gui/ControllerConnectionDialog.cpp b/src/gui/ControllerConnectionDialog.cpp index 49747e08785..02857b03465 100644 --- a/src/gui/ControllerConnectionDialog.cpp +++ b/src/gui/ControllerConnectionDialog.cpp @@ -188,11 +188,14 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, m_userController = new ComboBox( m_userGroupBox, "Controller" ); m_userController->setGeometry( 10, 24, 200, 22 ); - for (Controller * c : Engine::getSong()->controllers()) { m_userController->model()->addItem( c->name() ); } + connect( m_userController->model(), SIGNAL( dataUnchanged() ), + this, SLOT( userSelected() ) ); + connect( m_userController->model(), SIGNAL( dataChanged() ), + this, SLOT( userSelected() ) ); // Mapping functions @@ -389,8 +392,15 @@ void ControllerConnectionDialog::userToggled() { m_midiGroupBox->model()->setValue( 0 ); } +} + - m_userController->setEnabled( enabled ); + + +void ControllerConnectionDialog::userSelected() +{ + m_userGroupBox->model()->setValue( 1 ); + userToggled(); } diff --git a/src/gui/widgets/EffectRackView.cpp b/src/gui/widgets/EffectRackView.cpp index b3f468d0eb3..c1e36547e68 100644 --- a/src/gui/widgets/EffectRackView.cpp +++ b/src/gui/widgets/EffectRackView.cpp @@ -231,7 +231,6 @@ void EffectRackView::addEffect() Effect * fx = esd.instantiateSelectedPlugin( fxChain() ); - fxChain()->m_enabledModel.setValue( true ); fxChain()->appendEffect( fx ); update();