This PR makes coin selection work when multiple wallets are loaded - each loaded wallet has it’s own coin control dialog.
Closes #15725.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
Make unsigned
button next to Send
by achow101)If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Note to reviewers: previously CoinControlDialog::updateLabels
was called with 2 different “dialogs” (CoinControlDialog
and SendCoinsDialog
) and both have the same set of labels except for labelCoinControlInsuffFunds
. So, in order to remove static members and usages of findChild
, most of the code of updateLabels
is now duplicate.
Let me know if you prefer the 2nd commit split. IMO I’d prefer to follow up later.
Travis seems to fail:
0qt/coincontroldialog.cpp: In member function ‘void CoinControlDialog::updateView()’:
13030qt/coincontroldialog.cpp:607:84: error: invalid conversion from ‘CoinControlDialog*’ to ‘int’ [-fpermissive]
23031 CCoinControlWidgetItem *itemWalletAddress = new CCoinControlWidgetItem(this);
33032 ^
43033In file included from qt/coincontroldialog.cpp:9:0:
53034./qt/coincontroldialog.h:35:14: note: initializing argument 1 of ‘CCoinControlWidgetItem::CCoinControlWidgetItem(int)’
63035 explicit CCoinControlWidgetItem(int type = Type) : QTreeWidgetItem(type) {}
651@@ -652,6 +652,16 @@ void SendCoinsDialog::updateFeeMinimizedLabel()
652 }
653 }
654
655+CoinControlDialog* SendCoinsDialog::coinControlDialog()
656+{
657+ if (!m_coin_control_dialog) {
658+ m_coin_control_dialog = new CoinControlDialog(platformStyle, this);
QDialog
widget changes its default location.
Is it desirable?
651@@ -652,6 +652,16 @@ void SendCoinsDialog::updateFeeMinimizedLabel()
652 }
653 }
654
655+CoinControlDialog* SendCoinsDialog::coinControlDialog()
656+{
657+ if (!m_coin_control_dialog) {
658+ m_coin_control_dialog = new CoinControlDialog(platformStyle, this);
659+ m_coin_control_dialog->setModel(model);
model
to the CoinControlDialog
constructor?
setModel()
approach in various places where the model isn’t known at construction time, but that’s not the case here. But agree it’s not really related.
762@@ -753,10 +763,7 @@ void SendCoinsDialog::coinControlFeatureChanged(bool checked)
763 // Coin Control: button inputs -> show actual coin control dialog
764 void SendCoinsDialog::coinControlButtonClicked()
765 {
766- CoinControlDialog dlg(platformStyle);
767- dlg.setModel(model);
768- dlg.exec();
769- coinControlUpdateLabels();
770+ coinControlDialog()->open();
544+ QLabel *l2 = ui->labelCoinControlAmount;
545+ QLabel *l3 = ui->labelCoinControlFee;
546+ QLabel *l4 = ui->labelCoinControlAfterFee;
547+ QLabel *l5 = ui->labelCoinControlBytes;
548+ QLabel *l7 = ui->labelCoinControlLowOutput;
549+ QLabel *l8 = ui->labelCoinControlChange;
updateLabels()
is a member function now, we could get rid of these intermediate variables (lN
). Maybe scriptdiff?
This will improve code readability significantly.
I agree but I think that refactor, and others like #17457 (review), could come next.
I’m also very tempted to fix other things, but I just want to ditch the static coin control to fix the issue.
CoinControlDialog
was open once, the output list is not updated when new coins arrive.
This removes the nested event loop when.
Sorry for the delay, I am happy to take a look, but I’m getting the same build failure that Travis is seeing. Not sure why only some Travis builds get it and not others.
(EDIT, I misread before:) Looks like a rebase refactored something and you need to update a callsite to match.
🐙 This pull request conflicts with the target branch and needs rebase.