1
0
Fork 0

Basic validation of added scenery paths.

Try to catch uses adding parent directories and hence missing
scenery.
This commit is contained in:
James Turner 2017-02-10 23:04:00 +00:00
parent 227087b3a8
commit a83947edbf

View file

@ -102,6 +102,25 @@ void AddOnsPage::onAddSceneryPath()
{
QString path = QFileDialog::getExistingDirectory(this, tr("Choose scenery folder"));
if (!path.isEmpty()) {
// validation
SGPath p(path.toStdString());
SGPath objectsPath = p / "Objects";
SGPath terrainPath = p / "Terrain";
if (!objectsPath.exists() && !terrainPath.exists()) {
QMessageBox mb;
mb.setText(QString("The folder '%1' doesn't appear to contain scenery - add anyway?").arg(path));
mb.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
mb.setDefaultButton(QMessageBox::No);
mb.setInformativeText("Added scenery should contain folders called 'Objects' and / or 'Terrain'");
mb.exec();
if (mb.result() == QMessageBox::No) {
return;
}
}
m_ui->sceneryPathsList->addItem(path);
saveSceneryPaths();
}