Add support for custom button labels to Qt wxMessageDialog
Just set the label if it's specified.
This commit is contained in:
parent
f3260b3b16
commit
09fe965219
1 changed files with 11 additions and 4 deletions
|
|
@ -14,6 +14,7 @@
|
|||
#include "wx/qt/private/winevent.h"
|
||||
|
||||
#include <QtWidgets/qmessagebox.h>
|
||||
#include <QtWidgets/qpushbutton.h>
|
||||
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue