Generate wxDialogInit event for wxDialog under wxQT

This commit is contained in:
Graham Dawes
2019-01-21 13:53:59 +00:00
parent 467bb0ec66
commit 9cfecad878
2 changed files with 26 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ public:
virtual int ShowModal() wxOVERRIDE;
virtual void EndModal(int retCode) wxOVERRIDE;
virtual bool IsModal() const wxOVERRIDE;
virtual bool Show(bool show) wxOVERRIDE;
QDialog *GetDialogHandle() const;

View File

@@ -74,7 +74,12 @@ int wxDialog::ShowModal()
WX_HOOK_MODAL_DIALOG();
wxCHECK_MSG( GetHandle() != NULL, -1, "Invalid dialog" );
bool ret = GetDialogHandle()->exec();
QDialog *qDialog = GetDialogHandle();
qDialog->setModal(true);
Show(true);
bool ret = qDialog->exec();
if ( GetReturnCode() == 0 )
return ret ? wxID_OK : wxID_CANCEL;
return GetReturnCode();
@@ -95,6 +100,25 @@ bool wxDialog::IsModal() const
return GetDialogHandle()->isModal();
}
bool wxDialog::Show(bool show)
{
if ( show == IsShown() )
return false;
if ( !show && IsModal() )
EndModal(wxID_CANCEL);
if ( show && CanDoLayoutAdaptation() )
DoLayoutAdaptation();
const bool ret = wxDialogBase::Show(show);
if (show)
InitDialog();
return ret;
}
QDialog *wxDialog::GetDialogHandle() const
{
return static_cast<QDialog*>(m_qtWindow);