Remove obj_c for macOS Dock icon menu

Qt `setAsDockMenu()` does this work.
This commit is contained in:
Hennadii Stepanov 2018-11-02 10:58:14 +02:00
parent 2464925e7b
commit 6b1d2972bf
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
3 changed files with 4 additions and 36 deletions

View file

@ -607,7 +607,9 @@ void BitcoinGUI::createTrayIconMenu()
// Note: On macOS, the Dock icon is used to provide the tray's functionality. // Note: On macOS, the Dock icon is used to provide the tray's functionality.
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, this, &BitcoinGUI::macosDockIconActivated); connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, this, &BitcoinGUI::macosDockIconActivated);
trayIconMenu = dockIconHandler->dockMenu();
trayIconMenu = new QMenu(this);
trayIconMenu->setAsDockMenu();
#endif #endif
// Configuration of the tray icon (or Dock icon) menu // Configuration of the tray icon (or Dock icon) menu

View file

@ -7,11 +7,6 @@
#include <QObject> #include <QObject>
QT_BEGIN_NAMESPACE
class QMenu;
class QWidget;
QT_END_NAMESPACE
/** macOS-specific Dock icon handler. /** macOS-specific Dock icon handler.
*/ */
class MacDockIconHandler : public QObject class MacDockIconHandler : public QObject
@ -19,9 +14,6 @@ class MacDockIconHandler : public QObject
Q_OBJECT Q_OBJECT
public: public:
~MacDockIconHandler();
QMenu *dockMenu();
static MacDockIconHandler *instance(); static MacDockIconHandler *instance();
static void cleanup(); static void cleanup();
@ -30,9 +22,6 @@ Q_SIGNALS:
private: private:
MacDockIconHandler(); MacDockIconHandler();
QWidget *m_dummyWidget;
QMenu *m_dockMenu;
}; };
#endif // BITCOIN_QT_MACDOCKICONHANDLER_H #endif // BITCOIN_QT_MACDOCKICONHANDLER_H

View file

@ -4,11 +4,7 @@
#include "macdockiconhandler.h" #include "macdockiconhandler.h"
#include <QMenu>
#include <QWidget>
#undef slots #undef slots
#include <Cocoa/Cocoa.h>
#include <objc/objc.h> #include <objc/objc.h>
#include <objc/message.h> #include <objc/message.h>
@ -32,28 +28,9 @@ void setupDockClickHandler() {
class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:"); class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:");
} }
MacDockIconHandler::MacDockIconHandler() : QObject() MacDockIconHandler::MacDockIconHandler() : QObject()
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
setupDockClickHandler(); setupDockClickHandler();
this->m_dummyWidget = new QWidget();
this->m_dockMenu = new QMenu(this->m_dummyWidget);
#if QT_VERSION >= 0x050200
this->m_dockMenu->setAsDockMenu();
#endif
[pool release];
}
MacDockIconHandler::~MacDockIconHandler()
{
delete this->m_dummyWidget;
}
QMenu *MacDockIconHandler::dockMenu()
{
return this->m_dockMenu;
} }
MacDockIconHandler *MacDockIconHandler::instance() MacDockIconHandler *MacDockIconHandler::instance()