diff options
author | Thomas Hartmann <[email protected]> | 2024-08-23 16:52:12 +0200 |
---|---|---|
committer | Thomas Hartmann <[email protected]> | 2024-08-27 13:23:20 +0000 |
commit | 8f97c61aa8db5410e72e452ad1a244f975c9f439 (patch) | |
tree | 4bf0e55a193ee8e9123c322837f5e5b63a5fae38 /src/plugins/qmlprojectmanager/qmlprojectplugin.cpp | |
parent | 06e7b16e971c842253eb1b19ed2954563c3761a6 (diff) |
QmlProject: Open a fake project if a single .ui.qml file is opened
If a single ui.qml file is opened in Qt Design Studio we open
a fake project that includes the folder of the opened ui.qml file.
If a .ui.qml file is opened and no project is opened in Qt Design Studio
we open a "fake" project with the specific name, that provides a default.
We can later extend this to supporting import paths and other advanced features.
Task-number: QDS-13171
Change-Id: Icecb669d7149c4850da7dd908e9b3e1619d74c7d
Reviewed-by: Burak Hancerli <[email protected]>
Reviewed-by: Thomas Hartmann <[email protected]>
Diffstat (limited to 'src/plugins/qmlprojectmanager/qmlprojectplugin.cpp')
-rw-r--r-- | src/plugins/qmlprojectmanager/qmlprojectplugin.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp index a30aec37830..2f8ce7c7f42 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp @@ -25,12 +25,12 @@ #include <extensionsystem/iplugin.h> +#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectmanager.h> #include <projectexplorer/projectnodes.h> #include <projectexplorer/projecttree.h> #include <projectexplorer/runcontrol.h> -#include <projectexplorer/projectmanager.h> #include <projectexplorer/target.h> #include <qmlprofiler/qmlprofilerruncontrol.h> @@ -403,6 +403,19 @@ void QmlProjectPlugin::initialize() != fileNode->filePath()); }); + connect(EditorManager::instance(), + &EditorManager::documentOpened, + this, + [](Core::IDocument *document) { + if (!ProjectManager::startupProject() + && document->filePath().completeSuffix() == "ui.qml") { + const Utils::FilePath fileName = Utils::FilePath::fromString( + document->filePath().toString() + Constants::fakeProjectName); + auto result = ProjectExplorer::ProjectExplorerPlugin::openProjects({fileName}); + QTC_ASSERT(result.project(), return); + } + }); + QmlProjectExporter::CMakeGenerator::createMenuAction(this); QmlProjectExporter::PythonGenerator::createMenuAction(this); } |