-
Notifications
You must be signed in to change notification settings - Fork 15
/
lqtutils_ui.mm
88 lines (67 loc) · 2.15 KB
/
lqtutils_ui.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <QUrl>
#include <UIKit/UIKit.h>
#include "lqtutils_ui.h"
namespace lqt {
ScreenLock::ScreenLock() :
m_isValid(false)
{
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];
}
ScreenLock::~ScreenLock()
{
[[UIApplication sharedApplication] setIdleTimerDisabled: NO];
}
double QmlUtils::safeAreaBottomInset()
{
if (@available(iOS 11.0, *)) {
UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
return window.safeAreaInsets.bottom;
}
return 0;
}
double QmlUtils::safeAreaTopInset()
{
if (@available(iOS 11.0, *)) {
UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
return window.safeAreaInsets.top;
}
return 0;
}
double QmlUtils::safeAreaLeftInset()
{
if (@available(iOS 11.0, *)) {
UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
return window.safeAreaInsets.left;
}
return 0;
}
double QmlUtils::safeAreaRightInset()
{
if (@available(iOS 11.0, *)) {
UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
return window.safeAreaInsets.right;
}
return 0;
}
bool QmlUtils::shareResource(const QUrl& resUrl, const QString& /* mimeType */, const QString& /* authority */)
{
NSString* nsFilePath = resUrl.toLocalFile().toNSString();
NSURL* url = [NSURL fileURLWithPath:nsFilePath];
if (!url) {
qWarning() << "Invalid file name:" << resUrl.toLocalFile();
return false;
}
NSArray* dataToShare = @[url];
UIActivityViewController* activityViewController = [[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];
[activityViewController autorelease];
UIView* view = [[[[UIApplication sharedApplication] keyWindow] rootViewController] view];
activityViewController.popoverPresentationController.sourceView = view;
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:activityViewController animated:YES completion:nil];
return true;
}
QRectF QmlUtils::visibleDisplayFrame()
{
qWarning() << "Not implemented";
return QRectF();
}
}