mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-19 12:14:06 +00:00
b5349478cf
The next commit will add `.git-blame-ignore-revs` https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view
36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
#include "articlewebpage.hh"
|
|
#include "utils.hh"
|
|
|
|
ArticleWebPage::ArticleWebPage( QObject * parent ):
|
|
QWebEnginePage{ parent }
|
|
{
|
|
}
|
|
bool ArticleWebPage::acceptNavigationRequest( const QUrl & resUrl, NavigationType type, bool isMainFrame )
|
|
{
|
|
QUrl url = resUrl;
|
|
if ( url.scheme() == "bword" || url.scheme() == "entry" ) {
|
|
url.setScheme( "gdlookup" );
|
|
url.setHost( "localhost" );
|
|
url.setPath( "" );
|
|
auto [ valid, word ] = Utils::Url::getQueryWord( resUrl );
|
|
Utils::Url::addQueryItem( url, "word", word );
|
|
Utils::Url::addQueryItem( url, "group", lastReq.group );
|
|
Utils::Url::addQueryItem( url, "muted", lastReq.mutedDicts );
|
|
setUrl( url );
|
|
return false;
|
|
}
|
|
|
|
//save current gdlookup's values.
|
|
if ( url.scheme() == "gdlookup" ) {
|
|
lastReq.group = Utils::Url::queryItemValue( url, "group" );
|
|
lastReq.mutedDicts = Utils::Url::queryItemValue( url, "muted" );
|
|
}
|
|
|
|
if ( type == QWebEnginePage::NavigationTypeLinkClicked ) {
|
|
emit linkClicked( url );
|
|
return false;
|
|
}
|
|
|
|
return QWebEnginePage::acceptNavigationRequest( url, type, isMainFrame );
|
|
}
|