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.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
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
0SendConfirmationDialog confirmationDialog(tr("Confirm fee bump"), ...);
1confirmationDialog.setIcon(QMessageBox::Question);
QMessageBox::Question
by default, and the caller is free to change.
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);
QMessageBox::NoRole
instead of QMessageBox::Cancel
?
0 // We need to ensure the buttons have Yes/No roles, or they'll get ordered weird
NoRole
is neither Yes or No.
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.
NoRole
as having no role :-)
ACK d6adf3bc2db17ed3a17caa2ac5cf9095d70b53fb
The simplification of retval
could be its own commit.
Tested ACK d6adf3bc2db17ed3a17caa2ac5cf9095d70b53fb
Before:
With this PR:
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);
button()
returns nullptr
.
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:
0 // We need to ensure the buttons have Yes/No roles, or they'll get ordered weird
1 QAbstractButton * const cancel_button_obj = button(cancel_button);
2 removeButton(cancel_button_obj);
3 addButton(cancel_button_obj, QMessageBox::NoRole);
4 setEscapeButton(cancel_button_obj);
5 setDefaultButton(cancel_button);
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
?
setEscapeButton
?
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.
Both buttons can be replaced with other standard buttons
The SendConfirmationDialog is used for bumping the fee, where "Send" doesn't really make sense