forked from qt-creator/qt-creator
QmlProject: Prefer Qt 6 kits if the project is flagged as Qt 6 project
A .qmlproject can contain 'qt6Project: true'. If this is the case we prefer a Qt 6 kit, otherwise we prefer a Qt 5 kit. We only change this behavior if Qt Creator is in QDS mode. We should prefer desktop kits in any case. Task-number: QDS-4734 Change-Id: I90f6628cd071db01f2add068fd776774f7be133e Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
@@ -73,6 +73,23 @@ Q_LOGGING_CATEGORY(infoLogger, "QmlProjectManager.QmlBuildSystem", QtInfoMsg)
|
||||
|
||||
namespace QmlProjectManager {
|
||||
|
||||
static bool isQtDesignStudio()
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
const QString qdsStandaloneEntry = "QML/Designer/StandAloneMode"; //entry from qml settings
|
||||
|
||||
return settings->value(qdsStandaloneEntry, false).toBool();
|
||||
}
|
||||
static int preferedQtTarget(Target *target)
|
||||
{
|
||||
if (target) {
|
||||
const QmlBuildSystem *buildSystem = qobject_cast<QmlBuildSystem *>(target->buildSystem());
|
||||
if (buildSystem && buildSystem->qt6Project())
|
||||
return 6;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
const char openInQDSAppSetting[] = "OpenInQDSApp";
|
||||
|
||||
static void openQDS(const QString &qdsPath, const Utils::FilePath &fileName)
|
||||
@@ -102,12 +119,9 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
setBuildSystemCreator([](Target *t) { return new QmlBuildSystem(t); });
|
||||
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
const QString qdsStandaloneEntry = "QML/Designer/StandAloneMode"; //entry from qml settings
|
||||
const QString qdsInstallationEntry = "QML/Designer/DesignStudioInstallation"; //set in installer
|
||||
|
||||
const bool isDesigner = settings->value(qdsStandaloneEntry, false).toBool();
|
||||
|
||||
if (!isDesigner) {
|
||||
if (!isQtDesignStudio()) {
|
||||
const QString qdsPath = settings->value(qdsInstallationEntry).toString();
|
||||
const bool foundQDS = Utils::FilePath::fromString(qdsPath).exists();
|
||||
|
||||
@@ -406,8 +420,10 @@ Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *erro
|
||||
|
||||
if (!activeTarget()) {
|
||||
// find a kit that matches prerequisites (prefer default one)
|
||||
const QList<Kit*> kits = Utils::filtered(KitManager::kits(), [this](const Kit *k) {
|
||||
return !containsType(projectIssues(k), Task::TaskType::Error);
|
||||
const QList<Kit *> kits = Utils::filtered(KitManager::kits(), [this](const Kit *k) {
|
||||
return !containsType(projectIssues(k), Task::TaskType::Error)
|
||||
&& DeviceTypeKitAspect::deviceTypeId(k)
|
||||
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
||||
});
|
||||
|
||||
if (!kits.isEmpty()) {
|
||||
@@ -416,6 +432,29 @@ Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *erro
|
||||
else
|
||||
addTargetForKit(kits.first());
|
||||
}
|
||||
|
||||
if (isQtDesignStudio()) {
|
||||
auto setKitWithVersion = [&](int qtMajorVersion) {
|
||||
const QList<Kit *> qtVersionkits
|
||||
= Utils::filtered(kits, [qtMajorVersion](const Kit *k) {
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(k);
|
||||
return (version && version->qtVersion().majorVersion == qtMajorVersion);
|
||||
});
|
||||
if (!qtVersionkits.isEmpty()) {
|
||||
if (qtVersionkits.contains(KitManager::defaultKit()))
|
||||
addTargetForDefaultKit();
|
||||
else
|
||||
addTargetForKit(qtVersionkits.first());
|
||||
}
|
||||
};
|
||||
|
||||
int preferedVersion = preferedQtTarget(activeTarget());
|
||||
|
||||
if (activeTarget())
|
||||
removeTarget(activeTarget());
|
||||
|
||||
setKitWithVersion(preferedVersion);
|
||||
}
|
||||
}
|
||||
|
||||
return RestoreResult::Ok;
|
||||
|
Reference in New Issue
Block a user