Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qiosservices.mm
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qiosservices.h"
5
6#include <QtCore/qurl.h>
7#include <QtCore/qdebug.h>
8#include <QtCore/private/qcore_mac_p.h>
9#include <QtCore/qscopedvaluerollback.h>
10
11#include <QtGui/qdesktopservices.h>
12
13#import <UIKit/UIApplication.h>
14
16
18{
20 qWarning() << "openUrl not implement for application extensions yet";
21 return false;
22 }
23
24 // avoid recursing back into self
25 if (url == m_handlingUrl)
26 return false;
27
28 if (url.scheme().isEmpty())
29 return openDocument(url);
30
31 NSURL *nsUrl = url.toNSURL();
32 UIApplication *application = qt_apple_sharedApplication();
33
34 if (![application canOpenURL:nsUrl])
35 return false;
36
37 static SEL openUrlSelector = @selector(openURL:options:completionHandler:);
38 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:
39 [UIApplication instanceMethodSignatureForSelector:openUrlSelector]];
40 invocation.target = application;
41 invocation.selector = openUrlSelector;
42
43 static auto kEmptyDictionary = @{};
44 // Indices 0 and 1 are self and _cmd
45 [invocation setArgument:&nsUrl atIndex:2];
46 [invocation setArgument:&kEmptyDictionary atIndex:3];
47 // Fourth argument is nil, so left unset
48
49 [invocation invoke];
50
51 return true;
52}
53
55{
56 // FIXME: Implement using UIDocumentInteractionController
58}
59
60/* Callback from iOS that the application should handle a URL */
62{
63 QScopedValueRollback<QUrl> rollback(m_handlingUrl, url);
64
65 // FIXME: Add platform services callback from QDesktopServices::setUrlHandler
66 // so that we can warn the user if calling setUrlHandler without also setting
67 // up the matching keys in the Info.plist file (CFBundleURLTypes and friends).
69}
70
static bool openUrl(const QUrl &url)
Opens the given url in the appropriate Web browser for the user's desktop environment,...
bool openUrl(const QUrl &url)
bool openDocument(const QUrl &url)
bool handleUrl(const QUrl &url)
virtual bool openDocument(const QUrl &url)
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
\inmodule QtCore
Definition qurl.h:94
QString scheme() const
Returns the scheme of the URL.
Definition qurl.cpp:1991
Combined button and popup list for selecting options.
bool qt_apple_isApplicationExtension()
Definition qcore_mac.mm:424
AppleApplication * qt_apple_sharedApplication()
Definition qcore_mac.mm:431
#define qWarning
Definition qlogging.h:166
QUrl url("example.com")
[constructor-url-reference]