From ba871065e0f40e9197fa4ee0ffe76530bb6fca11 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 1 Feb 2018 10:32:07 -0800 Subject: Clean up our Objective-C usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move ivars into @implementation - Use instancetype where applicable - Use dot notation for property access - Use subscript operator for dictionaries and arrays - Format selectors consistently - Use proper style for init methods - Use generics instead of void pointers where possible - Use "range for" loops instead of indexing - Replace or replace IBAction/IBOutlet with void Change-Id: I1667812a51d4dfe44ae80fe337cb1f4bc9699d92 Reviewed-by: Jake Petroules Reviewed-by: Tor Arne Vestbø --- .../qiosimagepickercontroller.h | 6 +- .../qiosimagepickercontroller.mm | 14 ++-- src/plugins/platforms/ios/qiosclipboard.mm | 24 +++--- src/plugins/platforms/ios/qioseventdispatcher.mm | 2 +- src/plugins/platforms/ios/qiosinputcontext.mm | 15 ++-- src/plugins/platforms/ios/qiosintegration.mm | 2 +- src/plugins/platforms/ios/qiosmenu.mm | 32 ++++---- .../platforms/ios/qiosoptionalplugininterface.h | 4 +- src/plugins/platforms/ios/qiosscreen.mm | 14 ++-- src/plugins/platforms/ios/qiostextinputoverlay.mm | 85 +++++++++------------- src/plugins/platforms/ios/qiostextresponder.h | 10 +-- src/plugins/platforms/ios/qiostextresponder.mm | 42 ++++++----- src/plugins/platforms/ios/qiosviewcontroller.h | 2 +- src/plugins/platforms/ios/qiosviewcontroller.mm | 36 +++++---- src/plugins/platforms/ios/qioswindow.mm | 6 +- .../platforms/ios/quiaccessibilityelement.h | 7 +- .../platforms/ios/quiaccessibilityelement.mm | 13 ++-- src/plugins/platforms/ios/quiview.h | 15 +--- src/plugins/platforms/ios/quiview.mm | 74 ++++++++++--------- src/plugins/platforms/ios/quiview_accessibility.mm | 7 +- 20 files changed, 193 insertions(+), 217 deletions(-) (limited to 'src/plugins/platforms/ios') diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.h b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.h index c52d498cd4..201b277494 100644 --- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.h +++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.h @@ -41,8 +41,6 @@ #include "../../qiosfiledialog.h" -@interface QIOSImagePickerController : UIImagePickerController { - QIOSFileDialog *m_fileDialog; -} -- (id)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog; +@interface QIOSImagePickerController : UIImagePickerController +- (instancetype)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog; @end diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.mm b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.mm index 78e0f00ab4..79d4ecf83f 100644 --- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.mm +++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosimagepickercontroller.mm @@ -41,15 +41,17 @@ #include "qiosimagepickercontroller.h" -@implementation QIOSImagePickerController +@implementation QIOSImagePickerController { + QIOSFileDialog *m_fileDialog; +} -- (id)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog +- (instancetype)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog { self = [super init]; if (self) { m_fileDialog = fileDialog; - [self setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; - [self setDelegate:self]; + self.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; + self.delegate = self; } return self; } @@ -57,8 +59,8 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { Q_UNUSED(picker); - NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL]; - QUrl fileUrl = QUrl::fromLocalFile(QString::fromNSString([url description])); + NSURL *url = info[UIImagePickerControllerReferenceURL]; + QUrl fileUrl = QUrl::fromLocalFile(QString::fromNSString(url.description)); m_fileDialog->selectedFilesChanged(QList() << fileUrl); emit m_fileDialog->accept(); } diff --git a/src/plugins/platforms/ios/qiosclipboard.mm b/src/plugins/platforms/ios/qiosclipboard.mm index 9a975eadc9..6bdbf94d3f 100644 --- a/src/plugins/platforms/ios/qiosclipboard.mm +++ b/src/plugins/platforms/ios/qiosclipboard.mm @@ -46,11 +46,11 @@ #include @interface UIPasteboard (QUIPasteboard) - + (UIPasteboard *)pasteboardWithQClipboardMode:(QClipboard::Mode)mode; ++ (instancetype)pasteboardWithQClipboardMode:(QClipboard::Mode)mode; @end @implementation UIPasteboard (QUIPasteboard) -+ (UIPasteboard *)pasteboardWithQClipboardMode:(QClipboard::Mode)mode ++ (instancetype)pasteboardWithQClipboardMode:(QClipboard::Mode)mode { NSString *name = (mode == QClipboard::Clipboard) ? UIPasteboardNameGeneral : UIPasteboardNameFind; return [UIPasteboard pasteboardWithName:name create:NO]; @@ -60,17 +60,15 @@ // -------------------------------------------------------------------- @interface QUIClipboard : NSObject -{ -@public +@end + +@implementation QUIClipboard { QIOSClipboard *m_qiosClipboard; NSInteger m_changeCountClipboard; NSInteger m_changeCountFindBuffer; } -@end - -@implementation QUIClipboard -- (id)initWithQIOSClipboard:(QIOSClipboard *)qiosClipboard +- (instancetype)initWithQIOSClipboard:(QIOSClipboard *)qiosClipboard { self = [super init]; if (self) { @@ -149,7 +147,7 @@ QStringList QIOSMimeData::formats() const { QStringList foundMimeTypes; UIPasteboard *pb = [UIPasteboard pasteboardWithQClipboardMode:m_mode]; - NSArray *pasteboardTypes = [pb pasteboardTypes]; + NSArray *pasteboardTypes = [pb pasteboardTypes]; for (NSUInteger i = 0; i < [pasteboardTypes count]; ++i) { QString uti = QString::fromNSString([pasteboardTypes objectAtIndex:i]); @@ -164,7 +162,7 @@ QStringList QIOSMimeData::formats() const QVariant QIOSMimeData::retrieveData(const QString &mimeType, QVariant::Type) const { UIPasteboard *pb = [UIPasteboard pasteboardWithQClipboardMode:m_mode]; - NSArray *pasteboardTypes = [pb pasteboardTypes]; + NSArray *pasteboardTypes = [pb pasteboardTypes]; foreach (QMacInternalPasteboardMime *converter, QMacInternalPasteboardMime::all(QMacInternalPasteboardMime::MIME_ALL)) { @@ -213,12 +211,12 @@ void QIOSClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) UIPasteboard *pb = [UIPasteboard pasteboardWithQClipboardMode:mode]; if (!mimeData) { - pb.items = [NSArray array]; + pb.items = [NSArray *> array]; return; } mimeData->deleteLater(); - NSMutableDictionary *pbItem = [NSMutableDictionary dictionaryWithCapacity:mimeData->formats().size()]; + NSMutableDictionary *pbItem = [NSMutableDictionary dictionaryWithCapacity:mimeData->formats().size()]; foreach (const QString &mimeType, mimeData->formats()) { foreach (QMacInternalPasteboardMime *converter, @@ -246,7 +244,7 @@ void QIOSClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) } } - pb.items = [NSArray arrayWithObject:pbItem]; + pb.items = @[pbItem]; } bool QIOSClipboard::supportsMode(QClipboard::Mode mode) const diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm index a6f6a7aac9..7a2399efcd 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.mm +++ b/src/plugins/platforms/ios/qioseventdispatcher.mm @@ -245,7 +245,7 @@ extern "C" int main(int argc, char *argv[]); static void __attribute__((noinline, noreturn)) user_main_trampoline() { - NSArray *arguments = [[NSProcessInfo processInfo] arguments]; + NSArray *arguments = [[NSProcessInfo processInfo] arguments]; int argc = arguments.count; char **argv = new char*[argc]; diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index 050c592aca..3e22634071 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -67,7 +67,7 @@ static QUIView *focusView() @implementation QIOSLocaleListener -- (id)init +- (instancetype)init { if (self = [super init]) { NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; @@ -95,16 +95,15 @@ static QUIView *focusView() // ------------------------------------------------------------------------- -@interface QIOSKeyboardListener : UIGestureRecognizer { - @private - QT_PREPEND_NAMESPACE(QIOSInputContext) *m_context; -} +@interface QIOSKeyboardListener : UIGestureRecognizer @property BOOL hasDeferredScrollToCursor; @end -@implementation QIOSKeyboardListener +@implementation QIOSKeyboardListener { + QT_PREPEND_NAMESPACE(QIOSInputContext) *m_context; +} -- (id)initWithQIOSInputContext:(QT_PREPEND_NAMESPACE(QIOSInputContext) *)context +- (instancetype)initWithQIOSInputContext:(QT_PREPEND_NAMESPACE(QIOSInputContext) *)context { if (self = [super initWithTarget:self action:@selector(gestureStateChanged:)]) { @@ -574,7 +573,7 @@ void QIOSInputContext::scroll(int y) // Raise all known windows to above the status-bar if we're scrolling the screen, // while keeping the relative window level between the windows the same. - NSArray *applicationWindows = [[UIApplication sharedApplication] windows]; + NSArray *applicationWindows = [[UIApplication sharedApplication] windows]; static QHash originalWindowLevels; for (UIWindow *window in applicationWindows) { if (keyboardScrollIsActive && !originalWindowLevels.contains(window)) diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 92c1e39d72..5f9f7ad96d 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -97,7 +97,7 @@ QIOSIntegration::QIOSIntegration() QDir::setCurrent(QString::fromUtf8([[[NSBundle mainBundle] bundlePath] UTF8String])); UIScreen *mainScreen = [UIScreen mainScreen]; - NSMutableArray *screens = [[[UIScreen screens] mutableCopy] autorelease]; + NSMutableArray *screens = [[[UIScreen screens] mutableCopy] autorelease]; if (![screens containsObject:mainScreen]) { // Fallback for iOS 7.1 (QTBUG-42345) [screens insertObject:mainScreen atIndex:0]; diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm index 6c70676a31..74a77de757 100644 --- a/src/plugins/platforms/ios/qiosmenu.mm +++ b/src/plugins/platforms/ios/qiosmenu.mm @@ -60,14 +60,14 @@ QIOSMenu *QIOSMenu::m_currentMenu = 0; static NSString *const kSelectorPrefix = @"_qtMenuItem_"; -@interface QUIMenuController : UIResponder { - QIOSMenuItemList m_visibleMenuItems; -} +@interface QUIMenuController : UIResponder @end -@implementation QUIMenuController +@implementation QUIMenuController { + QIOSMenuItemList m_visibleMenuItems; +} -- (id)initWithVisibleMenuItems:(const QIOSMenuItemList &)visibleMenuItems +- (instancetype)initWithVisibleMenuItems:(const QIOSMenuItemList &)visibleMenuItems { if (self = [super init]) { [self setVisibleMenuItems:visibleMenuItems]; @@ -80,7 +80,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_"; return self; } --(void)dealloc +- (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self @@ -91,7 +91,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_"; - (void)setVisibleMenuItems:(const QIOSMenuItemList &)visibleMenuItems { m_visibleMenuItems = visibleMenuItems; - NSMutableArray *menuItemArray = [NSMutableArray arrayWithCapacity:m_visibleMenuItems.size()]; + NSMutableArray *menuItemArray = [NSMutableArray arrayWithCapacity:m_visibleMenuItems.size()]; // Create an array of UIMenuItems, one for each visible QIOSMenuItem. Each // UIMenuItem needs a callback assigned, so we assign one of the placeholder methods // added to UIWindow (QIOSMenuActionTargets) below. Each method knows its own index, which @@ -107,7 +107,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_"; [[UIMenuController sharedMenuController] setMenuVisible:YES animated:NO]; } --(void)menuClosed +- (void)menuClosed { QIOSMenu::currentMenu()->dismiss(); } @@ -141,19 +141,19 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_"; // ------------------------------------------------------------------------- -@interface QUIPickerView : UIPickerView { - QIOSMenuItemList m_visibleMenuItems; - QPointer m_focusObjectWithPickerView; - NSInteger m_selectedRow; -} +@interface QUIPickerView : UIPickerView @property(retain) UIToolbar *toolbar; @end -@implementation QUIPickerView +@implementation QUIPickerView { + QIOSMenuItemList m_visibleMenuItems; + QPointer m_focusObjectWithPickerView; + NSInteger m_selectedRow; +} -- (id)initWithVisibleMenuItems:(const QIOSMenuItemList &)visibleMenuItems selectItem:(const QIOSMenuItem *)selectItem +- (instancetype)initWithVisibleMenuItems:(const QIOSMenuItemList &)visibleMenuItems selectItem:(const QIOSMenuItem *)selectItem { if (self = [super init]) { [self setVisibleMenuItems:visibleMenuItems selectItem:selectItem]; @@ -172,7 +172,7 @@ static NSString *const kSelectorPrefix = @"_qtMenuItem_"; UIBarButtonItem *doneButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(closeMenu)] autorelease]; - [self.toolbar setItems:[NSArray arrayWithObjects:cancelButton, spaceButton, doneButton, nil]]; + [self.toolbar setItems:@[cancelButton, spaceButton, doneButton]]; [self setDelegate:self]; [self setDataSource:self]; diff --git a/src/plugins/platforms/ios/qiosoptionalplugininterface.h b/src/plugins/platforms/ios/qiosoptionalplugininterface.h index 660c74e856..bae9e5a0d8 100644 --- a/src/plugins/platforms/ios/qiosoptionalplugininterface.h +++ b/src/plugins/platforms/ios/qiosoptionalplugininterface.h @@ -44,10 +44,10 @@ #include "qiosfiledialog.h" -QT_BEGIN_NAMESPACE - Q_FORWARD_DECLARE_OBJC_CLASS(UIViewController); +QT_BEGIN_NAMESPACE + #define QIosOptionalPluginInterface_iid "org.qt-project.Qt.QPA.ios.optional" class QIosOptionalPluginInterface diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index c394592d76..91d26c88c2 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -130,16 +130,14 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen) // ------------------------------------------------------------------------- -@interface QIOSOrientationListener : NSObject { - @public - QIOSScreen *m_screen; -} -- (id)initWithQIOSScreen:(QIOSScreen *)screen; +@interface QIOSOrientationListener : NSObject @end -@implementation QIOSOrientationListener +@implementation QIOSOrientationListener { + QIOSScreen *m_screen; +} -- (id)initWithQIOSScreen:(QIOSScreen *)screen +- (instancetype)initWithQIOSScreen:(QIOSScreen *)screen { self = [super init]; if (self) { @@ -193,7 +191,7 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen) @implementation QUIWindow -- (id)initWithFrame:(CGRect)frame +- (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) self->_sendingEvent = NO; diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm index fe3c29d037..ff696f5b7f 100644 --- a/src/plugins/platforms/ios/qiostextinputoverlay.mm +++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm @@ -96,7 +96,7 @@ static void executeBlockWithoutAnimation(Block block) @implementation QIOSEditMenu -- (id)init +- (instancetype)init { if (self = [super init]) { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; @@ -160,7 +160,13 @@ static void executeBlockWithoutAnimation(Block block) // ------------------------------------------------------------------------- -@interface QIOSLoupeLayer : CALayer { +@interface QIOSLoupeLayer : CALayer +@property (nonatomic, retain) UIView *targetView; +@property (nonatomic, assign) CGPoint focalPoint; +@property (nonatomic, assign) BOOL visible; +@end + +@implementation QIOSLoupeLayer { UIView *_snapshotView; BOOL _pendingSnapshotUpdate; UIView *_loupeImageView; @@ -168,14 +174,8 @@ static void executeBlockWithoutAnimation(Block block) CGFloat _loupeOffset; QTimer _updateTimer; } -@property (nonatomic, retain) UIView *targetView; -@property (nonatomic, assign) CGPoint focalPoint; -@property (nonatomic, assign) BOOL visible; -@end -@implementation QIOSLoupeLayer - -- (id)initWithSize:(CGSize)size cornerRadius:(CGFloat)cornerRadius bottomOffset:(CGFloat)bottomOffset +- (instancetype)initWithSize:(CGSize)size cornerRadius:(CGFloat)cornerRadius bottomOffset:(CGFloat)bottomOffset { if (self = [super init]) { _loupeOffset = bottomOffset + (size.height / 2); @@ -301,26 +301,22 @@ static void executeBlockWithoutAnimation(Block block) // ------------------------------------------------------------------------- -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) -@interface QIOSHandleLayer : CALayer { -#else -@interface QIOSHandleLayer : CALayer { -#endif - CALayer *_handleCursorLayer; - CALayer *_handleKnobLayer; - Qt::Edge _selectionEdge; -} +@interface QIOSHandleLayer : CALayer @property (nonatomic, assign) CGRect cursorRectangle; @property (nonatomic, assign) CGFloat handleScale; @property (nonatomic, assign) BOOL visible; @property (nonatomic, copy) Block onAnimationDidStop; @end -@implementation QIOSHandleLayer +@implementation QIOSHandleLayer { + CALayer *_handleCursorLayer; + CALayer *_handleKnobLayer; + Qt::Edge _selectionEdge; +} @dynamic handleScale; -- (id)initWithKnobAtEdge:(Qt::Edge)selectionEdge +- (instancetype)initWithKnobAtEdge:(Qt::Edge)selectionEdge { if (self = [super init]) { CGColorRef bgColor = [UIColor colorWithRed:0.1 green:0.4 blue:0.9 alpha:1].CGColor; @@ -355,16 +351,8 @@ static void executeBlockWithoutAnimation(Block block) // The handle should "bounce" in when becoming visible CAKeyframeAnimation * animation = [CAKeyframeAnimation animationWithKeyPath:key]; [animation setDuration:0.5]; - animation.values = [NSArray arrayWithObjects: - [NSNumber numberWithFloat:0], - [NSNumber numberWithFloat:1.3], - [NSNumber numberWithFloat:1.3], - [NSNumber numberWithFloat:1], nil]; - animation.keyTimes = [NSArray arrayWithObjects: - [NSNumber numberWithFloat:0], - [NSNumber numberWithFloat:0.3], - [NSNumber numberWithFloat:0.9], - [NSNumber numberWithFloat:1], nil]; + animation.values = @[@(0.0f), @(1.3f), @(1.3f), @(1.0f)]; + animation.keyTimes = @[@(0.0f), @(0.3f), @(0.9f), @(1.0f)]; return animation; } else { CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:key]; @@ -436,8 +424,13 @@ static void executeBlockWithoutAnimation(Block block) below will inherit. It takes care of creating and showing a magnifier glass depending on the current gesture state. */ -@interface QIOSLoupeRecognizer : UIGestureRecognizer { -@public +@interface QIOSLoupeRecognizer : UIGestureRecognizer +@property (nonatomic, assign) QPointF focalPoint; +@property (nonatomic, assign) BOOL dragTriggersGesture; +@property (nonatomic, readonly) UIView *focusView; +@end + +@implementation QIOSLoupeRecognizer { QIOSLoupeLayer *_loupeLayer; UIView *_desktopView; CGPoint _firstTouchPoint; @@ -445,14 +438,8 @@ static void executeBlockWithoutAnimation(Block block) QTimer _triggerStateBeganTimer; int _originalCursorFlashTime; } -@property (nonatomic, assign) QPointF focalPoint; -@property (nonatomic, assign) BOOL dragTriggersGesture; -@property (nonatomic, readonly) UIView *focusView; -@end -@implementation QIOSLoupeRecognizer - -- (id)init +- (instancetype)init { if (self = [super initWithTarget:self action:@selector(gestureStateChanged)]) { self.enabled = NO; @@ -657,7 +644,10 @@ static void executeBlockWithoutAnimation(Block block) on the sides. If the user starts dragging on a handle (or do a press and hold), it will show a magnifier glass that follows the handle as it moves. */ -@interface QIOSSelectionRecognizer : QIOSLoupeRecognizer { +@interface QIOSSelectionRecognizer : QIOSLoupeRecognizer +@end + +@implementation QIOSSelectionRecognizer { CALayer *_clipRectLayer; QIOSHandleLayer *_cursorLayer; QIOSHandleLayer *_anchorLayer; @@ -669,11 +659,8 @@ static void executeBlockWithoutAnimation(Block block) QMetaObject::Connection _anchorConnection; QMetaObject::Connection _clipRectConnection; } -@end - -@implementation QIOSSelectionRecognizer -- (id)init +- (instancetype)init { if (self = [super init]) { self.delaysTouchesBegan = YES; @@ -889,15 +876,15 @@ static void executeBlockWithoutAnimation(Block block) visibility of the edit menu will be toggled. Otherwise, if there's a selection, a first tap will close the edit menu (if any), and a second tap will remove the selection. */ -@interface QIOSTapRecognizer : UITapGestureRecognizer { +@interface QIOSTapRecognizer : UITapGestureRecognizer +@end + +@implementation QIOSTapRecognizer { int _cursorPosOnPress; UIView *_focusView; } -@end - -@implementation QIOSTapRecognizer -- (id)init +- (instancetype)init { if (self = [super initWithTarget:self action:@selector(gestureStateChanged)]) { self.enabled = NO; diff --git a/src/plugins/platforms/ios/qiostextresponder.h b/src/plugins/platforms/ios/qiostextresponder.h index 77be2cf2fe..074598c1c3 100644 --- a/src/plugins/platforms/ios/qiostextresponder.h +++ b/src/plugins/platforms/ios/qiostextresponder.h @@ -49,16 +49,8 @@ class QIOSInputContext; QT_END_NAMESPACE @interface QIOSTextInputResponder : UIResponder -{ - @private - QT_PREPEND_NAMESPACE(QIOSInputContext) *m_inputContext; - QT_PREPEND_NAMESPACE(QInputMethodQueryEvent) *m_configuredImeState; - QString m_markedText; - BOOL m_inSendEventToFocusObject; - BOOL m_inSelectionChange; -} -- (id)initWithInputContext:(QT_PREPEND_NAMESPACE(QIOSInputContext) *)context; +- (instancetype)initWithInputContext:(QT_PREPEND_NAMESPACE(QIOSInputContext) *)context; - (BOOL)needsKeyboardReconfigure:(Qt::InputMethodQueries)updatedProperties; - (void)notifyInputDelegate:(Qt::InputMethodQueries)updatedProperties; diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index b029c49a67..91a088ede1 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -55,13 +55,13 @@ @interface QUITextPosition : UITextPosition @property (nonatomic) NSUInteger index; -+ (QUITextPosition *)positionWithIndex:(NSUInteger)index; ++ (instancetype)positionWithIndex:(NSUInteger)index; @end @implementation QUITextPosition -+ (QUITextPosition *)positionWithIndex:(NSUInteger)index ++ (instancetype)positionWithIndex:(NSUInteger)index { QUITextPosition *pos = [[QUITextPosition alloc] init]; pos.index = index; @@ -75,15 +75,15 @@ @interface QUITextRange : UITextRange @property (nonatomic) NSRange range; -+ (QUITextRange *)rangeWithNSRange:(NSRange)range; ++ (instancetype)rangeWithNSRange:(NSRange)range; @end @implementation QUITextRange -+ (QUITextRange *)rangeWithNSRange:(NSRange)nsrange ++ (instancetype)rangeWithNSRange:(NSRange)nsrange { - QUITextRange *range = [[QUITextRange alloc] init]; + QUITextRange *range = [[self alloc] init]; range.range = nsrange; return [range autorelease]; } @@ -117,7 +117,7 @@ @implementation WrapperView -- (id)initWithView:(UIView *)view +- (instancetype)initWithView:(UIView *)view { if (self = [self init]) { [self addSubview:view]; @@ -132,7 +132,7 @@ - (void)layoutSubviews { - UIView* view = [self.subviews firstObject]; + UIView *view = [self.subviews firstObject]; view.frame = self.bounds; // FIXME: During orientation changes the size and position @@ -161,9 +161,15 @@ // ------------------------------------------------------------------------- -@implementation QIOSTextInputResponder +@implementation QIOSTextInputResponder { + QT_PREPEND_NAMESPACE(QIOSInputContext) *m_inputContext; + QT_PREPEND_NAMESPACE(QInputMethodQueryEvent) *m_configuredImeState; + QString m_markedText; + BOOL m_inSendEventToFocusObject; + BOOL m_inSelectionChange; +} -- (id)initWithInputContext:(QT_PREPEND_NAMESPACE(QIOSInputContext) *)inputContext +- (instancetype)initWithInputContext:(QT_PREPEND_NAMESPACE(QIOSInputContext) *)inputContext { if (!(self = [self init])) return self; @@ -548,7 +554,7 @@ [self sendKeyPressRelease:key modifiers:modifiers]; } -- (void)addKeyCommandsToArray:(NSMutableArray *)array key:(NSString *)key +- (void)addKeyCommandsToArray:(NSMutableArray *)array key:(NSString *)key { SEL s = @selector(keyCommandTriggered:); [array addObject:[UIKeyCommand keyCommandWithInput:key modifierFlags:0 action:s]]; @@ -559,19 +565,19 @@ [array addObject:[UIKeyCommand keyCommandWithInput:key modifierFlags:UIKeyModifierCommand|UIKeyModifierShift action:s]]; } -- (NSArray *)keyCommands +- (NSArray *)keyCommands { // Since keyCommands is called for every key // press/release, we cache the result static dispatch_once_t once; - static NSMutableArray *array; + static NSMutableArray *array; dispatch_once(&once, ^{ // We let Qt move the cursor around when the arrow keys are being used. This // is normally implemented through UITextInput, but since IM in Qt have poor // support for moving the cursor vertically, and even less support for selecting // text across multiple paragraphs, we do this through key events. - array = [NSMutableArray new]; + array = [NSMutableArray new]; [self addKeyCommandsToArray:array key:UIKeyInputUpArrow]; [self addKeyCommandsToArray:array key:UIKeyInputDownArrow]; [self addKeyCommandsToArray:array key:UIKeyInputLeftArrow]; @@ -825,13 +831,13 @@ return startRect.united(endRect).toCGRect(); } -- (NSArray *)selectionRectsForRange:(UITextRange *)range +- (NSArray *)selectionRectsForRange:(UITextRange *)range { Q_UNUSED(range); // This method is supposed to return a rectangle for each line with selection. Since we don't // expose an API in Qt/IM for getting this information, and since we never seems to be getting // a call from UIKit for this, we return an empty array until a need arise. - return [[NSArray new] autorelease]; + return [[NSArray new] autorelease]; } - (CGRect)caretRectForPosition:(UITextPosition *)position @@ -916,7 +922,7 @@ QObject *focusObject = QGuiApplication::focusObject(); if (!focusObject) - return [NSDictionary dictionary]; + return @{}; // Assume position is the same as the cursor for now. QInputMethodQueryEvent with Qt::ImFont // needs to be extended to take an extra position argument before this can be fully correct. @@ -925,8 +931,8 @@ QFont qfont = qvariant_cast(e.value(Qt::ImFont)); UIFont *uifont = [UIFont fontWithName:qfont.family().toNSString() size:qfont.pointSize()]; if (!uifont) - return [NSDictionary dictionary]; - return [NSDictionary dictionaryWithObject:uifont forKey:NSFontAttributeName]; + return @{}; + return @{NSFontAttributeName: uifont}; } #endif diff --git a/src/plugins/platforms/ios/qiosviewcontroller.h b/src/plugins/platforms/ios/qiosviewcontroller.h index 07d5535e1a..7af4c83b48 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.h +++ b/src/plugins/platforms/ios/qiosviewcontroller.h @@ -48,7 +48,7 @@ QT_END_NAMESPACE @interface QIOSViewController : UIViewController -- (id)initWithQIOSScreen:(QT_PREPEND_NAMESPACE(QIOSScreen) *)screen; +- (instancetype)initWithQIOSScreen:(QT_PREPEND_NAMESPACE(QIOSScreen) *)screen; - (void)updateProperties; #ifndef Q_OS_TVOS diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index a7663b9e94..787c6b8409 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -56,12 +56,8 @@ // ------------------------------------------------------------------------- -@interface QIOSViewController () { - @public - QPointer m_screen; - BOOL m_updatingProperties; - QMetaObject::Connection m_focusWindowChangeConnection; -} +@interface QIOSViewController () +@property (nonatomic, assign) QPointer platformScreen; @property (nonatomic, assign) BOOL changingOrientation; @end @@ -72,7 +68,7 @@ @implementation QIOSDesktopManagerView -- (id)init +- (instancetype)init { if (!(self = [super init])) return nil; @@ -125,7 +121,7 @@ { Q_UNUSED(subview); - QT_PREPEND_NAMESPACE(QIOSScreen) *screen = self.qtViewController->m_screen; + QT_PREPEND_NAMESPACE(QIOSScreen) *screen = self.qtViewController.platformScreen; // The 'window' property of our view is not valid until the window // has been shown, so we have to access it through the QIOSScreen. @@ -170,7 +166,7 @@ // here. iOS will still use the latest rendered frame to create the // application switcher thumbnail, but it will be based on the last // active orientation of the application. - QIOSScreen *screen = self.qtViewController->m_screen; + QIOSScreen *screen = self.qtViewController.platformScreen; qCDebug(lcQpaWindow) << "ignoring layout of subviews while suspended," << "likely system snapshot of" << screen->screen()->primaryOrientation(); return; @@ -246,7 +242,10 @@ // ------------------------------------------------------------------------- -@implementation QIOSViewController +@implementation QIOSViewController { + BOOL m_updatingProperties; + QMetaObject::Connection m_focusWindowChangeConnection; +} #ifndef Q_OS_TVOS @synthesize prefersStatusBarHidden; @@ -254,11 +253,10 @@ @synthesize preferredStatusBarStyle; #endif -- (id)initWithQIOSScreen:(QT_PREPEND_NAMESPACE(QIOSScreen) *)screen +- (instancetype)initWithQIOSScreen:(QT_PREPEND_NAMESPACE(QIOSScreen) *)screen { if (self = [self init]) { - m_screen = screen; - + self.platformScreen = screen; self.changingOrientation = NO; #ifndef Q_OS_TVOS @@ -316,7 +314,7 @@ - (BOOL)shouldAutorotate { #ifndef Q_OS_TVOS - return m_screen && m_screen->uiScreen() == [UIScreen mainScreen] && !self.lockedOrientation; + return self.platformScreen && self.platformScreen->uiScreen() == [UIScreen mainScreen] && !self.lockedOrientation; #else return NO; #endif @@ -396,8 +394,8 @@ if (!QCoreApplication::instance()) return; - if (m_screen) - m_screen->updateProperties(); + if (self.platformScreen) + self.platformScreen->updateProperties(); } // ------------------------------------------------------------------------- @@ -407,12 +405,12 @@ if (!isQtApplication()) return; - if (!m_screen || !m_screen->screen()) + if (!self.platformScreen || !self.platformScreen->screen()) return; // For now we only care about the main screen, as both the statusbar // visibility and orientation is only appropriate for the main screen. - if (m_screen->uiScreen() != [UIScreen mainScreen]) + if (self.platformScreen->uiScreen() != [UIScreen mainScreen]) return; // Prevent recursion caused by updating the status bar appearance (position @@ -434,7 +432,7 @@ return; // We only care about changes to focusWindow that involves our screen - if (!focusWindow->screen() || focusWindow->screen()->handle() != m_screen) + if (!focusWindow->screen() || focusWindow->screen()->handle() != self.platformScreen) return; // All decisions are based on the the top level window diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 6ee258e363..cdec57de71 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -96,7 +96,7 @@ QIOSWindow::~QIOSWindow() [m_view touchesCancelled:[NSSet set] withEvent:0]; clearAccessibleCache(); - m_view->m_qioswindow = 0; + m_view.platformWindow = 0; [m_view removeFromSuperview]; [m_view release]; } @@ -139,7 +139,7 @@ void QIOSWindow::setVisible(bool visible) } else if (!visible && [m_view isActiveWindow]) { // Our window was active/focus window but now hidden, so relinquish // focus to the next possible window in the stack. - NSArray *subviews = m_view.viewController.view.subviews; + NSArray *subviews = m_view.viewController.view.subviews; for (int i = int(subviews.count) - 1; i >= 0; --i) { UIView *view = [subviews objectAtIndex:i]; if (view.hidden) @@ -301,7 +301,7 @@ void QIOSWindow::raiseOrLower(bool raise) if (!isQtApplication()) return; - NSArray *subviews = m_view.superview.subviews; + NSArray *subviews = m_view.superview.subviews; if (subviews.count == 1) return; diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.h b/src/plugins/platforms/ios/quiaccessibilityelement.h index 03abf5407e..6b8efdcede 100644 --- a/src/plugins/platforms/ios/quiaccessibilityelement.h +++ b/src/plugins/platforms/ios/quiaccessibilityelement.h @@ -45,13 +45,12 @@ #ifndef QT_NO_ACCESSIBILITY -@interface QMacAccessibilityElement : UIAccessibilityElement -{} +@interface QT_MANGLE_NAMESPACE(QMacAccessibilityElement) : UIAccessibilityElement @property (readonly) QAccessible::Id axid; -- (id)initWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view; -+ (QMacAccessibilityElement *)elementWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view; +- (instancetype)initWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view; ++ (instancetype)elementWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view; @end diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.mm b/src/plugins/platforms/ios/quiaccessibilityelement.mm index a26ba61b3c..3154536aad 100644 --- a/src/plugins/platforms/ios/quiaccessibilityelement.mm +++ b/src/plugins/platforms/ios/quiaccessibilityelement.mm @@ -42,20 +42,23 @@ #ifndef QT_NO_ACCESSIBILITY #include "private/qaccessiblecache_p.h" +#include "private/qcore_mac_p.h" + +QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAccessibilityElement); @implementation QMacAccessibilityElement -- (id)initWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view +- (instancetype)initWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view { Q_ASSERT((int)anId < 0); - self = [super initWithAccessibilityContainer: view]; + self = [super initWithAccessibilityContainer:view]; if (self) _axid = anId; return self; } -+ (id)elementWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view ++ (instancetype)elementWithId:(QAccessible::Id)anId withAccessibilityContainer:(id)view { Q_ASSERT(anId); if (!anId) @@ -63,10 +66,10 @@ QAccessibleCache *cache = QAccessibleCache::instance(); - QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *element = cache->elementForId(anId); + QMacAccessibilityElement *element = cache->elementForId(anId); if (!element) { Q_ASSERT(QAccessible::accessibleInterface(anId)); - element = [[self alloc] initWithId:anId withAccessibilityContainer: view]; + element = [[self alloc] initWithId:anId withAccessibilityContainer:view]; cache->insertElement(anId, element); } return element; diff --git a/src/plugins/platforms/ios/quiview.h b/src/plugins/platforms/ios/quiview.h index 3e3c579075..e1d5d5af0c 100644 --- a/src/plugins/platforms/ios/quiview.h +++ b/src/plugins/platforms/ios/quiview.h @@ -53,21 +53,10 @@ QT_END_NAMESPACE @class QIOSViewController; @interface QUIView : UIView -{ - @public - QT_PREPEND_NAMESPACE(QIOSWindow) *m_qioswindow; - @private - QHash m_activeTouches; - UITouch *m_activePencilTouch; - int m_nextTouchId; - - @private - NSMutableArray *m_accessibleElements; -}; - -- (id)initWithQIOSWindow:(QT_PREPEND_NAMESPACE(QIOSWindow) *)window; +- (instancetype)initWithQIOSWindow:(QT_PREPEND_NAMESPACE(QIOSWindow) *)window; - (void)sendUpdatedExposeEvent; - (BOOL)isActiveWindow; +@property (nonatomic, assign) QT_PREPEND_NAMESPACE(QIOSWindow) *platformWindow; @end @interface QUIView (Accessibility) diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 584dfe9b41..53a4485609 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -55,7 +55,12 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") -@implementation QUIView +@implementation QUIView { + QHash m_activeTouches; + UITouch *m_activePencilTouch; + int m_nextTouchId; + NSMutableArray *m_accessibleElements; +} + (void)load { @@ -82,25 +87,26 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") return [CAEAGLLayer class]; } -- (id)initWithQIOSWindow:(QT_PREPEND_NAMESPACE(QIOSWindow) *)window +- (instancetype)initWithQIOSWindow:(QT_PREPEND_NAMESPACE(QIOSWindow) *)window { if (self = [self initWithFrame:window->geometry().toCGRect()]) { - m_qioswindow = window; - m_accessibleElements = [[NSMutableArray alloc] init]; + self.platformWindow = window; + m_accessibleElements = [[NSMutableArray alloc] init]; } return self; } -- (id)initWithFrame:(CGRect)frame +- (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { // Set up EAGL layer CAEAGLLayer *eaglLayer = static_cast(self.layer); eaglLayer.opaque = TRUE; - eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:YES], kEAGLDrawablePropertyRetainedBacking, - kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; + eaglLayer.drawableProperties = @{ + kEAGLDrawablePropertyRetainedBacking: @(YES), + kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8 + }; if (isQtApplication()) self.hidden = YES; @@ -156,7 +162,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") #ifndef QT_NO_DEBUG_STREAM QString platformWindowDescription; QDebug debug(&platformWindowDescription); - debug.nospace() << "; " << m_qioswindow << ">"; + debug.nospace() << "; " << self.platformWindow << ">"; NSRange lastCharacter = [description rangeOfComposedCharacterSequenceAtIndex:description.length - 1]; [description replaceCharactersInRange:lastCharacter withString:platformWindowDescription.toNSString()]; #endif @@ -210,10 +216,10 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") if (!CGAffineTransformIsIdentity(self.transform)) qWarning() << self << "has a transform set. This is not supported."; - QWindow *window = m_qioswindow->window(); + QWindow *window = self.platformWindow->window(); QRect lastReportedGeometry = qt_window_private(window)->geometry; QRect currentGeometry = QRectF::fromCGRect(self.frame).toRect(); - qCDebug(lcQpaWindow) << m_qioswindow << "new geometry is" << currentGeometry; + qCDebug(lcQpaWindow) << self.platformWindow << "new geometry is" << currentGeometry; QWindowSystemInterface::handleGeometryChange(window, currentGeometry); if (currentGeometry.size() != lastReportedGeometry.size()) { @@ -237,29 +243,29 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") { QRegion region; - if (m_qioswindow->isExposed()) { + if (self.platformWindow->isExposed()) { QSize bounds = QRectF::fromCGRect(self.layer.bounds).toRect().size(); - Q_ASSERT(m_qioswindow->geometry().size() == bounds); - Q_ASSERT(self.hidden == !m_qioswindow->window()->isVisible()); + Q_ASSERT(self.platformWindow->geometry().size() == bounds); + Q_ASSERT(self.hidden == !self.platformWindow->window()->isVisible()); region = QRect(QPoint(), bounds); } - qCDebug(lcQpaWindow) << m_qioswindow << region << "isExposed" << m_qioswindow->isExposed(); - QWindowSystemInterface::handleExposeEvent(m_qioswindow->window(), region); + qCDebug(lcQpaWindow) << self.platformWindow << region << "isExposed" << self.platformWindow->isExposed(); + QWindowSystemInterface::handleExposeEvent(self.platformWindow->window(), region); } - (void)safeAreaInsetsDidChange { - QWindowSystemInterface::handleSafeAreaMarginsChanged(m_qioswindow->window()); + QWindowSystemInterface::handleSafeAreaMarginsChanged(self.platformWindow->window()); } // ------------------------------------------------------------------------- - (BOOL)canBecomeFirstResponder { - return !(m_qioswindow->window()->flags() & Qt::WindowDoesNotAcceptFocus); + return !(self.platformWindow->window()->flags() & Qt::WindowDoesNotAcceptFocus); } - (BOOL)becomeFirstResponder @@ -280,10 +286,10 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") qImDebug() << self << "became first responder"; } - if (qGuiApp->focusWindow() != m_qioswindow->window()) - QWindowSystemInterface::handleWindowActivated(m_qioswindow->window()); + if (qGuiApp->focusWindow() != self.platformWindow->window()) + QWindowSystemInterface::handleWindowActivated(self.platformWindow->window()); else - qImDebug() << m_qioswindow->window() << "already active, not sending window activation"; + qImDebug() << self.platformWindow->window() << "already active, not sending window activation"; return YES; } @@ -361,7 +367,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") -(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { - if (m_qioswindow->window()->flags() & Qt::WindowTransparentForInput) + if (self.platformWindow->window()->flags() & Qt::WindowTransparentForInput) return NO; return [super pointInside:point withEvent:event]; } @@ -378,7 +384,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") for (UITouch *cTouch in cTouches) { QPointF localViewPosition = QPointF::fromCGPoint([cTouch preciseLocationInView:self]); QPoint localViewPositionI = localViewPosition.toPoint(); - QPointF globalScreenPosition = m_qioswindow->mapToGlobal(localViewPositionI) + + QPointF globalScreenPosition = self.platformWindow->mapToGlobal(localViewPositionI) + (localViewPosition - localViewPositionI); qreal pressure = cTouch.force / cTouch.maximumPossibleForce; // azimuth unit vector: +x to the right, +y going downwards @@ -391,7 +397,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") qCDebug(lcQpaTablet) << i << ":" << timeStamp << localViewPosition << pressure << state << "azimuth" << azimuth.dx << azimuth.dy << "angle" << azimuthAngle << "altitude" << cTouch.altitudeAngle << "xTilt" << qBound(-60.0, altitudeAngle * azimuth.dx, 60.0) << "yTilt" << qBound(-60.0, altitudeAngle * azimuth.dy, 60.0); - QWindowSystemInterface::handleTabletEvent(m_qioswindow->window(), timeStamp, localViewPosition, globalScreenPosition, + QWindowSystemInterface::handleTabletEvent(self.platformWindow->window(), timeStamp, localViewPosition, globalScreenPosition, // device, pointerType, buttons QTabletEvent::RotationStylus, QTabletEvent::Pen, state == Qt::TouchPointReleased ? Qt::NoButton : Qt::LeftButton, // pressure, xTilt, yTilt @@ -415,12 +421,12 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") // just map from the local view position to global coordinates. // tvOS: all touches start at the center of the screen and move from there. QPoint localViewPosition = QPointF::fromCGPoint([uiTouch locationInView:self]).toPoint(); - QPoint globalScreenPosition = m_qioswindow->mapToGlobal(localViewPosition); + QPoint globalScreenPosition = self.platformWindow->mapToGlobal(localViewPosition); touchPoint.area = QRectF(globalScreenPosition, QSize(0, 0)); // FIXME: Do we really need to support QTouchDevice::NormalizedPosition? - QSize screenSize = m_qioswindow->screen()->geometry().size(); + QSize screenSize = self.platformWindow->screen()->geometry().size(); touchPoint.normalPosition = QPointF(globalScreenPosition.x() / screenSize.width(), globalScreenPosition.y() / screenSize.height()); @@ -439,7 +445,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") } if (m_activeTouches.isEmpty()) return; - QWindowSystemInterface::handleTouchEvent(m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values()); + QWindowSystemInterface::handleTouchEvent(self.platformWindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values()); if (!static_cast(self.window).sendingEvent) { // The event is likely delivered as part of delayed touch delivery, via // _UIGestureEnvironmentSortAndSendDelayedTouches, due to one of the two @@ -450,10 +456,10 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") // alert dialog, will fail to recognize. To be on the safe side, we deliver // the event asynchronously. QWindowSystemInterface::handleTouchEvent( - m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values()); + self.platformWindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values()); } else { QWindowSystemInterface::handleTouchEvent( - m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values()); + self.platformWindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values()); } } @@ -481,8 +487,8 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") #endif } - if (m_qioswindow->shouldAutoActivateWindow() && m_activeTouches.size() == 1) { - QPlatformWindow *topLevel = m_qioswindow; + if (self.platformWindow->shouldAutoActivateWindow() && m_activeTouches.size() == 1) { + QPlatformWindow *topLevel = self.platformWindow; while (QPlatformWindow *p = topLevel->parent()) topLevel = p; if (topLevel->window() != QGuiApplication::focusWindow()) @@ -552,7 +558,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") NSTimeInterval timestamp = event ? event.timestamp : [[NSProcessInfo processInfo] systemUptime]; QIOSIntegration *iosIntegration = static_cast(QGuiApplicationPrivate::platformIntegration()); - QWindowSystemInterface::handleTouchCancelEvent(m_qioswindow->window(), ulong(timestamp * 1000), iosIntegration->touchDevice()); + QWindowSystemInterface::handleTouchCancelEvent(self.platformWindow->window(), ulong(timestamp * 1000), iosIntegration->touchDevice()); } - (int)mapPressTypeToKey:(UIPress*)press @@ -580,7 +586,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") int key = [self mapPressTypeToKey:press]; if (key == Qt::Key_unknown) continue; - if (QWindowSystemInterface::handleKeyEvent(m_qioswindow->window(), type, key, Qt::NoModifier)) + if (QWindowSystemInterface::handleKeyEvent(self.platformWindow->window(), type, key, Qt::NoModifier)) handled = true; } @@ -634,7 +640,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") - (QWindow *)qwindow { if ([self isKindOfClass:[QUIView class]]) { - if (QT_PREPEND_NAMESPACE(QIOSWindow) *w = static_cast(self)->m_qioswindow) + if (QT_PREPEND_NAMESPACE(QIOSWindow) *w = static_cast(self).platformWindow) return w->window(); } return nil; diff --git a/src/plugins/platforms/ios/quiview_accessibility.mm b/src/plugins/platforms/ios/quiview_accessibility.mm index 69a4d375bd..a3f4156a59 100644 --- a/src/plugins/platforms/ios/quiview_accessibility.mm +++ b/src/plugins/platforms/ios/quiview_accessibility.mm @@ -49,8 +49,9 @@ if (!iface || iface->state().invisible || (iface->text(QAccessible::Name).isEmpty() && iface->text(QAccessible::Value).isEmpty() && iface->text(QAccessible::Description).isEmpty())) return; QAccessible::Id accessibleId = QAccessible::uniqueId(iface); - UIAccessibilityElement *elem = [[QMacAccessibilityElement alloc] initWithId: accessibleId withAccessibilityContainer: self]; - [m_accessibleElements addObject:[elem autorelease]]; + UIAccessibilityElement *elem = [[QT_MANGLE_NAMESPACE(QMacAccessibilityElement) alloc] initWithId:accessibleId withAccessibilityContainer:self]; + [m_accessibleElements addObject:elem]; + [elem release]; } - (void)createAccessibleContainer:(QAccessibleInterface *)iface @@ -73,7 +74,7 @@ if ([m_accessibleElements count]) return; - QWindow *win = m_qioswindow->window(); + QWindow *win = self.platformWindow->window(); QAccessibleInterface *iface = win->accessibleRoot(); if (iface) [self createAccessibleContainer: iface]; -- cgit v1.2.3