qt: Replace NetworkToggleStatusBarControl with generic ClickableLabel

Generalize the clickable label functionality.

We will use this to add similar functionality to the sync icon.
This commit is contained in:
Wladimir J. van der Laan
2016-11-24 14:26:20 +01:00
parent bc121b0eb1
commit 827d9a3be8
4 changed files with 35 additions and 31 deletions

View File

@@ -199,7 +199,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
labelWalletEncryptionIcon = new QLabel();
labelWalletHDStatusIcon = new QLabel();
connectionsControl = new NetworkToggleStatusBarControl();
connectionsControl = new GUIUtil::ClickableLabel();
labelBlocksIcon = new QLabel();
if(enableWallet)
{
@@ -244,6 +244,8 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
// Subscribe to notifications from core
subscribeToCoreSignals();
connect(connectionsControl, SIGNAL(clicked(QPoint)), this, SLOT(toggleNetworkActive()));
modalOverlay = new ModalOverlay(this->centralWidget());
#ifdef ENABLE_WALLET
if(enableWallet)
@@ -490,7 +492,6 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
}
#endif // ENABLE_WALLET
unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel());
connectionsControl->setClientModel(_clientModel);
OptionsModel* optionsModel = _clientModel->getOptionsModel();
if(optionsModel)
@@ -517,7 +518,6 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
walletFrame->setClientModel(nullptr);
#endif // ENABLE_WALLET
unitDisplayControl->setOptionsModel(nullptr);
connectionsControl->setClientModel(nullptr);
}
}
@@ -1171,6 +1171,13 @@ void BitcoinGUI::unsubscribeFromCoreSignals()
uiInterface.ThreadSafeQuestion.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
}
void BitcoinGUI::toggleNetworkActive()
{
if (clientModel) {
clientModel->setNetworkActive(!clientModel->getNetworkActive());
}
}
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
optionsModel(0),
menu(0)
@@ -1244,16 +1251,3 @@ 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)
{
this->clientModel = _clientModel;
}