forked from qt-creator/qt-creator
qmlprieview: fix that init language is the chosen one
* removes language feature from preview service * it is handled by an extra DebugTranslationService until now * Qt versions without that extra service can not preview languages anymore * Introduce the use of QmlPreviewRunnerSetting. It makes it easier to add more properties in the future * Language needs an extra handling because it needs the loadUrl to find existing languages. So we save the language to a m_scheduledInitLanguage and emit this after the loadFile call happend. Change-Id: I7f4aec97f7b61d6b290f225282169da594eb9160 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -45,17 +45,13 @@ namespace QmlPreview {
|
||||
|
||||
static const QString QmlServerUrl = "QmlServerUrl";
|
||||
|
||||
QmlPreviewRunner::QmlPreviewRunner(ProjectExplorer::RunControl *runControl,
|
||||
QmlPreviewFileLoader fileLoader,
|
||||
QmlPreviewFileClassifier fileClassifier,
|
||||
QmlPreviewFpsHandler fpsHandler,
|
||||
float initialZoom)
|
||||
: RunWorker(runControl)
|
||||
QmlPreviewRunner::QmlPreviewRunner(const QmlPreviewRunnerSetting &settings)
|
||||
: RunWorker(settings.runControl)
|
||||
{
|
||||
setId("QmlPreviewRunner");
|
||||
m_connectionManager.setFileLoader(fileLoader);
|
||||
m_connectionManager.setFileClassifier(fileClassifier);
|
||||
m_connectionManager.setFpsHandler(fpsHandler);
|
||||
m_connectionManager.setFileLoader(settings.fileLoader);
|
||||
m_connectionManager.setFileClassifier(settings.fileClassifier);
|
||||
m_connectionManager.setFpsHandler(settings.fpsHandler);
|
||||
|
||||
connect(this, &QmlPreviewRunner::loadFile,
|
||||
&m_connectionManager, &Internal::QmlPreviewConnectionManager::loadFile);
|
||||
@@ -70,24 +66,29 @@ QmlPreviewRunner::QmlPreviewRunner(ProjectExplorer::RunControl *runControl,
|
||||
&m_connectionManager, &Internal::QmlPreviewConnectionManager::changeElideWarning);
|
||||
|
||||
connect(&m_connectionManager, &Internal::QmlPreviewConnectionManager::connectionOpened,
|
||||
this, [this, initialZoom]() {
|
||||
if (initialZoom > 0)
|
||||
emit zoom(initialZoom);
|
||||
this, [this, settings]() {
|
||||
if (settings.zoom > 0)
|
||||
emit zoom(settings.zoom);
|
||||
if (!settings.language.isEmpty())
|
||||
emit language(settings.language);
|
||||
if (settings.translationElideWarning)
|
||||
emit changeElideWarning(true);
|
||||
|
||||
emit ready();
|
||||
});
|
||||
|
||||
connect(&m_connectionManager, &Internal::QmlPreviewConnectionManager::restart,
|
||||
runControl, [this, runControl]() {
|
||||
if (!runControl->isRunning())
|
||||
runControl(), [this]() {
|
||||
if (!runControl()->isRunning())
|
||||
return;
|
||||
|
||||
this->connect(runControl, &ProjectExplorer::RunControl::stopped, runControl, [runControl]() {
|
||||
this->connect(runControl(), &ProjectExplorer::RunControl::stopped, [this]() {
|
||||
ProjectExplorer::ProjectExplorerPlugin::runRunConfiguration(
|
||||
runControl->runConfiguration(),
|
||||
runControl()->runConfiguration(),
|
||||
ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE, true);
|
||||
});
|
||||
|
||||
runControl->initiateStop();
|
||||
runControl()->initiateStop();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user