From e306322931be4a9246957e0775bd1e8d07e040aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Thu, 6 Oct 2022 23:18:15 -0300 Subject: [PATCH] Minor change in PluginManager window. --- src/tools/ecode/plugins/pluginmanager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tools/ecode/plugins/pluginmanager.cpp b/src/tools/ecode/plugins/pluginmanager.cpp index 38d5c5df2..84a3abc10 100644 --- a/src/tools/ecode/plugins/pluginmanager.cpp +++ b/src/tools/ecode/plugins/pluginmanager.cpp @@ -137,9 +137,11 @@ class UIPluginManagerTable : public UITableView { public: UIPluginManagerTable() : UITableView() {} + std::function onModelEnabledChange; + std::function getCheckBoxFn( const ModelIndex& index, const PluginsModel* model ) { - return [index, model]( UIPushButton* but ) -> UITextView* { + return [index, model, this]( UIPushButton* but ) -> UITextView* { UICheckBox* chk = UICheckBox::New(); chk->setChecked( model->data( model->index( index.row(), PluginsModel::Enabled ) ).asBool() ); @@ -155,6 +157,8 @@ class UIPluginManagerTable : public UITableView { std::string id( model->data( model->index( index.row(), PluginsModel::Id ) ).asCStr() ); model->getManager()->setEnabled( id, checked ); + if ( onModelEnabledChange ) + onModelEnabledChange( id, checked ); } return 1; } ); @@ -237,6 +241,9 @@ UIWindow* UIPluginManager::New( UISceneNode* sceneNode, PluginManager* manager, prefs->setEnabled( manager->isEnabled( def->id ) && manager->get( def->id )->hasFileConfig() ); } ); + tv->onModelEnabledChange = [&, prefs, manager]( const std::string& id, bool enabled ) { + prefs->setEnabled( enabled && manager->get( id )->hasFileConfig() ); + }; win->center(); return win; }