Remove obj_c for macOS Dock icon setting

Qt `setWindowIcon()` does this work.
This commit is contained in:
Hennadii Stepanov 2018-10-31 20:04:05 +02:00
parent f1e2f2a859
commit 53bb6be3f8
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
3 changed files with 0 additions and 41 deletions

View file

@ -92,12 +92,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
windowTitle += tr("Node");
}
windowTitle += " " + networkStyle->getTitleAddText();
#ifndef Q_OS_MAC
QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
setWindowIcon(networkStyle->getTrayAndWindowIcon());
#else
MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
#endif
setWindowTitle(windowTitle);
rpcConsole = new RPCConsole(node, _platformStyle, 0);

View file

@ -9,7 +9,6 @@
#include <QObject>
QT_BEGIN_NAMESPACE
class QIcon;
class QMenu;
class QWidget;
QT_END_NAMESPACE
@ -24,7 +23,6 @@ public:
~MacDockIconHandler();
QMenu *dockMenu();
void setIcon(const QIcon &icon);
void setMainWindow(QMainWindow *window);
static MacDockIconHandler *instance();
static void cleanup();

View file

@ -4,9 +4,7 @@
#include "macdockiconhandler.h"
#include <QImageWriter>
#include <QMenu>
#include <QBuffer>
#include <QWidget>
#undef slots
@ -71,39 +69,6 @@ QMenu *MacDockIconHandler::dockMenu()
return this->m_dockMenu;
}
void MacDockIconHandler::setIcon(const QIcon &icon)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSImage *image = nil;
if (icon.isNull())
image = [[NSImage imageNamed:@"NSApplicationIcon"] retain];
else {
// generate NSImage from QIcon and use this as dock icon.
QSize size = icon.actualSize(QSize(128, 128));
QPixmap pixmap = icon.pixmap(size);
// 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(&notificationBuffer, "PNG");
if (writer.write(pixmap.toImage())) {
NSData* macImgData = [NSData dataWithBytes:notificationBuffer.buffer().data()
length:notificationBuffer.buffer().size()];
image = [[NSImage alloc] initWithData:macImgData];
}
}
if(!image) {
// if testnet image could not be created, load std. app icon
image = [[NSImage imageNamed:@"NSApplicationIcon"] retain];
}
}
[NSApp setApplicationIconImage:image];
[image release];
[pool release];
}
MacDockIconHandler *MacDockIconHandler::instance()
{
if (!s_instance)