Replace the temporary file hack currently used to change Bitcoin-Qt's dock icon (OS X) with a buffer-based solution.
This commit is contained in:
parent
1de2992e07
commit
bd0aa10519
1 changed files with 8 additions and 8 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <QImageWriter>
|
||||
#include <QMenu>
|
||||
#include <QTemporaryFile>
|
||||
#include <QBuffer>
|
||||
#include <QWidget>
|
||||
|
||||
#undef slots
|
||||
|
@ -95,14 +95,14 @@ void MacDockIconHandler::setIcon(const QIcon &icon)
|
|||
QSize size = icon.actualSize(QSize(128, 128));
|
||||
QPixmap pixmap = icon.pixmap(size);
|
||||
|
||||
// write temp file hack (could also be done through QIODevice [memory])
|
||||
QTemporaryFile notificationIconFile;
|
||||
if (!pixmap.isNull() && notificationIconFile.open()) {
|
||||
QImageWriter writer(¬ificationIconFile, "PNG");
|
||||
// Write image into a R/W buffer from raw pixmap, then save the image.
|
||||
QBuffer notificationBuffer;
|
||||
if (!pixmap.isNull() && notificationBuffer.open(QIODevice::ReadWrite)) {
|
||||
QImageWriter writer(¬ificationBuffer, "PNG");
|
||||
if (writer.write(pixmap.toImage())) {
|
||||
const char *cString = notificationIconFile.fileName().toUtf8().data();
|
||||
NSString *macString = [NSString stringWithCString:cString encoding:NSUTF8StringEncoding];
|
||||
image = [[NSImage alloc] initWithContentsOfFile:macString];
|
||||
NSData* macImgData = [NSData dataWithBytes:notificationBuffer.buffer().data()
|
||||
length:notificationBuffer.buffer().size()];
|
||||
image = [[NSImage alloc] initWithData:macImgData];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue