QmlPreview: Simplify QmlPreviewRunner

Change-Id: Icdbc65ec39dd63d59f5bc96b21649a9d488be920
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
hjk
2019-03-13 18:14:34 +01:00
parent 60f18b6170
commit fbc043c96d
2 changed files with 13 additions and 14 deletions

View File

@@ -50,21 +50,20 @@ QmlPreviewRunner::QmlPreviewRunner(ProjectExplorer::RunControl *runControl,
: RunWorker(runControl) : RunWorker(runControl)
{ {
setId("QmlPreviewRunner"); setId("QmlPreviewRunner");
m_connectionManager.reset(new Internal::QmlPreviewConnectionManager(this)); m_connectionManager.setFileLoader(fileLoader);
m_connectionManager->setFileLoader(fileLoader); m_connectionManager.setFileClassifier(fileClassifier);
m_connectionManager->setFileClassifier(fileClassifier); m_connectionManager.setFpsHandler(fpsHandler);
m_connectionManager->setFpsHandler(fpsHandler);
connect(this, &QmlPreviewRunner::loadFile, connect(this, &QmlPreviewRunner::loadFile,
m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::loadFile); &m_connectionManager, &Internal::QmlPreviewConnectionManager::loadFile);
connect(this, &QmlPreviewRunner::rerun, connect(this, &QmlPreviewRunner::rerun,
m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::rerun); &m_connectionManager, &Internal::QmlPreviewConnectionManager::rerun);
connect(this, &QmlPreviewRunner::zoom, connect(this, &QmlPreviewRunner::zoom,
m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::zoom); &m_connectionManager, &Internal::QmlPreviewConnectionManager::zoom);
connect(this, &QmlPreviewRunner::language, connect(this, &QmlPreviewRunner::language,
m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::language); &m_connectionManager, &Internal::QmlPreviewConnectionManager::language);
connect(m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::connectionOpened, connect(&m_connectionManager, &Internal::QmlPreviewConnectionManager::connectionOpened,
this, [this, initialZoom, initialLocale]() { this, [this, initialZoom, initialLocale]() {
if (initialZoom > 0) if (initialZoom > 0)
emit zoom(initialZoom); emit zoom(initialZoom);
@@ -73,7 +72,7 @@ QmlPreviewRunner::QmlPreviewRunner(ProjectExplorer::RunControl *runControl,
emit ready(); emit ready();
}); });
connect(m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::restart, connect(&m_connectionManager, &Internal::QmlPreviewConnectionManager::restart,
runControl, [runControl]() { runControl, [runControl]() {
if (!runControl->isRunning()) if (!runControl->isRunning())
return; return;
@@ -90,14 +89,14 @@ QmlPreviewRunner::QmlPreviewRunner(ProjectExplorer::RunControl *runControl,
void QmlPreviewRunner::start() void QmlPreviewRunner::start()
{ {
m_connectionManager->setTarget(runControl()->target()); m_connectionManager.setTarget(runControl()->target());
m_connectionManager->connectToServer(serverUrl()); m_connectionManager.connectToServer(serverUrl());
reportStarted(); reportStarted();
} }
void QmlPreviewRunner::stop() void QmlPreviewRunner::stop()
{ {
m_connectionManager->disconnectFromServer(); m_connectionManager.disconnectFromServer();
reportStopped(); reportStopped();
} }

View File

@@ -56,7 +56,7 @@ private:
void start() override; void start() override;
void stop() override; void stop() override;
QScopedPointer<Internal::QmlPreviewConnectionManager> m_connectionManager; Internal::QmlPreviewConnectionManager m_connectionManager;
}; };
class LocalQmlPreviewSupport : public ProjectExplorer::SimpleTargetRunner class LocalQmlPreviewSupport : public ProjectExplorer::SimpleTargetRunner