The SendConfirmationDialog is used for bumping the fee, where "Send" doesn't really make sense
Customisation of the dialog is also needed for #16944 and #15987 so might as well use it for this too.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
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.
The SendConfirmationDialog is used for bumping the fee, where "Send" doesn't really make sense
I think it still does make some sense, as in 'send bumped transaction'. This adds a lot of complexity just to set a button text.
891 | + : QMessageBox(parent), 892 | + m_yes_button_text(yes_button_text), 893 | + secDelay(_secDelay) 894 | { 895 | - setIcon(QMessageBox::Question); 896 | + setIcon(icon);
Instead of another constructor argument, let the caller change the icon? Like
SendConfirmationDialog confirmationDialog(tr("Confirm fee bump"), ...);
confirmationDialog.setIcon(QMessageBox::Question);
No reply?
I don't know that it makes sense to create a SCD without a chosen icon...
I'd be happy to have QMessageBox::Question by default, and the caller is free to change.
Ok, done
Concept ACK.
904 | + setStandardButtons(yes_button | cancel_button); 905 | + 906 | + // We need to ensure the buttons have Yes/No roles, or they'll get ordered weird 907 | + QAbstractButton * const cancel_button_obj = button(cancel_button); 908 | + removeButton(cancel_button_obj); 909 | + addButton(cancel_button_obj, QMessageBox::NoRole);
Why QMessageBox::NoRole instead of QMessageBox::Cancel?
// We need to ensure the buttons have Yes/No roles, or they'll get ordered weird
That's not very clear; NoRole is neither Yes or No.
Operating systems have different rules about which button needs to be on the left (I don't care too deeply though). Is that the "weird" ordering you're seeing?
https://doc.qt.io/qt-5/qmessagebox.html
| NoRole | The button is a "No"-like button. |
|---|
Yes, it has to do with which button is left/right.
Oh wait, I miss-read NoRole as having no role :-)
ACK d6adf3bc2db17ed3a17caa2ac5cf9095d70b53fb
The simplification of retval could be its own commit.
Tested ACK d6adf3bc2db17ed3a17caa2ac5cf9095d70b53fb
Before: <img width="451" alt="Bildschirmfoto 2019-11-15 um 14 04 47" src="https://user-images.githubusercontent.com/178464/68983816-f0929c00-07b0-11ea-84b8-49251b7f5b16.png"> <img width="585" alt="Bildschirmfoto 2019-11-15 um 13 57 28" src="https://user-images.githubusercontent.com/178464/68983822-f4262300-07b0-11ea-9723-67da2696862b.png">
With this PR: <img width="451" alt="Bildschirmfoto 2019-11-15 um 14 04 04" src="https://user-images.githubusercontent.com/178464/68983829-01431200-07b1-11ea-8f41-e5679c7bd393.png">
<img width="585" alt="Bildschirmfoto 2019-11-15 um 14 00 05" src="https://user-images.githubusercontent.com/178464/68983857-29cb0c00-07b1-11ea-99d7-750244effd26.png">
899 | setInformativeText(informative_text); 900 | setDetailedText(detailed_text); 901 | - setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); 902 | - setDefaultButton(QMessageBox::Cancel); 903 | - yesButton = button(QMessageBox::Yes); 904 | + setStandardButtons(yes_button | cancel_button);
Does this line actually do anything, if we subsequently remove both buttons and re-add them? Can we just call addButton twice to the same effect, and not have to remove them first?
@gwillen I think that has something to do with ordering: #17463 (review)
This is required so that the buttons are instanced otherwise button() returns nullptr.
Rebased
As @gwillen points out inline, I'm able to drop this entire code block with no visible change. At least not on macOS with QT 5.13.2:
// We need to ensure the buttons have Yes/No roles, or they'll get ordered weird
QAbstractButton * const cancel_button_obj = button(cancel_button);
removeButton(cancel_button_obj);
addButton(cancel_button_obj, QMessageBox::NoRole);
setEscapeButton(cancel_button_obj);
setDefaultButton(cancel_button);
<img width="345" alt="Schermafbeelding 2020-01-03 om 15 51 27" src="https://user-images.githubusercontent.com/10217/71712726-85288a80-2e41-11ea-8347-35286599ed72.png">
Otherwise 350234028786a139b7faf08655f27d97c9ff66e8 looks good.
942 | @@ -935,7 +943,8 @@ int SendConfirmationDialog::exec() 943 | { 944 | updateYesButton(); 945 | countDownTimer.start(1000); 946 | - return QMessageBox::exec(); 947 | + QMessageBox::exec(); 948 | + return (buttonRole(clickedButton()) == QMessageBox::YesRole);
Just noting that clickedButton() can return nullptr - in that case buttonRole(nullptr) returns InvalidRole so this is safe.
I wonder why not compare the exec() return agains QMessageBox::Yes?
The YesRole button might not be Yes.
And no, according to the Qt documentation, it can't return nullptr...
Oh because of setEscapeButton?
Right
Sorry but I really dislike the "super" constructor - I don't see how that's preferable over calling a couple of setters, which is more expressive and obvious.
It's also unfortunately that it needs to remove/add buttons to fix the order.
Approach ACK.
Both buttons can be replaced with other standard buttons
The SendConfirmationDialog is used for bumping the fee, where "Send" doesn't really make sense
Rebased