Minor dialog beautification.

This commit is contained in:
Jeff Young 2022-04-19 11:25:29 +01:00
parent c619a63c06
commit 84f620a96e
1 changed files with 38 additions and 23 deletions

View File

@ -46,6 +46,9 @@
#include <string_utils.h> #include <string_utils.h>
static int g_option = 0;
/** /**
* Helper control to inquire user what to do on library save as operation. * Helper control to inquire user what to do on library save as operation.
*/ */
@ -55,58 +58,71 @@ public:
SAVE_AS_HELPER( wxWindow* aParent ) : SAVE_AS_HELPER( wxWindow* aParent ) :
wxPanel( aParent ) wxPanel( aParent )
{ {
m_simpleSaveAs = new wxRadioButton( this, wxID_ANY, _( "Normal save as operation" ), m_simpleSaveAs = new wxRadioButton( this, wxID_ANY, _( "Do not update library tables" ),
wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
m_simpleSaveAs->SetToolTip( _( "Do not perform any additional operations after saving " m_simpleSaveAs->SetToolTip( _( "Do not perform any additional operations after saving "
"library." ) ); "library." ) );
m_replaceTableEntry = new wxRadioButton( this, wxID_ANY, m_replaceTableEntry = new wxRadioButton( this, wxID_ANY,
_( "Replace library table entry" ) ); _( "Update existing library table entry" ) );
m_replaceTableEntry->SetToolTip( _( "Replace symbol library table entry with new library." m_replaceTableEntry->SetToolTip( _( "Update symbol library table entry to point to new "
"\n\nThe original library will no longer be available " "library.\n\n"
"The original library will no longer be available "
"for use." ) ); "for use." ) );
m_addGlobalTableEntry = new wxRadioButton( this, wxID_ANY, m_addGlobalTableEntry = new wxRadioButton( this, wxID_ANY,
_( "Add new global library table entry" ) ); _( "Add new global library table entry" ) );
m_addGlobalTableEntry->SetToolTip( _( "Add new entry to the global symbol library table." m_addGlobalTableEntry->SetToolTip( _( "Add new entry to the global symbol library table."
"\n\nThe symbol library table nickname is suffixed " "\n\nThe symbol library table nickname is suffixed "
"with\nan integer to ensure no duplicate table " "with\nan integer to prevent duplicate table "
"entries." ) ); "entries." ) );
m_addProjectTableEntry = new wxRadioButton( this, wxID_ANY, m_addProjectTableEntry = new wxRadioButton( this, wxID_ANY,
_( "Add new project library table entry" ) ); _( "Add new project library table entry" ) );
m_addProjectTableEntry->SetToolTip( _( "Add new entry to the project symbol library table." m_addProjectTableEntry->SetToolTip( _( "Add new entry to the project symbol library table."
"\n\nThe symbol library table nickname is suffixed " "\n\nThe symbol library table nickname is suffixed "
"with\nan integer to ensure no duplicate table " "with\nan integer to prevent duplicate table "
"entries." ) ); "entries." ) );
wxBoxSizer* sizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
sizer->Add( m_simpleSaveAs, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 5 ); sizer->Add( m_simpleSaveAs, 0, wxLEFT | wxRIGHT | wxTOP, 5 );
sizer->Add( m_replaceTableEntry, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5 ); sizer->Add( m_replaceTableEntry, 0, wxLEFT | wxRIGHT | wxTOP, 5 );
sizer->Add( m_addGlobalTableEntry, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5 ); sizer->Add( m_addGlobalTableEntry, 0, wxLEFT | wxRIGHT | wxTOP, 5 );
sizer->Add( m_addProjectTableEntry, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5 ); sizer->Add( m_addProjectTableEntry, 0, wxLEFT | wxRIGHT | wxTOP | wxBOTTOM, 5 );
SetSizerAndFit( sizer ); SetSizerAndFit( sizer );
SetOption( static_cast<SAH_TYPE>( g_option ) );
}
~SAVE_AS_HELPER()
{
g_option = GetOption();
} }
enum SAH_TYPE enum SAH_TYPE
{ {
UNDEFINED = -1, NORMAL_SAVE_AS = 0,
NORMAL_SAVE_AS,
REPLACE_TABLE_ENTRY, REPLACE_TABLE_ENTRY,
ADD_GLOBAL_TABLE_ENTRY, ADD_GLOBAL_TABLE_ENTRY,
ADD_PROJECT_TABLE_ENTRY ADD_PROJECT_TABLE_ENTRY
}; };
void SetOption( SAH_TYPE aOption )
{
m_simpleSaveAs->SetValue( aOption == NORMAL_SAVE_AS );
m_replaceTableEntry->SetValue( aOption == REPLACE_TABLE_ENTRY );
m_addGlobalTableEntry->SetValue( aOption == ADD_GLOBAL_TABLE_ENTRY );
m_addProjectTableEntry->SetValue( aOption == ADD_PROJECT_TABLE_ENTRY );
}
SAH_TYPE GetOption() const SAH_TYPE GetOption() const
{ {
if( m_simpleSaveAs->GetValue() ) if( m_replaceTableEntry->GetValue() )
return SAH_TYPE::NORMAL_SAVE_AS;
else if( m_replaceTableEntry->GetValue() )
return SAH_TYPE::REPLACE_TABLE_ENTRY; return SAH_TYPE::REPLACE_TABLE_ENTRY;
else if( m_addGlobalTableEntry->GetValue() ) else if( m_addGlobalTableEntry->GetValue() )
return ADD_GLOBAL_TABLE_ENTRY; return ADD_GLOBAL_TABLE_ENTRY;
else if( m_addProjectTableEntry->GetValue() ) else if( m_addProjectTableEntry->GetValue() )
return ADD_PROJECT_TABLE_ENTRY; return ADD_PROJECT_TABLE_ENTRY;
else else
return UNDEFINED; return SAH_TYPE::NORMAL_SAVE_AS;
} }
/** /**
@ -125,10 +141,10 @@ public:
} }
private: private:
wxRadioButton* m_simpleSaveAs; wxRadioButton* m_simpleSaveAs;
wxRadioButton* m_replaceTableEntry; wxRadioButton* m_replaceTableEntry;
wxRadioButton* m_addGlobalTableEntry; wxRadioButton* m_addGlobalTableEntry;
wxRadioButton* m_addProjectTableEntry; wxRadioButton* m_addProjectTableEntry;
}; };
@ -1045,7 +1061,7 @@ bool SYMBOL_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
{ {
wxFileName fn; wxFileName fn;
wxString msg; wxString msg;
SAVE_AS_HELPER::SAH_TYPE type = SAVE_AS_HELPER::SAH_TYPE::UNDEFINED; SAVE_AS_HELPER::SAH_TYPE type = SAVE_AS_HELPER::SAH_TYPE::NORMAL_SAVE_AS;
SCH_IO_MGR::SCH_FILE_T fileType = SCH_IO_MGR::SCH_FILE_T::SCH_KICAD; SCH_IO_MGR::SCH_FILE_T fileType = SCH_IO_MGR::SCH_FILE_T::SCH_KICAD;
PROJECT& prj = Prj(); PROJECT& prj = Prj();
@ -1142,7 +1158,6 @@ bool SYMBOL_EDIT_FRAME::saveLibrary( const wxString& aLibrary, bool aNewFile )
resyncLibTree = addLibTableEntry( fn.GetFullPath(), PROJECT_LIB_TABLE ); resyncLibTree = addLibTableEntry( fn.GetFullPath(), PROJECT_LIB_TABLE );
break; break;
case SAVE_AS_HELPER::SAH_TYPE::NORMAL_SAVE_AS:
default: default:
break; break;
} }