+ fixes #0001760: FC fails to load a *.FCStd file if the filename lacks the *.FCStd file extension
This commit is contained in:
parent
72f947433c
commit
7aa91ecee3
|
@ -133,10 +133,20 @@ void StdCmdOpen::activated(int iMsg)
|
||||||
QString selectedFilter;
|
QString selectedFilter;
|
||||||
QStringList fileList = FileDialog::getOpenFileNames(getMainWindow(),
|
QStringList fileList = FileDialog::getOpenFileNames(getMainWindow(),
|
||||||
QObject::tr("Open document"), QString(), formatList, &selectedFilter);
|
QObject::tr("Open document"), QString(), formatList, &selectedFilter);
|
||||||
|
if (fileList.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
// load the files with the associated modules
|
// load the files with the associated modules
|
||||||
SelectModule::Dict dict = SelectModule::importHandler(fileList, selectedFilter);
|
SelectModule::Dict dict = SelectModule::importHandler(fileList, selectedFilter);
|
||||||
for (SelectModule::Dict::iterator it = dict.begin(); it != dict.end(); ++it) {
|
if (dict.isEmpty()) {
|
||||||
getGuiApplication()->open(it.key().toUtf8(), it.value().toAscii());
|
QMessageBox::critical(getMainWindow(),
|
||||||
|
qApp->translate("StdCmdOpen", "Cannot open file"),
|
||||||
|
qApp->translate("StdCmdOpen", "Loading the file %1 is not supported").arg(fileList.front()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (SelectModule::Dict::iterator it = dict.begin(); it != dict.end(); ++it) {
|
||||||
|
getGuiApplication()->open(it.key().toUtf8(), it.value().toAscii());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,22 @@ void FileDialog::onSelectedFilter(const QString& filter)
|
||||||
|
|
||||||
void FileDialog::accept()
|
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();
|
QFileDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user