fix: when history forward/back ,the founded dictionary does not change

fixed #184
This commit is contained in:
Xiao YiFang 2022-11-04 21:23:42 +08:00
parent c8f445f165
commit 208cd50979
3 changed files with 11 additions and 6 deletions

View file

@ -429,9 +429,10 @@ ArticleRequest::ArticleRequest(
data.resize( header.size() );
memcpy( &data.front(), header.data(), header.size() );
// Accumulate main forms
//clear founded dicts.
emit GlobalBroadcaster::instance()->dictionaryClear( ActiveDictIds{word} );
// Accumulate main forms
for( unsigned x = 0; x < activeDicts.size(); ++x )
{
sptr< Dictionary::WordSearchRequest > s = activeDicts[ x ]->findHeadwordsForSynonym( gd::toWString( word ) );

View file

@ -401,6 +401,7 @@ void ArticleView::showDefinition( Config::InputPhrase const & phrase, unsigned g
Contexts const & contexts_ )
{
currentWord = phrase.phrase.trimmed();
historyMode = false;
currentActiveDictIds.clear();
// first, let's stop the player
audioPlayer->stop();
@ -484,6 +485,7 @@ void ArticleView::showDefinition( QString const & word, QStringList const & dict
if( dictIDs.isEmpty() )
return;
currentWord = word.trimmed();
historyMode = false;
// first, let's stop the player
audioPlayer->stop();
@ -1623,6 +1625,8 @@ void ArticleView::back()
if ( canGoBack() )
{
saveHistoryUserData();
currentActiveDictIds.clear();
historyMode = true;
ui.definition->back();
}
}
@ -1630,6 +1634,8 @@ void ArticleView::back()
void ArticleView::forward()
{
saveHistoryUserData();
currentActiveDictIds.clear();
historyMode = true;
ui.definition->forward();
}
@ -2619,7 +2625,7 @@ void ArticleView::highlightAllFtsOccurences( QWebEnginePage::FindFlags flags )
}
void ArticleView::setActiveDictIds(ActiveDictIds ad) {
if (ad.word == currentWord) {
if (ad.word == currentWord || historyMode) {
// ignore all other signals.
qDebug() << "receive dicts, current word:" << currentWord << ad.word << ":" << ad.dictIds;
currentActiveDictIds << ad.dictIds;
@ -2712,10 +2718,6 @@ void ArticleView::performFtsFindOperation( bool backwards )
#endif
ui.ftsSearchStatusLabel->setText( searchStatusMessage( ftsPosition + 1, allMatches.size() ) );
// Store new highlighted selection
// ui.definition->page()->
// runJavaScript( QString( "%1=window.getSelection().getRangeAt(0);_=0;" )
// .arg( rangeVarName ) );
}
void ArticleView::on_ftsSearchPrevious_clicked()

View file

@ -70,6 +70,8 @@ class ArticleView: public QFrame
/// current active dict id list;
QStringList currentActiveDictIds;
bool historyMode=false;
//current active dictionary id;
QString activeDictId;