src/gui/util/qsystemtrayicon_mac.mm
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
--- a/src/gui/util/qsystemtrayicon_mac.mm	Tue Jan 26 12:42:25 2010 +0200
+++ b/src/gui/util/qsystemtrayicon_mac.mm	Tue Feb 02 00:43:10 2010 +0200
@@ -314,8 +314,22 @@
 {
     Q_UNUSED(notification);
     down = NO;
+
+    if( ![self icon]->icon().isNull() ) {
+#ifndef QT_MAC_USE_COCOA
+        const short scale = GetMBarHeight()-4;
+#else
+        CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
+        const short scale = hgt - 4;
+#endif
+        NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale))));
+        [self setImage: nsimage];
+        [nsimage release];
+    }
+
     if([self icon]->contextMenu())
         [self icon]->contextMenu()->hide();
+
     [self setNeedsDisplay:YES];
 }
 
@@ -327,6 +341,20 @@
         [self icon]->contextMenu()->hide();
     [self setNeedsDisplay:YES];
 
+#ifndef QT_MAC_USE_COCOA
+    const short scale = GetMBarHeight()-4;
+#else
+    CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
+    const short scale = hgt - 4;
+#endif
+
+    if( down && ![self icon]->icon().isNull() ) {
+        NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage([self icon]->icon().pixmap(QSize(scale, scale), QIcon::Selected)));
+        [self setImage: nsaltimage];
+        [nsaltimage release];
+    }
+
+
     if (down)
         [parent triggerSelector:self];
     else if ((clickCount%2))