Do not parent dialogs to non top level windows in panels or widgets.

This commit is contained in:
Wayne Stambaugh 2024-02-02 12:47:34 -05:00
parent 4d49762714
commit 92c2ddf77a
27 changed files with 176 additions and 104 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2023 CERN
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2023-2024 KiCad Developers, see AUTHORS.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 as published by the
@ -645,7 +645,8 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
}
else if( index == count - 2 )
{
wxTextEntryDialog dlg( this, _( "Layer preset name:" ), _( "Save Layer Preset" ) );
wxTextEntryDialog dlg( wxGetTopLevelParent( this ), _( "Layer preset name:" ),
_( "Save Layer Preset" ) );
if( dlg.ShowModal() != wxID_OK )
{
@ -660,7 +661,7 @@ void APPEARANCE_CONTROLS_3D::onLayerPresetChanged( wxCommandEvent& aEvent )
if( LAYER_PRESET_3D* preset = cfg->FindPreset( name ) )
{
if( !IsOK( this, _( "Overwrite existing preset?" ) ) )
if( !IsOK( wxGetTopLevelParent( this ), _( "Overwrite existing preset?" ) ) )
{
resetSelection();
return;
@ -792,7 +793,8 @@ void APPEARANCE_CONTROLS_3D::onViewportChanged( wxCommandEvent& aEvent )
// Save current state to new preset
wxString name;
wxTextEntryDialog dlg( this, _( "Viewport name:" ), _( "Save Viewport" ), name );
wxTextEntryDialog dlg( wxGetTopLevelParent( this ), _( "Viewport name:" ),
_( "Save Viewport" ), name );
if( dlg.ShowModal() != wxID_OK )
{

View File

@ -128,7 +128,8 @@ void PANEL_COLOR_SETTINGS::OnThemeChanged( wxCommandEvent& event )
return;
FOOTPRINT_NAME_VALIDATOR themeNameValidator;
wxTextEntryDialog dlg( this, _( "New theme name:" ), _( "Add Color Theme" ) );
wxTextEntryDialog dlg( wxGetTopLevelParent( this ), _( "New theme name:" ),
_( "Add Color Theme" ) );
dlg.SetTextValidator( themeNameValidator );
if( dlg.ShowModal() != wxID_OK )
@ -388,4 +389,4 @@ wxString PANEL_COLOR_SETTINGS::GetSettingsDropdownName(COLOR_SETTINGS* aSettings
name += wxS( " " ) + _( "(read-only)" );
return name;
}
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.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
@ -229,7 +229,8 @@ bool PANEL_GRID_SETTINGS::TransferDataToWindow()
void PANEL_GRID_SETTINGS::OnAddGrid( wxCommandEvent& event )
{
GRID newGrid = GRID{ wxEmptyString, "", "" };
DIALOG_GRID_SETTINGS dlg( this->GetParent(), m_eventSource, m_unitsProvider, newGrid );
DIALOG_GRID_SETTINGS dlg( wxGetTopLevelParent( this ), m_eventSource, m_unitsProvider,
newGrid );
if( dlg.ShowModal() != wxID_OK )
return;
@ -241,8 +242,11 @@ void PANEL_GRID_SETTINGS::OnAddGrid( wxCommandEvent& event )
{
if( newGrid == g )
{
DisplayError( this, wxString::Format( _( "Grid size '%s' already exists." ),
g.UserUnitsMessageText( m_unitsProvider ) ) );
wxWindow* topLevelParent = wxGetTopLevelParent( this );
DisplayError( topLevelParent,
wxString::Format( _( "Grid size '%s' already exists." ),
g.UserUnitsMessageText( m_unitsProvider ) ) );
return;
}
}
@ -260,7 +264,10 @@ void PANEL_GRID_SETTINGS::OnRemoveGrid( wxCommandEvent& event )
if( gridCfg.grids.size() <= 1 )
{
DisplayError( this, wxString::Format( _( "At least one grid size is required." ) ) );
wxWindow* topLevelParent = wxGetTopLevelParent( this );
DisplayError( topLevelParent,
wxString::Format( _( "At least one grid size is required." ) ) );
return;
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2023 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2024 Kicad Developers, see AUTHORS.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
@ -200,7 +200,8 @@ void PANEL_HOTKEYS_EDITOR::ImportHotKeys()
{
wxString filename = wxFileSelector( _( "Import Hotkeys File:" ), m_frame->GetMruPath(),
wxEmptyString, FILEEXT::HotkeyFileExtension,
FILEEXT::HotkeyFileWildcard(), wxFD_OPEN, this );
FILEEXT::HotkeyFileWildcard(), wxFD_OPEN,
wxGetTopLevelParent( this ) );
if( filename.IsEmpty() )
return;
@ -229,8 +230,9 @@ void PANEL_HOTKEYS_EDITOR::ImportHotKeys()
void PANEL_HOTKEYS_EDITOR::dumpHotkeys()
{
wxString filename = wxFileSelector( wxT( "Hotkeys File" ), m_frame->GetMruPath(),
wxEmptyString, FILEEXT::TextFileExtension, FILEEXT::TextFileWildcard(),
wxFD_SAVE, this );
wxEmptyString, FILEEXT::TextFileExtension,
FILEEXT::TextFileWildcard(),
wxFD_SAVE, wxGetTopLevelParent( this ) );
if( filename.IsEmpty() )
return;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2018 jean-pierre.charras
* Copyright (C) 2011-2023 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2011-2024 Kicad Developers, see AUTHORS.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
@ -81,9 +81,10 @@ bool PANEL_IMAGE_EDITOR::CheckValues()
if( size_min < MIN_SIZE ) // if the size is too small, the image will be hard to locate
{
wxMessageBox( wxString::Format( _( "This scale results in an image which is too small "
"(%.2f mm or %.1f mil)." ),
25.4 / 300 * size_min, 1000.0 / 300.0 * size_min ) );
wxMessageDialog( wxGetTopLevelParent( this ),
wxString::Format( _( "This scale results in an image which is too "
"small (%.2f mm or %.1f mil)." ),
25.4 / 300 * size_min, 1000.0 / 300.0 * size_min ) );
return false;
}
@ -92,9 +93,10 @@ bool PANEL_IMAGE_EDITOR::CheckValues()
if( size_max > MAX_SIZE )
{
// the actual size is 25.4/300 * size_max in mm
if( !IsOK( this, wxString::Format( _( "This scale results in an image which is very large "
"(%.1f mm or %.2f in). Are you sure?" ),
25.4 / 300 * size_max, size_max / 300.0 ) ) )
if( !IsOK( wxGetTopLevelParent( this ),
wxString::Format( _( "This scale results in an image which is very large "
"(%.1f mm or %.2f in). Are you sure?" ),
25.4 / 300 * size_max, size_max / 300.0 ) ) )
{
return false;
}

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2004-2009 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2009-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2009-2024 KiCad Developers, see AUTHORS.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
@ -156,7 +156,8 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( wxWindow* aParentWindow, EDA_DRA
wxGridCellAttr* attr = new wxGridCellAttr;
attr->SetRenderer( new GRID_CELL_COLOR_RENDERER( PAGED_DIALOG::GetDialog( this ) ) );
attr->SetEditor( new GRID_CELL_COLOR_SELECTOR( PAGED_DIALOG::GetDialog( this ), m_netclassGrid ) );
attr->SetEditor( new GRID_CELL_COLOR_SELECTOR( PAGED_DIALOG::GetDialog( this ),
m_netclassGrid ) );
m_netclassGrid->SetColAttr( GRID_SCHEMATIC_COLOR, attr );
attr = new wxGridCellAttr;
@ -595,7 +596,9 @@ void PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick( wxCommandEvent& event )
}
else if( curRow == 0 )
{
DisplayErrorMessage( this, _( "The default net class is required." ) );
wxWindow* topLevelParent = wxGetTopLevelParent( this );
DisplayErrorMessage( topLevelParent, _( "The default net class is required." ) );
return;
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2024 KiCad Developers, see AUTHORS.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
@ -236,9 +236,11 @@ void PANEL_TEXT_VARIABLES::OnUpdateUI( wxUpdateUIEvent& event )
int width = m_TextVars->GetClientRect().GetWidth();
m_TextVars->AutoSizeColumn( TV_NAME_COL );
m_TextVars->SetColSize( TV_NAME_COL, std::max( 72, m_TextVars->GetColSize( TV_NAME_COL ) ) );
m_TextVars->SetColSize( TV_NAME_COL,
std::max( 72, m_TextVars->GetColSize( TV_NAME_COL ) ) );
m_TextVars->SetColSize( TV_VALUE_COL, std::max( 120, width - m_TextVars->GetColSize( TV_NAME_COL ) ) );
m_TextVars->SetColSize( TV_VALUE_COL,
std::max( 120, width - m_TextVars->GetColSize( TV_NAME_COL ) ) );
m_gridWidthsDirty = false;
}
@ -253,7 +255,9 @@ void PANEL_TEXT_VARIABLES::OnUpdateUI( wxUpdateUIEvent& event )
wxString errorMsg = m_errorMsg;
m_errorMsg = wxEmptyString;
DisplayErrorMessage( this, errorMsg );
wxWindow* topLevelParent = wxGetTopLevelParent( this );
DisplayErrorMessage( topLevelParent, errorMsg );
m_TextVars->SetFocus();
m_TextVars->MakeCellVisible( m_errorRow, m_errorCol );

View File

@ -386,7 +386,8 @@ void WX_HTML_REPORT_PANEL::onBtnSaveToFile( wxCommandEvent& event )
msg.Printf( _( "Cannot write report to file '%s'." ),
fn.GetFullPath().GetData() );
wxMessageBox( msg, _( "File save error" ), wxOK | wxICON_ERROR, this );
wxMessageBox( msg, _( "File save error" ), wxOK | wxICON_ERROR,
wxGetTopLevelParent( this ) );
return;
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2024 KiCad Developers, see AUTHORS.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 as published by the
@ -145,7 +145,8 @@ bool PANEL_EESCHEMA_COLOR_SETTINGS::validateSave( bool aQuiet )
"and they will not be seen on the screen. Are you\n"
"sure you want to use these colors?" );
if( wxMessageBox( msg, _( "Warning" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
if( wxMessageBox( msg, _( "Warning" ), wxYES_NO | wxICON_QUESTION,
wxGetTopLevelParent( this ) ) == wxNO )
return false;
break;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 CERN
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2021-2024 KiCad Developers, see AUTHORS.txt for contributors.
* @author Jon Evans <jon@craftyjon.com>
*
* This program is free software: you can redistribute it and/or modify it
@ -394,7 +394,9 @@ void PANEL_SETUP_BUSES::OnUpdateUI( wxUpdateUIEvent& event )
wxString errorMsg = m_errorMsg;
m_errorMsg = wxEmptyString;
DisplayErrorMessage( this, errorMsg );
wxWindow* topLevelParent = wxGetTopLevelParent( this );
DisplayErrorMessage( topLevelParent, errorMsg );
m_errorGrid->SetFocus();
m_errorGrid->MakeCellVisible( m_errorRow, 0 );

View File

@ -433,7 +433,9 @@ bool PANEL_SYM_LIB_TABLE::verifyTables()
else
msg = _( "A library table row path cell is empty." );
wxMessageDialog badCellDlg( this, msg, _( "Invalid Row Definition" ),
wxWindow* topLevelParent = wxGetTopLevelParent( this );
wxMessageDialog badCellDlg( topLevelParent, msg, _( "Invalid Row Definition" ),
wxYES_NO | wxCENTER | wxICON_QUESTION | wxYES_DEFAULT );
badCellDlg.SetExtendedMessage( _( "Empty cells will result in all rows that are "
"invalid to be removed from the table." ) );
@ -462,7 +464,9 @@ bool PANEL_SYM_LIB_TABLE::verifyTables()
m_cur_grid->MakeCellVisible( r, 0 );
m_cur_grid->SetGridCursor( r, 1 );
wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) );
wxWindow* topLevelParent = wxGetTopLevelParent( this );
wxMessageDialog errdlg( topLevelParent, msg, _( "Library Nickname Error" ) );
errdlg.ShowModal();
return false;
}
@ -512,7 +516,9 @@ bool PANEL_SYM_LIB_TABLE::verifyTables()
m_cur_grid->MakeCellVisible( r2, 0 );
m_cur_grid->SetGridCursor( r2, 1 );
wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) );
wxWindow* topLevelParent = wxGetTopLevelParent( this );
wxMessageDialog errdlg( topLevelParent, msg, _( "Library Nickname Error" ) );
errdlg.ShowModal();
return false;
@ -550,7 +556,9 @@ bool PANEL_SYM_LIB_TABLE::verifyTables()
{
msg.Printf( _( "Symbol library '%s' failed to load." ), row.GetNickName() );
wxMessageDialog errdlg( this, msg + wxS( "\n" ) + ioe.What(),
wxWindow* topLevelParent = wxGetTopLevelParent( this );
wxMessageDialog errdlg( topLevelParent, msg + wxS( "\n" ) + ioe.What(),
_( "Error Loading Library" ) );
errdlg.ShowModal();
@ -641,7 +649,8 @@ void PANEL_SYM_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
if( !applyToAll )
{
// The cancel button adds the library to the table anyway
addDuplicates = OKOrCancelDialog( this, warning, wxString::Format( msg, nickname ),
addDuplicates = OKOrCancelDialog( wxGetTopLevelParent( this ), warning,
wxString::Format( msg, nickname ),
detailedMsg, _( "Skip" ), _( "Add Anyway" ),
&applyToAll ) == wxID_CANCEL;
}
@ -876,7 +885,10 @@ void PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries( wxCommandEvent& event )
if( !legacyLib.Exists() )
{
msg.Printf( _( "Library '%s' not found." ), relPath );
DisplayErrorMessage( this, msg );
wxWindow* topLevelParent = wxGetTopLevelParent( this );
DisplayErrorMessage( topLevelParent, msg );
continue;
}
@ -917,7 +929,10 @@ void PANEL_SYM_LIB_TABLE::onConvertLegacyLibraries( wxCommandEvent& event )
else
{
msg.Printf( _( "Failed to save symbol library file '%s'." ), newLib.GetFullPath() );
DisplayErrorMessage( this, msg );
wxWindow* topLevelParent = wxGetTopLevelParent( this );
DisplayErrorMessage( topLevelParent, msg );
}
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.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
@ -181,7 +181,8 @@ KICOMMON_API int OKOrCancelDialog( wxWindow* aParent, const wxString& aWarning,
const wxString& aMessage,
const wxString& aDetailedMessage = wxEmptyString,
const wxString& aOKLabel = wxEmptyString,
const wxString& aCancelLabel = wxEmptyString, bool* aApplyToAll = nullptr );
const wxString& aCancelLabel = wxEmptyString,
bool* aApplyToAll = nullptr );

View File

@ -166,4 +166,4 @@ void KICAD_MANAGER_FRAME::OnImportEasyEdaProFiles( wxCommandEvent& event )
{
ImportNonKiCadProject( _( "Import EasyEDA Pro Project" ), FILEEXT::EasyEdaProFileWildcard(), { "INPUT" },
{ "INPUT" }, SCH_IO_MGR::SCH_EASYEDAPRO, PCB_IO_MGR::EASYEDAPRO );
}
}

View File

@ -106,7 +106,7 @@ PANEL_PACKAGES_VIEW::PANEL_PACKAGES_VIEW( wxWindow*
PANEL_PACKAGES_VIEW::~PANEL_PACKAGES_VIEW()
{
m_splitter1->Disconnect( wxEVT_IDLE, wxIdleEventHandler( PANEL_PACKAGES_VIEW::SetSashOnIdle ),
NULL, this );
NULL, this );
COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
cfg->m_PackageManager.sash_pos = m_splitter1->GetSashPosition();
@ -516,7 +516,8 @@ void PANEL_PACKAGES_VIEW::OnDownloadVersionClicked( wxCommandEvent& event )
if( !ver_it->download_url )
{
wxMessageBox( _( "Package download url is not specified" ),
_( "Error downloading package" ), wxICON_INFORMATION | wxOK, this );
_( "Error downloading package" ), wxICON_INFORMATION | wxOK,
wxGetTopLevelParent( this ) );
return;
}
@ -559,7 +560,8 @@ void PANEL_PACKAGES_VIEW::OnDownloadVersionClicked( wxCommandEvent& event )
&& wxMessageBox(
_( "Integrity of the downloaded package could not be verified, hash "
"does not match. Are you sure you want to keep this file?" ),
_( "Keep downloaded file" ), wxICON_EXCLAMATION | wxYES_NO, this )
_( "Keep downloaded file" ), wxICON_EXCLAMATION | wxYES_NO,
wxGetTopLevelParent( this ) )
== wxNO )
{
wxRemoveFile( path );
@ -610,7 +612,8 @@ void PANEL_PACKAGES_VIEW::OnVersionActionClicked( wxCommandEvent& event )
if( !ver_it->compatible
&& wxMessageBox( _( "This package version is incompatible with your KiCad version or "
"platform. Are you sure you want to install it anyway?" ),
_( "Install package" ), wxICON_EXCLAMATION | wxYES_NO, this )
_( "Install package" ), wxICON_EXCLAMATION | wxYES_NO,
wxGetTopLevelParent( this ) )
== wxNO )
{
return;

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.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

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.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
@ -1038,7 +1038,7 @@ void PROJECT_TREE_PANE::onRenameFile( wxCommandEvent& event )
wxString buffer = m_TreeProject->GetItemText( curr_item );
wxString msg = wxString::Format( _( "Change filename: '%s'" ),
tree_data[0]->GetFileName() );
wxTextEntryDialog dlg( this, msg, _( "Change filename" ), buffer );
wxTextEntryDialog dlg( wxGetTopLevelParent( this ), msg, _( "Change filename" ), buffer );
if( dlg.ShowModal() != wxID_OK )
return; // canceled by user
@ -1535,8 +1535,10 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent )
if( error == 0 )
{
// Directory is already a git repository
wxWindow* topLevelParent = wxGetTopLevelParent( this );
DisplayInfoMessage( this, _( "The selected directory is already a git project." ) );
DisplayInfoMessage( topLevelParent,
_( "The selected directory is already a git project." ) );
git_repository_free( repo );
return;
}
@ -1552,7 +1554,7 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent )
if( m_gitLastError != git_error_last()->klass )
{
m_gitLastError = git_error_last()->klass;
DisplayErrorMessage( this, _( "Failed to initialize git project." ),
DisplayErrorMessage( m_parent, _( "Failed to initialize git project." ),
git_error_last()->message );
}
@ -1565,7 +1567,7 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent )
}
}
DIALOG_GIT_REPOSITORY dlg( this, repo );
DIALOG_GIT_REPOSITORY dlg( wxGetTopLevelParent( this ), repo );
dlg.SetTitle( _( "Set default remote" ) );
@ -1620,7 +1622,7 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent )
if( m_gitLastError != git_error_last()->klass )
{
m_gitLastError = git_error_last()->klass;
DisplayErrorMessage( this, _( "Failed to set default remote." ),
DisplayErrorMessage( m_parent, _( "Failed to set default remote." ),
git_error_last()->message );
}
@ -1636,7 +1638,9 @@ void PROJECT_TREE_PANE::onGitInitializeProject( wxCommandEvent& aEvent )
handler.SetPassword( m_TreeProject->GitCommon()->GetPassword() );
handler.SetSSHKey( m_TreeProject->GitCommon()->GetSSHKey() );
handler.SetProgressReporter( std::make_unique<WX_PROGRESS_REPORTER>( this, _( "Fetching Remote" ), 1 ) );
handler.SetProgressReporter( std::make_unique<WX_PROGRESS_REPORTER>( this,
_( "Fetching Remote" ),
1 ) );
handler.PerformFetch();
@ -1673,7 +1677,9 @@ void PROJECT_TREE_PANE::onGitPullProject( wxCommandEvent& aEvent )
handler.SetPassword( m_TreeProject->GitCommon()->GetPassword() );
handler.SetSSHKey( m_TreeProject->GitCommon()->GetSSHKey() );
handler.SetProgressReporter( std::make_unique<WX_PROGRESS_REPORTER>( this, _( "Fetching Remote" ), 1 ) );
handler.SetProgressReporter( std::make_unique<WX_PROGRESS_REPORTER>( this,
_( "Fetching Remote" ),
1 ) );
handler.PerformPull();
}
@ -1693,13 +1699,15 @@ void PROJECT_TREE_PANE::onGitPushProject( wxCommandEvent& aEvent )
handler.SetPassword( m_TreeProject->GitCommon()->GetPassword() );
handler.SetSSHKey( m_TreeProject->GitCommon()->GetSSHKey() );
handler.SetProgressReporter( std::make_unique<WX_PROGRESS_REPORTER>( this, _( "Fetching Remote" ), 1 ) );
handler.SetProgressReporter( std::make_unique<WX_PROGRESS_REPORTER>( this,
_( "Fetching Remote" ),
1 ) );
if( handler.PerformPush() != PushResult::Success )
{
wxString errorMessage = handler.GetErrorString();
DisplayErrorMessage( this, _( "Failed to push project" ), errorMessage );
DisplayErrorMessage( m_parent, _( "Failed to push project" ), errorMessage );
}
}
@ -1745,13 +1753,13 @@ void PROJECT_TREE_PANE::onGitSwitchBranch( wxCommandEvent& aEvent )
if( !repo )
return;
DIALOG_GIT_SWITCH dlg( this, repo );
DIALOG_GIT_SWITCH dlg( wxGetTopLevelParent( this ), repo );
int retval = dlg.ShowModal();
wxString branchName = dlg.GetBranchName();
if( retval == wxID_ADD )
git_create_branch( repo, branchName);
git_create_branch( repo, branchName );
else if( retval != wxID_OK )
return;
@ -1761,8 +1769,9 @@ void PROJECT_TREE_PANE::onGitSwitchBranch( wxCommandEvent& aEvent )
if( git_reference_lookup( &branchRef, repo, branchName.mb_str() ) != GIT_OK &&
git_reference_dwim( &branchRef, repo, branchName.mb_str() ) != GIT_OK )
{
wxString errorMessage = wxString::Format( _( "Failed to lookup branch '%s': %s" ), branchName, giterr_last()->message );
DisplayError( this, errorMessage );
wxString errorMessage = wxString::Format( _( "Failed to lookup branch '%s': %s" ),
branchName, giterr_last()->message );
DisplayError( m_parent, errorMessage );
return;
}
@ -1774,7 +1783,7 @@ void PROJECT_TREE_PANE::onGitSwitchBranch( wxCommandEvent& aEvent )
{
wxString errorMessage =
wxString::Format( _( "Failed to find branch head for '%s'" ), branchName );
DisplayError( this, errorMessage );
DisplayError( m_parent, errorMessage );
git_reference_free( branchRef );
return;
}
@ -1785,7 +1794,7 @@ void PROJECT_TREE_PANE::onGitSwitchBranch( wxCommandEvent& aEvent )
{
wxString errorMessage =
wxString::Format( _( "Failed to switch to branch '%s'" ), branchName );
DisplayError( this, errorMessage );
DisplayError( m_parent, errorMessage );
git_reference_free( branchRef );
git_object_free( branchObj );
return;
@ -1796,7 +1805,7 @@ void PROJECT_TREE_PANE::onGitSwitchBranch( wxCommandEvent& aEvent )
{
wxString errorMessage = wxString::Format(
_( "Failed to update HEAD reference for branch '%s'" ), branchName );
DisplayError( this, errorMessage );
DisplayError( m_parent, errorMessage );
git_reference_free( branchRef );
git_object_free( branchObj );
return;
@ -1813,7 +1822,8 @@ void PROJECT_TREE_PANE::onGitRemoveVCS( wxCommandEvent& aEvent )
git_repository* repo = m_TreeProject->GetGitRepo();
if( !repo
|| !IsOK( this, _( "Are you sure you want to remove git tracking from this project?" ) ) )
|| !IsOK( wxGetTopLevelParent( this ),
_( "Are you sure you want to remove git tracking from this project?" ) ) )
{
return;
}
@ -1830,7 +1840,7 @@ void PROJECT_TREE_PANE::onGitRemoveVCS( wxCommandEvent& aEvent )
if( !RmDirRecursive( fn.GetPath(), &errors ) )
{
DisplayErrorMessage( this, _( "Failed to remove git directory" ), errors );
DisplayErrorMessage( m_parent, _( "Failed to remove git directory" ), errors );
}
// Clear all item states
@ -2129,7 +2139,8 @@ void PROJECT_TREE_PANE::onGitCommit( wxCommandEvent& aEvent )
git_status_list_free( status_list );
// Create a commit dialog
DIALOG_GIT_COMMIT dlg( this, repo, authorName, authorEmail, modifiedFiles );
DIALOG_GIT_COMMIT dlg( wxGetTopLevelParent( this ), repo, authorName, authorEmail,
modifiedFiles );
auto ret = dlg.ShowModal();
if( ret == wxID_OK )

View File

@ -673,7 +673,7 @@ void PROPERTIES_FRAME::onScintillaCharAdded( wxStyledTextEvent &aEvent )
void PROPERTIES_FRAME::onHelp( wxCommandEvent& aEvent )
{
// Show the system variables for worksheet text:
HTML_MESSAGE_BOX dlg( this, _( "Predefined Keywords" ) );
HTML_MESSAGE_BOX dlg( wxGetTopLevelParent( this ), _( "Predefined Keywords" ) );
wxString message;
message << _( "Texts can include keywords." ) << "<br>";

View File

@ -196,7 +196,7 @@ void PANEL_REGULATOR::OnDataFileSelection( wxCommandEvent& event )
void PANEL_REGULATOR::OnAddRegulator( wxCommandEvent& event )
{
DIALOG_REGULATOR_FORM dlg( this, wxEmptyString );
DIALOG_REGULATOR_FORM dlg( wxGetTopLevelParent( this ), wxEmptyString );
if( dlg.ShowModal() != wxID_OK )
return;
@ -230,7 +230,7 @@ void PANEL_REGULATOR::OnEditRegulator( wxCommandEvent& event )
if( item == nullptr )
return;
DIALOG_REGULATOR_FORM dlg( this, name );
DIALOG_REGULATOR_FORM dlg( wxGetTopLevelParent( this ), name );
dlg.CopyRegulatorDataToDialog( item );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2011 jean-pierre.charras
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2024 Kicad Developers, see AUTHORS.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
@ -28,7 +28,7 @@
extern double DoubleFromString( const wxString& TextValue );
DIALOG_REGULATOR_FORM::DIALOG_REGULATOR_FORM( PANEL_REGULATOR* parent, const wxString& aRegName ) :
DIALOG_REGULATOR_FORM::DIALOG_REGULATOR_FORM( wxWindow* parent, const wxString& aRegName ) :
DIALOG_REGULATOR_FORM_BASE( parent )
{
m_textCtrlName->SetValue( aRegName );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2011 jean-pierre.charras
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.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
@ -39,7 +39,7 @@ class REGULATOR_DATA;
class DIALOG_REGULATOR_FORM : public DIALOG_REGULATOR_FORM_BASE
{
public:
DIALOG_REGULATOR_FORM( PANEL_REGULATOR* parent, const wxString& aRegName );
DIALOG_REGULATOR_FORM( wxWindow* parent, const wxString& aRegName );
~DIALOG_REGULATOR_FORM();

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.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
@ -473,7 +473,8 @@ bool PANEL_FP_EDITOR_DEFAULTS::TransferDataFromWindow()
if( errorsMsg.IsEmpty() )
return true;
KIDIALOG dlg( this, errorsMsg, KIDIALOG::KD_ERROR, _( "Parameter error" ) );
KIDIALOG dlg( wxGetTopLevelParent( this ), errorsMsg, KIDIALOG::KD_ERROR,
_( "Parameter error" ) );
dlg.ShowModal();
return false;

View File

@ -541,7 +541,9 @@ bool PANEL_FP_LIB_TABLE::verifyTables()
else
msg = _( "A library table row path cell is empty." );
wxMessageDialog badCellDlg( this, msg, _( "Invalid Row Definition" ),
wxWindow* topLevelParent = wxGetTopLevelParent( this );
wxMessageDialog badCellDlg( topLevelParent, msg, _( "Invalid Row Definition" ),
wxYES_NO | wxCENTER | wxICON_QUESTION | wxYES_DEFAULT );
badCellDlg.SetExtendedMessage( _( "Empty cells will result in all rows that are "
"invalid to be removed from the table." ) );
@ -570,7 +572,9 @@ bool PANEL_FP_LIB_TABLE::verifyTables()
m_cur_grid->MakeCellVisible( r, 0 );
m_cur_grid->SetGridCursor( r, 1 );
wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) );
wxWindow* topLevelParent = wxGetTopLevelParent( this );
wxMessageDialog errdlg( topLevelParent, msg, _( "Library Nickname Error" ) );
errdlg.ShowModal();
return false;
}
@ -616,7 +620,9 @@ bool PANEL_FP_LIB_TABLE::verifyTables()
m_cur_grid->MakeCellVisible( r2, 0 );
m_cur_grid->SetGridCursor( r2, 1 );
wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) );
wxWindow* topLevelParent = wxGetTopLevelParent( this );
wxMessageDialog errdlg( topLevelParent, msg, _( "Library Nickname Error" ) );
errdlg.ShowModal();
return false;
}
@ -833,7 +839,7 @@ void PANEL_FP_LIB_TABLE::onMigrateLibraries( wxCommandEvent& event )
if( !legacyLib.Exists() )
{
msg.Printf( _( "Library '%s' not found." ), relPath );
DisplayErrorMessage( this, msg );
DisplayErrorMessage( wxGetTopLevelParent( this ), msg );
continue;
}
@ -875,7 +881,7 @@ void PANEL_FP_LIB_TABLE::onMigrateLibraries( wxCommandEvent& event )
else
{
msg.Printf( _( "Failed to save footprint library file '%s'." ), newLib.GetFullPath() );
DisplayErrorMessage( this, msg );
DisplayErrorMessage( wxGetTopLevelParent( this ), msg );
}
}
}
@ -1026,7 +1032,8 @@ void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
if( !applyToAll )
{
// The cancel button adds the library to the table anyway
addDuplicates = OKOrCancelDialog( this, warning, wxString::Format( msg, nickname ),
addDuplicates = OKOrCancelDialog( wxGetTopLevelParent( this ), warning,
wxString::Format( msg, nickname ),
detailedMsg, _( "Skip" ), _( "Add Anyway" ),
&applyToAll ) == wxID_CANCEL;
}
@ -1155,6 +1162,7 @@ void PANEL_FP_LIB_TABLE::populateEnvironReadOnlyTable()
// the current project.
unique.insert( PROJECT_VAR_NAME );
unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() );
// This special environment variable is used to locate 3d shapes
unique.insert( KICAD7_3DMODEL_DIR );

