From 20167a7fe9c1e62881d1673ad05a9779e614d9d3 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 4 Mar 2020 10:53:14 +0100 Subject: 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 Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp') diff --git a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp index 114d6dacd8..fee8063f13 100644 --- a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp +++ b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp @@ -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(suggestedName.utf16()), uint(suggestedName.length())); -- cgit v1.2.3