Add a KICAD_TEST_NOTI env var for a fake notification on launch

This commit is contained in:
Marek Roszko 2023-08-06 14:00:55 -04:00
parent 5cbe3c5d42
commit a0ebedc0ac
3 changed files with 14 additions and 13 deletions

View File

@ -120,19 +120,11 @@ public:
m_hlDismiss->Bind( wxEVT_HYPERLINK, &NOTIFICATION_PANEL::onDismiss, this ); m_hlDismiss->Bind( wxEVT_HYPERLINK, &NOTIFICATION_PANEL::onDismiss, this );
Bind( wxEVT_SET_FOCUS, &NOTIFICATION_PANEL::onFocusSet, this );
SetSizer( mainSizer ); SetSizer( mainSizer );
Layout(); Layout();
} }
private: private:
void onFocusSet( wxFocusEvent& aEvent )
{
// hmmph
}
void onDetails( wxHyperlinkEvent& aEvent ) void onDetails( wxHyperlinkEvent& aEvent )
{ {
wxString url = aEvent.GetURL(); wxString url = aEvent.GetURL();
@ -287,6 +279,12 @@ void NOTIFICATIONS_MANAGER::Load()
// failed to load the json // failed to load the json
return; return;
} }
if( wxGetEnv( wxT( "KICAD_TEST_NOTI" ), nullptr ) )
{
CreateOrUpdate( wxS( "test" ), wxS( "Test Notification" ), wxS( "Test please ignore" ),
wxS( "https://kicad.org" ) );
}
} }
@ -301,11 +299,13 @@ void NOTIFICATIONS_MANAGER::Save()
} }
void NOTIFICATIONS_MANAGER::Create( const wxString& aKey, void NOTIFICATIONS_MANAGER::CreateOrUpdate( const wxString& aKey,
const wxString& aTitle, const wxString& aTitle,
const wxString& aDescription, const wxString& aDescription,
const wxString& aHref ) const wxString& aHref )
{ {
wxCHECK_RET( !aKey.IsEmpty(), wxS( "Notification key must not be empty" ) );
auto it = std::find_if( m_notifications.begin(), m_notifications.end(), auto it = std::find_if( m_notifications.begin(), m_notifications.end(),
[&]( const NOTIFICATION& noti ) [&]( const NOTIFICATION& noti )
{ {

View File

@ -55,14 +55,15 @@ public:
NOTIFICATIONS_MANAGER(); NOTIFICATIONS_MANAGER();
/** /**
* Creates a notification with the given parameters * Creates a notification with the given parameters or updates an existing one with the same key
* @param aKey is a unique key for the notification, this allows removing *
* @param aKey is a unique key for the notification, this allows removing or updating the same notification
* @param aTitle is the displayed title for the event * @param aTitle is the displayed title for the event
* @param aDescription is the text that displays underneath the title and has slightly more info * @param aDescription is the text that displays underneath the title and has slightly more info
* them later programtically in case a notificaiton is no logner required * them later programtically in case a notificaiton is no logner required
* @param aHref is link to external or internal content * @param aHref is link to external or internal content
*/ */
void Create( const wxString& aKey, const wxString& aTitle, const wxString& aDescription, void CreateOrUpdate( const wxString& aKey, const wxString& aTitle, const wxString& aDescription,
const wxString& aHref = wxEmptyString ); const wxString& aHref = wxEmptyString );
/** /**

View File

@ -289,7 +289,7 @@ void KICAD_MANAGER_FRAME::CreatePCM()
if( aUpdateCount > 0 ) if( aUpdateCount > 0 )
{ {
Pgm().GetNotificationsManager().Create( Pgm().GetNotificationsManager().CreateOrUpdate(
wxS( "pcm" ), wxS( "pcm" ),
_( "PCM Updates Available" ), _( "PCM Updates Available" ),
wxString::Format( _( "%d package update(s) avaliable" ), aUpdateCount ), wxString::Format( _( "%d package update(s) avaliable" ), aUpdateCount ),