A better way of handling standalone project files
This commit is contained in:
parent
be0aad5984
commit
9f7bca38b3
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
|
|
||||||
PROJECT::PROJECT() :
|
PROJECT::PROJECT() :
|
||||||
|
m_readOnly( false ),
|
||||||
m_projectFile( nullptr ),
|
m_projectFile( nullptr ),
|
||||||
m_localSettings( nullptr )
|
m_localSettings( nullptr )
|
||||||
{
|
{
|
||||||
|
|
|
@ -794,6 +794,10 @@ bool SETTINGS_MANAGER::SaveProject( const wxString& aFullPath )
|
||||||
if( path.empty() )
|
if( path.empty() )
|
||||||
path = Prj().GetProjectFullName();
|
path = Prj().GetProjectFullName();
|
||||||
|
|
||||||
|
// TODO: refactor for MDI
|
||||||
|
if( Prj().IsReadOnly() )
|
||||||
|
return false;
|
||||||
|
|
||||||
if( !m_project_files.count( path ) )
|
if( !m_project_files.count( path ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,8 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
|
||||||
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
||||||
wxBookCtrlEventHandler( DIALOG_SCHEMATIC_SETUP::OnPageChange ), NULL, this );
|
wxBookCtrlEventHandler( DIALOG_SCHEMATIC_SETUP::OnPageChange ), NULL, this );
|
||||||
|
|
||||||
if( Prj().IsNullProject() )
|
if( Prj().IsReadOnly() )
|
||||||
m_infoBar->ShowMessage( _( "No project is loaded. Changes will not be saved." ) );
|
m_infoBar->ShowMessage( _( "Project is missing or read-only. Changes will not be saved." ) );
|
||||||
|
|
||||||
FinishDialogSettings();
|
FinishDialogSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,9 +290,12 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
Schematic().SetProject( nullptr );
|
Schematic().SetProject( nullptr );
|
||||||
GetSettingsManager()->UnloadProject( &Prj() );
|
GetSettingsManager()->UnloadProject( &Prj() );
|
||||||
|
|
||||||
// Do not load a project if one doesn't exist. This normally happens if we are
|
GetSettingsManager()->LoadProject( pro.GetFullPath() );
|
||||||
|
|
||||||
|
// Do not allow saving a project if one doesn't exist. This normally happens if we are
|
||||||
// standalone and opening a board that has been moved from its project folder.
|
// standalone and opening a board that has been moved from its project folder.
|
||||||
GetSettingsManager()->LoadProject( pro.Exists() ? pro.GetFullPath() : "" );
|
if( !pro.Exists() )
|
||||||
|
Prj().SetReadOnly();
|
||||||
|
|
||||||
CreateScreens();
|
CreateScreens();
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,10 @@ public:
|
||||||
*/
|
*/
|
||||||
VTBL_ENTRY bool IsNullProject() const;
|
VTBL_ENTRY bool IsNullProject() const;
|
||||||
|
|
||||||
|
VTBL_ENTRY bool IsReadOnly() const { return m_readOnly || IsNullProject(); }
|
||||||
|
|
||||||
|
VTBL_ENTRY void SetReadOnly( bool aReadOnly = true ) { m_readOnly = aReadOnly; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of the sheet identified by the given UUID.
|
* Return the name of the sheet identified by the given UUID.
|
||||||
*/
|
*/
|
||||||
|
@ -332,6 +336,9 @@ private:
|
||||||
wxFileName m_project_name; ///< \<fullpath\>/\<basename\>.pro
|
wxFileName m_project_name; ///< \<fullpath\>/\<basename\>.pro
|
||||||
wxString m_pro_date_and_time;
|
wxString m_pro_date_and_time;
|
||||||
|
|
||||||
|
///> True if the project is read-only: no project files will be written
|
||||||
|
bool m_readOnly;
|
||||||
|
|
||||||
/// Backing store for project data -- owned by SETTINGS_MANAGER
|
/// Backing store for project data -- owned by SETTINGS_MANAGER
|
||||||
PROJECT_FILE* m_projectFile;
|
PROJECT_FILE* m_projectFile;
|
||||||
|
|
||||||
|
|
|
@ -95,8 +95,8 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
|
||||||
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
||||||
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), NULL, this );
|
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), NULL, this );
|
||||||
|
|
||||||
if( Prj().IsNullProject() )
|
if( Prj().IsReadOnly() )
|
||||||
m_infoBar->ShowMessage( _( "No project is loaded. Changes will not be saved." ) );
|
m_infoBar->ShowMessage( _( "Project is missing or read-only. Changes will not be saved." ) );
|
||||||
|
|
||||||
FinishDialogSettings();
|
FinishDialogSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -521,9 +521,12 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
|
|
||||||
mgr->UnloadProject( &mgr->Prj() );
|
mgr->UnloadProject( &mgr->Prj() );
|
||||||
|
|
||||||
// Do not load a project if one doesn't exist. This normally happens if we are
|
mgr->LoadProject( pro.GetFullPath() );
|
||||||
|
|
||||||
|
// Do not allow saving a project if one doesn't exist. This normally happens if we are
|
||||||
// standalone and opening a board that has been moved from its project folder.
|
// standalone and opening a board that has been moved from its project folder.
|
||||||
mgr->LoadProject( pro.Exists() ? pro.GetFullPath() : "" );
|
if( !pro.Exists() )
|
||||||
|
Prj().SetReadOnly();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue