// Code stolen from QWebEnginePage so we could FIX it. Browser had real problems when a stringlist containing an
// empty list returned.
{
// 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 $
// can work with) and mimetypes ranging from text/plain or images/* to application/vnd.openxmlformats-officedocument.spreadsheetm$
Q_UNUSED(acceptedMimeTypes);
switch (static_cast<WebContentsAdapterClient::FileChooserMode>(mode)) {
case WebContentsAdapterClient::OpenMultiple:
break;
// Chromium extension, not exposed as part of the public API for now.
case WebContentsAdapterClient::UploadFolder:
break;
case WebContentsAdapterClient::Save:
ret <<
QFileDialog::getSaveFileName(view
(),
QString(),
(QStandardPaths
::writableLocation(QStandardPaths
::DownloadLocation) + oldFiles.
first()));
break;
default:
case WebContentsAdapterClient::Open:
break;
}
// Needed fix
if (ret.count() > 0)
{
if (ret[0].trimmed().length() > 0)
return ret;
}
return emptyList;
}
// Code stolen from QWebEnginePage so we could FIX it. Browser had real problems when a stringlist containing an
// empty list returned.
QStringList MyWebEnginePage::chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes)
{
// 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 $
// can work with) and mimetypes ranging from text/plain or images/* to application/vnd.openxmlformats-officedocument.spreadsheetm$
Q_UNUSED(acceptedMimeTypes);
QStringList ret;
QStringList emptyList;
switch (static_cast<WebContentsAdapterClient::FileChooserMode>(mode)) {
case WebContentsAdapterClient::OpenMultiple:
ret = QFileDialog::getOpenFileNames(view(), QString());
break;
// Chromium extension, not exposed as part of the public API for now.
case WebContentsAdapterClient::UploadFolder:
ret << QFileDialog::getExistingDirectory(view(), tr("Select folder to upload")) + QLatin1Char('/');
break;
case WebContentsAdapterClient::Save:
ret << QFileDialog::getSaveFileName(view(), QString(), (QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + oldFiles.first()));
break;
default:
case WebContentsAdapterClient::Open:
ret << QFileDialog::getOpenFileName(view(), QString(), oldFiles.first());
break;
}
// Needed fix
if (ret.count() > 0)
{
if (ret[0].trimmed().length() > 0)
return ret;
}
return emptyList;
}
To copy to clipboard, switch view to plain text mode
Bookmarks