DeviceCheckBuildStep: Employ task tree for running

Task-number: QTCREATORBUG-29168
Change-Id: I3506663263d8ebdc922bd6ac1b11357f4a6dba8f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2023-07-13 00:11:04 +02:00
parent 870a1dca4d
commit b1f1624b6e

View File

@@ -8,9 +8,10 @@
#include "../projectexplorertr.h" #include "../projectexplorertr.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "idevice.h"
#include "idevicefactory.h" #include "idevicefactory.h"
#include <solutions/tasking/tasktree.h>
#include <QMessageBox> #include <QMessageBox>
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -26,40 +27,43 @@ public:
bool init() override bool init() override
{ {
if (!BuildStep::init())
return false;
IDevice::ConstPtr device = DeviceKitAspect::device(kit()); IDevice::ConstPtr device = DeviceKitAspect::device(kit());
if (!device) { if (device)
Utils::Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(kit()); return true;
IDeviceFactory *factory = IDeviceFactory::find(deviceTypeId);
if (!factory || !factory->canCreate()) {
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
return false;
}
QMessageBox msgBox(QMessageBox::Question, Tr::tr("Set Up Device"), Utils::Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(kit());
Tr::tr("There is no device set up for this kit. Do you want to add a device?"), IDeviceFactory *factory = IDeviceFactory::find(deviceTypeId);
QMessageBox::Yes|QMessageBox::No); if (!factory || !factory->canCreate()) {
msgBox.setDefaultButton(QMessageBox::Yes); emit addOutput(Tr::tr("No device configured."), OutputFormat::ErrorMessage);
if (msgBox.exec() == QMessageBox::No) { return false;
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
return false;
}
IDevice::Ptr newDevice = factory->create();
if (newDevice.isNull()) {
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
return false;
}
DeviceManager *dm = DeviceManager::instance();
dm->addDevice(newDevice);
DeviceKitAspect::setDevice(kit(), newDevice);
} }
QMessageBox msgBox(QMessageBox::Question, Tr::tr("Set Up Device"),
Tr::tr("There is no device set up for this kit. Do you want to add a device?"),
QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
if (msgBox.exec() == QMessageBox::No) {
emit addOutput(Tr::tr("No device configured."), OutputFormat::ErrorMessage);
return false;
}
IDevice::Ptr newDevice = factory->create();
if (newDevice.isNull()) {
emit addOutput(Tr::tr("No device configured."), OutputFormat::ErrorMessage);
return false;
}
DeviceManager *dm = DeviceManager::instance();
dm->addDevice(newDevice);
DeviceKitAspect::setDevice(kit(), newDevice);
return true; return true;
} }
void doRun() override { emit finished(true); } private:
Tasking::GroupItem runRecipe() final { return Tasking::Group{}; }
}; };
// Factory // Factory