share file for iOS
This commit is contained in:
parent
9ed16b81e8
commit
9601506270
6 changed files with 94 additions and 17 deletions
10
client/platforms/ios/MobileUtils.cpp
Normal file
10
client/platforms/ios/MobileUtils.cpp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include "MobileUtils.h"
|
||||
|
||||
MobileUtils::MobileUtils()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MobileUtils::shareText(const QStringList& filesToSend) {
|
||||
|
||||
}
|
||||
17
client/platforms/ios/MobileUtils.h
Normal file
17
client/platforms/ios/MobileUtils.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef MOBILEUTILS_H
|
||||
#define MOBILEUTILS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
class MobileUtils : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MobileUtils() = delete;
|
||||
|
||||
public slots:
|
||||
static void shareText(const QStringList& filesToSend);
|
||||
};
|
||||
|
||||
#endif // MOBILEUTILS_H
|
||||
33
client/platforms/ios/MobileUtils.mm
Normal file
33
client/platforms/ios/MobileUtils.mm
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#include "MobileUtils.h"
|
||||
|
||||
#include <UIKit/UIKit.h>
|
||||
|
||||
static UIViewController* getViewController() {
|
||||
NSArray *windows = [[UIApplication sharedApplication]windows];
|
||||
for (UIWindow *window in windows) {
|
||||
if (window.isKeyWindow) {
|
||||
return window.rootViewController;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
void MobileUtils::shareText(const QStringList& filesToSend) {
|
||||
NSMutableArray *sharingItems = [NSMutableArray new];
|
||||
|
||||
for (int i = 0; i < filesToSend.size(); i++) {
|
||||
NSURL *logFileUrl = [[NSURL alloc] initFileURLWithPath:filesToSend[i].toNSString()];
|
||||
[sharingItems addObject:logFileUrl];
|
||||
}
|
||||
|
||||
UIViewController *qtController = getViewController();
|
||||
if (!qtController) return;
|
||||
|
||||
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
|
||||
|
||||
[qtController presentViewController:activityController animated:YES completion:nil];
|
||||
UIPopoverPresentationController *popController = activityController.popoverPresentationController;
|
||||
if (popController) {
|
||||
popController.sourceView = qtController.view;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue