From f53d04a84d148a771dab3de9fe5f2f28e2d0240d Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Wed, 11 Nov 2020 14:08:11 +0100 Subject: Hide Tool action instead of not adding them. --- src/mainwindow.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 93ca415d..9bbe3da9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1652,6 +1652,9 @@ void MainWindow::registerPluginTool(IPluginTool *tool, QString name, QMenu *menu connect(action, SIGNAL(triggered()), this, SLOT(toolPluginInvoke()), Qt::QueuedConnection); menu->addAction(action); + if (!m_PluginContainer.isEnabled(tool)) { + action->setVisible(false); + } } void MainWindow::registerPluginTools(std::vector toolPlugins) @@ -1663,14 +1666,6 @@ void MainWindow::registerPluginTools(std::vector toolPlugins) } ); - // TODO: I don't know when this method is called? Maybe the check should be perform when - // the context menu is opened? - // Remove inactive plugins - toolPlugins.erase( - std::remove_if(toolPlugins.begin(), toolPlugins.end(), [this](IPluginTool *plugin) { return !m_PluginContainer.isEnabled(plugin); }), - toolPlugins.end() - ); - // Group the plugins into submenus QMap>> submenuMap; for (auto toolPlugin : toolPlugins) { -- cgit v1.3.1