* @brief Uninstalls the currently selected addon, returning false on an invalid selection * or a partial-delete failure. */
| 619 | * or a partial-delete failure. |
| 620 | */ |
| 621 | bool Misc::ExtensionManager::uninstallExtension() |
| 622 | { |
| 623 | if (m_selectedIndex < 0 || m_selectedIndex >= m_filteredExtensions.count()) |
| 624 | return false; |
| 625 | |
| 626 | const auto addon = m_filteredExtensions.at(m_selectedIndex).toMap(); |
| 627 | const auto id = addon.value("id").toString(); |
| 628 | const auto type = addon.value("type").toString(); |
| 629 | |
| 630 | if (id.isEmpty() || !isInstalled(id)) |
| 631 | return false; |
| 632 | |
| 633 | const auto installDir = extensionsPath() + "/" + type + "/" + id; |
| 634 | const bool removed = QDir(installDir).removeRecursively(); |
| 635 | |
| 636 | m_installedExtensions.remove(id); |
| 637 | m_pluginMetadataCache.remove(id); |
| 638 | saveInstalledManifest(); |
| 639 | |
| 640 | Q_EMIT extensionUninstalled(id); |
| 641 | applyFilter(); |
| 642 | rebuildInstalledPlugins(); |
| 643 | |
| 644 | return removed; |
| 645 | } |
| 646 | |
| 647 | //-------------------------------------------------------------------------------------------------- |
| 648 | // Auto-update |