Reduce duplication of settings.
This commit is contained in:
parent
b4c5e64db2
commit
29c942816e
|
@ -117,9 +117,8 @@ void EDA_BASE_FRAME::commonInit( FRAME_T aFrameType )
|
|||
m_infoBar = nullptr;
|
||||
m_settingsManager = nullptr;
|
||||
m_fileHistory = nullptr;
|
||||
m_hasAutoSave = false;
|
||||
m_supportsAutoSave = false;
|
||||
m_autoSaveState = false;
|
||||
m_autoSaveInterval = -1;
|
||||
m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
|
||||
m_userUnits = EDA_UNITS::MILLIMETRES;
|
||||
m_isClosing = false;
|
||||
|
@ -277,14 +276,14 @@ bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
|
|||
if( Pgm().m_Quitting )
|
||||
return true;
|
||||
|
||||
if( !m_isClosing && m_hasAutoSave && IsShown() && IsActive()
|
||||
if( !m_isClosing && m_supportsAutoSave && IsShown() && IsActive()
|
||||
&& m_autoSaveState != isAutoSaveRequired()
|
||||
&& m_autoSaveInterval > 0 )
|
||||
&& GetAutoSaveInterval() > 0 )
|
||||
{
|
||||
if( !m_autoSaveState )
|
||||
{
|
||||
wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
|
||||
m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
|
||||
m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
|
||||
m_autoSaveState = true;
|
||||
}
|
||||
else if( m_autoSaveTimer->IsRunning() )
|
||||
|
@ -299,29 +298,16 @@ bool EDA_BASE_FRAME::ProcessEvent( wxEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void EDA_BASE_FRAME::SetAutoSaveInterval( int aInterval )
|
||||
int EDA_BASE_FRAME::GetAutoSaveInterval() const
|
||||
{
|
||||
m_autoSaveInterval = aInterval;
|
||||
|
||||
if( m_autoSaveTimer->IsRunning() )
|
||||
{
|
||||
if( m_autoSaveInterval > 0 )
|
||||
{
|
||||
m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_autoSaveTimer->Stop();
|
||||
m_autoSaveState = false;
|
||||
}
|
||||
}
|
||||
return Pgm().GetCommonSettings()->m_System.autosave_interval;
|
||||
}
|
||||
|
||||
|
||||
void EDA_BASE_FRAME::onAutoSaveTimer( wxTimerEvent& aEvent )
|
||||
{
|
||||
if( !doAutoSave() )
|
||||
m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
|
||||
m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
|
||||
}
|
||||
|
||||
|
||||
|
@ -711,9 +697,6 @@ void EDA_BASE_FRAME::LoadWindowSettings( const WINDOW_SETTINGS* aCfg )
|
|||
{
|
||||
LoadWindowState( aCfg->state );
|
||||
|
||||
if( m_hasAutoSave )
|
||||
m_autoSaveInterval = Pgm().GetCommonSettings()->m_System.autosave_interval;
|
||||
|
||||
m_perspective = aCfg->perspective;
|
||||
m_mruPath = aCfg->mru_path;
|
||||
|
||||
|
@ -754,10 +737,6 @@ void EDA_BASE_FRAME::SaveWindowSettings( WINDOW_SETTINGS* aCfg )
|
|||
wxLogTrace( traceDisplayLocation, "Saving config position (%d, %d) with size (%d, %d)",
|
||||
m_framePos.x, m_framePos.y, m_frameSize.x, m_frameSize.y );
|
||||
|
||||
// TODO(JE) should auto-save in common settings be overwritten by every app?
|
||||
if( m_hasAutoSave )
|
||||
Pgm().GetCommonSettings()->m_System.autosave_interval = m_autoSaveInterval;
|
||||
|
||||
// Once this is fully implemented, wxAuiManager will be used to maintain
|
||||
// the persistence of the main frame and all it's managed windows and
|
||||
// all of the legacy frame persistence position code can be removed.
|
||||
|
|
|
@ -290,7 +290,18 @@ void EDA_DRAW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
|
|||
COMMON_SETTINGS* settings = Pgm().GetCommonSettings();
|
||||
KIGFX::VIEW_CONTROLS* viewControls = GetCanvas()->GetViewControls();
|
||||
|
||||
SetAutoSaveInterval( settings->m_System.autosave_interval );
|
||||
if( m_supportsAutoSave && m_autoSaveTimer->IsRunning() )
|
||||
{
|
||||
if( GetAutoSaveInterval() > 0 )
|
||||
{
|
||||
m_autoSaveTimer->Start( GetAutoSaveInterval() * 1000, wxTIMER_ONE_SHOT );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_autoSaveTimer->Stop();
|
||||
m_autoSaveState = false;
|
||||
}
|
||||
}
|
||||
|
||||
viewControls->LoadSettings();
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
m_schematic = new SCHEMATIC( nullptr );
|
||||
|
||||
m_showBorderAndTitleBlock = true; // true to show sheet references
|
||||
m_hasAutoSave = true;
|
||||
m_supportsAutoSave = true;
|
||||
m_aboutTitle = _( "KiCad Schematic Editor" );
|
||||
|
||||
m_findReplaceDialog = nullptr;
|
||||
|
|
|
@ -206,9 +206,7 @@ public:
|
|||
|
||||
void OnMaximize( wxMaximizeEvent& aEvent );
|
||||
|
||||
void SetAutoSaveInterval( int aInterval );
|
||||
|
||||
int GetAutoSaveInterval() const { return m_autoSaveInterval; }
|
||||
int GetAutoSaveInterval() const;
|
||||
|
||||
bool IsType( FRAME_T aType ) const { return m_ident == aType; }
|
||||
FRAME_T GetFrameType() const { return m_ident; }
|
||||
|
@ -714,9 +712,8 @@ private:
|
|||
|
||||
FILE_HISTORY* m_fileHistory; // The frame's recently opened file list
|
||||
|
||||
bool m_hasAutoSave;
|
||||
bool m_supportsAutoSave;
|
||||
bool m_autoSaveState;
|
||||
int m_autoSaveInterval; // The auto save interval time in seconds.
|
||||
wxTimer* m_autoSaveTimer;
|
||||
|
||||
int m_undoRedoCountMax; // undo/Redo command Max depth
|
||||
|
|
|
@ -186,7 +186,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
m_SelViaSizeBox = nullptr;
|
||||
m_SelLayerBox = nullptr;
|
||||
m_show_layer_manager_tools = true;
|
||||
m_hasAutoSave = true;
|
||||
m_supportsAutoSave = true;
|
||||
|
||||
// We don't know what state board was in when it was last saved, so we have to
|
||||
// assume dirty
|
||||
|
|
Loading…
Reference in New Issue