Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-109560

wasm: Improve support for file drag-and-drop

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • GUI: Drag and Drop
    • None

    Description

      Drag and drop of files is supported by the web platform, however the behavior is different than from desktop platforms in some aspects.

      Qt on desktop platforms: dropping files results in drop events with the mime type “text/uri-list”, where the data is a list of file:/// urls to the files.

      Web Platform: dropping files results in drop events with a files array populated with JS File objects. File can be used to read file data asynchronously -  see https://developer.mozilla.org/en-US/docs/Web/API/File

      Qt for WebAssembly: Currently, results are mixed: dropping an image file gives us the image (with mime type “application/x-qt-image”). Dropping an unknown file type does not work as well: the mime type is empty, and we don't get the full file data.

      We should try to unify behavior across all platforms, if possible. The issue here is similar to the file dialog issue with Qt Quick: Users of the FileDialog class expects an URL, while the native API provides Qt with a File object. (both can be used to read the file contents, but they are not interchangeable)

      Possible solution: Implement a custom file engine

      • Can be read-only and immutable, with file content populated in advance. This enables usage from synchronous API (such as QFile).
      • Applications get file urls or paths with a custom schema which causes QFile to read from the custom file engine.
      • Optionally make use of asyncify to stream file content from the async File API.
      • Memory optimization: hold file data in as JS ArrayBuffer objects, copy into heap memory on demand.

      Attachments

        Issue Links

          Activity

            People

              sorvig Morten Sørvig
              sorvig Morten Sørvig
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: