GUI: SendConfirmationDialog: Defer button setup until exec

This commit is contained in:
Luke Dashjr 2021-08-12 21:42:50 +00:00
parent 86c5b4f00a
commit 08ce9ecf45
2 changed files with 9 additions and 7 deletions

View File

@ -1055,15 +1055,19 @@ void SendCoinsDialog::coinControlUpdateLabels()
} }
SendConfirmationDialog::SendConfirmationDialog(const QString& title, const QString& text, const QString& informative_text, const QString& detailed_text, int _secDelay, bool enable_send, bool always_show_unsigned, QWidget* parent) SendConfirmationDialog::SendConfirmationDialog(const QString& title, const QString& text, const QString& informative_text, const QString& detailed_text, int _secDelay, bool enable_send, bool always_show_unsigned, QWidget* parent)
: QMessageBox(parent), secDelay(_secDelay), m_enable_send(enable_send) : QMessageBox(parent), secDelay(_secDelay), m_enable_save(always_show_unsigned || !enable_send), m_enable_send(enable_send)
{ {
setIcon(QMessageBox::Question); setIcon(QMessageBox::Question);
setWindowTitle(title); // On macOS, the window title is ignored (as required by the macOS Guidelines). setWindowTitle(title); // On macOS, the window title is ignored (as required by the macOS Guidelines).
setText(text); setText(text);
setInformativeText(informative_text); setInformativeText(informative_text);
setDetailedText(detailed_text); setDetailedText(detailed_text);
}
int SendConfirmationDialog::exec()
{
setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
if (always_show_unsigned || !enable_send) addButton(QMessageBox::Save); if (m_enable_save) addButton(QMessageBox::Save);
setDefaultButton(QMessageBox::Cancel); setDefaultButton(QMessageBox::Cancel);
yesButton = button(QMessageBox::Yes); yesButton = button(QMessageBox::Yes);
if (confirmButtonText.isEmpty()) { if (confirmButtonText.isEmpty()) {
@ -1071,13 +1075,10 @@ SendConfirmationDialog::SendConfirmationDialog(const QString& title, const QStri
} }
m_psbt_button = button(QMessageBox::Save); m_psbt_button = button(QMessageBox::Save);
updateButtons(); updateButtons();
connect(&countDownTimer, &QTimer::timeout, this, &SendConfirmationDialog::countDown);
}
int SendConfirmationDialog::exec() connect(&countDownTimer, &QTimer::timeout, this, &SendConfirmationDialog::countDown);
{
updateButtons();
countDownTimer.start(1s); countDownTimer.start(1s);
return QMessageBox::exec(); return QMessageBox::exec();
} }

View File

@ -144,6 +144,7 @@ private:
QTimer countDownTimer; QTimer countDownTimer;
int secDelay; int secDelay;
QString confirmButtonText{tr("Send")}; QString confirmButtonText{tr("Send")};
bool m_enable_save;
bool m_enable_send; bool m_enable_send;
QString m_psbt_button_text{tr("Create Unsigned")}; QString m_psbt_button_text{tr("Create Unsigned")};
}; };