Hide infobar for save when saving

This commit is contained in:
Seth Hillbrand 2021-02-16 15:42:39 -08:00
parent f9c7eae63a
commit dbbe9cdee4
4 changed files with 57 additions and 4 deletions

View File

@ -47,7 +47,8 @@ WX_INFOBAR::WX_INFOBAR( wxWindow* aParent, wxAuiManager* aMgr, wxWindowID aWinid
m_showTime( 0 ),
m_updateLock( false ),
m_showTimer( nullptr ),
m_auiManager( aMgr )
m_auiManager( aMgr ),
m_type( MESSAGE_TYPE::GENERIC )
{
m_showTimer = new wxTimer( this, ID_CLOSE_INFOBAR );
@ -136,10 +137,32 @@ void WX_INFOBAR::ShowMessage( const wxString& aMessage, int aFlags )
if( m_showTime > 0 )
m_showTimer->StartOnce( m_showTime );
m_type = MESSAGE_TYPE::GENERIC;
m_updateLock = false;
}
void WX_INFOBAR::ShowMessage( const wxString& aMessage, int aFlags, MESSAGE_TYPE aType )
{
// Don't do anything if we requested the UI update
if( m_updateLock )
return;
ShowMessage( aMessage, aFlags );
m_type = aType;
}
void WX_INFOBAR::DismissOutdatedSave()
{
if( m_updateLock || m_type != MESSAGE_TYPE::OUTDATED_SAVE )
return;
Dismiss();
}
void WX_INFOBAR::Dismiss()
{
// Don't do anything if we requested the UI update

View File

@ -489,7 +489,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
m_infoBar->AddCloseButton();
m_infoBar->ShowMessage( _( "This file was created by an older version of KiCad. "
"It will be converted to the new format when saved." ),
wxICON_WARNING );
wxICON_WARNING, WX_INFOBAR::MESSAGE_TYPE::OUTDATED_SAVE );
// Legacy schematic can have duplicate time stamps so fix that before converting
// to the s-expression format.
@ -506,7 +506,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
m_infoBar->AddCloseButton();
m_infoBar->ShowMessage( _( "This file was created by an older version of KiCad. "
"It will be converted to the new format when saved." ),
wxICON_WARNING );
wxICON_WARNING, WX_INFOBAR::MESSAGE_TYPE::OUTDATED_SAVE );
}
for( SCH_SCREEN* screen = schematic.GetFirst(); screen; screen = schematic.GetNext() )
@ -839,6 +839,8 @@ bool SCH_EDIT_FRAME::SaveProject()
UpdateTitle();
m_infoBar->DismissOutdatedSave();
return success;
}

View File

@ -82,6 +82,16 @@ public:
~WX_INFOBAR();
/**
* Sets the type of message for special handling if needed
*/
enum class MESSAGE_TYPE
{
GENERIC, /**< GENERIC Are messages that do not have special handling */
OUTDATED_SAVE/**< OUTDATED_SAVE Messages that should be cleared on save */
};
/**
* Set the time period to show the infobar.
*
@ -160,12 +170,27 @@ public:
*/
void ShowMessage( const wxString& aMessage, int aFlags = wxICON_INFORMATION ) override;
/**
* Show the info bar with the provided message and icon, setting the type
*
* @param aMessage is the message to display
* @param aFlags is the flag containing the icon to display on the left side of the infobar
* @param aType is the type of message being displayed
*/
void ShowMessage( const wxString& aMessage, int aFlags, MESSAGE_TYPE aType );
/**
* Dismisses the infobar and updates the containing layout and AUI manager
* (if one is provided).
*/
void Dismiss() override;
/**
* Dismisses the infobar for outdated save warnings and updates the containing
* layout and AUI manager (if one is provided).
*/
void DismissOutdatedSave();
/**
* Send the infobar an event telling it to show a message.
*
@ -226,6 +251,7 @@ protected:
bool m_updateLock; ///< True if this infobar requested the UI update
wxTimer* m_showTimer; ///< The timer counting the autoclose period
wxAuiManager* m_auiManager; ///< The AUI manager that contains this infobar
MESSAGE_TYPE m_type; ///< The type of message being displayed
OPT<std::function<void(void)>> m_callback; ///< Optional callback made when closing infobar

View File

@ -759,7 +759,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
m_infoBar->AddCloseButton();
m_infoBar->ShowMessage( _( "This file was created by an older version of KiCad. "
"It will be converted to the new format when saved." ),
wxICON_WARNING );
wxICON_WARNING, WX_INFOBAR::MESSAGE_TYPE::OUTDATED_SAVE );
}
// Import footprints into a project-specific library
@ -1040,6 +1040,8 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory,
SetStatusText( lowerTxt, 0 );
// Get rid of the old version conversion warning, or any other dismissable warning :)
m_infoBar->DismissOutdatedSave();
if( m_infoBar->IsShown() && m_infoBar->HasCloseButton() )
m_infoBar->Dismiss();