2022-05-18 14:31:47 +00:00
|
|
|
#include "articlewebpage.h"
|
2022-06-08 00:19:23 +00:00
|
|
|
#include "utils.hh"
|
2023-03-25 12:10:28 +00:00
|
|
|
#include "globalbroadcaster.h"
|
2022-05-18 14:31:47 +00:00
|
|
|
|
2023-03-25 12:10:28 +00:00
|
|
|
ArticleWebPage::ArticleWebPage( QObject * parent ):
|
|
|
|
QWebEnginePage{ GlobalBroadcaster::instance()->profile, parent }
|
2022-05-18 14:31:47 +00:00
|
|
|
{
|
|
|
|
}
|
2022-06-08 00:19:23 +00:00
|
|
|
bool ArticleWebPage::acceptNavigationRequest( const QUrl & resUrl, NavigationType type, bool isMainFrame )
|
2022-05-18 14:31:47 +00:00
|
|
|
{
|
2022-06-08 00:19:23 +00:00
|
|
|
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" );
|
|
|
|
}
|
|
|
|
|
2022-05-18 14:31:47 +00:00
|
|
|
if( type == QWebEnginePage::NavigationTypeLinkClicked )
|
|
|
|
{
|
|
|
|
emit linkClicked( url );
|
2022-07-10 06:27:50 +00:00
|
|
|
return false;
|
2022-05-18 14:31:47 +00:00
|
|
|
}
|
2022-06-08 00:19:23 +00:00
|
|
|
|
2022-05-18 14:31:47 +00:00
|
|
|
return QWebEnginePage::acceptNavigationRequest( url, type, isMainFrame );
|
|
|
|
}
|