From dbbe9cdee4c45163e0888dc786a59efff5e7d1c1 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 16 Feb 2021 15:42:39 -0800 Subject: [PATCH] Hide infobar for save when saving --- common/widgets/infobar.cpp | 25 ++++++++++++++++++++++++- eeschema/files-io.cpp | 6 ++++-- include/widgets/infobar.h | 26 ++++++++++++++++++++++++++ pcbnew/files.cpp | 4 +++- 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/common/widgets/infobar.cpp b/common/widgets/infobar.cpp index 383da3b2f9..d529471993 100644 --- a/common/widgets/infobar.cpp +++ b/common/widgets/infobar.cpp @@ -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 diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 4beda24d58..2ee92ef669 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -489,7 +489,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& 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& 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; } diff --git a/include/widgets/infobar.h b/include/widgets/infobar.h index 435236ca43..ba3265fe89 100644 --- a/include/widgets/infobar.h +++ b/include/widgets/infobar.h @@ -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> m_callback; ///< Optional callback made when closing infobar diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 991fe95376..fdf737ee1d 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -759,7 +759,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& 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();