6#import <Photos/Photos.h>
8#include <QtCore/qstandardpaths.h>
9#include <QtGui/qwindow.h>
12#include <QtCore/private/qcore_mac_p.h>
46 const QString scheme = initialDir.scheme();
49 if (
directory.startsWith(
"assets-library:"_L1) || scheme ==
"assets-library"_L1)
50 return showImagePickerDialog(
parent);
52 return showNativeDocumentPickerDialog(
parent);
58void QIOSFileDialog::showImagePickerDialog_helper(
QWindow *
parent)
62 [
window.rootViewController presentViewController:m_viewController animated:YES completion:nil];
67 if (!m_viewController) {
72 m_viewController = [
plugin->createImagePickerController(
this) retain];
78 if (!m_viewController) {
79 qWarning() <<
"QIOSFileDialog: Could not resolve Qt plugin that gives access to photos on iOS";
92 const auto authStatus = [PHPhotoLibrary authorizationStatus];
93 if (authStatus == PHAuthorizationStatusAuthorized) {
94 showImagePickerDialog_helper(
parent);
95 }
else if (authStatus == PHAuthorizationStatusNotDetermined) {
98 [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
99 dispatch_async(dispatch_get_main_queue(), ^{
100 if (status == PHAuthorizationStatusAuthorized) {
101 if (thisGuard && winGuard)
102 thisGuard->showImagePickerDialog_helper(winGuard);
104 }
else if (thisGuard) {
105 emit thisGuard->reject();
112 qWarning() <<
"QIOSFileDialog: insufficient permission, cannot pick images";
119bool QIOSFileDialog::showNativeDocumentPickerDialog(
QWindow *
parent)
126 [
window.rootViewController presentViewController:m_viewController animated:YES completion:nil];
144 [m_viewController dismissViewControllerAnimated:YES completion:nil];
146 m_viewController =
nullptr;
159 if (m_selection.
count() == 1)
static QString currentPath()
Returns the absolute path of the application's current directory.
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
void exit(int returnCode=0)
Tells the event loop to exit with a return code.
MetaDataList metaData() const
QObject * instance(int index) const
AcceptMode acceptMode() const
QUrl initialDirectory() const
QUrl directory() const override
QList< QUrl > selectedFiles() const override
bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override
void selectedFilesChanged(const QList< QUrl > &selection)
QFactoryLoader * optionalPlugins()
static QIOSIntegration * instance()
qsizetype size() const noexcept
qsizetype count() const noexcept
QObject * parent() const
Returns a pointer to the parent object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
AppleApplication * qt_apple_sharedApplication()
GLenum GLuint GLintptr GLsizeiptr size
[1]
QItemSelection * selection
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent