diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2022-03-18 10:34:12 +0100 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2022-03-21 08:59:08 +0100 |
commit | fb9d2be11ed53c106fbbb8eb73a3ae7902ecb4ab (patch) | |
tree | 536246cccdf969d3e057ee0ab742c76117ae5594 /src/imports | |
parent | edb18d6101e8bb9dd265330dbe019722181d7577 (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.
Fixes: QTBUG-94391
Change-Id: Ic6ba95e301857d9b72ee6f5ddb819b9aae9e66e3
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit d10d1f97d0aadb1f26e99db1ef2c1c3d53458a38)
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/platform/qquickplatformfiledialog.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/imports/platform/qquickplatformfiledialog.cpp b/src/imports/platform/qquickplatformfiledialog.cpp index c73bb7df..79ecfed5 100644 --- a/src/imports/platform/qquickplatformfiledialog.cpp +++ b/src/imports/platform/qquickplatformfiledialog.cpp @@ -552,8 +552,14 @@ QUrl QQuickPlatformFileDialog::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() == QStringLiteral("content"); + if (!isContentScheme && !suffix.isEmpty() && !path.endsWith(QLatin1Char('/')) + && path.lastIndexOf(QLatin1Char('.')) == -1) { url.setPath(path + QLatin1Char('.') + suffix); + } + return url; } |