iOS: refactor usage of photos into optional plugin
Starting from iOS 10, apps that tries to access photos on the device need to specify the reason for this up front by adding the key 'NSPhotoLibraryUsageDescription' into Info.plist. If the key is missing, the app will be rejected from AppStore. This causes problems for the iOS plugin as it stands since parts of it already tries to access photos, e.g to show an image picker dialog if a file dialog is set to open QStandardPaths::PicturesLocation. This means that currently, all apps written with Qt will be rejected from AppStore unless the developer adds this key, whether he tries to access photos or not. To solve this, we choose to split the plugin into two parts, one that contains the core functionality, and one that contains optional support. The latter will need to be enabled explicit by the developer in the pro file, or in this case, indirectly by adding the right key to the Info.plist. This patch refactors the code in the plugin that gives access to photos into a separate optional plugin called 'nsphotolibrarysupport'. Change-Id: Ic4351eb0bbfffdf840fd88cd00bb29a25907798f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Jake Petroules <jake.petroules@qt.io>bb10
parent
60dbd80e5a
commit
99ce5d5e85
|
|
@ -9,6 +9,7 @@ QMAKE_DOCS = $$PWD/doc/qtgui.qdocconf
|
|||
|
||||
MODULE_PLUGIN_TYPES = \
|
||||
platforms \
|
||||
platforms/darwin \
|
||||
xcbglintegrations \
|
||||
platformthemes \
|
||||
platforminputcontexts \
|
||||
|
|
|
|||
|
|
@ -1,61 +1,2 @@
|
|||
TARGET = qios
|
||||
|
||||
QT += core-private gui-private platformsupport-private
|
||||
LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary
|
||||
|
||||
OBJECTIVE_SOURCES = \
|
||||
plugin.mm \
|
||||
qiosintegration.mm \
|
||||
qioseventdispatcher.mm \
|
||||
qioswindow.mm \
|
||||
qiosscreen.mm \
|
||||
qiosbackingstore.mm \
|
||||
qiosapplicationdelegate.mm \
|
||||
qiosapplicationstate.mm \
|
||||
qiosviewcontroller.mm \
|
||||
qioscontext.mm \
|
||||
qiosinputcontext.mm \
|
||||
qiostheme.mm \
|
||||
qiosglobal.mm \
|
||||
qiosservices.mm \
|
||||
quiview.mm \
|
||||
qiosclipboard.mm \
|
||||
quiaccessibilityelement.mm \
|
||||
qiosplatformaccessibility.mm \
|
||||
qiostextresponder.mm \
|
||||
qiosmenu.mm \
|
||||
qiosfileengineassetslibrary.mm \
|
||||
qiosfiledialog.mm
|
||||
|
||||
HEADERS = \
|
||||
qiosintegration.h \
|
||||
qioseventdispatcher.h \
|
||||
qioswindow.h \
|
||||
qiosscreen.h \
|
||||
qiosbackingstore.h \
|
||||
qiosapplicationdelegate.h \
|
||||
qiosapplicationstate.h \
|
||||
qiosviewcontroller.h \
|
||||
qioscontext.h \
|
||||
qiosinputcontext.h \
|
||||
qiostheme.h \
|
||||
qiosglobal.h \
|
||||
qiosservices.h \
|
||||
quiview.h \
|
||||
qiosclipboard.h \
|
||||
quiaccessibilityelement.h \
|
||||
qiosplatformaccessibility.h \
|
||||
qiostextresponder.h \
|
||||
qiosmenu.h \
|
||||
qiosfileenginefactory.h \
|
||||
qiosfileengineassetslibrary.h \
|
||||
qiosfiledialog.h
|
||||
|
||||
OTHER_FILES = \
|
||||
quiview_textinput.mm \
|
||||
quiview_accessibility.mm
|
||||
|
||||
PLUGIN_TYPE = platforms
|
||||
PLUGIN_CLASS_NAME = QIOSIntegrationPlugin
|
||||
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
|
||||
load(qt_plugin)
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = kernel.pro optional
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
TARGET = qios
|
||||
|
||||
QT += core-private gui-private platformsupport-private
|
||||
LIBS += -framework Foundation -framework UIKit -framework QuartzCore
|
||||
|
||||
OBJECTIVE_SOURCES = \
|
||||
plugin.mm \
|
||||
qiosintegration.mm \
|
||||
qioseventdispatcher.mm \
|
||||
qioswindow.mm \
|
||||
qiosscreen.mm \
|
||||
qiosbackingstore.mm \
|
||||
qiosapplicationdelegate.mm \
|
||||
qiosapplicationstate.mm \
|
||||
qiosviewcontroller.mm \
|
||||
qioscontext.mm \
|
||||
qiosinputcontext.mm \
|
||||
qiostheme.mm \
|
||||
qiosglobal.mm \
|
||||
qiosservices.mm \
|
||||
quiview.mm \
|
||||
qiosclipboard.mm \
|
||||
quiaccessibilityelement.mm \
|
||||
qiosplatformaccessibility.mm \
|
||||
qiostextresponder.mm \
|
||||
qiosmenu.mm \
|
||||
qiosfiledialog.mm
|
||||
|
||||
HEADERS = \
|
||||
qiosintegration.h \
|
||||
qioseventdispatcher.h \
|
||||
qioswindow.h \
|
||||
qiosscreen.h \
|
||||
qiosbackingstore.h \
|
||||
qiosapplicationdelegate.h \
|
||||
qiosapplicationstate.h \
|
||||
qiosviewcontroller.h \
|
||||
qioscontext.h \
|
||||
qiosinputcontext.h \
|
||||
qiostheme.h \
|
||||
qiosglobal.h \
|
||||
qiosservices.h \
|
||||
quiview.h \
|
||||
qiosclipboard.h \
|
||||
quiaccessibilityelement.h \
|
||||
qiosplatformaccessibility.h \
|
||||
qiostextresponder.h \
|
||||
qiosmenu.h \
|
||||
qiosfiledialog.h
|
||||
|
||||
OTHER_FILES = \
|
||||
quiview_textinput.mm \
|
||||
quiview_accessibility.mm
|
||||
|
||||
PLUGIN_TYPE = platforms
|
||||
PLUGIN_CLASS_NAME = QIOSIntegrationPlugin
|
||||
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
|
||||
load(qt_plugin)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
TARGET = qiosnsphotolibrarysupport
|
||||
|
||||
QT += core gui gui-private
|
||||
LIBS += -framework UIKit -framework AssetsLibrary
|
||||
|
||||
HEADERS = \
|
||||
qiosfileengineassetslibrary.h \
|
||||
qiosfileenginefactory.h \
|
||||
qiosimagepickercontroller.h
|
||||
|
||||
OBJECTIVE_SOURCES = \
|
||||
plugin.mm \
|
||||
qiosfileengineassetslibrary.mm \
|
||||
qiosimagepickercontroller.mm \
|
||||
|
||||
OTHER_FILES = \
|
||||
plugin.json
|
||||
|
||||
PLUGIN_CLASS_NAME = QIosOptionalPlugin_NSPhotoLibrary
|
||||
PLUGIN_EXTENDS = -
|
||||
PLUGIN_TYPE = platforms/darwin
|
||||
load(qt_plugin)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"Keys": [ "NSPhotoLibrarySupport" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "../../qiosoptionalplugininterface.h"
|
||||
#include "../../qiosfiledialog.h"
|
||||
|
||||
#include "qiosimagepickercontroller.h"
|
||||
#include "qiosfileenginefactory.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QIosOptionalPlugin_NSPhotoLibrary : public QObject, QIosOptionalPluginInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID QIosOptionalPluginInterface_iid FILE "plugin.json")
|
||||
Q_INTERFACES(QIosOptionalPluginInterface)
|
||||
|
||||
public:
|
||||
explicit QIosOptionalPlugin_NSPhotoLibrary(QObject* = 0) {};
|
||||
~QIosOptionalPlugin_NSPhotoLibrary() {}
|
||||
|
||||
UIViewController* createImagePickerController(QIOSFileDialog *fileDialog) const override
|
||||
{
|
||||
return [[[QIOSImagePickerController alloc] initWithQIOSFileDialog:fileDialog] autorelease];
|
||||
}
|
||||
|
||||
private:
|
||||
QIOSFileEngineFactory m_fileEngineFactory;
|
||||
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "plugin.moc"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#include "../../qiosfiledialog.h"
|
||||
|
||||
@interface QIOSImagePickerController : UIImagePickerController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> {
|
||||
QIOSFileDialog *m_fileDialog;
|
||||
}
|
||||
- (id)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog;
|
||||
@end
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#include "qiosimagepickercontroller.h"
|
||||
|
||||
@implementation QIOSImagePickerController
|
||||
|
||||
- (id)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
m_fileDialog = fileDialog;
|
||||
[self setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
|
||||
[self setDelegate:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
|
||||
{
|
||||
Q_UNUSED(picker);
|
||||
NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];
|
||||
QUrl fileUrl = QUrl::fromLocalFile(QString::fromNSString([url description]));
|
||||
m_fileDialog->selectedFilesChanged(QList<QUrl>() << fileUrl);
|
||||
emit m_fileDialog->accept();
|
||||
}
|
||||
|
||||
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
|
||||
{
|
||||
Q_UNUSED(picker)
|
||||
emit m_fileDialog->reject();
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS = nsphotolibrarysupport
|
||||
|
|
@ -66,6 +66,8 @@ private:
|
|||
QList<QUrl> m_selection;
|
||||
QEventLoop m_eventLoop;
|
||||
UIViewController *m_viewController;
|
||||
|
||||
bool showImagePickerDialog(QWindow *parent);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -31,52 +31,18 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qiosfiledialog.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#include <QtCore/qstandardpaths.h>
|
||||
#include <QtGui/qwindow.h>
|
||||
#include <QDebug>
|
||||
|
||||
@interface QIOSImagePickerController : UIImagePickerController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> {
|
||||
QIOSFileDialog *m_fileDialog;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation QIOSImagePickerController
|
||||
|
||||
- (id)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
m_fileDialog = fileDialog;
|
||||
[self setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
|
||||
[self setDelegate:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
|
||||
{
|
||||
Q_UNUSED(picker);
|
||||
NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];
|
||||
QUrl fileUrl = QUrl::fromLocalFile(QString::fromNSString([url description]));
|
||||
m_fileDialog->selectedFilesChanged(QList<QUrl>() << fileUrl);
|
||||
emit m_fileDialog->accept();
|
||||
}
|
||||
|
||||
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
|
||||
{
|
||||
Q_UNUSED(picker)
|
||||
emit m_fileDialog->reject();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
#include "qiosfiledialog.h"
|
||||
#include "qiosintegration.h"
|
||||
#include "qiosoptionalplugininterface.h"
|
||||
|
||||
QIOSFileDialog::QIOSFileDialog()
|
||||
: m_viewController(0)
|
||||
: m_viewController(Q_NULLPTR)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -98,17 +64,36 @@ bool QIOSFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality window
|
|||
bool acceptOpen = options()->acceptMode() == QFileDialogOptions::AcceptOpen;
|
||||
QString directory = options()->initialDirectory().toLocalFile();
|
||||
|
||||
if (acceptOpen && directory.startsWith(QLatin1String("assets-library:"))) {
|
||||
m_viewController = [[QIOSImagePickerController alloc] initWithQIOSFileDialog:this];
|
||||
UIWindow *window = parent ? reinterpret_cast<UIView *>(parent->winId()).window
|
||||
: [UIApplication sharedApplication].keyWindow;
|
||||
[window.rootViewController presentViewController:m_viewController animated:YES completion:nil];
|
||||
return true;
|
||||
}
|
||||
if (acceptOpen && directory.startsWith(QLatin1String("assets-library:")))
|
||||
return showImagePickerDialog(parent);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QIOSFileDialog::showImagePickerDialog(QWindow *parent)
|
||||
{
|
||||
if (!m_viewController) {
|
||||
QFactoryLoader *plugins = QIOSIntegration::instance()->optionalPlugins();
|
||||
for (int i = 0; i < plugins->metaData().size(); ++i) {
|
||||
QIosOptionalPluginInterface *plugin = qobject_cast<QIosOptionalPluginInterface *>(plugins->instance(i));
|
||||
m_viewController = [plugin->createImagePickerController(this) retain];
|
||||
if (m_viewController)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_viewController) {
|
||||
qWarning() << "QIOSFileDialog: Could not resolve Qt plugin that gives access to photos on iOS";
|
||||
return false;
|
||||
}
|
||||
|
||||
UIWindow *window = parent ? reinterpret_cast<UIView *>(parent->winId()).window
|
||||
: [UIApplication sharedApplication].keyWindow;
|
||||
[window.rootViewController presentViewController:m_viewController animated:YES completion:nil];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QIOSFileDialog::hide()
|
||||
{
|
||||
// QFileDialog will remember the last directory set, and open subsequent dialogs in the same
|
||||
|
|
@ -120,6 +105,8 @@ void QIOSFileDialog::hide()
|
|||
emit directoryEntered(QUrl::fromLocalFile(QDir::currentPath()));
|
||||
|
||||
[m_viewController dismissViewControllerAnimated:YES completion:nil];
|
||||
[m_viewController release];
|
||||
m_viewController = Q_NULLPTR;
|
||||
m_eventLoop.exit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,9 @@
|
|||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
|
||||
#include <QtCore/private/qfactoryloader_p.h>
|
||||
|
||||
#include "qiosapplicationstate.h"
|
||||
#include "qiosfileenginefactory.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -91,6 +92,8 @@ public:
|
|||
void setDebugWindowManagement(bool);
|
||||
bool debugWindowManagement() const;
|
||||
|
||||
QFactoryLoader *optionalPlugins() { return m_optionalPlugins; }
|
||||
|
||||
private:
|
||||
QPlatformFontDatabase *m_fontDatabase;
|
||||
QPlatformClipboard *m_clipboard;
|
||||
|
|
@ -99,7 +102,7 @@ private:
|
|||
QIOSApplicationState m_applicationState;
|
||||
QIOSServices *m_platformServices;
|
||||
mutable QPlatformAccessibility *m_accessibility;
|
||||
QIOSFileEngineFactory m_fileEngineFactory;
|
||||
QFactoryLoader *m_optionalPlugins;
|
||||
|
||||
bool m_debugWindowManagement;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
#include "qiosinputcontext.h"
|
||||
#include "qiostheme.h"
|
||||
#include "qiosservices.h"
|
||||
#include "qiosoptionalplugininterface.h"
|
||||
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
|
||||
|
|
@ -68,6 +69,7 @@ QIOSIntegration::QIOSIntegration()
|
|||
, m_inputContext(0)
|
||||
, m_platformServices(new QIOSServices)
|
||||
, m_accessibility(0)
|
||||
, m_optionalPlugins(new QFactoryLoader(QIosOptionalPluginInterface_iid, QLatin1String("/platforms/darwin")))
|
||||
, m_debugWindowManagement(false)
|
||||
{
|
||||
if (![UIApplication sharedApplication]) {
|
||||
|
|
@ -112,6 +114,9 @@ QIOSIntegration::QIOSIntegration()
|
|||
m_touchDevice->setCapabilities(touchCapabilities);
|
||||
QWindowSystemInterface::registerTouchDevice(m_touchDevice);
|
||||
QMacInternalPasteboardMime::initializeMimeTypes();
|
||||
|
||||
for (int i = 0; i < m_optionalPlugins->metaData().size(); ++i)
|
||||
qobject_cast<QIosOptionalPluginInterface *>(m_optionalPlugins->instance(i))->initPlugin();
|
||||
}
|
||||
|
||||
QIOSIntegration::~QIOSIntegration()
|
||||
|
|
@ -134,6 +139,9 @@ QIOSIntegration::~QIOSIntegration()
|
|||
|
||||
delete m_accessibility;
|
||||
m_accessibility = 0;
|
||||
|
||||
delete m_optionalPlugins;
|
||||
m_optionalPlugins = 0;
|
||||
}
|
||||
|
||||
bool QIOSIntegration::hasCapability(Capability cap) const
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QIOPLUGININTERFACE_H
|
||||
#define QIOPLUGININTERFACE_H
|
||||
|
||||
#include <QtCore/QtPlugin>
|
||||
|
||||
#include "qiosfiledialog.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_FORWARD_DECLARE_OBJC_CLASS(UIViewController);
|
||||
|
||||
#define QIosOptionalPluginInterface_iid "org.qt-project.Qt.QPA.ios.optional"
|
||||
|
||||
class QIosOptionalPluginInterface
|
||||
{
|
||||
public:
|
||||
virtual ~QIosOptionalPluginInterface() {}
|
||||
virtual void initPlugin() const {};
|
||||
virtual UIViewController* createImagePickerController(QIOSFileDialog *) const { return Q_NULLPTR; };
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE(QIosOptionalPluginInterface, QIosOptionalPluginInterface_iid)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QIOPLUGININTERFACE_H
|
||||
Loading…
Reference in New Issue