| 151 | } |
| 152 | |
| 153 | void SendCoinsDialog::setModel(WalletModel *_model) |
| 154 | { |
| 155 | this->model = _model; |
| 156 | |
| 157 | if(_model && _model->getOptionsModel()) |
| 158 | { |
| 159 | for(int i = 0; i < ui->entries->count(); ++i) |
| 160 | { |
| 161 | SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); |
| 162 | if(entry) |
| 163 | { |
| 164 | entry->setModel(_model); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | interfaces::WalletBalances balances = _model->wallet().getBalances(); |
| 169 | setBalance(balances); |
| 170 | connect(_model, &WalletModel::balanceChanged, this, &SendCoinsDialog::setBalance); |
| 171 | connect(_model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &SendCoinsDialog::updateDisplayUnit); |
| 172 | updateDisplayUnit(); |
| 173 | |
| 174 | // Coin Control |
| 175 | connect(_model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &SendCoinsDialog::coinControlUpdateLabels); |
| 176 | connect(_model->getOptionsModel(), &OptionsModel::coinControlFeaturesChanged, this, &SendCoinsDialog::coinControlFeatureChanged); |
| 177 | ui->frameCoinControl->setVisible(_model->getOptionsModel()->getCoinControlFeatures()); |
| 178 | coinControlUpdateLabels(); |
| 179 | |
| 180 | // fee section |
| 181 | for (const int n : confTargets) { |
| 182 | ui->confTargetSelector->addItem(tr("%1 (%2 blocks)").arg(GUIUtil::formatNiceTimeOffset(n*Params().GetConsensus().nPowTargetSpacing)).arg(n)); |
| 183 | } |
| 184 | connect(ui->confTargetSelector, qOverload<int>(&QComboBox::currentIndexChanged), this, &SendCoinsDialog::updateSmartFeeLabel); |
| 185 | connect(ui->confTargetSelector, qOverload<int>(&QComboBox::currentIndexChanged), this, &SendCoinsDialog::coinControlUpdateLabels); |
| 186 | |
| 187 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) |
| 188 | connect(ui->groupFee, &QButtonGroup::idClicked, this, &SendCoinsDialog::updateFeeSectionControls); |
| 189 | connect(ui->groupFee, &QButtonGroup::idClicked, this, &SendCoinsDialog::coinControlUpdateLabels); |
| 190 | #else |
| 191 | connect(ui->groupFee, qOverload<int>(&QButtonGroup::buttonClicked), this, &SendCoinsDialog::updateFeeSectionControls); |
| 192 | connect(ui->groupFee, qOverload<int>(&QButtonGroup::buttonClicked), this, &SendCoinsDialog::coinControlUpdateLabels); |
| 193 | #endif |
| 194 | |
| 195 | connect(ui->customFee, &BitcoinAmountField::valueChanged, this, &SendCoinsDialog::coinControlUpdateLabels); |
| 196 | connect(ui->optInRBF, &QCheckBox::stateChanged, this, &SendCoinsDialog::updateSmartFeeLabel); |
| 197 | connect(ui->optInRBF, &QCheckBox::stateChanged, this, &SendCoinsDialog::coinControlUpdateLabels); |
| 198 | CAmount requiredFee = model->wallet().getRequiredFee(1000); |
| 199 | ui->customFee->SetMinValue(requiredFee); |
| 200 | if (ui->customFee->value() < requiredFee) { |
| 201 | ui->customFee->setValue(requiredFee); |
| 202 | } |
| 203 | ui->customFee->setSingleStep(requiredFee); |
| 204 | updateFeeSectionControls(); |
| 205 | updateSmartFeeLabel(); |
| 206 | |
| 207 | // set default rbf checkbox state |
| 208 | ui->optInRBF->setCheckState(Qt::Checked); |
| 209 | |
| 210 | if (model->wallet().hasExternalSigner()) { |
no test coverage detected