diff options
| author | Ivan Solovev <ivan.solovev@qt.io> | 2022-03-15 11:55:33 +0100 |
|---|---|---|
| committer | Ivan Solovev <ivan.solovev@qt.io> | 2022-03-17 17:50:12 +0100 |
| commit | d10d1f97d0aadb1f26e99db1ef2c1c3d53458a38 (patch) | |
| tree | 42a4d1efda1576b0f82ef5b614821133203eaf11 /src/labs/platform/qquicklabsplatformfiledialog.cpp | |
| parent | 066ed34d126b264cafd1ead2bb823d33ee72a520 (diff) | |
FileDialog: do not add default suffix when content scheme is used
On Android when a file is selected using the default file manager,
the selected file is reported using the url with "content" scheme. This
url does not use file suffixes.
Before this patch, if the FileDialog had a defaultSuffix specified, that
suffix was added to the returned content url, and as a result the file
could not be found.
This problem exists FileDialog from both QtQuick.Dialogs and
Qt.labs.platforms, so this patch implements the similar fix in both of
them.
Fixes: QTBUG-94391
Pick-to: 6.3 6.2
Change-Id: Ic6ba95e301857d9b72ee6f5ddb819b9aae9e66e3
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/labs/platform/qquicklabsplatformfiledialog.cpp')
| -rw-r--r-- | src/labs/platform/qquicklabsplatformfiledialog.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/labs/platform/qquicklabsplatformfiledialog.cpp b/src/labs/platform/qquicklabsplatformfiledialog.cpp index 1650d043ec..d16f8f7f92 100644 --- a/src/labs/platform/qquicklabsplatformfiledialog.cpp +++ b/src/labs/platform/qquicklabsplatformfiledialog.cpp @@ -554,8 +554,13 @@ QUrl QQuickLabsPlatformFileDialog::addDefaultSuffix(const QUrl &file) const QUrl url = file; const QString path = url.path(); const QString suffix = m_options->defaultSuffix(); - if (!suffix.isEmpty() && !path.endsWith(QLatin1Char('/')) && path.lastIndexOf(QLatin1Char('.')) == -1) + // Urls with "content" scheme do not require suffixes. Such schemes are + // used on Android. + const bool isContentScheme = url.scheme() == u"content"_qs; + if (!isContentScheme && !suffix.isEmpty() && !path.endsWith(QLatin1Char('/')) + && path.lastIndexOf(QLatin1Char('.')) == -1) { url.setPath(path + QLatin1Char('.') + suffix); + } return url; } |
