From fb67ac6368aeb9547cc78551708e4ed0d9e4bbfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 12 Dec 2018 13:52:52 +0100 Subject: Modernize QNSImageView implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use Objc properties instead of instance variables. Change-Id: I4bddf2c9c824467d7c42dd5bb0c3b4aacd6b27be Reviewed-by: Tor Arne Vestbø --- .../platforms/cocoa/qcocoasystemtrayicon.mm | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index 0158895441..3a7ac60424 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -105,6 +105,8 @@ QT_USE_NAMESPACE @end @interface QT_MANGLE_NAMESPACE(QNSImageView) : NSImageView +@property (nonatomic, assign) BOOL down; +@property (nonatomic, assign) QT_MANGLE_NAMESPACE(QNSStatusItem) *parent; @end QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSStatusItem); @@ -277,36 +279,32 @@ QT_END_NAMESPACE @implementation NSStatusItem (Qt) @end -@implementation QNSImageView { - BOOL down; - QT_MANGLE_NAMESPACE(QNSStatusItem) *parent; -} - +@implementation QNSImageView - (instancetype)initWithParent:(QNSStatusItem *)myParent { self = [super init]; - parent = myParent; - down = NO; + self.parent = myParent; + self.down = NO; return self; } - (void)menuTrackingDone:(NSNotification *)__unused notification { - down = NO; + self.down = NO; [self setNeedsDisplay:YES]; } - (void)mousePressed:(NSEvent *)mouseEvent { - down = YES; + self.down = YES; int clickCount = [mouseEvent clickCount]; [self setNeedsDisplay:YES]; if (clickCount == 2) { [self menuTrackingDone:nil]; - [parent doubleClickSelector:self]; + [self.parent doubleClickSelector:self]; } else { - [parent triggerSelector:self button:cocoaButton2QtButton(mouseEvent)]; + [self.parent triggerSelector:self button:cocoaButton2QtButton(mouseEvent)]; } } @@ -344,7 +342,7 @@ QT_END_NAMESPACE } - (void)drawRect:(NSRect)rect { - [[parent item] drawStatusBarBackgroundInRect:rect withHighlight:down]; + [[self.parent item] drawStatusBarBackgroundInRect:rect withHighlight:self.down]; [super drawRect:rect]; } @end -- cgit v1.2.3