Code style
This commit is contained in:
parent
89e74140eb
commit
3673c23696
|
@ -453,6 +453,7 @@ void EDA_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
|
|||
void EDA_BASE_FRAME::LoadWindowState( const wxString& aFileName )
|
||||
{
|
||||
const PROJECT_FILE_STATE* state = Prj().GetLocalSettings().GetFileState( aFileName );
|
||||
|
||||
if( state != nullptr )
|
||||
{
|
||||
LoadWindowState( state->window );
|
||||
|
|
|
@ -430,7 +430,7 @@ void LIB_EDIT_FRAME::setupUIConditions()
|
|||
}
|
||||
|
||||
|
||||
bool LIB_EDIT_FRAME::canCloseWindow(wxCloseEvent& aEvent)
|
||||
bool LIB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
||||
{
|
||||
// Shutdown blocks must be determined and vetoed as early as possible
|
||||
if( SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
|
||||
|
|
|
@ -657,7 +657,11 @@ public:
|
|||
|
||||
int GetMaxUndoItems() const { return m_UndoRedoCountMax; }
|
||||
|
||||
bool NonUserClose( bool aForce ) { m_isNonUserClose = true; return Close( aForce ); };
|
||||
bool NonUserClose( bool aForce )
|
||||
{
|
||||
m_isNonUserClose = true;
|
||||
return Close( aForce );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -190,7 +190,8 @@ c * @return true if the file was saved
|
|||
* @param aTarget is the storage destination
|
||||
* @return True if set, false if not
|
||||
*/
|
||||
static bool SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, wxString& aTarget );
|
||||
static bool SetIfPresent( const nlohmann::json& aObj, const std::string& aPath,
|
||||
wxString& aTarget );
|
||||
|
||||
/**
|
||||
* Sets the given bool if the given key/path is present
|
||||
|
@ -214,7 +215,8 @@ c * @return true if the file was saved
|
|||
* @param aTarget is the storage destination
|
||||
* @return True if set, false if not
|
||||
*/
|
||||
static bool SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, unsigned int& aTarget );
|
||||
static bool SetIfPresent( const nlohmann::json& aObj, const std::string& aPath,
|
||||
unsigned int& aTarget );
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
|
@ -648,59 +648,68 @@ void KICAD_MANAGER_FRAME::PrintPrjInfo()
|
|||
PrintMsg( msg );
|
||||
}
|
||||
|
||||
|
||||
bool KICAD_MANAGER_FRAME::IsProjectActive()
|
||||
{
|
||||
return m_active_project;
|
||||
}
|
||||
|
||||
|
||||
void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent )
|
||||
{
|
||||
/**
|
||||
* We start loading the saved previously open windows on idle to avoid locking up the GUI earlier in project loading
|
||||
* This gives us the visual effect of a opened KiCad project but with a "busy" progress reporter
|
||||
* We start loading the saved previously open windows on idle to avoid locking up the GUI
|
||||
* earlier in project loading. This gives us the visual effect of a opened KiCad project but
|
||||
* with a "busy" progress reporter
|
||||
*/
|
||||
if( m_openSavedWindows )
|
||||
if( !m_openSavedWindows )
|
||||
return;
|
||||
|
||||
m_openSavedWindows = false;
|
||||
|
||||
if( Pgm().GetCommonSettings()->m_Session.remember_open_files )
|
||||
{
|
||||
m_openSavedWindows = false;
|
||||
if ( Pgm().GetCommonSettings()->m_Session.remember_open_files )
|
||||
int previousOpenCount =
|
||||
std::count_if( Prj().GetLocalSettings().m_files.begin(),
|
||||
Prj().GetLocalSettings().m_files.end(),
|
||||
[&]( const PROJECT_FILE_STATE& f )
|
||||
{
|
||||
return !f.fileName.EndsWith( ProjectFileExtension ) && f.open;
|
||||
} );
|
||||
|
||||
if( previousOpenCount > 0 )
|
||||
{
|
||||
int previousOpenCount = std::count_if( Prj().GetLocalSettings().m_files.begin(),
|
||||
Prj().GetLocalSettings().m_files.end(),
|
||||
[&]( const PROJECT_FILE_STATE& f )
|
||||
{
|
||||
return !f.fileName.EndsWith( ProjectFileExtension ) && f.open;
|
||||
} );
|
||||
if ( previousOpenCount > 0 )
|
||||
APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString,
|
||||
previousOpenCount, this );
|
||||
|
||||
int i = 0;
|
||||
|
||||
for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files )
|
||||
{
|
||||
APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString, previousOpenCount, this );
|
||||
|
||||
int i = 0;
|
||||
for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files )
|
||||
if( file.open )
|
||||
{
|
||||
if( file.open )
|
||||
progressReporter.Update( i++,
|
||||
wxString::Format( _( "Restoring \"%s\"" ), file.fileName ) );
|
||||
|
||||
wxFileName fn( file.fileName );
|
||||
|
||||
if( fn.GetExt() == LegacySchematicFileExtension
|
||||
|| fn.GetExt() == KiCadSchematicFileExtension )
|
||||
{
|
||||
progressReporter.Update(
|
||||
i++, wxString::Format( _( "Restoring \"%s\"" ), file.fileName ) );
|
||||
|
||||
wxFileName fn( file.fileName );
|
||||
if( fn.GetExt() == LegacySchematicFileExtension
|
||||
|| fn.GetExt() == KiCadSchematicFileExtension )
|
||||
{
|
||||
GetToolManager()->RunAction( KICAD_MANAGER_ACTIONS::editSchematic, true );
|
||||
}
|
||||
else if( fn.GetExt() == LegacyPcbFileExtension
|
||||
|| fn.GetExt() == KiCadPcbFileExtension )
|
||||
{
|
||||
GetToolManager()->RunAction( KICAD_MANAGER_ACTIONS::editPCB, true );
|
||||
}
|
||||
GetToolManager()->RunAction( KICAD_MANAGER_ACTIONS::editSchematic, true );
|
||||
}
|
||||
else if( fn.GetExt() == LegacyPcbFileExtension
|
||||
|| fn.GetExt() == KiCadPcbFileExtension )
|
||||
{
|
||||
GetToolManager()->RunAction( KICAD_MANAGER_ACTIONS::editPCB, true );
|
||||
}
|
||||
|
||||
wxYield();
|
||||
}
|
||||
|
||||
wxYield();
|
||||
}
|
||||
}
|
||||
|
||||
// clear file states regardless if we opened windows or not due to setting
|
||||
Prj().GetLocalSettings().ClearFileState();
|
||||
}
|
||||
}
|
||||
|
||||
// clear file states regardless if we opened windows or not due to setting
|
||||
Prj().GetLocalSettings().ClearFileState();
|
||||
}
|
||||
|
|
|
@ -812,7 +812,10 @@ bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
|||
wxString msg = _( "Save changes to \"%s\" before closing?" );
|
||||
|
||||
if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
|
||||
[&]()->bool { return Files_io_from_id( ID_SAVE_BOARD ); } ) )
|
||||
[&]() -> bool
|
||||
{
|
||||
return Files_io_from_id( ID_SAVE_BOARD );
|
||||
} ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue