summaryrefslogtreecommitdiffstats
path: root/src/gui/platform/wasm
Commit message (Collapse)AuthorAgeFilesLines
* wasm: saveFile(): copy data before returningMorten Sørvig2024-06-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | Make saveFile(char *, size) make an immediate copy of the data also for the case where we use a save file dialog. Previously it would make a copy after the file dialog was closed, but at that point the content pointer may be stale if the calling code did not keep it alive. This makes the behavior for the two save code paths be identical: a copy of the data will be made right away, before the function returns. This is also the only behavior which makes sense, since the function has no way of communicating to the caller when it is done with the data. Pick-to: 6.6 6.7 6.8 Change-Id: I890a4897f20251e9abbf90d0a4b96d8ba12d3740 Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io> Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
* wasm: Fix QFileDialog file filterPiotr Wierciński2023-08-252-72/+12
| | | | | | | | | | | | File filter was not properly processed when using LocalFileAPI. The QtFormat->AcceptList conversion was happening twice, resulting in erronous types. This prevented dialog from appearing on Chrome. Additionally remove unused debug code. Fixes: QTBUG-115087 Pick-to: 6.5 6.6 Change-Id: Ie6770e2f1d2aa7c3ad19f9ab105dbec8102d45fc Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: Add DOM accessors functions through NativeInterfacePiotr Wierciński2023-05-051-0/+17
| | | | | | | | | | | Expose document and clientArea emscripten objects through NativeInterface. This is required by WebView implementation for wasm platform. Task-number: QTBUG-75183 Change-Id: I6f2f084a9dbceb80d2186c7395c008f268a91e39 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* Copy memory to buffer when saving files on wasm with threading onMikolaj Boc2023-04-251-4/+28
| | | | | | | | | | | | | | | wasm heap uses a shared array buffer, which cannot be fed to FileSystemWritableFileStream.write due to security limitations. Heap memory has to be copied to a temporary buffer for the operation to succeed. This is only done if __EMSCRIPTEN_SHARED_MEMORY__ is on to optimize the non-threading path. Fixes: QTBUG-112881 Pick-to: 6.5 Change-Id: I0d117a8703caf4c17abc67b30df5248a53406d5f Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Replace Q_CORE_EXPORT with Q_AUTOTEST_EXPORT in qlocalfileapi_p.hMikolaj Boc2023-03-201-3/+6
| | | | | | | The only consumer outside of gui is the autotest target Change-Id: I2c6b41029ed5c53a2fd5f31f542128616620ddcf Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Support filter list for file input when opening a file on WASMMikolaj Boc2023-03-073-51/+81
| | | | | | | | | | The polyfill for file input on WASM now makes use of the supplied filter list. Some changes were introduced in the abstraction for filters so that they are usable both for the new file API and the legacy file input. Change-Id: Id6341be4d6a1647e17382d13da7be42491cfaf80 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: align QWasmLocalFileAccess API with 6.4Morten Sørvig2022-12-282-8/+86
| | | | | | | | | | | | | | | | | | | | | | This API is undocumented, but by keeping unchanged makes it easier to use from external projects. openFile(): Copy the accept/filter list parsing function from 6.4. It makes sense to implement this behind the API, so that user code doesn't have to reimplement it. saveFile(): Slightly more complicated; the new variant which takes a QByteArray is better since the implementation can then keep a reference to the data for as long as it needs, without copying the data. Add the const char * variant to keep existing code going for now. Adjust the calling code in widgets. Pick-to: 6.5 Change-Id: I1899ebffdb90e40429dcb10313ccc5334f20c34f Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Avoid mutual ownership in qstdweb's File::streamMikolaj Boc2022-12-221-1/+1
| | | | | | | | | | | | | | The mutual ownership of chunkCompleted<->fileReader caused both not to be freed, which resulted in a memory leak. Resolve this by introducing the ChunkedFileReader class which owns itself until file read is finished. Also, resolve a similar issue in qwasmlocalfileaccess. Fixes: QTBUG-109436 Pick-to: 6.5 Change-Id: Ieec4cde15a893fa6a2e21a62d3bb6637374c5364 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: use matchView() instead of match()Morten Sørvig2022-08-251-5/+5
| | | | | | | | QRegularExpression::match() is deprecated. Change-Id: I66c7b3043a3805614fedcdb081c7e704e9925e5e Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Use the local file APIs to save/load files on WASMMikolaj Boc2022-08-122-55/+173
| | | | | | | | | | | | QFileDialog::saveFileContent, QFileDialog::getOpenFileContent are now using local file APIs to access files on any browser that passes a feature check. The feature is thoroughly tested using sinon and a new mock library. Task-number: QTBUG-99611 Change-Id: I3dd27a9d21eb143c71ea7db0563f70ac7db3a3ac Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Create the Qt File Filter => showOpen/SaveFilePicker options mapperMikolaj Boc2022-07-052-0/+284
| | | | | | | | | | | | | As a preparatory measure for using showXFilePicker, the Qt file filter has to be transformed to the format used by the showXFilePicker (sXFP) options. A class structure reflecting the options was created. Based on an input in the form of a qt file filter, it will parse the filter to the sXFP options format. Unit tests were added and the code is not yet used in non-test env, next change will use it. Task-number: QTBUG-99611 Change-Id: I277286467a7b5ce6f323c19bdd31740a41b6a6be Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: export a few symbolsLorn Potter2022-06-011-3/+3
| | | | | | | These are needed for dynamic linking/ shared library Change-Id: Ibd01d2b70ecf4afca273d07fafb2a5bd0650cf94 Reviewed-by: David Skoland <david.skoland@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-162-76/+4
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Make sure all qtbase private headers include at least one otherThiago Macieira2022-02-241-2/+2
| | | | | | | | | | See script in qtbase/util/includeprivate for the rules. Since these files are being touched anyway, I also ran the updatecopyright.pl script too. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* wasm: improve qstdweb::EventCallbackMorten Johan Sørvig2022-02-111-1/+1
| | | | | | | | | | | | | We are storing a copy of the this pointer in the constructor, and later deference it to access EventCallback object memebers. This makes the class noncopyable: delete the copy constructor to make sure it isn’t. Also change the callback API to propagate the event to the event callback. Change-Id: Ida4bb192b3e905b260ebeec30293aad71b7d8c49 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: Move Blob creation code to qstdwebMorten Johan Sørvig2021-11-271-19/+5
| | | | | | | | | | | | | | Add Uint8Array::copyFrom() and Blob::copyFrom(), which constructs JS data containers with content copied from the C heap. These should not be confused with e.g. the Uint8Array(buffer, size) constructor, which creates a Uint8Array which references content on the heap, without making a copy. Change-Id: Id7d25d8044ee3914d74698e5a15c93226568eaf3 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: Move streamFile() to qstdwebMorten Johan Sørvig2021-11-261-39/+1
| | | | | | | | | This function is useful also outside of local file access, for example when reading clipboard (file) content. Change-Id: I132546deb6df2969467051c348c05d9331d2cfd2 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* gui: Fix typos in source code commentsJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: Ie53e5542a8f93856470982939ecd8ec90b323d69 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-071-3/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* wasm: Add saveFileContent()Morten Johan Sørvig2019-08-202-0/+39
| | | | | | | | Saves a file by file download, where the user can choose the file name and location using a file dialog. Change-Id: I4d2ecc76fc33bb65fdf3d7ca3fcd9566c62547dd Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* wasm: add local file access private APIMorten Johan Sørvig2019-02-073-0/+250
Access to the local file system is restricted by the Web sandbox, and a separate API an implementation is needed to facilitate this for Qt applications. This adds a private asynchronous callback-based C++ API for opening a file dialog and reading file content. The implementation uses a file input html element to show a file dialog, and then the uses the native File and FileReader APIs to read the selected file(s). Change-Id: I4e28baa032d7c3cd63241465f0ae55efd219a05b Reviewed-by: Lorn Potter <lorn.potter@gmail.com>