summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qfiledialog.h
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2019-01-18 15:02:32 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2019-02-07 06:49:31 +0000
commit928cab5ff1d931d00074d8930c41537109814371 (patch)
tree2e242d8143e4b975d1a22aa650de0060189db4bd /src/widgets/dialogs/qfiledialog.h
parent790cf25f9d811f2cda7e252b4f1844e8fce27e2a (diff)
wasm: add public API for local file access
The web sandbox restricts access to the local file system, which means Qt needs new public API to provide such access to applications. This adds a new static, asynchornous getOpenFileContent() function to QFileDialog, which will show a file dialog, read the file contents once a file has been selected, and finally call the user-provided callback with the selected file name and file data. auto fileReady = [](const QString &fileName, const QByteArray &fileContents) { // Process file } QFileDialog::getOpenFileContent("*.*", fileReady); This API can be expanded in at least two ways in the future: allow reading multiple files, and allow file streaming by returning a QOIDevice. Change-Id: I011b92fbcf21f0696604e66b7f9eb265c1a07aaa Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/widgets/dialogs/qfiledialog.h')
-rw-r--r--src/widgets/dialogs/qfiledialog.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h
index 8a99112081..c75795fd77 100644
--- a/src/widgets/dialogs/qfiledialog.h
+++ b/src/widgets/dialogs/qfiledialog.h
@@ -46,6 +46,8 @@
#include <QtCore/qurl.h>
#include <QtWidgets/qdialog.h>
+#include <functional>
+
QT_REQUIRE_CONFIG(filedialog);
QT_BEGIN_NAMESPACE
@@ -273,6 +275,8 @@ public:
Options options = Options(),
const QStringList &supportedSchemes = QStringList());
+ static void getOpenFileContent(const QString &nameFilter,
+ const std::function<void(const QString &, const QByteArray &)> &fileContentsReady);
protected:
QFileDialog(const QFileDialogArgs &args);