iOS plugin: Support picking folders for native file dialog
Fixes: QTBUG-104375 Change-Id: Idbc9eb44abed5e3cd0dd768a08bf8132aba58f43 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
443af8cd45
commit
dbe433f6d0
@ -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:
|
||||
|
@ -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 <UIKit/UIKit.h>
|
||||
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
|
||||
|
||||
#include "qiosfiledialog.h"
|
||||
|
||||
|
@ -12,27 +12,24 @@
|
||||
|
||||
- (instancetype)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog
|
||||
{
|
||||
NSMutableArray <NSString *> *docTypes = [[[NSMutableArray alloc] init] autorelease];
|
||||
UIDocumentPickerMode importMode;
|
||||
NSMutableArray <UTType *> *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;
|
||||
|
@ -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<UIView *>(parent->winId()).window
|
||||
|
Loading…
Reference in New Issue
Block a user