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 <yifang.xiao@noreply.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
xiaoyifang 2023-09-05 00:06:03 +08:00 committed by GitHub
parent b1ea47be26
commit 5c9beab96c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -379,6 +379,8 @@ void ArticleView::showDefinition( QString const & word,
if ( currentWord.isEmpty() ) if ( currentWord.isEmpty() )
return; return;
historyMode = false; historyMode = false;
//clear founded dicts.
currentActiveDictIds.clear();
// first, let's stop the player // first, let's stop the player
audioPlayer->stop(); audioPlayer->stop();
@ -2205,7 +2207,11 @@ void ArticleView::highlightFTSResults()
void ArticleView::setActiveDictIds( const ActiveDictIds & ad ) 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. // ignore all other signals.
qDebug() << "receive dicts, current word:" << currentWord << ad.word << ":" << ad.dictIds; qDebug() << "receive dicts, current word:" << currentWord << ad.word << ":" << ad.dictIds;
currentActiveDictIds << ad.dictIds; currentActiveDictIds << ad.dictIds;
@ -2216,8 +2222,12 @@ void ArticleView::setActiveDictIds( const ActiveDictIds & ad )
void ArticleView::dictionaryClear( const ActiveDictIds & ad ) void ArticleView::dictionaryClear( const ActiveDictIds & ad )
{ {
auto groupId = ad.groupId;
if ( groupId == 0 ) {
groupId = Instances::Group::AllGroupId;
}
// ignore all other signals. // ignore all other signals.
if ( ad.word == currentWord && ad.groupId == getCurrentGroup() ) { if ( ad.word == currentWord && groupId == getCurrentGroup() ) {
qDebug() << "clear current dictionaries:" << currentWord; qDebug() << "clear current dictionaries:" << currentWord;
currentActiveDictIds.clear(); currentActiveDictIds.clear();
} }