diff options
author | Andy Shaw <andy.shaw@digia.com> | 2015-04-08 13:09:10 +0200 |
---|---|---|
committer | Andy Shaw <andy.shaw@digia.com> | 2015-04-10 10:10:25 +0000 |
commit | 34ec0713bb5a2bc12782ab17ceabfead37c4b584 (patch) | |
tree | 8fccfe0caa8627c6afff7c5176ce6b3dd17d52e6 /src/plugins/platforms/cocoa/qcocoaintegration.mm | |
parent | b59521f2a40fab1205e7cec1c99c8c109f98021a (diff) |
Add a means to set the application icon where supported
On OS X the application icon can be changed at runtime, so this adds a way
to set this via the QPlatformIntegration.
[ChangeLog][OS X] QApplication::setWindowIcon now changes the icon for the
application in the dock.
Task-number: QTBUG-43999
Change-Id: Ice298c0bd52f10f4866f37c6d3f20cf5419b7a1b
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaintegration.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.mm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index aa33cfd8bc..c8f6dd05db 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -420,6 +420,7 @@ bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) cons case ForeignWindows: case RasterGLSurface: case ApplicationState: + case ApplicationIcon: return true; default: return QPlatformIntegration::hasCapability(cap); @@ -569,4 +570,16 @@ QList<QCocoaWindow *> *QCocoaIntegration::popupWindowStack() return &m_popupWindowStack; } +void QCocoaIntegration::setApplicationIcon(const QIcon &icon) const +{ + NSImage *image = nil; + if (!icon.isNull()) { + NSSize size = [[[NSApplication sharedApplication] dockTile] size]; + QPixmap pixmap = icon.pixmap(size.width, size.height); + image = static_cast<NSImage *>(qt_mac_create_nsimage(pixmap)); + } + [[NSApplication sharedApplication] setApplicationIconImage:image]; + [image release]; +} + QT_END_NAMESPACE |