From ad8b330ecce1b066eaa9c7ef2c7bd6df1f20153c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 7 Jun 2024 14:23:27 +0200 Subject: [PATCH] iOS: Merge UIView initializers We always create UIView via initWithQIOSWindow, so there is no need to keep part of the implementation in initWithFrame. Change-Id: I5311ed78fff3294ed49af70d482449cbf3b8211b Reviewed-by: Doris Verria (cherry picked from commit 29b6674d3f8d1012def9dbcf89521e4773175dc1) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/ios/quiview.mm | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 916683164cc..932b4eca603 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -92,7 +92,16 @@ inline ulong getTimeStamp(UIEvent *event) { if (self = [self initWithFrame:window->geometry().toCGRect()]) { self.platformWindow = window; + + if (isQtApplication()) + self.hidden = YES; + m_accessibleElements = [[NSMutableArray alloc] init]; + +#ifndef Q_OS_TVOS + self.multipleTouchEnabled = YES; +#endif + m_scrollGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleScroll:)]; @@ -109,6 +118,7 @@ inline ulong getTimeStamp(UIEvent *event) m_lastScrollCursorPos = CGPointZero; [self addGestureRecognizer:m_scrollGestureRecognizer]; + // Set up layer if ([self.layer isKindOfClass:CAMetalLayer.class]) { QWindow *window = self.platformWindow->window(); if (QColorSpace colorSpace = window->format().colorSpace(); colorSpace.isValid()) { @@ -119,17 +129,8 @@ inline ulong getTimeStamp(UIEvent *event) qCDebug(lcQpaWindow) << "Set" << self << "color space to" << metalLayer.colorspace; } } - } - - return self; -} - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) { #if QT_CONFIG(opengl) - if ([self.layer isKindOfClass:[CAEAGLLayer class]]) { - // Set up EAGL layer + else if ([self.layer isKindOfClass:[CAEAGLLayer class]]) { CAEAGLLayer *eaglLayer = static_cast(self.layer); eaglLayer.opaque = TRUE; eaglLayer.drawableProperties = @{ @@ -138,13 +139,6 @@ inline ulong getTimeStamp(UIEvent *event) }; } #endif - - if (isQtApplication()) - self.hidden = YES; - -#ifndef Q_OS_TVOS - self.multipleTouchEnabled = YES; -#endif } return self;