diff --git a/src/plugins/platforms/ios/CMakeLists.txt b/src/plugins/platforms/ios/CMakeLists.txt index e768898574..7b654af2a4 100644 --- a/src/plugins/platforms/ios/CMakeLists.txt +++ b/src/plugins/platforms/ios/CMakeLists.txt @@ -48,6 +48,7 @@ qt_disable_apple_app_extension_api_only(QIOSIntegrationPlugin) ## Scopes: ##################################################################### +qt_internal_find_apple_system_framework(FWUniformTypeIdentifiers UniformTypeIdentifiers) qt_internal_extend_target(QIOSIntegrationPlugin CONDITION QT_FEATURE_opengl LIBRARIES @@ -66,6 +67,7 @@ qt_internal_extend_target(QIOSIntegrationPlugin CONDITION NOT TVOS qiostextinputoverlay.h qiostextinputoverlay.mm LIBRARIES ${FWAssetsLibrary} + ${FWUniformTypeIdentifiers} ) #### Keys ignored in scope 6:.:.:kernel.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: diff --git a/src/plugins/platforms/ios/qiosdocumentpickercontroller.h b/src/plugins/platforms/ios/qiosdocumentpickercontroller.h index 9182a699b3..f0b7472539 100644 --- a/src/plugins/platforms/ios/qiosdocumentpickercontroller.h +++ b/src/plugins/platforms/ios/qiosdocumentpickercontroller.h @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #import +#import #include "qiosfiledialog.h" diff --git a/src/plugins/platforms/ios/qiosdocumentpickercontroller.mm b/src/plugins/platforms/ios/qiosdocumentpickercontroller.mm index 09934dda0e..765d8848d2 100644 --- a/src/plugins/platforms/ios/qiosdocumentpickercontroller.mm +++ b/src/plugins/platforms/ios/qiosdocumentpickercontroller.mm @@ -12,27 +12,24 @@ - (instancetype)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog { - NSMutableArray *docTypes = [[[NSMutableArray alloc] init] autorelease]; - UIDocumentPickerMode importMode; + NSMutableArray *docTypes = [[[NSMutableArray alloc] init] autorelease]; + switch (fileDialog->options()->fileMode()) { case QFileDialogOptions::AnyFile: case QFileDialogOptions::ExistingFile: case QFileDialogOptions::ExistingFiles: - [docTypes addObject:(__bridge NSString *)kUTTypeContent]; - [docTypes addObject:(__bridge NSString *)kUTTypeItem]; - [docTypes addObject:(__bridge NSString *)kUTTypeData]; - importMode = UIDocumentPickerModeImport; + [docTypes addObject:[UTType typeWithIdentifier:(__bridge NSString *)kUTTypeContent]]; + [docTypes addObject:[UTType typeWithIdentifier:(__bridge NSString *)kUTTypeItem]]; + [docTypes addObject:[UTType typeWithIdentifier:(__bridge NSString *)kUTTypeData]]; break; + // Showing files is not supported in Directory mode in iOS case QFileDialogOptions::Directory: case QFileDialogOptions::DirectoryOnly: - // Directory picking is not supported because it requires - // special handling not possible with the current QFilePicker - // implementation. - - Q_UNREACHABLE(); + [docTypes addObject:[UTType typeWithIdentifier:(__bridge NSString *)kUTTypeFolder]]; + break; } - if (self = [super initWithDocumentTypes:docTypes inMode:importMode]) { + if (self = [super initForOpeningContentTypes:docTypes]) { m_fileDialog = fileDialog; self.modalPresentationStyle = UIModalPresentationFormSheet; self.delegate = self; diff --git a/src/plugins/platforms/ios/qiosfiledialog.mm b/src/plugins/platforms/ios/qiosfiledialog.mm index 64e9445c43..3568a9e908 100644 --- a/src/plugins/platforms/ios/qiosfiledialog.mm +++ b/src/plugins/platforms/ios/qiosfiledialog.mm @@ -77,10 +77,6 @@ bool QIOSFileDialog::showImagePickerDialog(QWindow *parent) bool QIOSFileDialog::showNativeDocumentPickerDialog(QWindow *parent) { #ifndef Q_OS_TVOS - if (options()->fileMode() == QFileDialogOptions::Directory || - options()->fileMode() == QFileDialogOptions::DirectoryOnly) - return false; - m_viewController = [[QIOSDocumentPickerController alloc] initWithQIOSFileDialog:this]; UIWindow *window = parent ? reinterpret_cast(parent->winId()).window