-
Notifications
You must be signed in to change notification settings - Fork 2
/
appmanager.mm
68 lines (54 loc) · 1.39 KB
/
appmanager.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
#include "appmanager.h"
static AppManager* _appManager = 0;
#ifdef Q_OS_IOS
#import <UIKit/UIKit.h>
#include <QGuiApplication>
#include <QWindow>
#include <qpa/qplatformnativeinterface.h>
#include <QDebug>
@interface QIOSViewController
@end;
@interface QIOSViewController (QWSDemo)
@end;
@implementation QIOSViewController (QWSDemo)
- (UIStatusBarStyle)preferredStatusBarStyle
{
return _appManager && _appManager->lightContent() ? UIStatusBarStyleLightContent : UIStatusBarStyleDefault;
}
- (void)didReceiveMemoryWarning
{
}
@end
#endif
AppManager::AppManager(QObject *parent)
: QObject(parent)
, m_lightContent(false)
, m_window(0)
{
Q_ASSERT(_appManager == 0);
_appManager = this;
}
void AppManager::setLightContent(bool v)
{
if(m_lightContent != v)
{
m_lightContent = v;
emit lightContentChanged(v);
#ifdef Q_OS_IOS
if(0 == m_window)
{
m_window = QGuiApplication::focusWindow();
}
if(m_window)
{
UIView *view = static_cast<UIView*>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("uiview", m_window));
Q_ASSERT(view);
UIViewController* controller = [[view window] rootViewController];
Q_ASSERT(controller);
[controller setNeedsStatusBarAppearanceUpdate];
}
else
qDebug() << "No window";
#endif
}
}