forked from qt-creator/qt-creator
WebAssembly: Move the device infobar setup to the device files
Change-Id: I201c0f1dba59530e9e8183cb24974baed049196e Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -1,13 +1,27 @@
|
||||
// Copyright (C) 2019 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "webassemblyconstants.h"
|
||||
#include "webassemblydevice.h"
|
||||
|
||||
#include "webassemblyconstants.h"
|
||||
#include "webassemblyqtversion.h"
|
||||
#include "webassemblytoolchain.h"
|
||||
#include "webassemblytr.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/devicesupport/desktopdevice.h>
|
||||
#include <projectexplorer/devicesupport/idevicefactory.h>
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
|
||||
#include <utils/infobar.h>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -30,11 +44,31 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
IDevicePtr createWebAssemblyDevice()
|
||||
static IDevicePtr createWebAssemblyDevice()
|
||||
{
|
||||
return IDevicePtr(new WebAssemblyDevice);
|
||||
}
|
||||
|
||||
static void askUserAboutEmSdkSetup()
|
||||
{
|
||||
const char setupWebAssemblyEmSdk[] = "SetupWebAssemblyEmSdk";
|
||||
|
||||
if (!ICore::infoBar()->canInfoBeAdded(setupWebAssemblyEmSdk)
|
||||
|| !WebAssemblyQtVersion::isQtVersionInstalled()
|
||||
|| WebAssemblyToolChain::areToolChainsRegistered())
|
||||
return;
|
||||
|
||||
InfoBarEntry info(setupWebAssemblyEmSdk,
|
||||
Tr::tr("Setup Emscripten SDK for WebAssembly? "
|
||||
"To do it later, select Edit > Preferences > Devices > WebAssembly."),
|
||||
InfoBarEntry::GlobalSuppression::Enabled);
|
||||
info.addCustomButton(Tr::tr("Setup Emscripten SDK"), [setupWebAssemblyEmSdk] {
|
||||
ICore::infoBar()->removeInfo(setupWebAssemblyEmSdk);
|
||||
QTimer::singleShot(0, []() { ICore::showOptionsDialog(Constants::SETTINGS_ID); });
|
||||
});
|
||||
ICore::infoBar()->addInfo(info);
|
||||
}
|
||||
|
||||
class WebAssemblyDeviceFactory final : public IDeviceFactory
|
||||
{
|
||||
public:
|
||||
@@ -52,6 +86,11 @@ public:
|
||||
void setupWebAssemblyDevice()
|
||||
{
|
||||
static WebAssemblyDeviceFactory theWebAssemblyDeviceFactory;
|
||||
|
||||
QObject::connect(KitManager::instance(), &KitManager::kitsLoaded, [] {
|
||||
DeviceManager::instance()->addDevice(createWebAssemblyDevice());
|
||||
askUserAboutEmSdkSetup();
|
||||
});
|
||||
}
|
||||
|
||||
} // WebAssembly::Internal
|
||||
|
||||
@@ -3,12 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/devicesupport/idevicefwd.h>
|
||||
|
||||
namespace WebAssembly::Internal {
|
||||
|
||||
ProjectExplorer::IDevicePtr createWebAssemblyDevice();
|
||||
|
||||
void setupWebAssemblyDevice();
|
||||
|
||||
} // WebAssembly::Interenal
|
||||
|
||||
@@ -6,52 +6,18 @@
|
||||
#ifdef WITH_TESTS
|
||||
#include "webassembly_test.h"
|
||||
#endif // WITH_TESTS
|
||||
#include "webassemblyconstants.h"
|
||||
#include "webassemblydevice.h"
|
||||
#include "webassemblyqtversion.h"
|
||||
#include "webassemblyrunconfiguration.h"
|
||||
#include "webassemblytoolchain.h"
|
||||
#include "webassemblytr.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
|
||||
#include <utils/infobar.h>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace WebAssembly::Internal {
|
||||
|
||||
static void askUserAboutEmSdkSetup()
|
||||
{
|
||||
const char setupWebAssemblyEmSdk[] = "SetupWebAssemblyEmSdk";
|
||||
|
||||
if (!ICore::infoBar()->canInfoBeAdded(setupWebAssemblyEmSdk)
|
||||
|| !WebAssemblyQtVersion::isQtVersionInstalled()
|
||||
|| WebAssemblyToolChain::areToolChainsRegistered())
|
||||
return;
|
||||
|
||||
InfoBarEntry info(setupWebAssemblyEmSdk,
|
||||
Tr::tr("Setup Emscripten SDK for WebAssembly? "
|
||||
"To do it later, select Edit > Preferences > Devices > WebAssembly."),
|
||||
InfoBarEntry::GlobalSuppression::Enabled);
|
||||
info.addCustomButton(Tr::tr("Setup Emscripten SDK"), [setupWebAssemblyEmSdk] {
|
||||
ICore::infoBar()->removeInfo(setupWebAssemblyEmSdk);
|
||||
QTimer::singleShot(0, []() { ICore::showOptionsDialog(Constants::SETTINGS_ID); });
|
||||
});
|
||||
ICore::infoBar()->addInfo(info);
|
||||
}
|
||||
|
||||
class WebAssemblyPlugin final : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -69,13 +35,6 @@ public:
|
||||
addTest<WebAssemblyTest>();
|
||||
#endif // WITH_TESTS
|
||||
}
|
||||
void extensionsInitialized() final
|
||||
{
|
||||
connect(KitManager::instance(), &KitManager::kitsLoaded, this, [] {
|
||||
DeviceManager::instance()->addDevice(createWebAssemblyDevice());
|
||||
askUserAboutEmSdkSetup();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
} // WebAssembly::Internal
|
||||
|
||||
Reference in New Issue
Block a user