* @brief Checks installed extensions against the catalog and auto-updates any that have a newer * version available. */
| 653 | * version available. |
| 654 | */ |
| 655 | void Misc::ExtensionManager::autoUpdateExtensions() |
| 656 | { |
| 657 | if (m_loading) |
| 658 | return; |
| 659 | |
| 660 | if (m_autoUpdateQueue.isEmpty()) { |
| 661 | const auto ids = m_installedExtensions.keys(); |
| 662 | for (const auto& id : ids) |
| 663 | if (hasUpdate(id)) |
| 664 | m_autoUpdateQueue.append(id); |
| 665 | } |
| 666 | |
| 667 | if (m_autoUpdateQueue.isEmpty()) |
| 668 | return; |
| 669 | |
| 670 | const auto id = m_autoUpdateQueue.takeFirst(); |
| 671 | |
| 672 | bool found = false; |
| 673 | for (int i = 0; i < m_filteredExtensions.count(); ++i) { |
| 674 | if (m_filteredExtensions.at(i).toMap().value("id").toString() != id) |
| 675 | continue; |
| 676 | |
| 677 | m_selectedIndex = i; |
| 678 | Q_EMIT selectedIndexChanged(); |
| 679 | installExtension(); |
| 680 | found = true; |
| 681 | break; |
| 682 | } |
| 683 | |
| 684 | if (!m_autoUpdateQueue.isEmpty()) { |
| 685 | if (found && m_loading) { |
| 686 | connect( |
| 687 | this, |
| 688 | &ExtensionManager::extensionInstalled, |
| 689 | this, |
| 690 | [this]() { QTimer::singleShot(0, this, &ExtensionManager::autoUpdateExtensions); }, |
| 691 | Qt::SingleShotConnection); |
| 692 | } |
| 693 | |
| 694 | else { |
| 695 | QTimer::singleShot(0, this, &ExtensionManager::autoUpdateExtensions); |
| 696 | } |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | //-------------------------------------------------------------------------------------------------- |
| 701 | // Network reply handlers |