Library Editor: make 'Save All' the default save action
Fixes: lp:1748555 * https://bugs.launchpad.net/kicad/+bug/1748555
This commit is contained in:
parent
81b3c420fd
commit
3c9a5b0966
|
@ -218,8 +218,7 @@ static EDA_HOTKEY HkInsertPin( _HKI( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT
|
|||
static EDA_HOTKEY HkMoveLibItem( _HKI( "Move Library Item" ), HK_LIBEDIT_MOVE_GRAPHIC_ITEM, 'M' );
|
||||
|
||||
// Load/save files
|
||||
static EDA_HOTKEY HkSaveLib( _HKI( "Save Library" ), HK_SAVE_LIB, 'S' + GR_KB_CTRL + GR_KB_ALT, ID_LIBEDIT_SAVE_LIBRARY );
|
||||
static EDA_HOTKEY HkSavePart( _HKI( "Save Symbol" ), HK_SAVE_PART, 'S' + GR_KB_CTRL, ID_LIBEDIT_SAVE_PART );
|
||||
static EDA_HOTKEY HkSaveAllLib( _HKI( "Save All Libraries" ), HK_SAVE_ALL_LIBS, 'S' + GR_KB_CTRL, ID_LIBEDIT_SAVE_ALL_LIBS );
|
||||
static EDA_HOTKEY HkSaveSchematic( _HKI( "Save Schematic" ), HK_SAVE_SCH, 'S' + GR_KB_CTRL );
|
||||
static EDA_HOTKEY HkLoadSchematic( _HKI( "Load Schematic" ), HK_LOAD_SCH, 'L' + GR_KB_CTRL );
|
||||
|
||||
|
@ -320,8 +319,7 @@ static EDA_HOTKEY* schematic_Hotkey_List[] =
|
|||
// List of hotkey descriptors for library editor
|
||||
static EDA_HOTKEY* libEdit_Hotkey_List[] =
|
||||
{
|
||||
&HkSaveLib,
|
||||
&HkSavePart,
|
||||
&HkSaveAllLib,
|
||||
&HkCreatePin,
|
||||
&HkInsertPin,
|
||||
&HkMoveLibItem,
|
||||
|
|
|
@ -74,8 +74,7 @@ enum hotkey_id_commnand {
|
|||
HK_ADD_GRAPHIC_TEXT,
|
||||
HK_ADD_GRAPHIC_POLYLINE,
|
||||
HK_ADD_NOCONN_FLAG,
|
||||
HK_SAVE_LIB,
|
||||
HK_SAVE_PART,
|
||||
HK_SAVE_ALL_LIBS,
|
||||
HK_SAVE_SCH,
|
||||
HK_LOAD_SCH,
|
||||
HK_LEFT_CLICK,
|
||||
|
|
|
@ -348,7 +348,7 @@ LIB_EDIT_FRAME::~LIB_EDIT_FRAME()
|
|||
|
||||
void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
||||
{
|
||||
if( saveAllLibraries() )
|
||||
if( saveAllLibraries( true ) )
|
||||
Destroy();
|
||||
else
|
||||
Event.Veto();
|
||||
|
@ -501,10 +501,8 @@ void LIB_EDIT_FRAME::OnUpdatePartModified( wxUpdateUIEvent& aEvent )
|
|||
if( aEvent.GetId() == ID_LIBEDIT_SAVE_PART )
|
||||
{
|
||||
bool readOnly = libName.IsEmpty() || m_libMgr->IsLibraryReadOnly( libName );
|
||||
wxString text = AddHotkeyName( readOnly ? _( "&Save Symbol [Read Only]" ) : _( "&Save Symbol" ),
|
||||
g_Libedit_Hokeys_Descr, HK_SAVE_PART );
|
||||
|
||||
aEvent.SetText( text );
|
||||
aEvent.SetText( readOnly ? _( "&Save Symbol [Read Only]" ) : _( "&Save Symbol" ) );
|
||||
aEvent.Enable( !readOnly && !partName.IsEmpty()
|
||||
&& m_libMgr->IsPartModified( partName, libName ) );
|
||||
}
|
||||
|
@ -554,10 +552,7 @@ void LIB_EDIT_FRAME::OnUpdateSaveLib( wxUpdateUIEvent& event )
|
|||
wxString lib = getTargetLib();
|
||||
bool readOnly = lib.IsEmpty() || m_libMgr->IsLibraryReadOnly( lib );
|
||||
|
||||
wxString text = AddHotkeyName( readOnly ? _( "&Save Library [Read Only]" )
|
||||
: _( "&Save Library" ) , g_Libedit_Hokeys_Descr, HK_SAVE_PART );
|
||||
|
||||
event.SetText( text );
|
||||
event.SetText( readOnly ? _( "&Save Library [Read Only]" ) : _( "&Save Library" ) );
|
||||
event.Enable( !readOnly && m_libMgr->IsLibraryModified( lib ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -728,9 +728,11 @@ private:
|
|||
///> or the library that is currently modified.
|
||||
wxString getTargetLib() const;
|
||||
|
||||
///> Returns true when the operation has succeded (all requested libraries have been saved or
|
||||
///> none was selected and confirmed by OK).
|
||||
bool saveAllLibraries();
|
||||
/* Returns true when the operation has succeded (all requested libraries have been saved or
|
||||
* none was selected and confirmed by OK).
|
||||
* @param aClosing when true, then the list of unsaved libraries is always shown.
|
||||
*/
|
||||
bool saveAllLibraries( bool aClosing );
|
||||
|
||||
///> Creates or adds an existing library to the symbol library table.
|
||||
bool addLibraryFile( bool aCreateNew );
|
||||
|
|
|
@ -241,7 +241,8 @@ void LIB_EDIT_FRAME::OnSaveLibrary( wxCommandEvent& event )
|
|||
|
||||
void LIB_EDIT_FRAME::OnSaveAllLibraries( wxCommandEvent& event )
|
||||
{
|
||||
saveAllLibraries();
|
||||
saveAllLibraries( false );
|
||||
m_treePane->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
@ -590,7 +591,7 @@ bool LIB_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
|
|||
}
|
||||
|
||||
|
||||
bool LIB_EDIT_FRAME::saveAllLibraries()
|
||||
bool LIB_EDIT_FRAME::saveAllLibraries( bool aClosing )
|
||||
{
|
||||
wxArrayString unsavedLibraries;
|
||||
// There are two stages: first try to save libraries to the original files.
|
||||
|
@ -609,22 +610,41 @@ bool LIB_EDIT_FRAME::saveAllLibraries()
|
|||
unsavedLibraries.Add( lib );
|
||||
}
|
||||
|
||||
if( !unsavedLibraries.IsEmpty() )
|
||||
if( unsavedLibraries.IsEmpty() )
|
||||
break;
|
||||
|
||||
std::vector<int> libIdxs;
|
||||
|
||||
// Show a list of unsaved libraries when:
|
||||
// - library editor is closed
|
||||
// - there are multiple libraries modified
|
||||
// - another library is opened
|
||||
// - an error occurred when saving a library
|
||||
if( aClosing || unsavedLibraries.Count() > 1
|
||||
|| GetCurLib() != unsavedLibraries[0] || !firstRun )
|
||||
{
|
||||
auto res = SelectMultipleOptions( this, _( "Save Libraries" ),
|
||||
firstRun ? _( "Select libraries to save before closing" )
|
||||
: _( "Some libraries could not be saved to their original files.\n\n"
|
||||
"Do you want to save them to a new file?" ),
|
||||
bool accepted;
|
||||
|
||||
std::tie( accepted, libIdxs ) = SelectMultipleOptions( this, _( "Save Libraries" ),
|
||||
firstRun ? _( "Select libraries to save" )
|
||||
: _( "Some libraries could not be saved to their original files.\n\n"
|
||||
"Do you want to save them to a new file?" ),
|
||||
unsavedLibraries, true );
|
||||
|
||||
if( !res.first )
|
||||
if( !accepted )
|
||||
return false; // dialog has been cancelled
|
||||
|
||||
for( auto libIndex : res.second )
|
||||
allSaved &= saveLibrary( unsavedLibraries[libIndex], !firstRun );
|
||||
|
||||
firstRun = false;
|
||||
}
|
||||
|
||||
else if( unsavedLibraries.Count() == 1 || GetCurLib() == unsavedLibraries[0] )
|
||||
{
|
||||
// Save just current library, no questions asked
|
||||
libIdxs.push_back( 0 );
|
||||
}
|
||||
|
||||
for( auto libIndex : libIdxs )
|
||||
allSaved &= saveLibrary( unsavedLibraries[libIndex], !firstRun );
|
||||
|
||||
firstRun = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -79,9 +79,9 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
|||
fileMenu->AppendSeparator();
|
||||
|
||||
// Save library variants
|
||||
text = AddHotkeyName( _( "&Save Library" ), g_Libedit_Hokeys_Descr, HK_SAVE_LIB );
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_SAVE_LIBRARY, text,
|
||||
ID_LIBEDIT_SAVE_LIBRARY,
|
||||
_( "&Save Library" ),
|
||||
_( "Save the current active library" ),
|
||||
KiBitmap( save_library_xpm ) );
|
||||
|
||||
|
@ -91,10 +91,8 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
|||
_( "Save the current library to a new file" ),
|
||||
KiBitmap( save_as_xpm ) );
|
||||
|
||||
AddMenuItem( fileMenu,
|
||||
ID_LIBEDIT_SAVE_ALL_LIBS,
|
||||
_( "Save All &Libraries" ),
|
||||
_( "Save all library changes" ),
|
||||
text = AddHotkeyName( _( "Save All &Libraries" ), g_Libedit_Hokeys_Descr, HK_SAVE_ALL_LIBS );
|
||||
AddMenuItem( fileMenu, ID_LIBEDIT_SAVE_ALL_LIBS, text, _( "Save all library changes" ),
|
||||
KiBitmap( save_xpm ) );
|
||||
|
||||
// Separator
|
||||
|
@ -194,10 +192,9 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
|
|||
_( "Create a new empty symbol" ),
|
||||
KiBitmap( new_component_xpm ) );
|
||||
|
||||
text = AddHotkeyName( _( "&Save Symbol" ), g_Libedit_Hokeys_Descr, HK_SAVE_PART );
|
||||
AddMenuItem( partMenu,
|
||||
ID_LIBEDIT_SAVE_PART,
|
||||
text,
|
||||
_( "&Save Symbol" ),
|
||||
_( "Saves the current symbol to the library" ),
|
||||
KiBitmap( save_part_xpm ) );
|
||||
|
||||
|
|
Loading…
Reference in New Issue