Skip to content

Commit 53bb6be

Browse files
committed
Remove obj_c for macOS Dock icon setting
Qt `setWindowIcon()` does this work.
1 parent f1e2f2a commit 53bb6be

File tree

3 files changed

+0
-41
lines changed

3 files changed

+0
-41
lines changed

src/qt/bitcoingui.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
9292
windowTitle += tr("Node");
9393
}
9494
windowTitle += " " + networkStyle->getTitleAddText();
95-
#ifndef Q_OS_MAC
9695
QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
9796
setWindowIcon(networkStyle->getTrayAndWindowIcon());
98-
#else
99-
MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
100-
#endif
10197
setWindowTitle(windowTitle);
10298

10399
rpcConsole = new RPCConsole(node, _platformStyle, 0);

src/qt/macdockiconhandler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <QObject>
1010

1111
QT_BEGIN_NAMESPACE
12-
class QIcon;
1312
class QMenu;
1413
class QWidget;
1514
QT_END_NAMESPACE
@@ -24,7 +23,6 @@ class MacDockIconHandler : public QObject
2423
~MacDockIconHandler();
2524

2625
QMenu *dockMenu();
27-
void setIcon(const QIcon &icon);
2826
void setMainWindow(QMainWindow *window);
2927
static MacDockIconHandler *instance();
3028
static void cleanup();

src/qt/macdockiconhandler.mm

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
#include "macdockiconhandler.h"
66

7-
#include <QImageWriter>
87
#include <QMenu>
9-
#include <QBuffer>
108
#include <QWidget>
119

1210
#undef slots
@@ -71,39 +69,6 @@ void setupDockClickHandler() {
7169
return this->m_dockMenu;
7270
}
7371

74-
void MacDockIconHandler::setIcon(const QIcon &icon)
75-
{
76-
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
77-
NSImage *image = nil;
78-
if (icon.isNull())
79-
image = [[NSImage imageNamed:@"NSApplicationIcon"] retain];
80-
else {
81-
// generate NSImage from QIcon and use this as dock icon.
82-
QSize size = icon.actualSize(QSize(128, 128));
83-
QPixmap pixmap = icon.pixmap(size);
84-
85-
// Write image into a R/W buffer from raw pixmap, then save the image.
86-
QBuffer notificationBuffer;
87-
if (!pixmap.isNull() && notificationBuffer.open(QIODevice::ReadWrite)) {
88-
QImageWriter writer(&notificationBuffer, "PNG");
89-
if (writer.write(pixmap.toImage())) {
90-
NSData* macImgData = [NSData dataWithBytes:notificationBuffer.buffer().data()
91-
length:notificationBuffer.buffer().size()];
92-
image = [[NSImage alloc] initWithData:macImgData];
93-
}
94-
}
95-
96-
if(!image) {
97-
// if testnet image could not be created, load std. app icon
98-
image = [[NSImage imageNamed:@"NSApplicationIcon"] retain];
99-
}
100-
}
101-
102-
[NSApp setApplicationIconImage:image];
103-
[image release];
104-
[pool release];
105-
}
106-
10772
MacDockIconHandler *MacDockIconHandler::instance()
10873
{
10974
if (!s_instance)

0 commit comments

Comments
 (0)