From 5c9beab96cb55e642daa3f08fa3f496bf16e44d0 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Tue, 5 Sep 2023 00:06:03 +0800 Subject: [PATCH] fix: search in the current page does not clear found dictionary panel (#1123) * fix: search in the current page does not clear found dictionary panel * [autofix.ci] apply automated fixes --------- Co-authored-by: YiFang Xiao Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- src/ui/articleview.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ui/articleview.cc b/src/ui/articleview.cc index 36bebf1f..ebc3804a 100644 --- a/src/ui/articleview.cc +++ b/src/ui/articleview.cc @@ -379,6 +379,8 @@ void ArticleView::showDefinition( QString const & word, if ( currentWord.isEmpty() ) return; historyMode = false; + //clear founded dicts. + currentActiveDictIds.clear(); // first, let's stop the player audioPlayer->stop(); @@ -2205,7 +2207,11 @@ void ArticleView::highlightFTSResults() void ArticleView::setActiveDictIds( const ActiveDictIds & ad ) { - if ( ( ad.word == currentWord && ad.groupId == getCurrentGroup() ) || historyMode ) { + auto groupId = ad.groupId; + if ( groupId == 0 ) { + groupId = Instances::Group::AllGroupId; + } + if ( ( ad.word == currentWord && groupId == getCurrentGroup() ) || historyMode ) { // ignore all other signals. qDebug() << "receive dicts, current word:" << currentWord << ad.word << ":" << ad.dictIds; currentActiveDictIds << ad.dictIds; @@ -2216,8 +2222,12 @@ void ArticleView::setActiveDictIds( const ActiveDictIds & ad ) void ArticleView::dictionaryClear( const ActiveDictIds & ad ) { + auto groupId = ad.groupId; + if ( groupId == 0 ) { + groupId = Instances::Group::AllGroupId; + } // ignore all other signals. - if ( ad.word == currentWord && ad.groupId == getCurrentGroup() ) { + if ( ad.word == currentWord && groupId == getCurrentGroup() ) { qDebug() << "clear current dictionaries:" << currentWord; currentActiveDictIds.clear(); }