diff options
author | Eike Ziller <[email protected]> | 2024-05-03 15:24:00 +0200 |
---|---|---|
committer | Eike Ziller <[email protected]> | 2024-05-06 05:57:43 +0000 |
commit | bd99669503c2626954808d8c4689d33b217e24c8 (patch) | |
tree | c6323265c7c98c5843b15913e11329b11c6da05a /src/plugins/qmlprojectmanager/qmlprojectplugin.cpp | |
parent | 6ecd0f4023aa51394f5e5516b7481d4e173043b6 (diff) |
QML: Add an "external" editor for opening .ui.qml files in Design Studio
Using the logic from the landing page in design mode.
Users can select Qt Design Studio from the Open With... menu, or even
set it as the default editor in Preferences > Environment > MIME Types,
"application/x-qt.ui+qml"
Task-number: QTCREATORBUG-30754
Change-Id: Idd4e688f722dcf38735db7c1b9b31af02caeb045
Reviewed-by: Alessandro Portale <[email protected]>
Reviewed-by: <[email protected]>
Diffstat (limited to 'src/plugins/qmlprojectmanager/qmlprojectplugin.cpp')
-rw-r--r-- | src/plugins/qmlprojectmanager/qmlprojectplugin.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp index 9cd1bae9c67..1bc61c3b825 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp @@ -100,11 +100,6 @@ static void clearAlwaysOpenWithMode() ICore::settings()->remove(QmlProjectManager::Constants::ALWAYS_OPEN_UI_MODE); } -class QmlProjectPluginPrivate -{ -public: -}; - void openQDS(const FilePath &fileName) { const FilePath qdsPath = qdsInstallationEntry(); @@ -229,6 +224,26 @@ static QmlBuildSystem *qmlBuildSystemforFileNode(const FileNode *fileNode) return nullptr; } +class ExternalDesignStudioFactory : public Core::IEditorFactory +{ +public: + ExternalDesignStudioFactory() + { + setId("Qt.QtDesignStudio"); + setDisplayName(Tr::tr("Qt Design Studio")); + setMimeTypes({Utils::Constants::QMLUI_MIMETYPE}); + setEditorStarter([](const FilePath &filePath, [[maybe_unused]] QString *errorMessage) { + openInQDSWithProject(filePath); + return true; + }); + } +}; + +void setupExternalDesignStudio() +{ + static ExternalDesignStudioFactory theExternalDesignStudioFactory; +} + class QmlProjectPlugin final : public ExtensionSystem::IPlugin { Q_OBJECT @@ -274,6 +289,7 @@ private: void QmlProjectPlugin::initialize() { setupQmlProjectRunConfiguration(); + setupExternalDesignStudio(); if (!qmlDesignerEnabled()) { m_landingPage = new QdsLandingPage(); |