forked from qt-creator/qt-creator
ProjectExplorer: Report project-specific kit errors/warnings
Report project-specific warnings about the kit used in Project Mode. E.g. a python project should not complain about missing toolchains, while a qmake project should. Change-Id: I5ce6742683cdeffc7ff3f1a3e8f0b89aee9aa0b4 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -275,52 +275,42 @@ void QmlProject::refreshTargetDirectory()
|
||||
updateDeploymentData(target);
|
||||
}
|
||||
|
||||
bool QmlProject::supportsKit(const Kit *k, QString *errorMessage) const
|
||||
QList<Task> QmlProject::projectIssues(const Kit *k) const
|
||||
{
|
||||
if (!k->isValid()) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Kit is not valid.");
|
||||
return false;
|
||||
}
|
||||
QList<Task> result = Project::projectIssues(k);
|
||||
|
||||
const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
||||
if (!version)
|
||||
result.append(createProjectTask(Task::TaskType::Error, tr("No Qt version set in kit.")));
|
||||
|
||||
IDevice::ConstPtr dev = DeviceKitInformation::device(k);
|
||||
if (dev.isNull()) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Kit has no device.");
|
||||
return false;
|
||||
}
|
||||
if (dev.isNull())
|
||||
result.append(createProjectTask(Task::TaskType::Error, tr("Kit has no device.")));
|
||||
|
||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
|
||||
if (!version) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("No Qt version set in kit.");
|
||||
return false;
|
||||
}
|
||||
if (version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0)) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Qt version is too old.");
|
||||
return false;
|
||||
}
|
||||
if (version && version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0))
|
||||
result.append(createProjectTask(Task::TaskType::Error, tr("Qt version is too old.")));
|
||||
|
||||
if (dev.isNull() || !version)
|
||||
return result; // No need to check deeper than this
|
||||
|
||||
if (dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
if (version->type() == QtSupport::Constants::DESKTOPQT) {
|
||||
if (static_cast<QtSupport::DesktopQtVersion *>(version)->qmlsceneCommand().isEmpty()) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Qt version has no qmlscene command.");
|
||||
return false;
|
||||
if (static_cast<const QtSupport::DesktopQtVersion *>(version)->qmlsceneCommand().isEmpty()) {
|
||||
result.append(createProjectTask(Task::TaskType::Error,
|
||||
tr("Qt version has no qmlscene command.")));
|
||||
}
|
||||
} else {
|
||||
// Non-desktop Qt on a desktop device? We don't support that.
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Non-desktop Qt is used with a Desktop device.");
|
||||
return false;
|
||||
result.append(createProjectTask(Task::TaskType::Error,
|
||||
tr("Non-desktop Qt is used with a Desktop device.")));
|
||||
}
|
||||
} else {
|
||||
// If not a desktop device, don't check the Qt version for qmlscene.
|
||||
// The device is responsible for providing it and we assume qmlscene can be found
|
||||
// in $PATH if it's not explicitly given.
|
||||
}
|
||||
|
||||
// If not a desktop device, don't check the Qt version for qmlscene.
|
||||
// The device is responsible for providing it and we assume qmlscene can be found
|
||||
// in $PATH if it's not explicitly given.
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *errorMessage)
|
||||
@@ -334,7 +324,9 @@ Project::RestoreResult QmlProject::fromMap(const QVariantMap &map, QString *erro
|
||||
|
||||
if (!activeTarget()) {
|
||||
// find a kit that matches prerequisites (prefer default one)
|
||||
const QList<Kit*> kits = KitManager::kits([this](const Kit *k) { return supportsKit(k, nullptr); });
|
||||
const QList<Kit*> kits = KitManager::kits([this](const Kit *k) {
|
||||
return !containsType(projectIssues(k), Task::TaskType::Error);
|
||||
});
|
||||
|
||||
if (!kits.isEmpty()) {
|
||||
Kit *kit = kits.contains(KitManager::defaultKit()) ? KitManager::defaultKit() : kits.first();
|
||||
|
Reference in New Issue
Block a user