QmlProject: Propose to open QDS for any .ui.qml file

This is only enabled if no QmlDesigner plugin is found.

When a .ui.qml file is opened we check for a QDS installation.
If QDS is installed we propose to open QDS instead, if not
we show information on QDS.

Search oder for .qmlproject file. QDS requires a project file.

* Check if current project is .qmlproject
* Check if the current folder contains a .qmlproject
* Check folder for .qmlproject that contains the .ui.qml file
* Check parent folder for .qmlproject ...

If not .qmlproject is found we show an error message.
Enabling external link support for InfoBar.

Task-number: QDS-5065
Task-number: QDS-5066
Change-Id: I2c70c400c4d11b83a4848f9e002e180fa119f6e2
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Thomas Hartmann
2021-09-21 12:31:19 +02:00
parent 64e48988ed
commit ddccb87a87
4 changed files with 186 additions and 35 deletions

View File

@@ -27,10 +27,11 @@
#include "fileformat/qmlprojectfileformat.h"
#include "fileformat/qmlprojectitem.h"
#include "qmlprojectrunconfiguration.h"
#include "qmlprojectconstants.h"
#include "qmlprojectmanagerconstants.h"
#include "qmlprojectnodes.h"
#include "qmlprojectplugin.h"
#include "qmlprojectrunconfiguration.h"
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/documentmodel.h>
@@ -94,23 +95,6 @@ static int preferedQtTarget(Target *target)
const char openInQDSAppSetting[] = "OpenInQDSApp";
static void openQDS(const QString &qdsPath, const Utils::FilePath &fileName)
{
bool qdsStarted = false;
//-a and -client arguments help to append project to open design studio application
if (Utils::HostOsInfo::isMacHost())
qdsStarted = Utils::QtcProcess::startDetached({"/usr/bin/open", {"-a", qdsPath, fileName.toString()}});
else
//ToDo change qdsPath type to FilePath
qdsStarted = Utils::QtcProcess::startDetached({Utils::FilePath::fromString(qdsPath), {"-client", fileName.toString()}});
if (!qdsStarted) {
QMessageBox::warning(Core::ICore::dialogParent(),
fileName.fileName(),
QObject::tr("Failed to start Qt Design Studio."));
}
}
QmlProject::QmlProject(const Utils::FilePath &fileName)
: Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName)
{
@@ -121,23 +105,17 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
setNeedsBuildConfigurations(false);
setBuildSystemCreator([](Target *t) { return new QmlBuildSystem(t); });
QSettings *settings = Core::ICore::settings();
const QString qdsInstallationEntry = "QML/Designer/DesignStudioInstallation"; //set in installer
if (!isQtDesignStudio()) {
const QString qdsPath = settings->value(qdsInstallationEntry).toString();
const bool foundQDS = Utils::FilePath::fromString(qdsPath).exists();
if (foundQDS) {
auto lambda = [fileName, qdsPath]() {
if (QmlProjectPlugin::qdsInstallationExists()) {
auto lambda = [fileName]() {
if (Core::ICore::infoBar()->canInfoBeAdded(openInQDSAppSetting)) {
Utils::InfoBarEntry
info(openInQDSAppSetting,
tr("Would you like to open the project in Qt Design Studio?"),
Utils::InfoBarEntry::GlobalSuppression::Enabled);
info.setCustomButtonInfo(tr("Open in Qt Design Studio"), [&, qdsPath, fileName] {
info.setCustomButtonInfo(tr("Open in Qt Design Studio"), [&, fileName] {
Core::ICore::infoBar()->removeInfo(openInQDSAppSetting);
openQDS(qdsPath, fileName);
QmlProjectPlugin::openQDS(fileName);
});
Core::ICore::infoBar()->addInfo(info);
}