forked from qt-creator/qt-creator
McuSupport: Move askUserAboutMcuSupportKitsUpgrade closer to its user
Change-Id: I41f0eac4ce37db682c0d9be06acf84691eb225c0 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
#include <cmakeprojectmanager/cmakekitaspect.h>
|
||||
#include <cmakeprojectmanager/cmaketoolmanager.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <debugger/debuggeritem.h>
|
||||
#include <debugger/debuggeritemmanager.h>
|
||||
#include <debugger/debuggerkitaspect.h>
|
||||
@@ -29,14 +31,18 @@
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/infobar.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QTimer>
|
||||
|
||||
using CMakeProjectManager::CMakeConfig;
|
||||
using CMakeProjectManager::CMakeConfigItem;
|
||||
using CMakeProjectManager::CMakeConfigurationKitAspect;
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -491,6 +497,38 @@ QList<Kit *> outdatedKits()
|
||||
}
|
||||
|
||||
// Maintenance
|
||||
|
||||
static void askUserAboutMcuSupportKitsUpgrade(const SettingsHandler::Ptr &settingsHandler)
|
||||
{
|
||||
const char upgradeMcuSupportKits[] = "UpgradeMcuSupportKits";
|
||||
|
||||
if (!ICore::infoBar()->canInfoBeAdded(upgradeMcuSupportKits))
|
||||
return;
|
||||
|
||||
InfoBarEntry info(upgradeMcuSupportKits,
|
||||
Tr::tr("New version of Qt for MCUs detected. Upgrade existing kits?"),
|
||||
InfoBarEntry::GlobalSuppression::Enabled);
|
||||
using McuKitManager::UpgradeOption;
|
||||
static UpgradeOption selectedOption = UpgradeOption::Keep;
|
||||
|
||||
const QList<InfoBarEntry::ComboInfo> infos
|
||||
= {{Tr::tr("Create new kits"), QVariant::fromValue(UpgradeOption::Keep)},
|
||||
{Tr::tr("Replace existing kits"), QVariant::fromValue(UpgradeOption::Replace)}};
|
||||
|
||||
info.setComboInfo(infos, [](const InfoBarEntry::ComboInfo &selected) {
|
||||
selectedOption = selected.data.value<UpgradeOption>();
|
||||
});
|
||||
|
||||
info.addCustomButton(Tr::tr("Proceed"), [upgradeMcuSupportKits, settingsHandler] {
|
||||
ICore::infoBar()->removeInfo(upgradeMcuSupportKits);
|
||||
QTimer::singleShot(0, [settingsHandler]() {
|
||||
McuKitManager::upgradeKitsByCreatingNewPackage(settingsHandler, selectedOption);
|
||||
});
|
||||
});
|
||||
|
||||
ICore::infoBar()->addInfo(info);
|
||||
}
|
||||
|
||||
void createAutomaticKits(const SettingsHandler::Ptr &settingsHandler)
|
||||
{
|
||||
McuPackagePtr qtForMCUsPackage{createQtForMCUsPackage(settingsHandler)};
|
||||
@@ -562,7 +600,7 @@ void createAutomaticKits(const SettingsHandler::Ptr &settingsHandler)
|
||||
}
|
||||
}
|
||||
if (needsUpgrade)
|
||||
McuSupportPlugin::askUserAboutMcuSupportKitsUpgrade(settingsHandler);
|
||||
askUserAboutMcuSupportKitsUpgrade(settingsHandler);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -240,37 +240,6 @@ void McuSupportPlugin::askUserAboutMcuSupportKitsSetup()
|
||||
ICore::infoBar()->addInfo(info);
|
||||
}
|
||||
|
||||
void McuSupportPlugin::askUserAboutMcuSupportKitsUpgrade(const SettingsHandler::Ptr &settingsHandler)
|
||||
{
|
||||
const char upgradeMcuSupportKits[] = "UpgradeMcuSupportKits";
|
||||
|
||||
if (!ICore::infoBar()->canInfoBeAdded(upgradeMcuSupportKits))
|
||||
return;
|
||||
|
||||
Utils::InfoBarEntry info(upgradeMcuSupportKits,
|
||||
Tr::tr("New version of Qt for MCUs detected. Upgrade existing kits?"),
|
||||
Utils::InfoBarEntry::GlobalSuppression::Enabled);
|
||||
using McuKitManager::UpgradeOption;
|
||||
static UpgradeOption selectedOption = UpgradeOption::Keep;
|
||||
|
||||
const QList<Utils::InfoBarEntry::ComboInfo> infos
|
||||
= {{Tr::tr("Create new kits"), QVariant::fromValue(UpgradeOption::Keep)},
|
||||
{Tr::tr("Replace existing kits"), QVariant::fromValue(UpgradeOption::Replace)}};
|
||||
|
||||
info.setComboInfo(infos, [](const Utils::InfoBarEntry::ComboInfo &selected) {
|
||||
selectedOption = selected.data.value<UpgradeOption>();
|
||||
});
|
||||
|
||||
info.addCustomButton(Tr::tr("Proceed"), [upgradeMcuSupportKits, settingsHandler] {
|
||||
ICore::infoBar()->removeInfo(upgradeMcuSupportKits);
|
||||
QTimer::singleShot(0, [settingsHandler]() {
|
||||
McuKitManager::upgradeKitsByCreatingNewPackage(settingsHandler, selectedOption);
|
||||
});
|
||||
});
|
||||
|
||||
ICore::infoBar()->addInfo(info);
|
||||
}
|
||||
|
||||
void McuSupportPlugin::askUserAboutRemovingUninstalledTargetsKits()
|
||||
{
|
||||
const char removeUninstalledKits[] = "RemoveUninstalledKits";
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "settingshandler.h"
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <projectexplorer/target.h>
|
||||
@@ -25,7 +23,6 @@ public:
|
||||
void extensionsInitialized() final;
|
||||
|
||||
void askUserAboutMcuSupportKitsSetup();
|
||||
static void askUserAboutMcuSupportKitsUpgrade(const SettingsHandler::Ptr &settingsHandler);
|
||||
static void askUserAboutRemovingUninstalledTargetsKits();
|
||||
|
||||
Q_INVOKABLE static void updateDeployStep(ProjectExplorer::Target *target, bool enabled);
|
||||
|
||||
Reference in New Issue
Block a user