Skip to content

Commit

Permalink
fix: [filedialog] filename error when save
Browse files Browse the repository at this point in the history
Use only suffixes after the last dot

Log: fix filename error when save

Bug: https://pms.uniontech.com/bug-view-246943.html
  • Loading branch information
Johnson-zs committed Mar 27, 2024
1 parent e1140a2 commit e26150d
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,10 @@ void FileDialog::selectNameFilterByIndex(int index)
QStringList newNameFilters = QPlatformFileDialogHelper::cleanFilterList(nameFilter);

if (d->acceptMode == QFileDialog::AcceptSave && !newNameFilters.isEmpty()) {
DFMBASE_NAMESPACE::DMimeDatabase db;
QString fileName = statusBar()->lineEdit()->text();
const QString fileNameExtension = db.suffixForFileName(fileName);
DFMBASE_NAMESPACE::DMimeDatabase db;
int dotIndex = fileName.lastIndexOf(".");
const QString &fileNameExtension = dotIndex > 0 ? fileName.mid(dotIndex + 1) : db.suffixForFileName(fileName);
QString newNameFilterExtension { CoreHelper::findExtensioName(fileName, newNameFilters, &db) };

if (!newNameFilters.isEmpty())
Expand Down

0 comments on commit e26150d

Please sign in to comment.