summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/doc/snippets/qfileopenevent/Info.plist9
-rw-r--r--src/gui/kernel/qevent.cpp22
-rw-r--r--src/plugins/platforms/ios/qiosapplicationdelegate.mm9
3 files changed, 27 insertions, 13 deletions
diff --git a/src/gui/doc/snippets/qfileopenevent/Info.plist b/src/gui/doc/snippets/qfileopenevent/Info.plist
index 98ab05e708e..635298f7274 100644
--- a/src/gui/doc/snippets/qfileopenevent/Info.plist
+++ b/src/gui/doc/snippets/qfileopenevent/Info.plist
@@ -9,9 +9,9 @@
<key>CFBundleDocumentTypes</key>
<array>
<dict>
- <key>CFBundleTypeExtensions</key>
+ <key>LSItemContentTypes</key>
<array>
- <string>png</string>
+ <string>public.png</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
@@ -20,3 +20,8 @@
</dict>
</plist>
//! [Custom Info.plist]
+
+//! [iOS]
+<key>UISupportsDocumentBrowser</key>
+<true/>
+//! [iOS]
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.
diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.mm b/src/plugins/platforms/ios/qiosapplicationdelegate.mm
index 48f15c91ab8..380c5a588e6 100644
--- a/src/plugins/platforms/ios/qiosapplicationdelegate.mm
+++ b/src/plugins/platforms/ios/qiosapplicationdelegate.mm
@@ -111,8 +111,13 @@
QIOSServices *iosServices = static_cast<QIOSServices *>(iosIntegration->services());
- for (UIOpenURLContext *urlContext in URLContexts)
- iosServices->handleUrl(QUrl::fromNSURL(urlContext.URL));
+ for (UIOpenURLContext *urlContext in URLContexts) {
+ QUrl url = QUrl::fromNSURL(urlContext.URL);
+ if (url.isLocalFile())
+ QWindowSystemInterface::handleFileOpenEvent(url);
+ else
+ iosServices->handleUrl(url);
+ }
}
- (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity