diff options
Diffstat (limited to 'src/plugins/qmlpreview')
-rw-r--r-- | src/plugins/qmlpreview/CMakeLists.txt | 18 | ||||
-rw-r--r-- | src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmlpreview/qmlpreviewfileontargetfinder.cpp | 4 | ||||
-rw-r--r-- | src/plugins/qmlpreview/qmlpreviewplugin.cpp | 14 | ||||
-rw-r--r-- | src/plugins/qmlpreview/qmlpreviewplugin.h | 5 | ||||
-rw-r--r-- | src/plugins/qmlpreview/qmlpreviewruncontrol.cpp | 36 | ||||
-rw-r--r-- | src/plugins/qmlpreview/qmlpreviewruncontrol.h | 2 | ||||
-rw-r--r-- | src/plugins/qmlpreview/tests/qmlpreviewplugin_test.cpp | 2 |
8 files changed, 49 insertions, 34 deletions
diff --git a/src/plugins/qmlpreview/CMakeLists.txt b/src/plugins/qmlpreview/CMakeLists.txt new file mode 100644 index 0000000000..1788cb3847 --- /dev/null +++ b/src/plugins/qmlpreview/CMakeLists.txt @@ -0,0 +1,18 @@ +add_qtc_plugin(QmlPreview + DEPENDS QmlDebug qmljs + PLUGIN_DEPENDS Core ProjectExplorer QmlJSTools QtSupport ResourceEditor + SOURCES + qmlpreviewclient.cpp qmlpreviewclient.h + qmlpreviewconnectionmanager.cpp qmlpreviewconnectionmanager.h + qmlpreviewfileontargetfinder.cpp qmlpreviewfileontargetfinder.h + qmlpreviewplugin.cpp qmlpreviewplugin.h + qmlpreviewruncontrol.cpp qmlpreviewruncontrol.h + qmlpreview_global.h +) + +extend_qtc_plugin(QmlPreview + CONDITION WITH_TESTS + SOURCES + tests/qmlpreviewclient_test.cpp tests/qmlpreviewclient_test.h + tests/qmlpreviewplugin_test.cpp tests/qmlpreviewplugin_test.h +) diff --git a/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp b/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp index ad9c6467b6..af67b55f1c 100644 --- a/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp +++ b/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp @@ -49,7 +49,7 @@ QmlPreviewConnectionManager::QmlPreviewConnectionManager(QObject *parent) : void QmlPreviewConnectionManager::setTarget(ProjectExplorer::Target *target) { QtSupport::BaseQtVersion::populateQmlFileFinder(&m_projectFileFinder, target); - m_projectFileFinder.setAdditionalSearchDirectories(Utils::FileNameList()); + m_projectFileFinder.setAdditionalSearchDirectories(Utils::FilePathList()); m_targetFileFinder.setTarget(target); } diff --git a/src/plugins/qmlpreview/qmlpreviewfileontargetfinder.cpp b/src/plugins/qmlpreview/qmlpreviewfileontargetfinder.cpp index 95ed107fea..02b8161ed2 100644 --- a/src/plugins/qmlpreview/qmlpreviewfileontargetfinder.cpp +++ b/src/plugins/qmlpreview/qmlpreviewfileontargetfinder.cpp @@ -72,7 +72,7 @@ QString QmlPreviewFileOnTargetFinder::findPath(const QString &filePath, bool *su // Try the current node first. It's likely that this is the one we're looking for and if there // is any ambiguity (same file mapped to multiple qrc paths) it should take precedence. - ProjectExplorer::Node *currentNode = ProjectExplorer::ProjectTree::findCurrentNode(); + ProjectExplorer::Node *currentNode = ProjectExplorer::ProjectTree::currentNode(); if (currentNode && currentNode->filePath().toString() == filePath) { const QString path = resourceNodePath(currentNode); if (!path.isEmpty()) @@ -101,7 +101,7 @@ QString QmlPreviewFileOnTargetFinder::findPath(const QString &filePath, bool *su if (success) { // On desktop, if there is no "remote" path, then the application will load the local path. - *success = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(m_target->kit()) + *success = ProjectExplorer::DeviceTypeKitAspect::deviceTypeId(m_target->kit()) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; } return filePath; diff --git a/src/plugins/qmlpreview/qmlpreviewplugin.cpp b/src/plugins/qmlpreview/qmlpreviewplugin.cpp index b60996ae1f..630bd06fa1 100644 --- a/src/plugins/qmlpreview/qmlpreviewplugin.cpp +++ b/src/plugins/qmlpreview/qmlpreviewplugin.cpp @@ -76,7 +76,7 @@ signals: static QByteArray defaultFileLoader(const QString &filename, bool *success) { if (Core::DocumentModel::Entry *entry - = Core::DocumentModel::entryForFilePath(Utils::FileName::fromString(filename))) { + = Core::DocumentModel::entryForFilePath(Utils::FilePath::fromString(filename))) { if (!entry->isSuspended) { *success = true; return entry->document->contents(); @@ -111,7 +111,7 @@ bool QmlPreviewPlugin::initialize(const QStringList &arguments, QString *errorSt auto constraint = [](RunConfiguration *runConfiguration) { Target *target = runConfiguration ? runConfiguration->target() : nullptr; Kit *kit = target ? target->kit() : nullptr; - return DeviceTypeKitInformation::deviceTypeId(kit) == Constants::DESKTOP_DEVICE_TYPE; + return DeviceTypeKitAspect::deviceTypeId(kit) == Constants::DESKTOP_DEVICE_TYPE; }; RunControl::registerWorker<LocalQmlPreviewSupport>(Constants::QML_PREVIEW_RUN_MODE, constraint); @@ -143,7 +143,7 @@ bool QmlPreviewPlugin::initialize(const QStringList &arguments, QString *errorSt Constants::G_FILE_OTHER); action->setVisible(false); connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged, action, [action]() { - const Node *node = ProjectTree::findCurrentNode(); + const Node *node = ProjectTree::currentNode(); const FileNode *fileNode = node ? node->asFileNode() : nullptr; action->setVisible(fileNode ? fileNode->fileType() == FileType::QML : false); }); @@ -196,9 +196,9 @@ ExtensionSystem::IPlugin::ShutdownFlag QmlPreviewPlugin::aboutToShutdown() return SynchronousShutdown; } -QList<QObject *> QmlPreviewPlugin::createTestObjects() const +QVector<QObject *> QmlPreviewPlugin::createTestObjects() const { - QList<QObject *> tests; + QVector<QObject *> tests; #ifdef WITH_TESTS tests.append(new QmlPreviewClientTest); tests.append(new QmlPreviewPluginTest); @@ -297,8 +297,8 @@ void QmlPreviewPlugin::setFileLoader(QmlPreviewFileLoader fileLoader) void QmlPreviewPlugin::previewCurrentFile() { - const Node *currentNode = ProjectTree::findCurrentNode(); - if (!currentNode || currentNode->nodeType() != NodeType::File + const Node *currentNode = ProjectTree::currentNode(); + if (!currentNode || !currentNode->asFileNode() || currentNode->asFileNode()->fileType() != FileType::QML) return; diff --git a/src/plugins/qmlpreview/qmlpreviewplugin.h b/src/plugins/qmlpreview/qmlpreviewplugin.h index f1e780cf1d..559cbb81dd 100644 --- a/src/plugins/qmlpreview/qmlpreviewplugin.h +++ b/src/plugins/qmlpreview/qmlpreviewplugin.h @@ -25,9 +25,10 @@ #pragma once -#include <projectexplorer/runconfiguration.h> +#include <projectexplorer/runcontrol.h> #include <extensionsystem/iplugin.h> #include <qmljs/qmljsdialect.h> + #include <QUrl> #include <QThread> @@ -63,7 +64,7 @@ public: bool initialize(const QStringList &arguments, QString *errorString) override; void extensionsInitialized() override; ShutdownFlag aboutToShutdown() override; - QList<QObject *> createTestObjects() const override; + QVector<QObject *> createTestObjects() const override; QString previewedFile() const; void setPreviewedFile(const QString &previewedFile); diff --git a/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp b/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp index c54208f2ee..0a8ac9fb1a 100644 --- a/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp +++ b/src/plugins/qmlpreview/qmlpreviewruncontrol.cpp @@ -50,21 +50,20 @@ QmlPreviewRunner::QmlPreviewRunner(ProjectExplorer::RunControl *runControl, : RunWorker(runControl) { setId("QmlPreviewRunner"); - m_connectionManager.reset(new Internal::QmlPreviewConnectionManager(this)); - m_connectionManager->setFileLoader(fileLoader); - m_connectionManager->setFileClassifier(fileClassifier); - m_connectionManager->setFpsHandler(fpsHandler); + m_connectionManager.setFileLoader(fileLoader); + m_connectionManager.setFileClassifier(fileClassifier); + m_connectionManager.setFpsHandler(fpsHandler); connect(this, &QmlPreviewRunner::loadFile, - m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::loadFile); + &m_connectionManager, &Internal::QmlPreviewConnectionManager::loadFile); connect(this, &QmlPreviewRunner::rerun, - m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::rerun); + &m_connectionManager, &Internal::QmlPreviewConnectionManager::rerun); connect(this, &QmlPreviewRunner::zoom, - m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::zoom); + &m_connectionManager, &Internal::QmlPreviewConnectionManager::zoom); connect(this, &QmlPreviewRunner::language, - m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::language); - connect(m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::connectionOpened, + &m_connectionManager, &Internal::QmlPreviewConnectionManager::language); + connect(&m_connectionManager, &Internal::QmlPreviewConnectionManager::connectionOpened, this, [this, initialZoom, initialLocale]() { if (initialZoom > 0) emit zoom(initialZoom); @@ -73,15 +72,15 @@ QmlPreviewRunner::QmlPreviewRunner(ProjectExplorer::RunControl *runControl, emit ready(); }); - connect(m_connectionManager.data(), &Internal::QmlPreviewConnectionManager::restart, - runControl, [runControl, this]() { + connect(&m_connectionManager, &Internal::QmlPreviewConnectionManager::restart, + runControl, [runControl]() { if (!runControl->isRunning()) return; - ProjectExplorer::RunConfiguration *runConfig = runControl->runConfiguration(); - connect(runControl, &ProjectExplorer::RunControl::stopped, runConfig, [runConfig](){ + connect(runControl, &ProjectExplorer::RunControl::stopped, runControl, [runControl]() { ProjectExplorer::ProjectExplorerPlugin::runRunConfiguration( - runConfig, ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE, true); + runControl->runConfiguration(), + ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE, true); }); runControl->initiateStop(); @@ -90,17 +89,14 @@ QmlPreviewRunner::QmlPreviewRunner(ProjectExplorer::RunControl *runControl, void QmlPreviewRunner::start() { - ProjectExplorer::Target *target = nullptr; - if (ProjectExplorer::RunConfiguration *config = runControl()->runConfiguration()) - target = config->target(); - m_connectionManager->setTarget(target); - m_connectionManager->connectToServer(serverUrl()); + m_connectionManager.setTarget(runControl()->target()); + m_connectionManager.connectToServer(serverUrl()); reportStarted(); } void QmlPreviewRunner::stop() { - m_connectionManager->disconnectFromServer(); + m_connectionManager.disconnectFromServer(); reportStopped(); } diff --git a/src/plugins/qmlpreview/qmlpreviewruncontrol.h b/src/plugins/qmlpreview/qmlpreviewruncontrol.h index 889e7f641b..7a25a62c10 100644 --- a/src/plugins/qmlpreview/qmlpreviewruncontrol.h +++ b/src/plugins/qmlpreview/qmlpreviewruncontrol.h @@ -56,7 +56,7 @@ private: void start() override; void stop() override; - QScopedPointer<Internal::QmlPreviewConnectionManager> m_connectionManager; + Internal::QmlPreviewConnectionManager m_connectionManager; }; class LocalQmlPreviewSupport : public ProjectExplorer::SimpleTargetRunner diff --git a/src/plugins/qmlpreview/tests/qmlpreviewplugin_test.cpp b/src/plugins/qmlpreview/tests/qmlpreviewplugin_test.cpp index 3b84cd4d4f..9ca2f38b08 100644 --- a/src/plugins/qmlpreview/tests/qmlpreviewplugin_test.cpp +++ b/src/plugins/qmlpreview/tests/qmlpreviewplugin_test.cpp @@ -43,7 +43,7 @@ QmlPreviewPluginTest::QmlPreviewPluginTest(QObject *parent) : QObject(parent) static ExtensionSystem::IPlugin *getPlugin() { - const QList<ExtensionSystem::PluginSpec *> plugins = ExtensionSystem::PluginManager::plugins(); + const QVector<ExtensionSystem::PluginSpec *> plugins = ExtensionSystem::PluginManager::plugins(); auto it = std::find_if(plugins.begin(), plugins.end(), [](ExtensionSystem::PluginSpec *spec) { return spec->name() == "QmlPreview"; }); |