aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoingui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r--src/qt/bitcoingui.cpp30
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;
+ }
+}