// Copyright (C) 2024 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "quiwindow.h" #include "qiostheme.h" #include #include #include #include @implementation QUIWindow - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) self->_sendingEvent = NO; return self; } - (void)sendEvent:(UIEvent *)event { QScopedValueRollback sendingEvent(self->_sendingEvent, YES); [super sendEvent:event]; } #if !defined(Q_OS_VISIONOS) - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection { [super traitCollectionDidChange:previousTraitCollection]; if (!qGuiApp) return; Qt::ColorScheme colorScheme = self.traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark ? Qt::ColorScheme::Dark : Qt::ColorScheme::Light; if (self.screen == UIScreen.mainScreen) { // Check if the current userInterfaceStyle reports a different appearance than // the platformTheme's appearance. We might have set that one based on the UIScreen if (previousTraitCollection.userInterfaceStyle != self.traitCollection.userInterfaceStyle || QGuiApplicationPrivate::platformTheme()->colorScheme() != colorScheme) { QIOSTheme::initializeSystemPalette(); QWindowSystemInterface::handleThemeChange(); } } } #endif @end