diff options
author | hjk <hjk@qt.io> | 2019-08-07 18:05:15 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-08-09 12:34:42 +0000 |
commit | f9c221eb54ca3174c57f736b7afd5914147ab2a2 (patch) | |
tree | 1d58370c31fd3c342ddd133f659ee01adb017b22 /src/plugins/qmlpreview | |
parent | a88970db34357adaaedd7514490d94702744a7ec (diff) |
ProjectExplorer: Re-work setup runworker factories
This combines two of the previous three paths to create run workers,
and refers to RunConfigurations by id, not by type where possible
to decrease coupling between the classes.
Only allow "type of run configuration" and "type of device"
as the only possible kind of restriction and require a uniform
RunWorker constructor signature.
Adapt user code to fit that pattern.
Change-Id: I5a6d49c9a144785fd0235d7586f244b56f67b366
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/qmlpreview')
-rw-r--r-- | src/plugins/qmlpreview/qmlpreviewplugin.cpp | 13 | ||||
-rw-r--r-- | src/plugins/qmlpreview/qmlpreviewplugin.h | 1 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/plugins/qmlpreview/qmlpreviewplugin.cpp b/src/plugins/qmlpreview/qmlpreviewplugin.cpp index 88555b9f92..fde11cd983 100644 --- a/src/plugins/qmlpreview/qmlpreviewplugin.cpp +++ b/src/plugins/qmlpreview/qmlpreviewplugin.cpp @@ -108,13 +108,12 @@ bool QmlPreviewPlugin::initialize(const QStringList &arguments, QString *errorSt setFileClassifier(&defaultFileClassifier); setFpsHandler(&defaultFpsHandler); - auto constraint = [](RunConfiguration *runConfiguration) { - Target *target = runConfiguration ? runConfiguration->target() : nullptr; - Kit *kit = target ? target->kit() : nullptr; - return DeviceTypeKitAspect::deviceTypeId(kit) == Constants::DESKTOP_DEVICE_TYPE; - }; - - RunControl::registerWorker<LocalQmlPreviewSupport>(Constants::QML_PREVIEW_RUN_MODE, constraint); + m_runWorkerFactory.reset(new RunWorkerFactory{ + RunWorkerFactory::make<LocalQmlPreviewSupport>(), + {Constants::QML_PREVIEW_RUN_MODE}, + {}, // All runconfig. + {Constants::DESKTOP_DEVICE_TYPE} + }); Core::ActionContainer *menu = Core::ActionManager::actionContainer( Constants::M_BUILDPROJECT); diff --git a/src/plugins/qmlpreview/qmlpreviewplugin.h b/src/plugins/qmlpreview/qmlpreviewplugin.h index 559cbb81dd..faf89e767f 100644 --- a/src/plugins/qmlpreview/qmlpreviewplugin.h +++ b/src/plugins/qmlpreview/qmlpreviewplugin.h @@ -122,6 +122,7 @@ private: float m_zoomFactor = -1.0; QmlPreview::QmlPreviewFpsHandler m_fpsHandler = nullptr; QString m_locale; + std::unique_ptr<ProjectExplorer::RunWorkerFactory> m_runWorkerFactory; }; } // namespace Internal |