From 74a21e7e264659d72a94bc87585dc3cd7dca575e Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Sat, 2 Sep 2023 11:33:53 +0800 Subject: [PATCH] fix: epwing dictionary reference navigation restrict to certain dictionary --- src/dict/epwing_book.cc | 3 ++- src/ui/articleview.cc | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/dict/epwing_book.cc b/src/dict/epwing_book.cc index 46b12528..fe240385 100644 --- a/src/dict/epwing_book.cc +++ b/src/dict/epwing_book.cc @@ -839,7 +839,7 @@ QString EpwingBook::getPreviousTextWithLength( int page, int offset, int total, if ( buf.length() > TextSizeLimit ) { error_string = "Data too large"; currentPosition.page = 0; - return QString(); + return {}; } } @@ -1373,6 +1373,7 @@ void EpwingBook::finalizeText( QString & text ) url.setHost( "localhost" ); url.setPath( Utils::Url::ensureLeadingSlash( QString( "r%1At%2" ).arg( ebpos.page ).arg( ebpos.offset ) ) ); + url.setQuery( "dictionaries=" + dictID ); QString link = ""; diff --git a/src/ui/articleview.cc b/src/ui/articleview.cc index b291d48d..5f65362e 100644 --- a/src/ui/articleview.cc +++ b/src/ui/articleview.cc @@ -1010,6 +1010,14 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref, QString const & return; } + if ( Utils::Url::hasQueryItem( url, "dictionaries" ) ) { + // Specific dictionary group from full-text search + QStringList dictsList = Utils::Url::queryItemValue( url, "dictionaries" ).split( ",", Qt::SkipEmptyParts ); + + showDefinition( word, dictsList, QRegExp(), getGroup( url ), false ); + return; + } + QString newScrollTo( scrollTo ); if ( Utils::Url::hasQueryItem( url, "dict" ) ) { // Link to other dictionary