diff options
author | Jonas Schnelli <jonas.schnelli@include7.ch> | 2014-11-19 13:33:34 +0100 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2016-10-24 10:23:58 +0000 |
commit | b2b33d9017cd7bc92099338773313fdf4572dc4a (patch) | |
tree | a99ace8f2586c6d9e0973b9c7c6a71188d5527ce /src/qt/bitcoingui.cpp | |
parent | 32efa79e0e63b6d3f055326b2e6b794815d408ad (diff) |
Overhaul network activity toggle
- Rename RPC command "togglenetwork" to "setnetworkactive (true|false)"
- Add simple test case
- GUI toggle added to connections icon in statusbar
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r-- | src/qt/bitcoingui.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 69cdfc9c07..4cc30454a2 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -83,7 +83,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle * unitDisplayControl(0), labelWalletEncryptionIcon(0), labelWalletHDStatusIcon(0), - labelConnectionsIcon(0), + connectionsControl(0), labelBlocksIcon(0), progressBarLabel(0), progressBar(0), @@ -195,7 +195,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle * unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle); labelWalletEncryptionIcon = new QLabel(); labelWalletHDStatusIcon = new QLabel(); - labelConnectionsIcon = new QLabel(); + connectionsControl = new NetworkToggleStatusBarControl(); labelBlocksIcon = new QLabel(); if(enableWallet) { @@ -206,7 +206,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle * frameBlocksLayout->addWidget(labelWalletHDStatusIcon); } frameBlocksLayout->addStretch(); - frameBlocksLayout->addWidget(labelConnectionsIcon); + frameBlocksLayout->addWidget(connectionsControl); frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(labelBlocksIcon); frameBlocksLayout->addStretch(); @@ -480,6 +480,7 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel) } #endif // ENABLE_WALLET unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel()); + connectionsControl->setClientModel(_clientModel); OptionsModel* optionsModel = _clientModel->getOptionsModel(); if(optionsModel) @@ -699,13 +700,15 @@ void BitcoinGUI::updateNetworkState() case 7: case 8: case 9: icon = ":/icons/connect_3"; break; default: icon = ":/icons/connect_4"; break; } - labelConnectionsIcon->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); if (clientModel->getNetworkActive()) { - labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count)); + connectionsControl->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count)); } else { - labelConnectionsIcon->setToolTip(tr("Network activity disabled")); + connectionsControl->setToolTip(tr("Network activity disabled")); + icon = ":/icons/network_disabled"; } + + connectionsControl->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); } void BitcoinGUI::setNumConnections(int count) @@ -1220,3 +1223,18 @@ void UnitDisplayStatusBarControl::onMenuSelection(QAction* action) optionsModel->setDisplayUnit(action->data()); } } + +void NetworkToggleStatusBarControl::mousePressEvent(QMouseEvent *event) +{ + if (clientModel) { + clientModel->setNetworkActive(!clientModel->getNetworkActive()); + } +} + +/** Lets the control know about the Client Model */ +void NetworkToggleStatusBarControl::setClientModel(ClientModel *_clientModel) +{ + if (_clientModel) { + this->clientModel = _clientModel; + } +} |