[UI] TrayIcon + TrayIconMenu for OSX

This commit is contained in:
crowning- 2016-11-15 23:38:04 +01:00 committed by GitHub
parent 714f9a4f0d
commit 544d220819

View File

@ -653,20 +653,16 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle) void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
{ {
#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this); trayIcon = new QSystemTrayIcon(this);
QString toolTip = tr("Dash Core client") + " " + networkStyle->getTitleAddText(); QString toolTip = tr("Dash Core client") + " " + networkStyle->getTitleAddText();
trayIcon->setToolTip(toolTip); trayIcon->setToolTip(toolTip);
trayIcon->setIcon(networkStyle->getTrayAndWindowIcon()); trayIcon->setIcon(networkStyle->getTrayAndWindowIcon());
trayIcon->show(); trayIcon->show();
#endif
notificator = new Notificator(QApplication::applicationName(), trayIcon, this); notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
} }
void BitcoinGUI::createTrayIconMenu() void BitcoinGUI::createTrayIconMenu()
{ {
#ifndef Q_OS_MAC
// return if trayIcon is unset (only on non-Mac OSes) // return if trayIcon is unset (only on non-Mac OSes)
if (!trayIcon) if (!trayIcon)
return; return;
@ -676,12 +672,6 @@ void BitcoinGUI::createTrayIconMenu()
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
#else
// Note: On Mac, the dock icon is used to provide the tray's functionality.
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
dockIconHandler->setMainWindow((QMainWindow *)this);
trayIconMenu = dockIconHandler->dockMenu();
#endif
// Configuration of the tray icon (or dock icon) icon menu // Configuration of the tray icon (or dock icon) icon menu
trayIconMenu->addAction(toggleHideAction); trayIconMenu->addAction(toggleHideAction);
@ -702,10 +692,8 @@ void BitcoinGUI::createTrayIconMenu()
trayIconMenu->addAction(openConfEditorAction); trayIconMenu->addAction(openConfEditorAction);
trayIconMenu->addAction(openMNConfEditorAction); trayIconMenu->addAction(openMNConfEditorAction);
trayIconMenu->addAction(showBackupsAction); trayIconMenu->addAction(showBackupsAction);
#ifndef Q_OS_MAC // This is built-in on Mac
trayIconMenu->addSeparator(); trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction); trayIconMenu->addAction(quitAction);
#endif
} }
#ifndef Q_OS_MAC #ifndef Q_OS_MAC