read imported file configuration

This commit is contained in:
eugenyorbitsoftcom 2022-07-11 16:08:57 +06:00
parent 1800c1ff12
commit 9ed16b81e8
5 changed files with 126 additions and 3 deletions

View file

@ -300,7 +300,9 @@ ios {
platforms/ios/bigint.h \
platforms/ios/bigintipv6addr.h \
platforms/ios/ipaddress.h \
platforms/ios/ipaddressrange.h
platforms/ios/ipaddressrange.h \
platforms/ios/QtAppDelegate.h \
platforms/ios/QtAppDelegate-C-Interface.h
SOURCES -= \
platforms/ios/QRCodeReader.cpp
@ -312,7 +314,8 @@ ios {
platforms/ios/iosglue.mm \
platforms/ios/ipaddress.cpp \
platforms/ios/ipaddressrange.cpp \
platforms/ios/QRCodeReader.mm
platforms/ios/QRCodeReader.mm \
platforms/ios/QtAppDelegate.mm
Q_ENABLE_BITCODE.value = NO
Q_ENABLE_BITCODE.name = ENABLE_BITCODE

View file

@ -57,6 +57,10 @@
#include "native.h"
#endif
#if defined(Q_OS_IOS)
#include "QtAppDelegate-C-Interface.h"
#endif
static void loadTranslator()
{
QTranslator* translator = new QTranslator;
@ -88,7 +92,6 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
#endif
#ifdef Q_OS_WIN
AllowSetForegroundWindow(0);
#endif
@ -97,6 +100,10 @@ int main(int argc, char *argv[])
NativeHelpers::registerApplicationInstance(&app);
#endif
#if defined(Q_OS_IOS)
QtAppDelegateInitialize();
#endif
loadTranslator();
QFontDatabase::addApplicationFont(":/fonts/Lato-Black.ttf");
@ -203,6 +210,10 @@ int main(int argc, char *argv[])
engine->rootContext()->setContextProperty("VpnLogic", uiLogic->vpnLogic());
engine->rootContext()->setContextProperty("WizardLogic", uiLogic->wizardLogic());
#if defined(Q_OS_IOS)
setStartPageLogic(uiLogic->startPageLogic());
#endif
engine->load(url);
QObject::connect(&app, &QCoreApplication::aboutToQuit, uiLogic, [&engine, uiLogic](){

View file

@ -0,0 +1,9 @@
#ifndef QTAPPDELEGATECINTERFACE_H
#define QTAPPDELEGATECINTERFACE_H
#include "ui/pages_logic/StartPageLogic.h"
void QtAppDelegateInitialize();
void setStartPageLogic(StartPageLogic*);
#endif // QTAPPDELEGATECINTERFACE_H

View file

@ -0,0 +1,9 @@
#import <UIKit/UIKit.h>
#import "QtAppDelegate-C-Interface.h"
#include "ui/pages_logic/StartPageLogic.h"
@interface QtAppDelegate : UIResponder <UIApplicationDelegate>
+(QtAppDelegate *)sharedQtAppDelegate;
@property (nonatomic) StartPageLogic* startPageLogic;
@end

View file

@ -0,0 +1,91 @@
#import "QtAppDelegate.h"
#include <QFile>
@implementation QtAppDelegate
+(QtAppDelegate *)sharedQtAppDelegate {
static dispatch_once_t pred;
static QtAppDelegate *shared = nil;
dispatch_once(&pred, ^{
shared = [[super alloc] init];
});
return shared;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[application setMinimumBackgroundFetchInterval: UIApplicationBackgroundFetchIntervalMinimum];
// Override point for customization after application launch.
NSLog(@"Did this launch option happen");
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
NSLog(@"In the background");
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
NSLog(@"In the foreground");
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// We will add content here soon.
NSLog(@"In the completionHandler");
}
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
NSLog(@"Application openURL: %@", url);
if (url.fileURL) {
QString filePath(url.path.UTF8String);
qDebug() << "filePath:" << filePath;
if (filePath.isEmpty()) return NO;
QFile file(filePath);
bool isOpenFile = file.open(QIODevice::ReadOnly);
qDebug() << "isOpenFile:" << isOpenFile;
QByteArray data = file.readAll();
[QtAppDelegate sharedQtAppDelegate].startPageLogic->importConnectionFromCode(QString(data));
return YES;
}
return NO;
}
void QtAppDelegateInitialize()
{
[[UIApplication sharedApplication] setDelegate: [QtAppDelegate sharedQtAppDelegate]];
NSLog(@"Created a new AppDelegate");
}
void setStartPageLogic(StartPageLogic* startPage) {
[QtAppDelegate sharedQtAppDelegate].startPageLogic = startPage;
}
@end