split of createTrayIconMenu() from createTrayIcon() in BitcoinGUI
- this allows to setup the trayicon before we have and want a trayicon menu - should be of great use, when we remove that splash screen - fixes a small bug with the toggleHideAction icon, which is not only used with trayicon but also with the Mac dock
This commit is contained in:
parent
0c50d8b007
commit
f82102121f
2 changed files with 24 additions and 9 deletions
|
@ -90,7 +90,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
||||||
// Create the toolbars
|
// Create the toolbars
|
||||||
createToolBars();
|
createToolBars();
|
||||||
|
|
||||||
// Create the tray icon (or setup the dock icon)
|
// Create system tray icon and notification
|
||||||
createTrayIcon();
|
createTrayIcon();
|
||||||
|
|
||||||
// Create tabs
|
// Create tabs
|
||||||
|
@ -354,12 +354,17 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
|
||||||
// Just attach " [testnet]" to the existing tooltip
|
// Just attach " [testnet]" to the existing tooltip
|
||||||
trayIcon->setToolTip(trayIcon->toolTip() + QString(" ") + tr("[testnet]"));
|
trayIcon->setToolTip(trayIcon->toolTip() + QString(" ") + tr("[testnet]"));
|
||||||
trayIcon->setIcon(QIcon(":/icons/toolbar_testnet"));
|
trayIcon->setIcon(QIcon(":/icons/toolbar_testnet"));
|
||||||
toggleHideAction->setIcon(QIcon(":/icons/toolbar_testnet"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleHideAction->setIcon(QIcon(":/icons/toolbar_testnet"));
|
||||||
aboutAction->setIcon(QIcon(":/icons/toolbar_testnet"));
|
aboutAction->setIcon(QIcon(":/icons/toolbar_testnet"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,
|
||||||
|
// while the client has not yet fully loaded
|
||||||
|
if(trayIcon)
|
||||||
|
createTrayIconMenu();
|
||||||
|
|
||||||
// Keep up to date with client
|
// Keep up to date with client
|
||||||
setNumConnections(clientModel->getNumConnections());
|
setNumConnections(clientModel->getNumConnections());
|
||||||
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
|
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
|
||||||
|
@ -407,16 +412,26 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel)
|
||||||
|
|
||||||
void BitcoinGUI::createTrayIcon()
|
void BitcoinGUI::createTrayIcon()
|
||||||
{
|
{
|
||||||
QMenu *trayIconMenu;
|
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
trayIcon = new QSystemTrayIcon(this);
|
trayIcon = new QSystemTrayIcon(this);
|
||||||
trayIconMenu = new QMenu(this);
|
|
||||||
trayIcon->setContextMenu(trayIconMenu);
|
|
||||||
trayIcon->setToolTip(tr("Bitcoin client"));
|
trayIcon->setToolTip(tr("Bitcoin client"));
|
||||||
trayIcon->setIcon(QIcon(":/icons/toolbar"));
|
trayIcon->setIcon(QIcon(":/icons/toolbar"));
|
||||||
|
trayIcon->show();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
notificator = new Notificator(qApp->applicationName(), trayIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitcoinGUI::createTrayIconMenu()
|
||||||
|
{
|
||||||
|
QMenu *trayIconMenu;
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
|
trayIconMenu = new QMenu(this);
|
||||||
|
trayIcon->setContextMenu(trayIconMenu);
|
||||||
|
|
||||||
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||||
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
|
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
|
||||||
trayIcon->show();
|
|
||||||
#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();
|
||||||
|
@ -438,8 +453,6 @@ void BitcoinGUI::createTrayIcon()
|
||||||
trayIconMenu->addSeparator();
|
trayIconMenu->addSeparator();
|
||||||
trayIconMenu->addAction(quitAction);
|
trayIconMenu->addAction(quitAction);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
notificator = new Notificator(qApp->applicationName(), trayIcon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
|
|
|
@ -105,8 +105,10 @@ private:
|
||||||
void createMenuBar();
|
void createMenuBar();
|
||||||
/** Create the toolbars */
|
/** Create the toolbars */
|
||||||
void createToolBars();
|
void createToolBars();
|
||||||
/** Create system tray (notification) icon */
|
/** Create system tray icon and notification */
|
||||||
void createTrayIcon();
|
void createTrayIcon();
|
||||||
|
/** Create system tray menu (or setup the dock menu) */
|
||||||
|
void createTrayIconMenu();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/** Set number of connections shown in the UI */
|
/** Set number of connections shown in the UI */
|
||||||
|
|
Loading…
Reference in a new issue