From 8a979aeb86e88c7f7cad9cf27ac5e1f1fd7f50d3 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Sat, 16 Jul 2022 16:10:48 +0800 Subject: [PATCH 1/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 07a0665d..2bf0d0fa 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ This code has been run and tested on Windows 10/11, Ubuntu Linux, Mac OS X. qtdeclarative5-dev libxtst-dev liblzo2-dev libbz2-dev \ libao-dev libavutil-dev libavformat-dev libtiff5-dev libeb16-dev \ libqt5svg5-dev libqt5x11extras5-dev qttools5-dev \ - qttools5-dev-tools qtmultimedia5-dev libqt5multimedia5-plugins + qttools5-dev-tools qtmultimedia5-dev libqt5multimedia5-plugins libqt5webchannel5-dev qtwebengine5-dev ### Fedora 35 ``` From dd244e03369610c4168003f3f48cc20339898fb2 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Sun, 17 Jul 2022 06:54:53 +0800 Subject: [PATCH 2/3] opt: update dictionaries when disable certain dictionary --- article_maker.cc | 2 ++ articleview.cc | 18 +++++++++++++++--- articleview.hh | 2 ++ globalbroadcaster.h | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/article_maker.cc b/article_maker.cc index 41f97422..d73ec036 100644 --- a/article_maker.cc +++ b/article_maker.cc @@ -446,6 +446,8 @@ void ArticleRequest::altSearchFinished() if ( altsDone ) return; + emit GlobalBroadcaster::instance()->dictionaryClear( ActiveDictIds{word} ); + // Check every request for finishing for( list< sptr< Dictionary::WordSearchRequest > >::iterator i = altSearches.begin(); i != altSearches.end(); ) diff --git a/articleview.cc b/articleview.cc index 116fac27..887f6e66 100644 --- a/articleview.cc +++ b/articleview.cc @@ -360,6 +360,9 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au connect(GlobalBroadcaster::instance(), SIGNAL( dictionaryChanges(ActiveDictIds)), this, SLOT(setActiveDictIds(ActiveDictIds))); + connect( GlobalBroadcaster::instance(), &GlobalBroadcaster::dictionaryClear, this, + &ArticleView::dictionaryClear ); + channel = new QWebChannel(ui.definition->page()); agent = new ArticleViewAgent(this); attachWebChannelToHtml(); @@ -2609,16 +2612,25 @@ void ArticleView::highlightAllFtsOccurences( QWebEnginePage::FindFlags flags ) } void ArticleView::setActiveDictIds(ActiveDictIds ad) { - // ignore all other signals. - qDebug() << "receive dicts, current word:" << currentWord << ad.word << ":" << ad.dictIds; if (ad.word == currentWord) { - qDebug() << "receive dicts, current word accept:" << currentWord; + // ignore all other signals. + qDebug() << "receive dicts, current word:" << currentWord << ad.word << ":" << ad.dictIds; currentActiveDictIds << ad.dictIds; currentActiveDictIds.removeDuplicates(); 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? void ArticleView::performFtsFindOperation( bool backwards ) { diff --git a/articleview.hh b/articleview.hh index d3efa579..d47dfc05 100644 --- a/articleview.hh +++ b/articleview.hh @@ -367,6 +367,8 @@ private slots: void setActiveDictIds(ActiveDictIds); + void dictionaryClear( ActiveDictIds ad ); + private: /// Deduces group from the url. If there doesn't seem to be any group, diff --git a/globalbroadcaster.h b/globalbroadcaster.h index 6e6992c2..daf627b7 100644 --- a/globalbroadcaster.h +++ b/globalbroadcaster.h @@ -28,6 +28,7 @@ public: signals: void dictionaryChanges( ActiveDictIds ad ); + void dictionaryClear( ActiveDictIds ad ); }; #endif // GLOBAL_GLOBALBROADCASTER_H From 2298fa2a3da8f8a3d3ad494464cc2963d498f5cd Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Sun, 17 Jul 2022 18:22:39 +0800 Subject: [PATCH 3/3] opt:website tag regex expression refine --- iframeschemehandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iframeschemehandler.cpp b/iframeschemehandler.cpp index ba05cee8..b050cd14 100644 --- a/iframeschemehandler.cpp +++ b/iframeschemehandler.cpp @@ -54,7 +54,7 @@ void IframeSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob) // remove existed base tag articleString.remove( baseTag ) ; - QRegularExpression headTag( "", + QRegularExpression headTag( "", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption ); auto match = headTag.match( articleString, 0 );