Add user write permission tests to Kicad and other minor fixes.
* Check user write permissions before saving project file. * Append read only to file name and path in title bar when the user does not have write privileges. * Remove displaying file dialog every time the project file is saved. * Doxygen comment and coding style policy fixes.
This commit is contained in:
parent
1e2b145a2f
commit
09d5e6937c
|
@ -1,10 +1,7 @@
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file kicad.cpp
|
* @file kicad.cpp
|
||||||
* @brief Main kicad library manager file
|
* @brief Main kicad library manager file
|
||||||
*/
|
*/
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#include "fctsys.h"
|
#include "fctsys.h"
|
||||||
#include "appl_wxstruct.h"
|
#include "appl_wxstruct.h"
|
||||||
|
@ -24,7 +21,7 @@
|
||||||
|
|
||||||
#include "build_version.h"
|
#include "build_version.h"
|
||||||
|
|
||||||
const wxString g_KicadPrjFilenameExtension(wxT(".pro") );
|
const wxString g_KicadPrjFilenameExtension( wxT( ".pro" ) );
|
||||||
|
|
||||||
/* Import functions */
|
/* Import functions */
|
||||||
char* GetFileName( char* FullPathName );
|
char* GetFileName( char* FullPathName );
|
||||||
|
@ -42,17 +39,21 @@ IMPLEMENT_APP( WinEDA_App )
|
||||||
/* MacOSX: Needed for file association
|
/* MacOSX: Needed for file association
|
||||||
* http://wiki.wxwidgets.org/WxMac-specific_topics
|
* http://wiki.wxwidgets.org/WxMac-specific_topics
|
||||||
*/
|
*/
|
||||||
void WinEDA_App::MacOpenFile(const wxString &fileName) {
|
void WinEDA_App::MacOpenFile( const wxString &fileName )
|
||||||
KICAD_MANAGER_FRAME * frame = ((KICAD_MANAGER_FRAME*)GetTopWindow());
|
{
|
||||||
wxFileName fn = fileName;
|
KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) GetTopWindow();
|
||||||
|
wxFileName fn = fileName;
|
||||||
|
|
||||||
frame->m_ProjectFileName = fn;
|
frame->m_ProjectFileName = fn;
|
||||||
|
|
||||||
if( m_fileHistory.GetCount() )
|
if( m_fileHistory.GetCount() )
|
||||||
{
|
{
|
||||||
frame->m_ProjectFileName = m_fileHistory.GetHistoryFile( 0 );
|
frame->m_ProjectFileName = m_fileHistory.GetHistoryFile( 0 );
|
||||||
|
|
||||||
if( !frame->m_ProjectFileName.FileExists() )
|
if( !frame->m_ProjectFileName.FileExists() )
|
||||||
|
{
|
||||||
m_fileHistory.RemoveFileFromHistory( 0 );
|
m_fileHistory.RemoveFileFromHistory( 0 );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxCommandEvent cmd( 0, wxID_FILE1 );
|
wxCommandEvent cmd( 0, wxID_FILE1 );
|
||||||
|
@ -60,20 +61,23 @@ void WinEDA_App::MacOpenFile(const wxString &fileName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() +
|
wxString title = GetTitle() + wxT( " " ) + GetBuildVersion() +
|
||||||
wxT( " " ) + frame->m_ProjectFileName.GetFullPath() );
|
wxT( " " ) + frame->m_ProjectFileName.GetFullPath();
|
||||||
|
|
||||||
|
if( !fn.IsDirWritable() )
|
||||||
|
title += _( " [Read Only]" );
|
||||||
|
|
||||||
|
frame->SetTitle( title );
|
||||||
|
|
||||||
frame->m_LeftWin->ReCreateTreePrj();
|
frame->m_LeftWin->ReCreateTreePrj();
|
||||||
|
|
||||||
frame->PrintMsg( _( "Working dir: " ) + frame->m_ProjectFileName.GetPath() +
|
frame->PrintMsg( _( "Working dir: " ) + frame->m_ProjectFileName.GetPath() +
|
||||||
_( "\nProject: " ) + frame->m_ProjectFileName.GetFullName() +
|
_( "\nProject: " ) + frame->m_ProjectFileName.GetFullName() +
|
||||||
wxT( "\n" ) );
|
wxT( "\n" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
bool WinEDA_App::OnInit()
|
bool WinEDA_App::OnInit()
|
||||||
/*****************************************************************************/
|
|
||||||
{
|
{
|
||||||
KICAD_MANAGER_FRAME* frame;
|
KICAD_MANAGER_FRAME* frame;
|
||||||
|
|
||||||
|
@ -81,21 +85,26 @@ bool WinEDA_App::OnInit()
|
||||||
|
|
||||||
// read current setup and reopen last directory if no filename to open in command line
|
// read current setup and reopen last directory if no filename to open in command line
|
||||||
bool reopenLastUsedDirectory = argc == 1;
|
bool reopenLastUsedDirectory = argc == 1;
|
||||||
GetSettings(reopenLastUsedDirectory);
|
GetSettings( reopenLastUsedDirectory );
|
||||||
|
|
||||||
/* Make nameless project translatable */
|
/* Make nameless project translatable */
|
||||||
wxFileName namelessProject( wxGetCwd(), NAMELESS_PROJECT, ProjectFileExtension );
|
wxFileName namelessProject( wxGetCwd(), NAMELESS_PROJECT, ProjectFileExtension );
|
||||||
|
|
||||||
frame = new KICAD_MANAGER_FRAME( NULL, wxT( "KiCad" ),
|
frame = new KICAD_MANAGER_FRAME( NULL, wxT( "KiCad" ),
|
||||||
wxPoint( 30, 20 ), wxSize( 600, 400 ) );
|
wxPoint( 30, 20 ), wxSize( 600, 400 ) );
|
||||||
|
|
||||||
if( argc > 1 )
|
if( argc > 1 )
|
||||||
|
{
|
||||||
frame->m_ProjectFileName = argv[1];
|
frame->m_ProjectFileName = argv[1];
|
||||||
|
}
|
||||||
else if( m_fileHistory.GetCount() )
|
else if( m_fileHistory.GetCount() )
|
||||||
{
|
{
|
||||||
frame->m_ProjectFileName = m_fileHistory.GetHistoryFile( 0 );
|
frame->m_ProjectFileName = m_fileHistory.GetHistoryFile( 0 );
|
||||||
|
|
||||||
if( !frame->m_ProjectFileName.FileExists() )
|
if( !frame->m_ProjectFileName.FileExists() )
|
||||||
|
{
|
||||||
m_fileHistory.RemoveFileFromHistory( 0 );
|
m_fileHistory.RemoveFileFromHistory( 0 );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxCommandEvent cmd( 0, wxID_FILE1 );
|
wxCommandEvent cmd( 0, wxID_FILE1 );
|
||||||
|
@ -110,8 +119,13 @@ bool WinEDA_App::OnInit()
|
||||||
frame->OnLoadProject( cmd );
|
frame->OnLoadProject( cmd );
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() +
|
wxString title = GetTitle() + wxT( " " ) + GetBuildVersion() +
|
||||||
wxT( " " ) + frame->m_ProjectFileName.GetFullPath() );
|
wxT( " " ) + frame->m_ProjectFileName.GetFullPath();
|
||||||
|
|
||||||
|
if( !namelessProject.IsDirWritable() )
|
||||||
|
title += _( " [Read Only]" );
|
||||||
|
|
||||||
|
frame->SetTitle( title );
|
||||||
frame->ReCreateMenuBar();
|
frame->ReCreateMenuBar();
|
||||||
frame->RecreateBaseHToolbar();
|
frame->RecreateBaseHToolbar();
|
||||||
|
|
||||||
|
@ -137,8 +151,8 @@ bool WinEDA_App::OnInit()
|
||||||
}
|
}
|
||||||
#endif /* USE_SPLASH_IMAGE */
|
#endif /* USE_SPLASH_IMAGE */
|
||||||
|
|
||||||
frame->Show( TRUE );
|
frame->Show( true );
|
||||||
frame->Raise();
|
frame->Raise();
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,19 +74,27 @@ private:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
|
KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title,
|
||||||
const wxPoint& pos, const wxSize& size );
|
const wxPoint& pos, const wxSize& size );
|
||||||
|
|
||||||
~KICAD_MANAGER_FRAME();
|
~KICAD_MANAGER_FRAME();
|
||||||
|
|
||||||
/**
|
|
||||||
* Function CreateCommandToolbar
|
|
||||||
* Create the main buttons (fast launch buttons)
|
|
||||||
*/
|
|
||||||
void OnCloseWindow( wxCloseEvent& Event );
|
void OnCloseWindow( wxCloseEvent& Event );
|
||||||
void OnSize( wxSizeEvent& event );
|
void OnSize( wxSizeEvent& event );
|
||||||
void OnSashDrag( wxSashEvent& event );
|
void OnSashDrag( wxSashEvent& event );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function OnLoadProject
|
||||||
|
* loads an exiting or creates a new project (.pro) file.
|
||||||
|
*/
|
||||||
void OnLoadProject( wxCommandEvent& event );
|
void OnLoadProject( wxCommandEvent& event );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function OnSaveProject
|
||||||
|
* is the command event hendler to Save the project (.pro) file containing the top level
|
||||||
|
* configuration parameters.
|
||||||
|
*/
|
||||||
void OnSaveProject( wxCommandEvent& event );
|
void OnSaveProject( wxCommandEvent& event );
|
||||||
|
|
||||||
void OnArchiveFiles( wxCommandEvent& event );
|
void OnArchiveFiles( wxCommandEvent& event );
|
||||||
void OnUnarchiveFiles( wxCommandEvent& event );
|
void OnUnarchiveFiles( wxCommandEvent& event );
|
||||||
void OnRunPcbNew( wxCommandEvent& event );
|
void OnRunPcbNew( wxCommandEvent& event );
|
||||||
|
@ -105,7 +113,15 @@ public:
|
||||||
void Process_Preferences( wxCommandEvent& event );
|
void Process_Preferences( wxCommandEvent& event );
|
||||||
void ReCreateMenuBar();
|
void ReCreateMenuBar();
|
||||||
void RecreateBaseHToolbar();
|
void RecreateBaseHToolbar();
|
||||||
void PrintMsg( const wxString& text );
|
|
||||||
|
/**
|
||||||
|
* Function PrintMsg
|
||||||
|
* displays \a aText in the text panel.
|
||||||
|
*
|
||||||
|
* @param aText The text to display.
|
||||||
|
*/
|
||||||
|
void PrintMsg( const wxString& aText );
|
||||||
|
|
||||||
void ClearMsg();
|
void ClearMsg();
|
||||||
void SetLanguage( wxCommandEvent& event );
|
void SetLanguage( wxCommandEvent& event );
|
||||||
void OnRefresh( wxCommandEvent& event );
|
void OnRefresh( wxCommandEvent& event );
|
||||||
|
@ -117,7 +133,22 @@ public:
|
||||||
|
|
||||||
void CreateNewProject( const wxString PrjFullFileName );
|
void CreateNewProject( const wxString PrjFullFileName );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function LoadSettings
|
||||||
|
* loads the Kicad main frame specific configuration settings.
|
||||||
|
*
|
||||||
|
* Don't forget to call this base method from any derived classes or the
|
||||||
|
* settings will not get loaded.
|
||||||
|
*/
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SaveSettings
|
||||||
|
* saves the Kicad main frame specific configuration settings.
|
||||||
|
*
|
||||||
|
* Don't forget to call this base method from any derived classes or the
|
||||||
|
* settings will not get saved.
|
||||||
|
*/
|
||||||
void SaveSettings();
|
void SaveSettings();
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
@ -160,7 +191,12 @@ public:
|
||||||
void OnSize( wxSizeEvent& event );
|
void OnSize( wxSizeEvent& event );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* Function CreateCommandToolbar
|
||||||
|
* creates the main tool bar buttons (fast launch buttons)
|
||||||
|
*/
|
||||||
void CreateCommandToolbar( void );
|
void CreateCommandToolbar( void );
|
||||||
|
|
||||||
wxBitmapButton* AddBitmapButton( wxWindowID aId, const wxBitmap & aBitmap );
|
wxBitmapButton* AddBitmapButton( wxWindowID aId, const wxBitmap & aBitmap );
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/***********************************************************/
|
/***************************************************************/
|
||||||
/* mdiframe.cpp - KICAD_MANAGER_FRAME is the kicad main frame */
|
/* mainframe.cpp - KICAD_MANAGER_FRAME is the kicad main frame */
|
||||||
/***********************************************************/
|
/***************************************************************/
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation
|
#pragma implementation
|
||||||
|
@ -22,9 +22,9 @@ static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) );
|
||||||
|
|
||||||
|
|
||||||
KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent,
|
KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent,
|
||||||
const wxString& title,
|
const wxString& title,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size ) :
|
const wxSize& size ) :
|
||||||
EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME, title, pos, size )
|
EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME, title, pos, size )
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
@ -105,17 +105,12 @@ KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
void KICAD_MANAGER_FRAME::PrintMsg( const wxString& aText )
|
||||||
* Put text in the dialog frame
|
|
||||||
*/
|
|
||||||
void KICAD_MANAGER_FRAME::PrintMsg( const wxString& text )
|
|
||||||
{
|
{
|
||||||
m_RightWin->m_DialogWin->AppendText( text );
|
m_RightWin->m_DialogWin->AppendText( aText );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Resize windows when dragging window borders
|
|
||||||
*/
|
|
||||||
void KICAD_MANAGER_FRAME::OnSashDrag( wxSashEvent& event )
|
void KICAD_MANAGER_FRAME::OnSashDrag( wxSashEvent& event )
|
||||||
{
|
{
|
||||||
event.Skip();
|
event.Skip();
|
||||||
|
@ -148,7 +143,7 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
||||||
m_FrameSize.y = py;
|
m_FrameSize.y = py;
|
||||||
}
|
}
|
||||||
|
|
||||||
Event.SetCanVeto( TRUE );
|
Event.SetCanVeto( true );
|
||||||
|
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
|
|
||||||
|
@ -156,7 +151,8 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
||||||
if( wxGetApp().m_HtmlCtrl )
|
if( wxGetApp().m_HtmlCtrl )
|
||||||
{
|
{
|
||||||
if( wxGetApp().m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
|
if( wxGetApp().m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
|
||||||
wxGetApp().m_HtmlCtrl->GetFrame()->Close( TRUE );
|
wxGetApp().m_HtmlCtrl->GetFrame()->Close( true );
|
||||||
|
|
||||||
wxGetApp().m_HtmlCtrl = NULL;
|
wxGetApp().m_HtmlCtrl = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,16 +167,19 @@ void KICAD_MANAGER_FRAME::OnExit( wxCommandEvent& event )
|
||||||
Close( true );
|
Close( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnRunBitmapConverter( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnRunBitmapConverter( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
ExecuteFile( this, BITMAPCONVERTER_EXE, wxEmptyString );
|
ExecuteFile( this, BITMAPCONVERTER_EXE, wxEmptyString );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnRunPcbCalculator( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnRunPcbCalculator( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
ExecuteFile( this, PCB_CALCULATOR_EXE, wxEmptyString );
|
ExecuteFile( this, PCB_CALCULATOR_EXE, wxEmptyString );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxFileName fn( m_ProjectFileName );
|
wxFileName fn( m_ProjectFileName );
|
||||||
|
@ -211,8 +210,8 @@ void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
|
||||||
void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxFileName fn( m_ProjectFileName );
|
wxFileName fn( m_ProjectFileName );
|
||||||
wxString path = wxT("\"");
|
wxString path = wxT( "\"" );
|
||||||
path += fn.GetPath( wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME ) + wxT("\"");
|
path += fn.GetPath( wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME ) + wxT( "\"" );
|
||||||
|
|
||||||
ExecuteFile( this, GERBVIEW_EXE, path );
|
ExecuteFile( this, GERBVIEW_EXE, path );
|
||||||
}
|
}
|
||||||
|
@ -243,8 +242,9 @@ void KICAD_MANAGER_FRAME::OnOpenFileInTextEditor( wxCommandEvent& event )
|
||||||
if( dlg.ShowModal() == wxID_CANCEL )
|
if( dlg.ShowModal() == wxID_CANCEL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString filename = wxT("\"");
|
wxString filename = wxT( "\"" );
|
||||||
filename += dlg.GetPath() + wxT("\"");
|
filename += dlg.GetPath() + wxT( "\"" );
|
||||||
|
|
||||||
if( !dlg.GetPath().IsEmpty() && !wxGetApp().GetEditorName().IsEmpty() )
|
if( !dlg.GetPath().IsEmpty() && !wxGetApp().GetEditorName().IsEmpty() )
|
||||||
ExecuteFile( this, wxGetApp().GetEditorName(), filename );
|
ExecuteFile( this, wxGetApp().GetEditorName(), filename );
|
||||||
}
|
}
|
||||||
|
@ -262,12 +262,6 @@ void KICAD_MANAGER_FRAME::ClearMsg()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load Kicad main frame specific configuration settings.
|
|
||||||
*
|
|
||||||
* Don't forget to call this base method from any derived classes or the
|
|
||||||
* settings will not get loaded.
|
|
||||||
*/
|
|
||||||
void KICAD_MANAGER_FRAME::LoadSettings()
|
void KICAD_MANAGER_FRAME::LoadSettings()
|
||||||
{
|
{
|
||||||
wxASSERT( wxGetApp().m_EDA_Config != NULL );
|
wxASSERT( wxGetApp().m_EDA_Config != NULL );
|
||||||
|
@ -279,12 +273,6 @@ void KICAD_MANAGER_FRAME::LoadSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save Kicad main frame specific configuration settings.
|
|
||||||
*
|
|
||||||
* Don't forget to call this base method from any derived classes or the
|
|
||||||
* settings will not get saved.
|
|
||||||
*/
|
|
||||||
void KICAD_MANAGER_FRAME::SaveSettings()
|
void KICAD_MANAGER_FRAME::SaveSettings()
|
||||||
{
|
{
|
||||||
wxASSERT( wxGetApp().m_EDA_Config != NULL );
|
wxASSERT( wxGetApp().m_EDA_Config != NULL );
|
||||||
|
|
|
@ -27,18 +27,19 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString PrjFullFileName )
|
||||||
wxFileName newProjectName = PrjFullFileName;
|
wxFileName newProjectName = PrjFullFileName;
|
||||||
|
|
||||||
ClearMsg();
|
ClearMsg();
|
||||||
|
|
||||||
/* Init default config filename */
|
/* Init default config filename */
|
||||||
filename = wxGetApp().FindLibraryPath( wxT( "kicad" ) + g_KicadPrjFilenameExtension);
|
filename = wxGetApp().FindLibraryPath( wxT( "kicad" ) + g_KicadPrjFilenameExtension );
|
||||||
|
|
||||||
/* Check if file kicad.pro exist in template directory */
|
/* Check if file kicad.pro exist in template directory */
|
||||||
if( wxFileName::FileExists( filename ) )
|
if( wxFileName::FileExists( filename ) )
|
||||||
{
|
{
|
||||||
wxCopyFile( filename, PrjFullFileName );
|
wxCopyFile( filename, PrjFullFileName );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DisplayInfoMessage( NULL, _( "Project template file <kicad.pro> not found " ) );
|
DisplayInfoMessage( NULL, _( "Project template file <kicad.pro> not found. " ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Init schematic filename */
|
/* Init schematic filename */
|
||||||
|
@ -46,8 +47,7 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString PrjFullFileName )
|
||||||
SchematicFileExtension ).GetFullName();
|
SchematicFileExtension ).GetFullName();
|
||||||
|
|
||||||
/* Init pcb board filename */
|
/* Init pcb board filename */
|
||||||
m_BoardFileName = wxFileName( newProjectName.GetName(),
|
m_BoardFileName = wxFileName( newProjectName.GetName(), PcbFileExtension ).GetFullName();
|
||||||
PcbFileExtension ).GetFullName();
|
|
||||||
|
|
||||||
/* Init project filename */
|
/* Init project filename */
|
||||||
m_ProjectFileName = newProjectName;
|
m_ProjectFileName = newProjectName;
|
||||||
|
@ -56,15 +56,14 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString PrjFullFileName )
|
||||||
wxGetApp().WriteProjectConfig( PrjFullFileName, GeneralGroupName, NULL );
|
wxGetApp().WriteProjectConfig( PrjFullFileName, GeneralGroupName, NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loading a new project
|
|
||||||
*/
|
|
||||||
void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
int style;
|
int style;
|
||||||
wxString title;
|
wxString title;
|
||||||
|
|
||||||
ClearMsg();
|
ClearMsg();
|
||||||
|
|
||||||
if( event.GetId() != wxID_ANY )
|
if( event.GetId() != wxID_ANY )
|
||||||
{
|
{
|
||||||
if( event.GetId() == ID_NEW_PROJECT )
|
if( event.GetId() == ID_NEW_PROJECT )
|
||||||
|
@ -78,8 +77,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
|
||||||
style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
|
style = wxFD_OPEN | wxFD_FILE_MUST_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFileDialog dlg( this, title, wxGetCwd(), wxEmptyString,
|
wxFileDialog dlg( this, title, wxGetCwd(), wxEmptyString, ProjectFileWildcard, style );
|
||||||
ProjectFileWildcard, style );
|
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_CANCEL )
|
if( dlg.ShowModal() == wxID_CANCEL )
|
||||||
return;
|
return;
|
||||||
|
@ -90,24 +88,26 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
// Ensure project filename extension is .pro
|
// Ensure project filename extension is .pro
|
||||||
wxString fullname = m_ProjectFileName.GetFullPath();
|
wxString fullname = m_ProjectFileName.GetFullPath();
|
||||||
|
|
||||||
if ( !fullname.EndsWith( g_KicadPrjFilenameExtension ) )
|
if ( !fullname.EndsWith( g_KicadPrjFilenameExtension ) )
|
||||||
{
|
{
|
||||||
fullname += g_KicadPrjFilenameExtension;
|
fullname += g_KicadPrjFilenameExtension;
|
||||||
m_ProjectFileName.SetFullName( fullname );
|
m_ProjectFileName.SetFullName( fullname );
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateNewProject( m_ProjectFileName.GetFullPath() );
|
CreateNewProject( m_ProjectFileName.GetFullPath() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogDebug( wxT( "Loading Kicad project file: " ) +
|
wxLogDebug( wxT( "Loading Kicad project file: " ) + m_ProjectFileName.GetFullPath() );
|
||||||
m_ProjectFileName.GetFullPath() );
|
|
||||||
|
|
||||||
/* Check if project file exists and if it is not noname.pro */
|
/* Check if project file exists and if it is not noname.pro */
|
||||||
wxString filename = m_ProjectFileName.GetFullName();
|
wxString filename = m_ProjectFileName.GetFullName();
|
||||||
|
|
||||||
wxString nameless_prj = NAMELESS_PROJECT;
|
wxString nameless_prj = NAMELESS_PROJECT;
|
||||||
nameless_prj += g_KicadPrjFilenameExtension;
|
nameless_prj += g_KicadPrjFilenameExtension;
|
||||||
if( !m_ProjectFileName.FileExists() && !filename.IsSameAs(nameless_prj))
|
|
||||||
|
if( !m_ProjectFileName.FileExists() && !filename.IsSameAs( nameless_prj ) )
|
||||||
{
|
{
|
||||||
DisplayError( this, _( "Kicad project file <" ) +
|
DisplayError( this, _( "Kicad project file <" ) +
|
||||||
m_ProjectFileName.GetFullPath() + _( "> not found" ) );
|
m_ProjectFileName.GetFullPath() + _( "> not found" ) );
|
||||||
|
@ -118,8 +118,13 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
|
||||||
wxGetApp().ReadProjectConfig( m_ProjectFileName.GetFullPath(),
|
wxGetApp().ReadProjectConfig( m_ProjectFileName.GetFullPath(),
|
||||||
GeneralGroupName, NULL, false );
|
GeneralGroupName, NULL, false );
|
||||||
|
|
||||||
SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
|
title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
|
||||||
wxT( " " ) + m_ProjectFileName.GetFullPath() );
|
wxT( " " ) + m_ProjectFileName.GetFullPath();
|
||||||
|
|
||||||
|
if( !m_ProjectFileName.IsDirWritable() )
|
||||||
|
title += _( " [Read Only]" );
|
||||||
|
|
||||||
|
SetTitle( title );
|
||||||
UpdateFileHistory( m_ProjectFileName.GetFullPath() );
|
UpdateFileHistory( m_ProjectFileName.GetFullPath() );
|
||||||
m_LeftWin->ReCreateTreePrj();
|
m_LeftWin->ReCreateTreePrj();
|
||||||
|
|
||||||
|
@ -130,23 +135,10 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save the project top level configuration parameters.
|
|
||||||
*/
|
|
||||||
void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxString fn;
|
if( !IsWritable( m_ProjectFileName ) )
|
||||||
|
|
||||||
wxFileDialog dlg( this, _( "Save Project File" ), wxGetCwd(),
|
|
||||||
m_ProjectFileName.GetFullName(), ProjectFileWildcard,
|
|
||||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_CANCEL )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_ProjectFileName = dlg.GetPath();
|
wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(), GeneralGroupName, NULL );
|
||||||
|
|
||||||
wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(),
|
|
||||||
GeneralGroupName, NULL );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue