summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2019-11-19 17:49:19 +0100
committerSzabolcs David <davidsz@inf.u-szeged.hu>2019-11-29 14:34:10 +0100
commit6f0173c166d6f7a2237a031808a33b0d787acd1c (patch)
treee0a8661df378661ed97e3bdf1c0e5d05582ddc84 /src/webenginewidgets
parentaca2a6df402d6454c7bbe8b0e9816645fcec8342 (diff)
Support accept attribute of file input
Set name filters of QFileDialog and QML FileDialog to avoid presenting all file types. Task-number: QTBUG-76564 Change-Id: I321214a30bc7e875ad132b015c63282f4eb482bf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 524df0425..1a8eae0b9 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -2292,14 +2292,12 @@ ASSERT_ENUMS_MATCH(FilePickerController::OpenMultiple, QWebEnginePage::FileSelec
QStringList QWebEnginePage::chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes)
{
#if QT_CONFIG(filedialog)
- // FIXME: Should we expose this in QWebPage's API ? Right now it is very open and can contain a mix and match of file extensions (which QFileDialog
- // can work with) and mimetypes ranging from text/plain or images/* to application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
- Q_UNUSED(acceptedMimeTypes);
+ const QStringList &filter = FilePickerController::nameFilters(acceptedMimeTypes);
QStringList ret;
QString str;
switch (static_cast<FilePickerController::FileChooserMode>(mode)) {
case FilePickerController::OpenMultiple:
- ret = QFileDialog::getOpenFileNames(view(), QString());
+ ret = QFileDialog::getOpenFileNames(view(), QString(), QString(), filter.join(";;"), nullptr, QFileDialog::HideNameFilterDetails);
break;
// Chromium extension, not exposed as part of the public API for now.
case FilePickerController::UploadFolder:
@@ -2313,7 +2311,7 @@ QStringList QWebEnginePage::chooseFiles(FileSelectionMode mode, const QStringLis
ret << str;
break;
case FilePickerController::Open:
- str = QFileDialog::getOpenFileName(view(), QString(), oldFiles.first());
+ str = QFileDialog::getOpenFileName(view(), QString(), oldFiles.first(), filter.join(";;"), nullptr, QFileDialog::HideNameFilterDetails);
if (!str.isNull())
ret << str;
break;