diff options
| author | Tor Arne Vestbø <[email protected]> | 2025-11-14 17:50:25 +0100 |
|---|---|---|
| committer | Tor Arne Vestbø <[email protected]> | 2025-11-20 21:13:01 +0100 |
| commit | b3918b13a9278df3dcda33b2c5440eba58c8efe9 (patch) | |
| tree | 60c06c4edf6f69a0594488022315f044ce775c98 /src/gui/kernel | |
| parent | f1d0f5d7ee6cf4466a71bb68af0e87a68e558359 (diff) | |
iOS: Add support for QFileOpenEvent for external requests to open files
[ChangeLog][iOS] QFileOpenEvent is now sent if the user requests that
a supported file type is to be opened in the application. This requires
that the application declares supported file types via CFBundleDocumentTypes.
Change-Id: Ic3476ad703b51131a0973e3d6135e9aa05c2091f
Reviewed-by: Volker Hilsheimer <[email protected]>
Diffstat (limited to 'src/gui/kernel')
| -rw-r--r-- | src/gui/kernel/qevent.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index a95f94dea7e..b15441e6d59 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3711,24 +3711,28 @@ Q_IMPL_EVENT_COMMON(QShowEvent) File open events will be sent to the QApplication::instance() when the operating system requests that a file or URL should be opened. This is a high-level event that can be caused by different user actions - depending on the user's desktop environment; for example, double - clicking on an file icon in the Finder on \macos. + depending on the platform; for example, double clicking on an file in the + Finder or dragging a file to the application's Dock icon on \macos, + or sharing a file from another application on iOS. This event is only used to notify the application of a request. - It may be safely ignored. + It may be safely ignored if the file should not be opened. - \note This class is currently supported for \macos only. + \section1 Apple platforms - \section1 \macos Example - - In order to trigger the event on \macos, the application must be configured - to let the OS know what kind of file(s) it should react on. + In order to trigger the event on Apple platforms, the application must be + configured to let the OS know what kind of file(s) it should react on. For example, the following \c Info.plist file declares that the application - can act as a viewer for files with a PNG extension: + can act as a viewer for PNG files: \snippet qfileopenevent/Info.plist Custom Info.plist + The following key is also necessary on iOS for the application to + show up as an "Open With" action in e.g. the Files application: + + \snippet qfileopenevent/Info.plist iOS + The following implementation of a QApplication subclass shows how to handle QFileOpenEvent to open the file that was, for example, dropped on the Dock icon of the application. |
