From 09fe96521949a2c40c8a6c60fbb2733e8a35c373 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 11 Feb 2024 13:53:24 +0100 Subject: [PATCH] Add support for custom button labels to Qt wxMessageDialog Just set the label if it's specified. --- src/qt/msgdlg.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/qt/msgdlg.cpp b/src/qt/msgdlg.cpp index 8d98a1cdfa..cade4e8010 100644 --- a/src/qt/msgdlg.cpp +++ b/src/qt/msgdlg.cpp @@ -14,6 +14,7 @@ #include "wx/qt/private/winevent.h" #include +#include class wxQtMessageDialog : public wxQtEventSignalHandler< QMessageBox, wxMessageDialog > @@ -102,14 +103,20 @@ void wxQtMessageDialog::InitializeIfNeeded(wxMessageDialog& msgdlg) // Buttons const long style = msgdlg.GetMessageDialogStyle(); + const auto applyCustomLabelIfSet = [](QPushButton* button, const wxString& label) + { + if ( !label.empty() ) + button->setText( wxQtConvertString( label ) ); + }; + if ( style & wxOK ) - addButton( QMessageBox::Ok ); + applyCustomLabelIfSet(addButton( QMessageBox::Ok ), msgdlg.GetOKLabel()); if ( style & wxCANCEL ) - addButton( QMessageBox::Cancel ); + applyCustomLabelIfSet(addButton( QMessageBox::Cancel ), msgdlg.GetCancelLabel()); if ( style & wxYES_NO ) { - addButton( QMessageBox::Yes ); - addButton( QMessageBox::No ); + applyCustomLabelIfSet(addButton( QMessageBox::Yes ), msgdlg.GetYesLabel()); + applyCustomLabelIfSet(addButton( QMessageBox::No ), msgdlg.GetNoLabel()); } // Default button