From 15c136ead236d47bba27aa79ac3cf8fb6c593fa4 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 24 Aug 2020 23:17:14 +0100 Subject: [PATCH] Make a bunch of help dialogs modeless. Fixes https://gitlab.com/kicad/code/kicad/issues/5334 --- common/dialogs/dialog_configure_paths.cpp | 8 ++++---- common/html_messagebox.cpp | 8 ++++++++ eeschema/dialogs/dialog_bom.cpp | 11 +++++++---- eeschema/sch_text.cpp | 8 ++++---- include/html_messagebox.h | 20 ++++++++------------ pcbnew/dialogs/panel_setup_rules.cpp | 8 ++++---- 6 files changed, 35 insertions(+), 28 deletions(-) diff --git a/common/dialogs/dialog_configure_paths.cpp b/common/dialogs/dialog_configure_paths.cpp index 2c83ede8b6..89a074b259 100644 --- a/common/dialogs/dialog_configure_paths.cpp +++ b/common/dialogs/dialog_configure_paths.cpp @@ -587,9 +587,9 @@ void DIALOG_CONFIGURE_PATHS::OnHelp( wxCommandEvent& event ) } - HTML_MESSAGE_BOX dlg( GetParent(), _( "Environment Variable Help" ) ); - dlg.SetDialogSizeInDU( 400, 250 ); + HTML_MESSAGE_BOX* dlg = new HTML_MESSAGE_BOX( nullptr, _( "Environment Variable Help" ) ); + dlg->SetDialogSizeInDU( 400, 250 ); - dlg.AddHTML_Text( msg ); - dlg.ShowModal(); + dlg->AddHTML_Text( msg ); + dlg->ShowModeless(); } diff --git a/common/html_messagebox.cpp b/common/html_messagebox.cpp index 8a74e6bd33..21d6808371 100644 --- a/common/html_messagebox.cpp +++ b/common/html_messagebox.cpp @@ -121,3 +121,11 @@ void HTML_MESSAGE_BOX::AddHTML_Text( const wxString& message ) m_htmlWindow->AppendToPage( message ); } + +void HTML_MESSAGE_BOX::ShowModeless() +{ + m_sdbSizer1->Show( false ); + Layout(); + + Show( true ); +} diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index f863275fb0..f872dbcd28 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -589,13 +589,16 @@ void DIALOG_BOM::OnEditGenerator( wxCommandEvent& event ) void DIALOG_BOM::OnHelp( wxCommandEvent& event ) { - HTML_MESSAGE_BOX help_Dlg( this, _( "Bill of Material Generation Help" ) ); - help_Dlg.SetDialogSizeInDU( 500, 350 ); + HTML_MESSAGE_BOX* help_Dlg = new HTML_MESSAGE_BOX( nullptr, + _( "Bill of Material Generation Help" ) ); + + help_Dlg->SetDialogSizeInDU( 500, 350 ); wxString html_txt; ConvertMarkdown2Html( wxGetTranslation( s_bomHelpInfo ), html_txt ); - help_Dlg.m_htmlWindow->AppendToPage( html_txt ); - help_Dlg.ShowModal(); + + help_Dlg->m_htmlWindow->AppendToPage( html_txt ); + help_Dlg->ShowModeless(); } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 353015c3b0..f90288918e 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -1389,9 +1389,9 @@ void SCH_TEXT::ShowSyntaxHelp( wxWindow* aParentWindow ) " " "" ); - HTML_MESSAGE_BOX dlg( aParentWindow, _( "Syntax Help" ) ); - dlg.SetDialogSizeInDU( 280, 280 ); + HTML_MESSAGE_BOX* dlg = new HTML_MESSAGE_BOX( aParentWindow, _( "Syntax Help" ) ); + dlg->SetDialogSizeInDU( 280, 280 ); - dlg.AddHTML_Text( msg ); - dlg.ShowModal(); + dlg->AddHTML_Text( msg ); + dlg->ShowModeless(); } diff --git a/include/html_messagebox.h b/include/html_messagebox.h index 3c2aced74b..41f2f4bf14 100644 --- a/include/html_messagebox.h +++ b/include/html_messagebox.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2019 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 1992-2020 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -26,12 +26,6 @@ #define _html_messagebox_ -/** - * @file include/html_messagebox.h - * - * Subclass of DIALOG_DISPLAY_HTML_TEXT_BASE, which is generated by wxFormBuilder. - */ - #include <../common/dialogs/dialog_display_info_HTML_base.h> @@ -51,7 +45,7 @@ public: ~HTML_MESSAGE_BOX() override; /** - * set the dialog size, using a "logical value. + * set the dialog size, using a "logical" value. * the physical size in pixel will depend on the display definition * so a value used here shoul be OK with any display (HDPI for instance) * @param aWidth is a "logical" value of the dialog width. @@ -81,17 +75,19 @@ public: /** * Add a message (in bold) to message list. - * - * @param message = the message */ void MessageSet( const wxString& message ); /** * Add HTML text (without any change) to message list. - * - * @param message = the text to add */ void AddHTML_Text( const wxString& message ); + + /** + * Show a modeless version of the dialog (without an OK button). + */ + void ShowModeless(); + }; #endif // _html_messagebox_ diff --git a/pcbnew/dialogs/panel_setup_rules.cpp b/pcbnew/dialogs/panel_setup_rules.cpp index 7357367e58..1d81791b11 100644 --- a/pcbnew/dialogs/panel_setup_rules.cpp +++ b/pcbnew/dialogs/panel_setup_rules.cpp @@ -406,9 +406,9 @@ void PANEL_SETUP_RULES::OnSyntaxHelp( wxHyperlinkEvent& aEvent ) " (condition \"A.netclass == 'HV' && B.netclass == 'HV'\"))\r" ""; - HTML_MESSAGE_BOX dlg( m_parent, _( "Syntax Help" ) ); - dlg.SetDialogSizeInDU( 320, 320 ); + HTML_MESSAGE_BOX* dlg = new HTML_MESSAGE_BOX( nullptr, _( "Syntax Help" ) ); + dlg->SetDialogSizeInDU( 320, 320 ); - dlg.AddHTML_Text( msg ); - dlg.ShowModal(); + dlg->AddHTML_Text( msg ); + dlg->ShowModeless(); }