Save and re-load query string in Choose Symbol dialog.

While this has been requested on its own, it's primarily done here
because wxWidgets decided to send a SEARCH_CANCEL from a wxSearchCtrl
when hitting <ENTER> if the search control holes the empty string.
This causes us to not do a symbol instert in the Chooser dialog.

Fixes https://gitlab.com/kicad/code/kicad/issues/10169

Fixes https://gitlab.com/kicad/code/kicad/issues/7699
This commit is contained in:
Jeff Young 2022-04-16 23:55:19 +01:00
parent 9ff1ae5bdc
commit 7f4f5f2882
4 changed files with 30 additions and 4 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org> * Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2014-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -207,6 +207,18 @@ void LIB_TREE::ExpandLibId( const LIB_ID& aLibId )
} }
void LIB_TREE::SetSearchString( const wxString& aSearchString )
{
m_query_ctrl->SetValue( aSearchString );
}
wxString LIB_TREE::GetSearchString() const
{
return m_query_ctrl->GetValue();
}
void LIB_TREE::Regenerate( bool aKeepState ) void LIB_TREE::Regenerate( bool aKeepState )
{ {
STATE current; STATE current;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org> * Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -47,6 +47,8 @@
std::mutex DIALOG_CHOOSE_SYMBOL::g_Mutex; std::mutex DIALOG_CHOOSE_SYMBOL::g_Mutex;
wxString DIALOG_CHOOSE_SYMBOL::g_searchString;
DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL( SCH_BASE_FRAME* aParent, const wxString& aTitle, DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL( SCH_BASE_FRAME* aParent, const wxString& aTitle,
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& aAdapter, wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& aAdapter,
@ -130,6 +132,8 @@ DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL( SCH_BASE_FRAME* aParent, const wxStr
aAdapter->FinishTreeInitialization(); aAdapter->FinishTreeInitialization();
m_tree->SetSearchString( g_searchString );
m_hsplitter->SetSashGravity( 0.8 ); m_hsplitter->SetSashGravity( 0.8 );
m_hsplitter->SetMinimumPaneSize( 20 ); m_hsplitter->SetMinimumPaneSize( 20 );
m_hsplitter->SplitVertically( treePanel, ConstructRightPanel( m_hsplitter ) ); m_hsplitter->SplitVertically( treePanel, ConstructRightPanel( m_hsplitter ) );
@ -235,6 +239,8 @@ DIALOG_CHOOSE_SYMBOL::~DIALOG_CHOOSE_SYMBOL()
m_dbl_click_timer->Stop(); m_dbl_click_timer->Stop();
delete m_dbl_click_timer; delete m_dbl_click_timer;
g_searchString = m_tree->GetSearchString();
if( m_browser_button ) if( m_browser_button )
{ {
m_browser_button->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, m_browser_button->Unbind( wxEVT_COMMAND_BUTTON_CLICKED,

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org> * Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2014-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -203,6 +203,8 @@ public:
static std::mutex g_Mutex; static std::mutex g_Mutex;
protected: protected:
static wxString g_searchString;
wxTimer* m_dbl_click_timer; wxTimer* m_dbl_click_timer;
SYMBOL_PREVIEW_WIDGET* m_symbol_preview; SYMBOL_PREVIEW_WIDGET* m_symbol_preview;
wxButton* m_browser_button; wxButton* m_browser_button;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014 Henner Zeller <h.zeller@acm.org> * Copyright (C) 2014 Henner Zeller <h.zeller@acm.org>
* Copyright (C) 2014-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2014-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -97,6 +97,12 @@ public:
*/ */
void ExpandLibId( const LIB_ID& aLibId ); void ExpandLibId( const LIB_ID& aLibId );
/**
* Save/restore search string.
*/
void SetSearchString( const wxString& aSearchString );
wxString GetSearchString() const;
/** /**
* Regenerate the tree. * Regenerate the tree.
*/ */