summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/winrt
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-03-04 10:53:14 +0100
committerAndy Shaw <andy.shaw@qt.io>2020-03-09 14:53:50 +0100
commit20167a7fe9c1e62881d1673ad05a9779e614d9d3 (patch)
tree14ad8d49798544ad6314d25b45351a72e4906fbd /src/plugins/platforms/winrt
parent37a66236d2fd0d671c8ee37c5f9512d30f18c179 (diff)
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>
Diffstat (limited to 'src/plugins/platforms/winrt')
-rw-r--r--src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp10
1 files changed, 9 insertions, 1 deletions
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<const wchar_t *>(suggestedName.utf16()),
uint(suggestedName.length()));