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 <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Eike Ziller
2024-05-03 15:24:00 +02:00
parent 6ecd0f4023
commit bd99669503

View File

@@ -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();