Modernize QNSImageView implementation
Use Objc properties instead of instance variables. Change-Id: I4bddf2c9c824467d7c42dd5bb0c3b4aacd6b27be Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>bb10
parent
69f7115c43
commit
fb67ac6368
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue