1
0
Fork 0

Tolerate Aircraft/ prefix in preview paths

Reuqested by Jonathan R, allow Aircraft/<acft-dir>/foo paths to work
for preview iamges.

SF-ID: https://sourceforge.net/p/flightgear/codetickets/2644/
This commit is contained in:
James Turner 2021-08-29 19:24:36 +01:00
parent 74dd221e60
commit 06c03a0672

View file

@ -122,11 +122,28 @@ bool AircraftItem::initFromFile(QDir dir, QString filePath)
if (sim->hasChild("previews")) {
SGPropertyNode_ptr previewsNode = sim->getChild("previews");
const QString aircraftPrefix = "Aircraft/" + dir.dirName() + "/";
for (auto previewNode : previewsNode->getChildren("preview")) {
// add file path as url
QString pathInXml = QString::fromStdString(previewNode->getStringValue("path"));
// https://sourceforge.net/p/flightgear/codetickets/2644/
// allow Aircraft/ prefixed paths in previews; what we're actually doing here
// is trimming them back to the style we expect
if (pathInXml.startsWith(aircraftPrefix)) {
pathInXml = pathInXml.mid(aircraftPrefix.length());
}
QString previewPath = dir.absoluteFilePath(pathInXml);
if (!QFile::exists(previewPath)) {
qWarning() << "Missing local preview file" << previewPath;
continue;
}
previews.append(QUrl::fromLocalFile(previewPath));
}
}