aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-12-03 01:53:18 -0800
committerWladimir J. van der Laan <laanwj@gmail.com>2012-12-03 01:53:18 -0800
commit7a8dd988638e197e13c8faf366cfb81aa4d67783 (patch)
tree31afa7d107b8ad3e1122e3fc6a10e623d6e5721d /src
parentcd7fb7d1deece9da15d7750b3e05f729555a2cbe (diff)
parentf82102121f7c48d94c218af0089a71dde497fa07 (diff)
downloadbitcoin-7a8dd988638e197e13c8faf366cfb81aa4d67783.tar.xz
Merge pull request #2046 from Diapolo/traymenu
split of createTrayIconMenu() from createTrayIcon() in BitcoinGUI
Diffstat (limited to 'src')
-rw-r--r--src/qt/bitcoingui.cpp29
-rw-r--r--src/qt/bitcoingui.h4
2 files changed, 24 insertions, 9 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index e2350c09ee..aa45716c48 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -90,7 +90,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
// Create the toolbars
createToolBars();
- // Create the tray icon (or setup the dock icon)
+ // Create system tray icon and notification
createTrayIcon();
// Create tabs
@@ -354,12 +354,17 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
// Just attach " [testnet]" to the existing tooltip
trayIcon->setToolTip(trayIcon->toolTip() + QString(" ") + tr("[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"));
}
+ // 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
setNumConnections(clientModel->getNumConnections());
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
@@ -407,16 +412,26 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel)
void BitcoinGUI::createTrayIcon()
{
- QMenu *trayIconMenu;
#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this);
- trayIconMenu = new QMenu(this);
- trayIcon->setContextMenu(trayIconMenu);
+
trayIcon->setToolTip(tr("Bitcoin client"));
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)),
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
- trayIcon->show();
#else
// Note: On Mac, the dock icon is used to provide the tray's functionality.
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
@@ -438,8 +453,6 @@ void BitcoinGUI::createTrayIcon()
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
#endif
-
- notificator = new Notificator(qApp->applicationName(), trayIcon);
}
#ifndef Q_OS_MAC
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index 151b108be7..ecb3244ad5 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -105,8 +105,10 @@ private:
void createMenuBar();
/** Create the toolbars */
void createToolBars();
- /** Create system tray (notification) icon */
+ /** Create system tray icon and notification */
void createTrayIcon();
+ /** Create system tray menu (or setup the dock menu) */
+ void createTrayIconMenu();
public slots:
/** Set number of connections shown in the UI */