Move Configure Paths help inside dialog.

This allows us to switch back to a standard modal dialog (instead of
quasi-modal, which has problems with Ctrl-V in a search box inside a
standard file dialog -- such as when picking a path).

Fixes https://gitlab.com/kicad/code/kicad/issues/9473
This commit is contained in:
Jeff Young 2022-08-07 11:26:42 +01:00
parent 5c9aed62aa
commit 51b905ba32
3 changed files with 53 additions and 40 deletions

View File

@ -62,7 +62,8 @@ DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS( wxWindow* aParent, FILENAME_RESO
m_resolver( aResolver ),
m_gridWidth( 0 ),
m_gridWidthsDirty( true ),
m_helpDialog( nullptr )
m_helpBox( nullptr ),
m_heightBeforeHelp( 400 )
{
m_btnAddEnvVar->SetBitmap( KiBitmap( BITMAPS::small_plus ) );
m_btnDeleteEnvVar->SetBitmap( KiBitmap( BITMAPS::small_trash ) );
@ -128,9 +129,6 @@ DIALOG_CONFIGURE_PATHS::~DIALOG_CONFIGURE_PATHS()
m_SearchPaths->PopEventHandler( true );
m_EnvVars->PopEventHandler( true );
if( m_helpDialog )
m_helpDialog->Destroy();
m_EnvVars->Disconnect( wxEVT_GRID_CELL_CHANGING,
wxGridEventHandler( DIALOG_CONFIGURE_PATHS::OnGridCellChanging ),
nullptr, this );
@ -594,14 +592,12 @@ void DIALOG_CONFIGURE_PATHS::OnUpdateUI( wxUpdateUIEvent& event )
m_gridWidthsDirty = false;
}
// Handle a grid error. This is delayed to OnUpdateUI so that we can change focus
// even when the original validation was triggered from a killFocus event (and for
// dialog with notebooks, so that the corresponding notebook page can be shown in
// the background when triggered from an OK).
// Handle a grid error. This is delayed to OnUpdateUI so that we can change focus even when
// the original validation was triggered from a killFocus event.
if( m_errorGrid )
{
// We will re-enter this routine when the error dialog is displayed, so make
// sure we don't keep putting up more dialogs.
// We will re-enter this routine when the error dialog is displayed, so make sure we don't
// keep putting up more dialogs.
wxGrid* grid = m_errorGrid;
m_errorGrid = nullptr;
@ -628,38 +624,55 @@ void DIALOG_CONFIGURE_PATHS::OnGridSize( wxSizeEvent& event )
void DIALOG_CONFIGURE_PATHS::OnHelp( wxCommandEvent& event )
{
if( m_helpDialog )
wxSizer* sizerMain = GetSizer();
if( !m_helpBox )
{
m_helpDialog->ShowModeless();
return;
m_helpBox = new HTML_WINDOW( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxHW_SCROLLBAR_AUTO );
wxString msg = _( "Enter the name and value for each environment variable. Grey entries "
"are names that have been defined externally at the system or user "
"level. Environment variables defined at the system or user level "
"take precedence over the ones defined in this table. This means the "
"values in this table are ignored." );
msg << "<br><br><b>";
msg << _( "To ensure environment variable names are valid on all platforms, the name field "
"will only accept upper case letters, digits, and the underscore characters." );
msg << "</b>";
for( const wxString& var : ENV_VAR::GetPredefinedEnvVars() )
{
msg << "<br><br><b>" << var << "</b>";
const auto desc = ENV_VAR::LookUpEnvVarHelp( var );
if( desc.size() > 0 )
msg << ": " << desc;
}
m_helpBox->SetPage( msg );
m_helpBox->Show( false );
sizerMain->Insert( sizerMain->GetItemCount() - 1, m_helpBox, 1, wxALL|wxEXPAND, 10 );
}
wxString msg = _( "Enter the name and value for each environment variable. Grey entries "
"are names that have been defined externally at the system or user "
"level. Environment variables defined at the system or user level "
"take precedence over the ones defined in this table. This means the "
"values in this table are ignored." );
msg << "<br><br><b>";
msg << _( "To ensure environment variable names are valid on all platforms, the name field "
"will only accept upper case letters, digits, and the underscore characters." );
msg << "</b>";
for( const auto& var : ENV_VAR::GetPredefinedEnvVars() )
if( m_helpBox->IsShown() )
{
msg << "<br><br><b>" << var << "</b>";
m_helpBox->Show( false );
SetClientSize( wxSize( GetClientSize().x, m_heightBeforeHelp ) );
}
else
{
m_helpBox->Show( true );
m_heightBeforeHelp = GetClientSize().y;
const auto desc = ENV_VAR::LookUpEnvVarHelp( var );
if( desc.size() > 0 )
msg << ": " << desc;
int minHelpBoxHeight = GetTextExtent( wxT( "T" ) ).y * 20;
if( GetClientSize().y < minHelpBoxHeight * 2 )
SetClientSize( wxSize( GetClientSize().x, GetClientSize().y + minHelpBoxHeight ) );
}
m_helpDialog = new HTML_MESSAGE_BOX( nullptr, _( "Environment Variable Help" ) );
m_helpDialog->SetDialogSizeInDU( 400, 250 );
m_helpDialog->AddHTML_Text( msg );
m_helpDialog->ShowModeless();
// m_helpDialog will be destroyed when closing the dialog
Layout();
}

View File

@ -113,8 +113,7 @@ int COMMON_CONTROL::ConfigurePaths( const TOOL_EVENT& aEvent )
{
DIALOG_CONFIGURE_PATHS dlg( m_frame, nullptr );
// Use QuasiModal so that HTML help window will work
if( dlg.ShowQuasiModal() == wxID_OK )
if( dlg.ShowModal() == wxID_OK )
m_frame->Kiway().CommonSettingsChanged( true, false );
}

View File

@ -32,7 +32,7 @@
class FILENAME_RESOLVER;
class HTML_MESSAGE_BOX;
class HTML_WINDOW;
class DIALOG_CONFIGURE_PATHS: public DIALOG_CONFIGURE_PATHS_BASE
@ -74,7 +74,8 @@ private:
int m_gridWidth;
bool m_gridWidthsDirty;
HTML_MESSAGE_BOX* m_helpDialog;
HTML_WINDOW* m_helpBox;
int m_heightBeforeHelp;
};
#endif // _DIALOG_CONFIGURE_PATHS_H_