| 436 | } |
| 437 | |
| 438 | void BitcoinGUI::setClientModel(ClientModel *_clientModel) |
| 439 | { |
| 440 | this->clientModel = _clientModel; |
| 441 | if(_clientModel) |
| 442 | { |
| 443 | // Create system tray menu (or setup the dock menu) that late to prevent users from calling actions, |
| 444 | // while the client has not yet fully loaded |
| 445 | createTrayIconMenu(); |
| 446 | |
| 447 | // Keep up to date with client |
| 448 | updateNetworkState(); |
| 449 | connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); |
| 450 | connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool))); |
| 451 | |
| 452 | modalOverlay->setKnownBestHeight(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime())); |
| 453 | setNumBlocks(m_node.getNumBlocks(), QDateTime::fromTime_t(m_node.getLastBlockTime()), m_node.getVerificationProgress(), false); |
| 454 | connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool))); |
| 455 | |
| 456 | // Receive and report messages from client model |
| 457 | connect(_clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int))); |
| 458 | |
| 459 | // Show progress dialog |
| 460 | connect(_clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int))); |
| 461 | |
| 462 | rpcConsole->setClientModel(_clientModel); |
| 463 | |
| 464 | updateProxyIcon(); |
| 465 | |
| 466 | #ifdef ENABLE_WALLET |
| 467 | if(walletFrame) |
| 468 | { |
| 469 | walletFrame->setClientModel(_clientModel); |
| 470 | } |
| 471 | #endif // ENABLE_WALLET |
| 472 | unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel()); |
| 473 | |
| 474 | OptionsModel* optionsModel = _clientModel->getOptionsModel(); |
| 475 | if(optionsModel) |
| 476 | { |
| 477 | // be aware of the tray icon disable state change reported by the OptionsModel object. |
| 478 | connect(optionsModel,SIGNAL(hideTrayIconChanged(bool)),this,SLOT(setTrayIconVisible(bool))); |
| 479 | |
| 480 | // initialize the disable state of the tray icon with the current value in the model. |
| 481 | setTrayIconVisible(optionsModel->getHideTrayIcon()); |
| 482 | } |
| 483 | } else { |
| 484 | // Disable possibility to show main window via action |
| 485 | toggleHideAction->setEnabled(false); |
| 486 | if(trayIconMenu) |
| 487 | { |
| 488 | // Disable context menu on tray icon |
| 489 | trayIconMenu->clear(); |
| 490 | } |
| 491 | // Propagate cleared model to child objects |
| 492 | rpcConsole->setClientModel(nullptr); |
| 493 | #ifdef ENABLE_WALLET |
| 494 | if (walletFrame) |
| 495 | { |
nothing calls this directly
no test coverage detected