forked from qt-creator/qt-creator
QmlPreview: Simplify qmlChannel setup and passing
Change-Id: I8cecb89e0d84f4398c988be00b6cf3db22b15552 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -30,8 +30,6 @@ using namespace Utils;
|
||||
|
||||
namespace QmlPreview {
|
||||
|
||||
static const Key QmlServerUrl = "QmlServerUrl";
|
||||
|
||||
class RefreshTranslationWorker final : public RunWorker
|
||||
{
|
||||
public:
|
||||
@@ -69,8 +67,6 @@ public:
|
||||
QmlPreviewRunner(ProjectExplorer::RunControl *runControl,
|
||||
const QmlPreviewRunnerSetting &settings);
|
||||
|
||||
void setServerUrl(const QUrl &serverUrl);
|
||||
|
||||
signals:
|
||||
void loadFile(const QString &previewedFile, const QString &changedFile,
|
||||
const QByteArray &contents);
|
||||
@@ -140,7 +136,7 @@ QmlPreviewRunner::QmlPreviewRunner(RunControl *runControl, const QmlPreviewRunne
|
||||
void QmlPreviewRunner::start()
|
||||
{
|
||||
m_connectionManager.setTarget(runControl()->target());
|
||||
m_connectionManager.connectToServer(serverUrl());
|
||||
m_connectionManager.connectToServer(runControl()->qmlChannel());
|
||||
reportStarted();
|
||||
}
|
||||
|
||||
@@ -150,16 +146,6 @@ void QmlPreviewRunner::stop()
|
||||
reportStopped();
|
||||
}
|
||||
|
||||
void QmlPreviewRunner::setServerUrl(const QUrl &serverUrl)
|
||||
{
|
||||
recordData(QmlServerUrl, serverUrl);
|
||||
}
|
||||
|
||||
QUrl QmlPreviewRunner::serverUrl() const
|
||||
{
|
||||
return recordedData(QmlServerUrl).toUrl();
|
||||
}
|
||||
|
||||
QmlPreviewRunWorkerFactory::QmlPreviewRunWorkerFactory(QmlPreviewPlugin *plugin,
|
||||
const QmlPreviewRunnerSetting *runnerSettings)
|
||||
{
|
||||
@@ -195,16 +181,17 @@ public:
|
||||
: SimpleTargetRunner(runControl)
|
||||
{
|
||||
setId("LocalQmlPreviewSupport");
|
||||
const QUrl serverUrl = Utils::urlFromLocalSocket();
|
||||
|
||||
QmlPreviewRunner *preview = qobject_cast<QmlPreviewRunner *>(
|
||||
runControl->createWorker(ProjectExplorer::Constants::QML_PREVIEW_RUNNER));
|
||||
preview->setServerUrl(serverUrl);
|
||||
runControl->setQmlChannel(Utils::urlFromLocalSocket());
|
||||
|
||||
// Create QmlPreviewRunner
|
||||
RunWorker *preview =
|
||||
runControl->createWorker(ProjectExplorer::Constants::QML_PREVIEW_RUNNER);
|
||||
|
||||
addStopDependency(preview);
|
||||
addStartDependency(preview);
|
||||
|
||||
setStartModifier([this, runControl, serverUrl] {
|
||||
setStartModifier([this, runControl] {
|
||||
CommandLine cmd = commandLine();
|
||||
|
||||
if (const auto aspect = runControl->aspectData<QmlProjectManager::QmlMainFileAspect>()) {
|
||||
@@ -226,7 +213,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
cmd.addArg(qmlDebugLocalArguments(QmlPreviewServices, serverUrl.path()));
|
||||
cmd.addArg(qmlDebugLocalArguments(QmlPreviewServices, runControl->qmlChannel().path()));
|
||||
setCommandLine(cmd);
|
||||
|
||||
forceRunOnHost();
|
||||
|
Reference in New Issue
Block a user