+ fixes #0001760: FC fails to load a *.FCStd file if the filename lacks the *.FCStd file extension

This commit is contained in:
wmayer
2014-12-30 00:31:39 +01:00
parent 72f947433c
commit 7aa91ecee3
2 changed files with 28 additions and 2 deletions

View File

@@ -71,6 +71,22 @@ void FileDialog::onSelectedFilter(const QString& filter)
void FileDialog::accept()
{
// When saving to a file make sure that the entered filename ends with the selected
// file filter
if (acceptMode() == QFileDialog::AcceptSave) {
QStringList files = selectedFiles();
if (!files.isEmpty()) {
QString ext = this->defaultSuffix();
QString file = files.front();
if (!ext.isEmpty() && !file.endsWith(ext, Qt::CaseInsensitive)) {
file = QString::fromLatin1("%1.%2").arg(file).arg(ext);
// That's the built-in line edit
QLineEdit* fileNameEdit = this->findChild<QLineEdit*>(QString::fromLatin1("fileNameEdit"));
if (fileNameEdit)
fileNameEdit->setText(file);
}
}
}
QFileDialog::accept();
}