Remove obj_c for macOS Dock icon setting
Qt `setWindowIcon()` does this work.
Github-Pull: #14597
Rebased-From: 53bb6be3f8
This commit is contained in:
parent
d2ed162ce0
commit
4d4bc37df9
3 changed files with 0 additions and 41 deletions
|
@ -89,12 +89,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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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(¬ificationBuffer, "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)
|
||||
|
|
Loading…
Reference in a new issue