* \brief Remove the plugin from the plugin list in the settings (and unload it if rightNow == true). * * \param rightNow Set this to true if you want to unload the plugin immediately (which is not * always a good idea). The default behavior is to disable the plugin for the next program startup. */
| 115 | * always a good idea). The default behavior is to disable the plugin for the next program startup. |
| 116 | */ |
| 117 | void PluginManager::disablePlugin(const QString& absolutePath, bool rightNow) { |
| 118 | loadAll(); |
| 119 | |
| 120 | // remove the plugin from the settings |
| 121 | // TODO |
| 122 | // QSettings settings(SETTINGS_FORMAT, QSettings::UserScope, SciDAVis::appName, SciDAVis::appName); |
| 123 | // settings.beginGroup("PluginManager"); |
| 124 | // QStringList pluginPaths = settings.value("enabledPlugins", QStringList()).toStringList(); |
| 125 | // pluginPaths.removeDuplicates(); |
| 126 | // int index = pluginPaths.indexOf(absolutePath); |
| 127 | // if (index > -1) { |
| 128 | // pluginPaths.removeAt(index); |
| 129 | // settings.setValue("enabledPlugins", pluginPaths); |
| 130 | // } |
| 131 | // settings.endGroup(); |
| 132 | |
| 133 | // remove the related loader if it is in the list of failed loaders |
| 134 | for (auto* loader : m_pluginsWithErrors) { |
| 135 | if (loader->fileName() == absolutePath) { |
| 136 | m_pluginsWithErrors.removeAll(loader); |
| 137 | delete loader; |
| 138 | break; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | if (rightNow) { |
| 143 | // unload the plugin and remove the loader |
| 144 | for (auto* loader : m_loadedPlugins) { |
| 145 | if (loader->fileName() == absolutePath) { |
| 146 | m_allPlugins.removeAll(loader->instance()); |
| 147 | m_loadedPlugins.removeAll(loader); |
| 148 | loader->unload(); |
| 149 | delete loader; |
| 150 | break; |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * \brief Get all plugin root instances. |