src/gui/util/qsystemtrayicon_mac.mm
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
child 18 2f34d5167611
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   312 
   312 
   313 -(void)menuTrackingDone:(NSNotification*)notification
   313 -(void)menuTrackingDone:(NSNotification*)notification
   314 {
   314 {
   315     Q_UNUSED(notification);
   315     Q_UNUSED(notification);
   316     down = NO;
   316     down = NO;
       
   317 
       
   318     if( ![self icon]->icon().isNull() ) {
       
   319 #ifndef QT_MAC_USE_COCOA
       
   320         const short scale = GetMBarHeight()-4;
       
   321 #else
       
   322         CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
       
   323         const short scale = hgt - 4;
       
   324 #endif
       
   325         NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale))));
       
   326         [self setImage: nsimage];
       
   327         [nsimage release];
       
   328     }
       
   329 
   317     if([self icon]->contextMenu())
   330     if([self icon]->contextMenu())
   318         [self icon]->contextMenu()->hide();
   331         [self icon]->contextMenu()->hide();
       
   332 
   319     [self setNeedsDisplay:YES];
   333     [self setNeedsDisplay:YES];
   320 }
   334 }
   321 
   335 
   322 -(void)mousePressed:(NSEvent *)mouseEvent
   336 -(void)mousePressed:(NSEvent *)mouseEvent
   323 {
   337 {
   324     int clickCount = [mouseEvent clickCount];
   338     int clickCount = [mouseEvent clickCount];
   325     down = !down;
   339     down = !down;
   326     if(!down && [self icon]->contextMenu())
   340     if(!down && [self icon]->contextMenu())
   327         [self icon]->contextMenu()->hide();
   341         [self icon]->contextMenu()->hide();
   328     [self setNeedsDisplay:YES];
   342     [self setNeedsDisplay:YES];
       
   343 
       
   344 #ifndef QT_MAC_USE_COCOA
       
   345     const short scale = GetMBarHeight()-4;
       
   346 #else
       
   347     CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
       
   348     const short scale = hgt - 4;
       
   349 #endif
       
   350 
       
   351     if( down && ![self icon]->icon().isNull() ) {
       
   352         NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale), QIcon::Selected)));
       
   353         [self setImage: nsaltimage];
       
   354         [nsaltimage release];
       
   355     }
       
   356 
   329 
   357 
   330     if (down)
   358     if (down)
   331         [parent triggerSelector:self];
   359         [parent triggerSelector:self];
   332     else if ((clickCount%2))
   360     else if ((clickCount%2))
   333         [parent doubleClickSelector:self];
   361         [parent doubleClickSelector:self];