mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
opt: update dictionaries when disable certain dictionary
This commit is contained in:
parent
8a979aeb86
commit
dd244e0336
|
@ -446,6 +446,8 @@ void ArticleRequest::altSearchFinished()
|
||||||
if ( altsDone )
|
if ( altsDone )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
emit GlobalBroadcaster::instance()->dictionaryClear( ActiveDictIds{word} );
|
||||||
|
|
||||||
// Check every request for finishing
|
// Check every request for finishing
|
||||||
for( list< sptr< Dictionary::WordSearchRequest > >::iterator i =
|
for( list< sptr< Dictionary::WordSearchRequest > >::iterator i =
|
||||||
altSearches.begin(); i != altSearches.end(); )
|
altSearches.begin(); i != altSearches.end(); )
|
||||||
|
|
|
@ -360,6 +360,9 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au
|
||||||
connect(GlobalBroadcaster::instance(), SIGNAL( dictionaryChanges(ActiveDictIds)), this,
|
connect(GlobalBroadcaster::instance(), SIGNAL( dictionaryChanges(ActiveDictIds)), this,
|
||||||
SLOT(setActiveDictIds(ActiveDictIds)));
|
SLOT(setActiveDictIds(ActiveDictIds)));
|
||||||
|
|
||||||
|
connect( GlobalBroadcaster::instance(), &GlobalBroadcaster::dictionaryClear, this,
|
||||||
|
&ArticleView::dictionaryClear );
|
||||||
|
|
||||||
channel = new QWebChannel(ui.definition->page());
|
channel = new QWebChannel(ui.definition->page());
|
||||||
agent = new ArticleViewAgent(this);
|
agent = new ArticleViewAgent(this);
|
||||||
attachWebChannelToHtml();
|
attachWebChannelToHtml();
|
||||||
|
@ -2609,16 +2612,25 @@ void ArticleView::highlightAllFtsOccurences( QWebEnginePage::FindFlags flags )
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArticleView::setActiveDictIds(ActiveDictIds ad) {
|
void ArticleView::setActiveDictIds(ActiveDictIds ad) {
|
||||||
|
if (ad.word == currentWord) {
|
||||||
// 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;
|
||||||
if (ad.word == currentWord) {
|
|
||||||
qDebug() << "receive dicts, current word accept:" << currentWord;
|
|
||||||
currentActiveDictIds << ad.dictIds;
|
currentActiveDictIds << ad.dictIds;
|
||||||
currentActiveDictIds.removeDuplicates();
|
currentActiveDictIds.removeDuplicates();
|
||||||
emit updateFoundInDictsList();
|
emit updateFoundInDictsList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArticleView::dictionaryClear( ActiveDictIds ad )
|
||||||
|
{
|
||||||
|
// ignore all other signals.
|
||||||
|
if( ad.word == currentWord )
|
||||||
|
{
|
||||||
|
qDebug() << "clear current dictionaries:" << currentWord;
|
||||||
|
currentActiveDictIds.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//todo ,futher refinement?
|
//todo ,futher refinement?
|
||||||
void ArticleView::performFtsFindOperation( bool backwards )
|
void ArticleView::performFtsFindOperation( bool backwards )
|
||||||
{
|
{
|
||||||
|
|
|
@ -367,6 +367,8 @@ private slots:
|
||||||
|
|
||||||
void setActiveDictIds(ActiveDictIds);
|
void setActiveDictIds(ActiveDictIds);
|
||||||
|
|
||||||
|
void dictionaryClear( ActiveDictIds ad );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/// Deduces group from the url. If there doesn't seem to be any group,
|
/// Deduces group from the url. If there doesn't seem to be any group,
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dictionaryChanges( ActiveDictIds ad );
|
void dictionaryChanges( ActiveDictIds ad );
|
||||||
|
void dictionaryClear( ActiveDictIds ad );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLOBAL_GLOBALBROADCASTER_H
|
#endif // GLOBAL_GLOBALBROADCASTER_H
|
||||||
|
|
Loading…
Reference in a new issue