Create RunConfiguration specific QmlPreviewWorkerFactories

Instead of relying on the QmlPreviewRunWorkerFactory to match for all
RunConfiguration, every plugin needs to create a WorkerFactory for
its own RunConfiguration.

Similar to the SimpleTargetRunnerFactory there is now a
SimpleQmlPreviewRunnerFactory which makes the setup easy.

Change-Id: I350e5a047033a259dae91045486d4f41e7f58994
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Dominik Holland
2024-01-30 15:45:35 +01:00
parent 243d063cb9
commit 2a6de890c7
4 changed files with 24 additions and 0 deletions

View File

@@ -178,6 +178,7 @@ const char PERFPROFILER_RUNNER[]="PerfProfiler.Runner";
// RunWorkerFactory
const char QML_PROFILER_RUN_FACTORY[] = "RunWorkerFactory.LocalQmlProfilerSupport";
const char QML_PREVIEW_RUN_FACTORY[] = "RunWorkerFactory.LocalQmlPreviewSupport";
// RunConfig
const char QMAKE_RUNCONFIG_ID[] = "Qt4ProjectManager.Qt4RunConfiguration:";

View File

@@ -235,9 +235,14 @@ public:
LocalQmlPreviewSupportFactory::LocalQmlPreviewSupportFactory()
{
setId(ProjectExplorer::Constants::QML_PREVIEW_RUN_FACTORY);
setProduct<LocalQmlPreviewSupport>();
addSupportedRunMode(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE);
addSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
addSupportedRunConfig(ProjectExplorer::Constants::QMAKE_RUNCONFIG_ID);
addSupportedRunConfig(ProjectExplorer::Constants::QBS_RUNCONFIG_ID);
addSupportedRunConfig(ProjectExplorer::Constants::CMAKE_RUNCONFIG_ID);
addSupportedRunConfig(ProjectExplorer::Constants::CUSTOM_EXECUTABLE_RUNCONFIG_ID);
}
} // QmlPreview

View File

@@ -5,6 +5,7 @@
#include "qmlpreviewplugin.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>
namespace QmlPreview {
@@ -31,4 +32,17 @@ public:
LocalQmlPreviewSupportFactory();
};
class SimplePreviewRunnerFactory final : public ProjectExplorer::RunWorkerFactory
{
public:
explicit SimplePreviewRunnerFactory(const QList<Utils::Id> &runConfigs, const QList<Utils::Id> &extraRunModes = {})
{
cloneProduct(ProjectExplorer::Constants::QML_PREVIEW_RUN_FACTORY);
addSupportedRunMode(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE);
for (const Utils::Id &id : extraRunModes)
addSupportedRunMode(id);
setSupportedRunConfigs(runConfigs);
}
};
} // QmlPreview

View File

@@ -42,6 +42,8 @@
#include <qmljstools/qmljstoolsconstants.h>
#include <qmlpreview/qmlpreviewruncontrol.h>
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
@@ -59,6 +61,7 @@
#include <QTimer>
using namespace Core;
using namespace QmlPreview;
using namespace QmlProfiler;
using namespace Debugger;
using namespace ProjectExplorer;
@@ -257,6 +260,7 @@ private:
static SimpleTargetRunnerFactory runWorkerFactory{{Constants::QML_RUNCONFIG_ID}};
static SimpleQmlProfilerRunnerFactory qmlProfilerRunWorkerFactory{{Constants::QML_RUNCONFIG_ID}};
static SimpleDebugRunnerFactory debugRunWorkerFactory{{Constants::QML_RUNCONFIG_ID}};
static SimplePreviewRunnerFactory previewRunWorkerFactory{{Constants::QML_RUNCONFIG_ID}};
}
void displayQmlLandingPage();