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 {
|
namespace QmlPreview {
|
||||||
|
|
||||||
static const Key QmlServerUrl = "QmlServerUrl";
|
|
||||||
|
|
||||||
class RefreshTranslationWorker final : public RunWorker
|
class RefreshTranslationWorker final : public RunWorker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -69,8 +67,6 @@ public:
|
|||||||
QmlPreviewRunner(ProjectExplorer::RunControl *runControl,
|
QmlPreviewRunner(ProjectExplorer::RunControl *runControl,
|
||||||
const QmlPreviewRunnerSetting &settings);
|
const QmlPreviewRunnerSetting &settings);
|
||||||
|
|
||||||
void setServerUrl(const QUrl &serverUrl);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loadFile(const QString &previewedFile, const QString &changedFile,
|
void loadFile(const QString &previewedFile, const QString &changedFile,
|
||||||
const QByteArray &contents);
|
const QByteArray &contents);
|
||||||
@@ -140,7 +136,7 @@ QmlPreviewRunner::QmlPreviewRunner(RunControl *runControl, const QmlPreviewRunne
|
|||||||
void QmlPreviewRunner::start()
|
void QmlPreviewRunner::start()
|
||||||
{
|
{
|
||||||
m_connectionManager.setTarget(runControl()->target());
|
m_connectionManager.setTarget(runControl()->target());
|
||||||
m_connectionManager.connectToServer(serverUrl());
|
m_connectionManager.connectToServer(runControl()->qmlChannel());
|
||||||
reportStarted();
|
reportStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,16 +146,6 @@ void QmlPreviewRunner::stop()
|
|||||||
reportStopped();
|
reportStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlPreviewRunner::setServerUrl(const QUrl &serverUrl)
|
|
||||||
{
|
|
||||||
recordData(QmlServerUrl, serverUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
QUrl QmlPreviewRunner::serverUrl() const
|
|
||||||
{
|
|
||||||
return recordedData(QmlServerUrl).toUrl();
|
|
||||||
}
|
|
||||||
|
|
||||||
QmlPreviewRunWorkerFactory::QmlPreviewRunWorkerFactory(QmlPreviewPlugin *plugin,
|
QmlPreviewRunWorkerFactory::QmlPreviewRunWorkerFactory(QmlPreviewPlugin *plugin,
|
||||||
const QmlPreviewRunnerSetting *runnerSettings)
|
const QmlPreviewRunnerSetting *runnerSettings)
|
||||||
{
|
{
|
||||||
@@ -195,16 +181,17 @@ public:
|
|||||||
: SimpleTargetRunner(runControl)
|
: SimpleTargetRunner(runControl)
|
||||||
{
|
{
|
||||||
setId("LocalQmlPreviewSupport");
|
setId("LocalQmlPreviewSupport");
|
||||||
const QUrl serverUrl = Utils::urlFromLocalSocket();
|
|
||||||
|
|
||||||
QmlPreviewRunner *preview = qobject_cast<QmlPreviewRunner *>(
|
runControl->setQmlChannel(Utils::urlFromLocalSocket());
|
||||||
runControl->createWorker(ProjectExplorer::Constants::QML_PREVIEW_RUNNER));
|
|
||||||
preview->setServerUrl(serverUrl);
|
// Create QmlPreviewRunner
|
||||||
|
RunWorker *preview =
|
||||||
|
runControl->createWorker(ProjectExplorer::Constants::QML_PREVIEW_RUNNER);
|
||||||
|
|
||||||
addStopDependency(preview);
|
addStopDependency(preview);
|
||||||
addStartDependency(preview);
|
addStartDependency(preview);
|
||||||
|
|
||||||
setStartModifier([this, runControl, serverUrl] {
|
setStartModifier([this, runControl] {
|
||||||
CommandLine cmd = commandLine();
|
CommandLine cmd = commandLine();
|
||||||
|
|
||||||
if (const auto aspect = runControl->aspectData<QmlProjectManager::QmlMainFileAspect>()) {
|
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);
|
setCommandLine(cmd);
|
||||||
|
|
||||||
forceRunOnHost();
|
forceRunOnHost();
|
||||||
|
Reference in New Issue
Block a user