Symbol editor: disable saving legacy symbol libraries.
CHANGED: The symbol library save menu entry is now only enable when the currently selected library is modified. CHANGED: The symbol library save all menu entry and tool bar button are enabled when one or more of the symbol libraries have been modified. REMOVED: The ability to save symbol libraries in the legacy file format.
This commit is contained in:
parent
b624c7090a
commit
6c8b937e1b
|
@ -417,6 +417,8 @@ wxString LIB_EDIT_FRAME::SetCurLib( const wxString& aLibNickname )
|
||||||
|
|
||||||
m_libMgr->SetCurrentLib( aLibNickname );
|
m_libMgr->SetCurrentLib( aLibNickname );
|
||||||
|
|
||||||
|
ReCreateMenuBar();
|
||||||
|
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -909,7 +911,8 @@ bool LIB_EDIT_FRAME::IsContentModified()
|
||||||
// Test if any library has been modified
|
// Test if any library has been modified
|
||||||
for( const auto& libNickname : m_libMgr->GetLibraryNames() )
|
for( const auto& libNickname : m_libMgr->GetLibraryNames() )
|
||||||
{
|
{
|
||||||
if( m_libMgr->IsLibraryModified( libNickname ) )
|
if( m_libMgr->IsLibraryModified( libNickname )
|
||||||
|
&& !m_libMgr->IsLibraryReadOnly( libNickname ) )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -282,8 +282,8 @@ bool LIB_MANAGER::IsLibraryReadOnly( const wxString& aLibrary ) const
|
||||||
if( row )
|
if( row )
|
||||||
fileType = SCH_IO_MGR::EnumFromStr( row->GetType() );
|
fileType = SCH_IO_MGR::EnumFromStr( row->GetType() );
|
||||||
|
|
||||||
return ( fileType != SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY ) && fn.FileExists() &&
|
return ( fileType == SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY ) ||
|
||||||
( !fn.IsFileWritable() || !fn.IsDirWritable() );
|
( fn.FileExists() && !fn.IsFileWritable() ) || !fn.IsDirWritable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,9 @@ void LIB_EDIT_FRAME::updateTitle()
|
||||||
if( GetCurPart() )
|
if( GetCurPart() )
|
||||||
title += wxT( " \u2014 " ) + GetCurPart()->GetLibId().Format();
|
title += wxT( " \u2014 " ) + GetCurPart()->GetLibId().Format();
|
||||||
|
|
||||||
|
if( GetCurPart() && m_libMgr && m_libMgr->IsLibraryReadOnly( GetCurLib() ) )
|
||||||
|
title += " [Read Only Library]";
|
||||||
|
|
||||||
SetTitle( title );
|
SetTitle( title );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,9 +378,14 @@ void LIB_EDIT_FRAME::Save()
|
||||||
{
|
{
|
||||||
saveLibrary( libName, false );
|
saveLibrary( libName, false );
|
||||||
}
|
}
|
||||||
|
else if( !libName.IsEmpty() && m_libMgr->IsLibraryReadOnly( libName ) )
|
||||||
|
{
|
||||||
|
// Force a "Save As..." if the modified library is read only.
|
||||||
|
saveLibrary( libName, true );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Save Part
|
// Save a single library.
|
||||||
if( m_libMgr->FlushPart( partName, libName ) )
|
if( m_libMgr->FlushPart( partName, libName ) )
|
||||||
m_libMgr->ClearPartModified( partName, libName );
|
m_libMgr->ClearPartModified( partName, libName );
|
||||||
}
|
}
|
||||||
|
@ -838,7 +846,7 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
|
||||||
|
|
||||||
ClearMsgPanel();
|
ClearMsgPanel();
|
||||||
|
|
||||||
// Copy .lib file to .bak.
|
// Copy .kicad_symb file to .bak.
|
||||||
if( !backupFile( fn, "bak" ) )
|
if( !backupFile( fn, "bak" ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -895,7 +903,11 @@ bool LIB_EDIT_FRAME::saveAllLibraries( bool aRequireConfirmation )
|
||||||
{
|
{
|
||||||
// If saving under existing name fails then do a Save As..., and if that
|
// If saving under existing name fails then do a Save As..., and if that
|
||||||
// fails then cancel close action.
|
// fails then cancel close action.
|
||||||
if( !saveLibrary( libNickname, false ) && !saveLibrary( libNickname, true ) )
|
if( !m_libMgr->IsLibraryReadOnly( libNickname )
|
||||||
|
&& !saveLibrary( libNickname, false ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( !saveLibrary( libNickname, true ) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
LIB_ID libId = getTargetLibId();
|
LIB_ID libId = getTargetLibId();
|
||||||
const wxString& libName = libId.GetLibNickname();
|
const wxString& libName = libId.GetLibNickname();
|
||||||
const wxString& partName = libId.GetLibItemName();
|
const wxString& partName = libId.GetLibItemName();
|
||||||
bool readOnly = libName.IsEmpty() || m_libMgr->IsLibraryReadOnly( libName );
|
bool readOnly = libName.IsEmpty();
|
||||||
|
|
||||||
if( partName.IsEmpty() )
|
if( partName.IsEmpty() )
|
||||||
return ( !readOnly && m_libMgr->IsLibraryModified( libName ) );
|
return ( !readOnly && m_libMgr->IsLibraryModified( libName ) );
|
||||||
|
@ -53,6 +53,11 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
return ( !readOnly && m_libMgr->IsPartModified( partName, libName ) );
|
return ( !readOnly && m_libMgr->IsPartModified( partName, libName ) );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto saveAllEnableCondition = [this] ( const SELECTION& sel )
|
||||||
|
{
|
||||||
|
return m_libMgr->HasModifications();
|
||||||
|
};
|
||||||
|
|
||||||
//-- File menu -----------------------------------------------
|
//-- File menu -----------------------------------------------
|
||||||
//
|
//
|
||||||
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
|
CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
|
||||||
|
@ -64,7 +69,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
fileMenu->AddSeparator();
|
fileMenu->AddSeparator();
|
||||||
fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition );
|
fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition );
|
||||||
fileMenu->AddItem( ACTIONS::saveCopyAs, EE_CONDITIONS::ShowAlways );
|
fileMenu->AddItem( ACTIONS::saveCopyAs, EE_CONDITIONS::ShowAlways );
|
||||||
fileMenu->AddItem( ACTIONS::saveAll, EE_CONDITIONS::ShowAlways );
|
fileMenu->AddItem( ACTIONS::saveAll, saveAllEnableCondition );
|
||||||
fileMenu->AddItem( ACTIONS::revert, modifiedDocumentCondition );
|
fileMenu->AddItem( ACTIONS::revert, modifiedDocumentCondition );
|
||||||
|
|
||||||
fileMenu->AddSeparator();
|
fileMenu->AddSeparator();
|
||||||
|
|
|
@ -157,7 +157,7 @@ void LIB_EDIT_FRAME::SyncToolbars()
|
||||||
|
|
||||||
bool isEditable = m_my_part && m_my_part->IsRoot();
|
bool isEditable = m_my_part && m_my_part->IsRoot();
|
||||||
|
|
||||||
m_mainToolBar->Toggle( ACTIONS::saveAll, IsContentModified() );
|
m_mainToolBar->Toggle( ACTIONS::saveAll, m_libMgr->HasModifications() );
|
||||||
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
|
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
|
||||||
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
|
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
|
||||||
m_mainToolBar->Toggle( ACTIONS::zoomTool, IsCurrentTool( ACTIONS::zoomTool ) );
|
m_mainToolBar->Toggle( ACTIONS::zoomTool, IsCurrentTool( ACTIONS::zoomTool ) );
|
||||||
|
|
Loading…
Reference in New Issue