fix: GUI Disappearing #1522 (Mac OSX)
- this solution works stable on mac and ensures that the window get's reopened when the user clicks the dock icon . - tested on 10.8 with Qt4.8.4 and Qt5.0.1 Signed-off-by: Jonas Schnelli <jonas.schnelli@include7.ch>
This commit is contained in:
parent
463a58ae75
commit
4d17a1b0c2
@ -155,6 +155,7 @@ BitcoinGUI::~BitcoinGUI()
|
|||||||
trayIcon->hide();
|
trayIcon->hide();
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
delete appMenuBar;
|
delete appMenuBar;
|
||||||
|
MacDockIconHandler::instance()->setMainWindow(NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,6 +383,7 @@ void BitcoinGUI::createTrayIconMenu()
|
|||||||
#else
|
#else
|
||||||
// Note: On Mac, the dock icon is used to provide the tray's functionality.
|
// Note: On Mac, the dock icon is used to provide the tray's functionality.
|
||||||
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
|
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
|
||||||
|
dockIconHandler->setMainWindow((QMainWindow *)this);
|
||||||
trayIconMenu = dockIconHandler->dockMenu();
|
trayIconMenu = dockIconHandler->dockMenu();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define MACDOCKICONHANDLER_H
|
#define MACDOCKICONHANDLER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QMenu;
|
class QMenu;
|
||||||
@ -26,7 +27,7 @@ public:
|
|||||||
|
|
||||||
QMenu *dockMenu();
|
QMenu *dockMenu();
|
||||||
void setIcon(const QIcon &icon);
|
void setIcon(const QIcon &icon);
|
||||||
|
void setMainWindow(QMainWindow *window);
|
||||||
static MacDockIconHandler *instance();
|
static MacDockIconHandler *instance();
|
||||||
|
|
||||||
void handleDockIconClickEvent();
|
void handleDockIconClickEvent();
|
||||||
@ -40,6 +41,7 @@ private:
|
|||||||
DockIconClickEventHandler *m_dockIconClickEventHandler;
|
DockIconClickEventHandler *m_dockIconClickEventHandler;
|
||||||
QWidget *m_dummyWidget;
|
QWidget *m_dummyWidget;
|
||||||
QMenu *m_dockMenu;
|
QMenu *m_dockMenu;
|
||||||
|
QMainWindow *mainWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MACDOCKICONCLICKHANDLER_H
|
#endif // MACDOCKICONCLICKHANDLER_H
|
||||||
|
@ -37,9 +37,10 @@ extern void qt_mac_set_dock_menu(QMenu*);
|
|||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
Q_UNUSED(replyEvent)
|
Q_UNUSED(replyEvent)
|
||||||
|
|
||||||
if (dockIconHandler)
|
if (dockIconHandler) {
|
||||||
dockIconHandler->handleDockIconClickEvent();
|
dockIconHandler->handleDockIconClickEvent();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -54,10 +55,15 @@ MacDockIconHandler::MacDockIconHandler() : QObject()
|
|||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MacDockIconHandler::setMainWindow(QMainWindow *window) {
|
||||||
|
this->mainWindow = window;
|
||||||
|
}
|
||||||
|
|
||||||
MacDockIconHandler::~MacDockIconHandler()
|
MacDockIconHandler::~MacDockIconHandler()
|
||||||
{
|
{
|
||||||
[this->m_dockIconClickEventHandler release];
|
[this->m_dockIconClickEventHandler release];
|
||||||
delete this->m_dummyWidget;
|
delete this->m_dummyWidget;
|
||||||
|
this->setMainWindow(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu *MacDockIconHandler::dockMenu()
|
QMenu *MacDockIconHandler::dockMenu()
|
||||||
@ -94,5 +100,8 @@ MacDockIconHandler *MacDockIconHandler::instance()
|
|||||||
|
|
||||||
void MacDockIconHandler::handleDockIconClickEvent()
|
void MacDockIconHandler::handleDockIconClickEvent()
|
||||||
{
|
{
|
||||||
|
this->mainWindow->activateWindow();
|
||||||
|
this->mainWindow->show();
|
||||||
|
|
||||||
emit this->dockIconClicked();
|
emit this->dockIconClicked();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user