QmlPreview: Inline LocalQmlPreviewSupport

Task-number: QTCREATORBUG-29168
Change-Id: I93f17e165a714018375b3ec43b633d1a397c34dc
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2024-11-20 15:52:37 +01:00
parent 063fd3dcf8
commit 97ac8ea219

View File

@@ -174,13 +174,12 @@ QmlPreviewRunWorkerFactory::QmlPreviewRunWorkerFactory(QmlPreviewPlugin *plugin,
addSupportedRunMode(Constants::QML_PREVIEW_RUNNER); addSupportedRunMode(Constants::QML_PREVIEW_RUNNER);
} }
class LocalQmlPreviewSupport final : public SimpleTargetRunner LocalQmlPreviewSupportFactory::LocalQmlPreviewSupportFactory()
{ {
public: setId(ProjectExplorer::Constants::QML_PREVIEW_RUN_FACTORY);
LocalQmlPreviewSupport(RunControl *runControl) setProducer([](RunControl *runControl) {
: SimpleTargetRunner(runControl) auto worker = new SimpleTargetRunner(runControl);
{ worker->setId("LocalQmlPreviewSupport");
setId("LocalQmlPreviewSupport");
runControl->setQmlChannel(Utils::urlFromLocalSocket()); runControl->setQmlChannel(Utils::urlFromLocalSocket());
@@ -188,11 +187,11 @@ public:
RunWorker *preview = RunWorker *preview =
runControl->createWorker(ProjectExplorer::Constants::QML_PREVIEW_RUNNER); runControl->createWorker(ProjectExplorer::Constants::QML_PREVIEW_RUNNER);
addStopDependency(preview); worker->addStopDependency(preview);
addStartDependency(preview); worker->addStartDependency(preview);
setStartModifier([this, runControl] { worker->setStartModifier([worker, runControl] {
CommandLine cmd = commandLine(); CommandLine cmd = worker->commandLine();
if (const auto aspect = runControl->aspectData<QmlProjectManager::QmlMainFileAspect>()) { if (const auto aspect = runControl->aspectData<QmlProjectManager::QmlMainFileAspect>()) {
const auto qmlBuildSystem = qobject_cast<QmlProjectManager::QmlBuildSystem *>( const auto qmlBuildSystem = qobject_cast<QmlProjectManager::QmlBuildSystem *>(
@@ -214,17 +213,11 @@ public:
} }
cmd.addArg(qmlDebugLocalArguments(QmlPreviewServices, runControl->qmlChannel().path())); cmd.addArg(qmlDebugLocalArguments(QmlPreviewServices, runControl->qmlChannel().path()));
setCommandLine(cmd); worker->setCommandLine(cmd);
worker->forceRunOnHost();
forceRunOnHost();
}); });
} return worker;
}; });
LocalQmlPreviewSupportFactory::LocalQmlPreviewSupportFactory()
{
setId(ProjectExplorer::Constants::QML_PREVIEW_RUN_FACTORY);
setProduct<LocalQmlPreviewSupport>();
addSupportedRunMode(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE); addSupportedRunMode(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE);
addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);