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 <doris.verria@qt.io>
(cherry picked from commit 29b6674d3f8d1012def9dbcf89521e4773175dc1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-06-07 14:23:27 +02:00 committed by Qt Cherry-pick Bot
parent 6ce8738dd3
commit ad8b330ecc

View File

@ -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<UIAccessibilityElement *> 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<CAEAGLLayer *>(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;