View File

@ -245,7 +245,7 @@ void PANEL_PCBNEW_ACTION_PLUGINS::OnShowErrorsButtonClick( wxCommandEvent& event
// Now display the filtered trace in our dialog
// (a simple wxMessageBox is really not suitable for long messages)
DIALOG_FOOTPRINT_WIZARD_LOG logWindow( this );
DIALOG_FOOTPRINT_WIZARD_LOG logWindow( wxGetTopLevelParent( this ) );
logWindow.m_Message->SetValue( trace );
logWindow.ShowModal();
}

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2009 Isaac Marino Bavaresco, isaacbavaresco@yahoo.com.br
* Copyright (C) 2009 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2009-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2009-2024 KiCad Developers, see AUTHORS.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
@ -431,8 +431,9 @@ void PANEL_SETUP_LAYERS::DenyChangeCheckBox( wxCommandEvent& event )
if( source == copper )
{
DisplayError( this, _( "Use the Physical Stackup page to change the number of "
"copper layers." ) );
DisplayError( wxGetTopLevelParent( this ),
_( "Use the Physical Stackup page to change the number of "
"copper layers." ) );
copper->SetValue( true );
return;
@ -464,19 +465,21 @@ bool PANEL_SETUP_LAYERS::TransferDataFromWindow()
for( unsigned int ii = 0; ii < notremovableLayers.size(); ii++ )
msg << m_pcb->GetLayerName( notremovableLayers[ii] ) << wxT( "\n" );
if( !IsOK( this, wxString::Format( _( "Footprints have some items on removed layers:\n"
"%s\n"
"These items will be no longer accessible\n"
"Do you wish to continue?" ), msg ) ) )
if( !IsOK( wxGetTopLevelParent( this ),
wxString::Format( _( "Footprints have some items on removed layers:\n"
"%s\n"
"These items will be no longer accessible\n"
"Do you wish to continue?" ), msg ) ) )
{
return false;
}
}
if( !removedLayers.empty()
&& !IsOK( this, _( "Items have been found on removed layers. This operation will "
"delete all items from removed layers and cannot be undone.\n"
"Do you wish to continue?" ) ) )
&& !IsOK( wxGetTopLevelParent( this ),
_( "Items have been found on removed layers. This operation will "
"delete all items from removed layers and cannot be undone.\n"
"Do you wish to continue?" ) ) )
{
return false;
}
@ -799,7 +802,9 @@ bool PANEL_SETUP_LAYERS::CheckCopperLayerCount( BOARD* aWorkingBoard, BOARD* aIm
newNumLayers,
currNumLayers );
wxMessageDialog dlg( this, msg, _( "Inner Layers To Be Deleted" ),
wxWindow* topLevelParent = wxGetTopLevelParent( this );
wxMessageDialog dlg( topLevelParent, msg, _( "Inner Layers To Be Deleted" ),
wxICON_WARNING | wxSTAY_ON_TOP | wxYES | wxNO | wxNO_DEFAULT );
if( wxID_NO == dlg.ShowModal() )

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2024 KiCad Developers, see AUTHORS.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
@ -102,7 +102,7 @@ void PANEL_SETUP_RULES::onCharHook( wxKeyEvent& aEvent )
{
if( m_originalText != m_textEditor->GetText() )
{
if( IsOK( this, _( "Cancel Changes?" ) ) )
if( IsOK( wxGetTopLevelParent( this ), _( "Cancel Changes?" ) ) )
{
m_textEditor->SetText( m_originalText );
m_textEditor->SelectAll();

View File

@ -310,7 +310,8 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow()
if( errorsMsg.IsEmpty() )
return true;
KIDIALOG dlg( this, errorsMsg, KIDIALOG::KD_ERROR, _( "Parameter error" ) );
KIDIALOG dlg( wxGetTopLevelParent( this ), errorsMsg, KIDIALOG::KD_ERROR,
_( "Parameter error" ) );
dlg.ShowModal();
return false;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2020 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2021-2024 KiCad Developers, see AUTHORS.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 as published by the
@ -2635,7 +2635,8 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent )
if( m_lastSelectedUserPreset )
name = m_lastSelectedUserPreset->name;
wxTextEntryDialog dlg( this, _( "Layer preset name:" ), _( "Save Layer Preset" ), name );
wxTextEntryDialog dlg( wxGetTopLevelParent( this ), _( "Layer preset name:" ),
_( "Save Layer Preset" ), name );
if( dlg.ShowModal() != wxID_OK )
{
@ -2662,14 +2663,14 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent )
else if( preset->readOnly )
{
wxMessageBox( _( "Default presets cannot be modified.\nPlease use a different name." ),
_( "Error" ), wxOK | wxICON_ERROR, this );
_( "Error" ), wxOK | wxICON_ERROR, wxGetTopLevelParent( this ) );
resetSelection();
return;
}
else
{
// Ask the user if they want to overwrite the existing preset
if( !IsOK( this, _( "Overwrite existing preset?" ) ) )
if( !IsOK( wxGetTopLevelParent( this ), _( "Overwrite existing preset?" ) ) )
{
resetSelection();
return;
@ -2862,7 +2863,8 @@ void APPEARANCE_CONTROLS::onViewportChanged( wxCommandEvent& aEvent )
// Save current state to new preset
wxString name;
wxTextEntryDialog dlg( this, _( "Viewport name:" ), _( "Save Viewport" ), name );
wxTextEntryDialog dlg( wxGetTopLevelParent( this ),
_( "Viewport name:" ), _( "Save Viewport" ), name );
if( dlg.ShowModal() != wxID_OK )
{