Fix OSX button order issue in Unsaved Changes dialog.
Also changes the presentation of the string when the checkbox appears so that the "Changes will be lost" warning isn't hidden by the turndown. This last part may require conditional compilation as it's undocumented. Lastly, regularizes the Unsaved Changes strings between the apps.
This commit is contained in:
parent
8085899d0a
commit
4eab89d9ef
|
@ -152,21 +152,25 @@ long KIDIALOG::getStyle( KD_TYPE aType )
|
|||
}
|
||||
|
||||
|
||||
int UnsavedChangesDialog( wxWindow* parent, const wxString& aMessage, bool* aApplyToAll )
|
||||
int UnsavedChangesDialog( wxWindow* parent, wxString aMessage, bool* aApplyToAll )
|
||||
{
|
||||
static bool s_apply_to_all = false;
|
||||
|
||||
wxRichMessageDialog dlg( parent, aMessage, wxEmptyString,
|
||||
wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
|
||||
dlg.ShowDetailedText( _( "If you don't save, all your changes will be permanently lost." ) );
|
||||
dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Save" ) ),
|
||||
wxMessageDialog::ButtonLabel( _( "Discard Changes" ) ) );
|
||||
dlg.SetExtendedMessage( _( "If you don't save, all your changes will be permanently lost." ) );
|
||||
dlg.SetYesNoLabels( _( "Save" ), _( "Discard Changes" ) );
|
||||
|
||||
if( aApplyToAll )
|
||||
dlg.ShowCheckBox( _( "Apply to all" ), true );
|
||||
dlg.ShowCheckBox( _( "Apply to all" ), s_apply_to_all );
|
||||
|
||||
int ret = dlg.ShowModal();
|
||||
|
||||
if( aApplyToAll )
|
||||
{
|
||||
*aApplyToAll = dlg.IsCheckBoxChecked();
|
||||
s_apply_to_all = dlg.IsCheckBoxChecked();
|
||||
}
|
||||
|
||||
// Returns wxID_YES, wxID_NO, or wxID_CANCEL
|
||||
return ret;
|
||||
|
@ -175,14 +179,18 @@ int UnsavedChangesDialog( wxWindow* parent, const wxString& aMessage, bool* aApp
|
|||
|
||||
int UnsavedChangesDialog( wxWindow* parent, const wxString& aMessage )
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
// wxWidgets gets the button order wrong on Mac so use the other dialog.
|
||||
return UnsavedChangesDialog( parent, aMessage, nullptr );
|
||||
#else
|
||||
wxMessageDialog dlg( parent, aMessage, wxEmptyString,
|
||||
wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_WARNING | wxCENTER );
|
||||
dlg.SetExtendedMessage( _( "If you don't save, all your changes will be permanently lost." ) );
|
||||
dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Save" ) ),
|
||||
wxMessageDialog::ButtonLabel( _( "Discard Changes" ) ) );
|
||||
dlg.SetYesNoLabels( _( "Save" ), _( "Discard Changes" ) );
|
||||
|
||||
// Returns wxID_YES, wxID_NO, or wxID_CANCEL
|
||||
return dlg.ShowModal();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -191,8 +199,7 @@ bool ConfirmRevertDialog( wxWindow* parent, const wxString& aMessage )
|
|||
wxMessageDialog dlg( parent, aMessage, wxEmptyString,
|
||||
wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
|
||||
dlg.SetExtendedMessage( _( "Your current changes will be permanently lost." ) );
|
||||
dlg.SetOKCancelLabels( wxMessageDialog::ButtonLabel( _( "Revert" ) ),
|
||||
wxMessageDialog::ButtonLabel( _( "Cancel" ) ) );
|
||||
dlg.SetOKCancelLabels( _( "Revert" ), _( "Cancel" ) );
|
||||
|
||||
return dlg.ShowModal() == wxID_OK;
|
||||
}
|
||||
|
@ -217,8 +224,7 @@ int OKOrCancelDialog( wxWindow* aParent, const wxString& aWarning, const wxStrin
|
|||
wxRichMessageDialog dlg( aParent, aMessage, wxEmptyString,
|
||||
wxOK | wxCANCEL | wxOK_DEFAULT | wxICON_WARNING | wxCENTER );
|
||||
dlg.ShowDetailedText( _( "If you don't save, all your changes will be permanently lost." ) );
|
||||
dlg.SetOKCancelLabels( wxMessageDialog::ButtonLabel( aOKLabel ),
|
||||
wxMessageDialog::ButtonLabel( aCancelLabel ) );
|
||||
dlg.SetOKCancelLabels( aOKLabel, aCancelLabel );
|
||||
|
||||
if( aApplyToAll )
|
||||
dlg.ShowCheckBox( _( "Apply to all" ), true );
|
||||
|
@ -241,7 +247,8 @@ void DisplayError( wxWindow* parent, const wxString& text, int displaytime )
|
|||
int icon = displaytime > 0 ? wxICON_INFORMATION : wxICON_ERROR;
|
||||
|
||||
dialog = new wxMessageDialog( parent, text, _( "Warning" ),
|
||||
wxOK | wxCENTRE | wxRESIZE_BORDER | icon | wxSTAY_ON_TOP );
|
||||
wxOK | wxCENTRE | wxRESIZE_BORDER |
|
||||
icon | wxSTAY_ON_TOP );
|
||||
|
||||
dialog->ShowModal();
|
||||
dialog->Destroy();
|
||||
|
|
|
@ -274,7 +274,7 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
if( m_modified )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this, _( "Symbol to Footprint links have been modified. "
|
||||
"Save before exit?" ),
|
||||
"Save changes?" ),
|
||||
[&]()->bool { return SaveFootprintAssociation( false ); } ) )
|
||||
{
|
||||
Event.Veto();
|
||||
|
|
|
@ -907,7 +907,8 @@ bool SCH_EDIT_FRAME::AskToSaveChanges()
|
|||
{
|
||||
if( screen->IsModify() )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. Save changes?" ),
|
||||
if( !HandleUnsavedChanges( this, _( "The current schematic has been modified. "
|
||||
"Save changes?" ),
|
||||
[&]()->bool { return SaveProject(); } ) )
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -148,7 +148,8 @@ bool LIB_EDIT_FRAME::LoadComponentAndSelectLib( const LIB_ID& aLibId, int aUnit,
|
|||
|
||||
if( GetScreen()->IsModify() && GetCurPart() )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this, _( "The current symbol has been modified. Save changes?" ),
|
||||
if( !HandleUnsavedChanges( this, _( "The current symbol has been modified. "
|
||||
"Save changes?" ),
|
||||
[&]()->bool { return saveCurrentPart(); } ) )
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -517,10 +517,10 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
|||
|
||||
if( sheetList.IsModified() )
|
||||
{
|
||||
wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
|
||||
wxString msg = _( "Save changes to\n\"%s\"\nbefore closing?" );
|
||||
wxFileName fileName = g_RootSheet->GetScreen()->GetFileName();
|
||||
wxString msg = _( "Save changes to \"%s\" before closing?" );
|
||||
|
||||
if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName ),
|
||||
if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
|
||||
[&]()->bool { return SaveProject(); } ) )
|
||||
{
|
||||
aEvent.Veto();
|
||||
|
|
|
@ -154,9 +154,8 @@ wxString SCH_SHEET_PATH::Path() const
|
|||
|
||||
s = wxT( "/" ); // This is the root path
|
||||
|
||||
// start at 1 to avoid the root sheet,
|
||||
// which does not need to be added to the path
|
||||
// it's timestamp changes anyway.
|
||||
// Start at 1 to avoid the root sheet, which does not need to be added to the path.
|
||||
// It's timestamp changes anyway.
|
||||
for( unsigned i = 1; i < size(); i++ )
|
||||
{
|
||||
t.Printf( _( "%8.8lX/" ), (long unsigned) at( i )->GetTimeStamp() );
|
||||
|
@ -171,13 +170,14 @@ wxString SCH_SHEET_PATH::PathHumanReadable() const
|
|||
{
|
||||
wxString s;
|
||||
|
||||
if( size() == 1 )
|
||||
return _( "<root sheet>" );
|
||||
|
||||
s = wxT( "/" );
|
||||
|
||||
// start at 1 to avoid the root sheet, as above.
|
||||
// Start at 1 to avoid the root sheet, as above.
|
||||
for( unsigned i = 1; i < size(); i++ )
|
||||
{
|
||||
s = s + at( i )->GetName() + wxT( "/" );
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ bool HandleUnsavedChanges( wxWindow* aParent, const wxString& aMessage,
|
|||
* written back to the bool.
|
||||
* @return wxID_YES, wxID_CANCEL, wxID_NO.
|
||||
*/
|
||||
int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage, bool* aApplyToAll );
|
||||
int UnsavedChangesDialog( wxWindow* aParent, wxString aMessage, bool* aApplyToAll );
|
||||
|
||||
int UnsavedChangesDialog( wxWindow* aParent, const wxString& aMessage );
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ void PL_EDITOR_FRAME::OnFileHistory( wxCommandEvent& event )
|
|||
{
|
||||
if( GetScreen()->IsModify() )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this,
|
||||
_( "The current page layout has been modified. Save changes?" ),
|
||||
if( !HandleUnsavedChanges( this, _( "The current page layout has been modified. "
|
||||
"Save changes?" ),
|
||||
[&]()->bool { return saveCurrentPageLayout(); } ) )
|
||||
{
|
||||
return;
|
||||
|
@ -92,7 +92,8 @@ void PL_EDITOR_FRAME::Files_io( wxCommandEvent& event )
|
|||
|
||||
if( ( id == wxID_NEW || id == wxID_OPEN ) && GetScreen()->IsModify() )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this, _( "The current page layout has been modified. Save changes?" ),
|
||||
if( !HandleUnsavedChanges( this, _( "The current page layout has been modified. "
|
||||
"Save changes?" ),
|
||||
[&]()->bool { return saveCurrentPageLayout(); } ) )
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -241,8 +241,10 @@ void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
{
|
||||
if( GetScreen()->IsModify() )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this,
|
||||
_( "The current page layout has been modified. Save changes?" ),
|
||||
wxFileName filename = GetCurrFileName();
|
||||
wxString msg = _( "Save changes to \"%s\" before closing?" );
|
||||
|
||||
if( !HandleUnsavedChanges( this, wxString::Format( msg, filename.GetFullName() ),
|
||||
[&]()->bool { return saveCurrentPageLayout(); } ) )
|
||||
{
|
||||
Event.Veto();
|
||||
|
|
|
@ -451,7 +451,10 @@ void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
{
|
||||
if( GetScreen()->IsModify() && GetBoard()->GetFirstModule() )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this, _( "Save changes to footprint before closing?" ),
|
||||
wxString footprintName = GetBoard()->GetFirstModule()->GetFPID().GetLibItemName();
|
||||
wxString msg = _( "Save changes to \"%s\" before closing? " );
|
||||
|
||||
if( !HandleUnsavedChanges( this, wxString::Format( msg, footprintName ),
|
||||
[&]() -> bool { return SaveFootprint( GetBoard()->GetFirstModule() ); } ) )
|
||||
{
|
||||
Event.Veto();
|
||||
|
|
|
@ -206,8 +206,8 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
|
||||
if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this,
|
||||
_( "The current footprint has been modified. Save changes?" ),
|
||||
if( !HandleUnsavedChanges( this, _( "The current footprint has been modified. "
|
||||
"Save changes?" ),
|
||||
[&]() -> bool {
|
||||
return SaveFootprint( GetBoard()->GetFirstModule() );
|
||||
} ) )
|
||||
|
|
|
@ -104,8 +104,8 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
|
|||
{
|
||||
wxSafeYield( this, true ); // Allow frame to come to front before showing warning.
|
||||
|
||||
if( !HandleUnsavedChanges( this,
|
||||
_( "The current footprint has been modified. Save changes?" ),
|
||||
if( !HandleUnsavedChanges( this, _( "The current footprint has been modified. "
|
||||
"Save changes?" ),
|
||||
[&]() -> bool { return SaveFootprint( GetBoard()->Modules().front() ); } ) )
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -463,9 +463,10 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|||
{
|
||||
if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
|
||||
{
|
||||
wxString msg = _( "Save changes to\n\"%s\"\nbefore closing?" );
|
||||
wxFileName fileName = GetBoard()->GetFileName();
|
||||
wxString msg = _( "Save changes to \"%s\" before closing?" );
|
||||
|
||||
if( !HandleUnsavedChanges( this, wxString::Format( msg, GetBoard()->GetFileName() ),
|
||||
if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
|
||||
[&]()->bool { return Files_io_from_id( ID_SAVE_BOARD ); } ) )
|
||||
{
|
||||
Event.Veto();
|
||||
|
|
Loading…
Reference in New Issue