| 558 | } |
| 559 | |
| 560 | void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndHeaderTipInfo* tip_info) |
| 561 | { |
| 562 | this->clientModel = _clientModel; |
| 563 | if(_clientModel) |
| 564 | { |
| 565 | // Create system tray menu (or setup the dock menu) that late to prevent users from calling actions, |
| 566 | // while the client has not yet fully loaded |
| 567 | createTrayIconMenu(); |
| 568 | |
| 569 | // Keep up to date with client |
| 570 | setNetworkActive(m_node.getNetworkActive()); |
| 571 | connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, [this] { |
| 572 | GUIUtil::PopupMenu(m_network_context_menu, QCursor::pos()); |
| 573 | }); |
| 574 | connect(_clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections); |
| 575 | connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive); |
| 576 | |
| 577 | modalOverlay->setKnownBestHeight(tip_info->header_height, QDateTime::fromSecsSinceEpoch(tip_info->header_time)); |
| 578 | setNumBlocks(tip_info->block_height, QDateTime::fromSecsSinceEpoch(tip_info->block_time), tip_info->verification_progress, false, SynchronizationState::INIT_DOWNLOAD); |
| 579 | connect(_clientModel, &ClientModel::numBlocksChanged, this, &BitcoinGUI::setNumBlocks); |
| 580 | |
| 581 | // Receive and report messages from client model |
| 582 | connect(_clientModel, &ClientModel::message, [this](const QString &title, const QString &message, unsigned int style){ |
| 583 | this->message(title, message, style); |
| 584 | }); |
| 585 | |
| 586 | // Show progress dialog |
| 587 | connect(_clientModel, &ClientModel::showProgress, this, &BitcoinGUI::showProgress); |
| 588 | |
| 589 | rpcConsole->setClientModel(_clientModel, tip_info->block_height, tip_info->block_time, tip_info->verification_progress); |
| 590 | |
| 591 | updateProxyIcon(); |
| 592 | |
| 593 | #ifdef ENABLE_WALLET |
| 594 | if(walletFrame) |
| 595 | { |
| 596 | walletFrame->setClientModel(_clientModel); |
| 597 | } |
| 598 | #endif // ENABLE_WALLET |
| 599 | unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel()); |
| 600 | |
| 601 | OptionsModel* optionsModel = _clientModel->getOptionsModel(); |
| 602 | if (optionsModel && trayIcon) { |
| 603 | // be aware of the tray icon disable state change reported by the OptionsModel object. |
| 604 | connect(optionsModel, &OptionsModel::showTrayIconChanged, trayIcon, &QSystemTrayIcon::setVisible); |
| 605 | |
| 606 | // initialize the disable state of the tray icon with the current value in the model. |
| 607 | trayIcon->setVisible(optionsModel->getShowTrayIcon()); |
| 608 | } |
| 609 | } else { |
| 610 | if(trayIconMenu) |
| 611 | { |
| 612 | // Disable context menu on tray icon |
| 613 | trayIconMenu->clear(); |
| 614 | } |
| 615 | // Propagate cleared model to child objects |
| 616 | rpcConsole->setClientModel(nullptr); |
| 617 | #ifdef ENABLE_WALLET |
nothing calls this directly
no test coverage detected