WinRT: Use the fallbacks for getting the save file name

To bring it in line with the other platforms, then it needs to check if
the initially selected files are set and use the first one. Otherwise it
can fall back to the initial directory if that happens to include a
filename.

Change-Id: If34ae0e7e10b6a3c25e9422d9b4f2c21e6bfc8d1
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
bb10
Andy Shaw 2020-03-04 10:53:14 +01:00
parent 37a66236d2
commit 20167a7fe9
1 changed files with 9 additions and 1 deletions

View File

@ -397,7 +397,15 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit
RETURN_FALSE_IF_FAILED_WITH_ARGS("Failed to set default file extension \"%s\"", qPrintable(suffix));
}
const QString suggestedName = QFileInfo(d->saveFileName.toLocalFile()).fileName();
QString suggestedName = QFileInfo(d->saveFileName.toLocalFile()).fileName();
if (suggestedName.isEmpty() && dialogOptions->initiallySelectedFiles().size() > 0)
suggestedName = QFileInfo(dialogOptions->initiallySelectedFiles().first().toLocalFile())
.fileName();
if (suggestedName.isEmpty()) {
const auto fileInfo = QFileInfo(dialogOptions->initialDirectory().toLocalFile());
if (!fileInfo.isDir())
suggestedName = fileInfo.fileName();
}
if (!suggestedName.isEmpty()) {
HStringReference nativeSuggestedName(reinterpret_cast<const wchar_t *>(suggestedName.utf16()),
uint(suggestedName.length()));