| 76 | } |
| 77 | |
| 78 | void ReceiveCoinsDialog::setModel(WalletModel *_model) |
| 79 | { |
| 80 | this->model = _model; |
| 81 | |
| 82 | if(_model && _model->getOptionsModel()) |
| 83 | { |
| 84 | _model->getRecentRequestsTableModel()->sort(RecentRequestsTableModel::Date, Qt::DescendingOrder); |
| 85 | connect(_model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &ReceiveCoinsDialog::updateDisplayUnit); |
| 86 | updateDisplayUnit(); |
| 87 | |
| 88 | QTableView* tableView = ui->recentRequestsView; |
| 89 | tableView->setModel(_model->getRecentRequestsTableModel()); |
| 90 | tableView->sortByColumn(RecentRequestsTableModel::Date, Qt::DescendingOrder); |
| 91 | |
| 92 | connect(tableView->selectionModel(), |
| 93 | &QItemSelectionModel::selectionChanged, this, |
| 94 | &ReceiveCoinsDialog::recentRequestsView_selectionChanged); |
| 95 | |
| 96 | // Populate address type dropdown and select default |
| 97 | auto add_address_type = [&](OutputType type, const QString& text, const QString& tooltip) { |
| 98 | const auto index = ui->addressType->count(); |
| 99 | ui->addressType->addItem(text, (int) type); |
| 100 | ui->addressType->setItemData(index, tooltip, Qt::ToolTipRole); |
| 101 | if (model->wallet().getDefaultAddressType() == type) ui->addressType->setCurrentIndex(index); |
| 102 | }; |
| 103 | add_address_type(OutputType::LEGACY, "Base58 (Legacy)", "Not recommended due to higher fees and less protection against typos."); |
| 104 | add_address_type(OutputType::P2SH_SEGWIT, "Base58 (P2SH-SegWit)", "Generates an address compatible with older wallets."); |
| 105 | add_address_type(OutputType::BECH32, "Bech32 (SegWit)", "Generates a native segwit address (BIP-173). Some old wallets don't support it."); |
| 106 | if (model->wallet().taprootEnabled()) { |
| 107 | add_address_type(OutputType::BECH32M, "Bech32m (Taproot)", "Bech32m (BIP-350) is an upgrade to Bech32, wallet support is still limited."); |
| 108 | } |
| 109 | |
| 110 | // Set the button to be enabled or disabled based on whether the wallet can give out new addresses. |
| 111 | ui->receiveButton->setEnabled(model->wallet().canGetAddresses()); |
| 112 | |
| 113 | // Enable/disable the receive button if the wallet is now able/unable to give out new addresses. |
| 114 | connect(model, &WalletModel::canGetAddressesChanged, [this] { |
| 115 | ui->receiveButton->setEnabled(model->wallet().canGetAddresses()); |
| 116 | }); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | ReceiveCoinsDialog::~ReceiveCoinsDialog() |
| 121 | { |
no test coverage detected