iOS: Move QUIWindow implementation out of qiosscreen.mm
Task-number: QTBUG-121781 Change-Id: Iaa4388908d0d59022ec05b63696147a0d1d01ae1 Reviewed-by: Amr Elsayed <amr.elsayed@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
1a0c113b2d
commit
447a82ebe4
@ -27,6 +27,7 @@ qt_internal_add_plugin(QIOSIntegrationPlugin
|
||||
qioswindow.h qioswindow.mm
|
||||
quiaccessibilityelement.h quiaccessibilityelement.mm
|
||||
quiview.h quiview.mm
|
||||
quiwindow.mm quiwindow.h
|
||||
uistrings_p.h uistrings.cpp
|
||||
NO_PCH_SOURCES
|
||||
qioscontext.mm # undef QT_NO_FOREACH
|
||||
|
@ -10,10 +10,6 @@
|
||||
|
||||
@class QIOSOrientationListener;
|
||||
|
||||
@interface QUIWindow : UIWindow
|
||||
@property (nonatomic, readonly) BOOL sendingEvent;
|
||||
@end
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QIOSScreen : public QObject, public QPlatformScreen
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "qiosviewcontroller.h"
|
||||
#include "quiview.h"
|
||||
#include "qiostheme.h"
|
||||
#include "quiwindow.h"
|
||||
|
||||
#include <QtCore/private/qcore_mac_p.h>
|
||||
|
||||
@ -154,51 +155,6 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@implementation QUIWindow
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if ((self = [super initWithFrame:frame]))
|
||||
self->_sendingEvent = NO;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)sendEvent:(UIEvent *)event
|
||||
{
|
||||
QScopedValueRollback<BOOL> 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<QWindowSystemInterface::SynchronousDelivery>();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "qiosfontdialog.h"
|
||||
#include "qiosmessagedialog.h"
|
||||
#include "qiosscreen.h"
|
||||
#include "quiwindow.h"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "qiosscreen.h"
|
||||
#include "qioswindow.h"
|
||||
#include "qiosinputcontext.h"
|
||||
#include "quiwindow.h"
|
||||
#ifndef Q_OS_TVOS
|
||||
#include "qiosmenu.h"
|
||||
#endif
|
||||
|
13
src/plugins/platforms/ios/quiwindow.h
Normal file
13
src/plugins/platforms/ios/quiwindow.h
Normal file
@ -0,0 +1,13 @@
|
||||
// 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
|
||||
|
||||
#ifndef QUIWINDOW_H
|
||||
#define QUIWINDOW_H
|
||||
|
||||
#include <UIKit/UIWindow.h>
|
||||
|
||||
@interface QUIWindow : UIWindow
|
||||
@property (nonatomic, readonly) BOOL sendingEvent;
|
||||
@end
|
||||
|
||||
#endif // QUIWINDOW_H
|
56
src/plugins/platforms/ios/quiwindow.mm
Normal file
56
src/plugins/platforms/ios/quiwindow.mm
Normal file
@ -0,0 +1,56 @@
|
||||
// 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 <QtCore/qscopedvaluerollback.h>
|
||||
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <QtGui/qpa/qplatformtheme.h>
|
||||
|
||||
#include <UIKit/UIKit.h>
|
||||
|
||||
@implementation QUIWindow
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if ((self = [super initWithFrame:frame]))
|
||||
self->_sendingEvent = NO;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)sendEvent:(UIEvent *)event
|
||||
{
|
||||
QScopedValueRollback<BOOL> 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<QWindowSystemInterface::SynchronousDelivery>();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
Loading…
x
Reference in New Issue
Block a user