|
|
@ -6,7 +6,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include <QImageWriter> |
|
|
|
#include <QImageWriter> |
|
|
|
#include <QMenu> |
|
|
|
#include <QMenu> |
|
|
|
#include <QTemporaryFile> |
|
|
|
#include <QBuffer> |
|
|
|
#include <QWidget> |
|
|
|
#include <QWidget> |
|
|
|
|
|
|
|
|
|
|
|
#undef slots |
|
|
|
#undef slots |
|
|
@ -95,14 +95,14 @@ void MacDockIconHandler::setIcon(const QIcon &icon) |
|
|
|
QSize size = icon.actualSize(QSize(128, 128)); |
|
|
|
QSize size = icon.actualSize(QSize(128, 128)); |
|
|
|
QPixmap pixmap = icon.pixmap(size); |
|
|
|
QPixmap pixmap = icon.pixmap(size); |
|
|
|
|
|
|
|
|
|
|
|
// write temp file hack (could also be done through QIODevice [memory]) |
|
|
|
// Write image into a R/W buffer from raw pixmap, then save the image. |
|
|
|
QTemporaryFile notificationIconFile; |
|
|
|
QBuffer notificationBuffer; |
|
|
|
if (!pixmap.isNull() && notificationIconFile.open()) { |
|
|
|
if (!pixmap.isNull() && notificationBuffer.open(QIODevice::ReadWrite)) { |
|
|
|
QImageWriter writer(¬ificationIconFile, "PNG"); |
|
|
|
QImageWriter writer(¬ificationBuffer, "PNG"); |
|
|
|
if (writer.write(pixmap.toImage())) { |
|
|
|
if (writer.write(pixmap.toImage())) { |
|
|
|
const char *cString = notificationIconFile.fileName().toUtf8().data(); |
|
|
|
NSData* macImgData = [NSData dataWithBytes:notificationBuffer.buffer().data() |
|
|
|
NSString *macString = [NSString stringWithCString:cString encoding:NSUTF8StringEncoding]; |
|
|
|
length:notificationBuffer.buffer().size()]; |
|
|
|
image = [[NSImage alloc] initWithContentsOfFile:macString]; |
|
|
|
image = [[NSImage alloc] initWithData:macImgData]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|