iOS: Fade out statusbar when scrolling view due to VKB
Change-Id: I86923a2b2aa2d17d79ba3a11cabf37e615eaf4cc Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>bb10
parent
cc1058a278
commit
e7239e1ce3
|
|
@ -399,6 +399,8 @@ void QIOSInputContext::scroll(int y)
|
|||
animation.toValue = [NSValue valueWithCATransform3D:translationTransform];
|
||||
[rootView.layer addAnimation:animation forKey:@"AnimateSubLayerTransform"];
|
||||
rootView.layer.sublayerTransform = translationTransform;
|
||||
|
||||
[rootView.qtViewController updateProperties];
|
||||
}
|
||||
completion:^(BOOL){
|
||||
if (self)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ class QIOSScreen;
|
|||
|
||||
@property (nonatomic, assign) BOOL changingOrientation;
|
||||
@property (nonatomic, assign) BOOL prefersStatusBarHidden;
|
||||
@property (nonatomic, assign) UIStatusBarAnimation preferredStatusBarUpdateAnimation;
|
||||
|
||||
- (id)initWithQIOSScreen:(QIOSScreen *)screen;
|
||||
- (void)updateProperties;
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@
|
|||
|
||||
// Status bar may be initially hidden at startup through Info.plist
|
||||
self.prefersStatusBarHidden = infoPlistValue(@"UIStatusBarHidden", false);
|
||||
self.preferredStatusBarUpdateAnimation = UIStatusBarAnimationNone;
|
||||
|
||||
QObject::connect(qApp, &QGuiApplication::focusWindowChanged, [self]() {
|
||||
[self updateProperties];
|
||||
|
|
@ -182,47 +183,6 @@
|
|||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
- (void)updateProperties
|
||||
{
|
||||
if (!isQtApplication())
|
||||
return;
|
||||
|
||||
QWindow *focusWindow = QGuiApplication::focusWindow();
|
||||
|
||||
// If we don't have a focus window we leave the statusbar
|
||||
// as is, so that the user can activate a new window with
|
||||
// the same window state without the status bar jumping
|
||||
// back and forth.
|
||||
if (!focusWindow)
|
||||
return;
|
||||
|
||||
// We only care about changes to focusWindow that involves our screen
|
||||
if (!focusWindow->screen() || focusWindow->screen()->handle() != m_screen)
|
||||
return;
|
||||
|
||||
// All decisions are based on the the top level window
|
||||
focusWindow = qt_window_private(focusWindow)->topLevelWindow();
|
||||
|
||||
bool currentStatusBarVisibility = self.prefersStatusBarHidden;
|
||||
self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen;
|
||||
if (self.prefersStatusBarHidden != currentStatusBarVisibility) {
|
||||
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0)
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) {
|
||||
[self setNeedsStatusBarAppearanceUpdate];
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
[[UIApplication sharedApplication]
|
||||
setStatusBarHidden:self.prefersStatusBarHidden
|
||||
withAnimation:UIStatusBarAnimationNone];
|
||||
}
|
||||
|
||||
[self.view setNeedsLayout];
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
-(BOOL)shouldAutorotate
|
||||
{
|
||||
// Until a proper orientation and rotation API is in place, we always auto rotate.
|
||||
|
|
@ -298,6 +258,54 @@
|
|||
m_screen->updateProperties();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
- (void)updateProperties
|
||||
{
|
||||
if (!isQtApplication())
|
||||
return;
|
||||
|
||||
QWindow *focusWindow = QGuiApplication::focusWindow();
|
||||
|
||||
// If we don't have a focus window we leave the statusbar
|
||||
// as is, so that the user can activate a new window with
|
||||
// the same window state without the status bar jumping
|
||||
// back and forth.
|
||||
if (!focusWindow)
|
||||
return;
|
||||
|
||||
// We only care about changes to focusWindow that involves our screen
|
||||
if (!focusWindow->screen() || focusWindow->screen()->handle() != m_screen)
|
||||
return;
|
||||
|
||||
// All decisions are based on the the top level window
|
||||
focusWindow = qt_window_private(focusWindow)->topLevelWindow();
|
||||
|
||||
bool hasScrolledRootViewDueToVirtualKeyboard =
|
||||
!CATransform3DIsIdentity(self.view.layer.sublayerTransform);
|
||||
|
||||
bool currentStatusBarVisibility = self.prefersStatusBarHidden;
|
||||
self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen
|
||||
|| hasScrolledRootViewDueToVirtualKeyboard;
|
||||
self.preferredStatusBarUpdateAnimation = hasScrolledRootViewDueToVirtualKeyboard ?
|
||||
UIStatusBarAnimationFade : UIStatusBarAnimationNone;
|
||||
|
||||
if (self.prefersStatusBarHidden != currentStatusBarVisibility) {
|
||||
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0)
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) {
|
||||
[self setNeedsStatusBarAppearanceUpdate];
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
[[UIApplication sharedApplication]
|
||||
setStatusBarHidden:self.prefersStatusBarHidden
|
||||
withAnimation:self.preferredStatusBarUpdateAnimation];
|
||||
}
|
||||
|
||||
[self.view setNeedsLayout];
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0)
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue