mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
fix:loaded url twice
This commit is contained in:
parent
bf2640bb25
commit
a23409c875
|
@ -288,9 +288,9 @@ QNetworkReply * ArticleNetworkAccessManager::createRequest( Operation op,
|
|||
}
|
||||
|
||||
void ArticleNetworkAccessManager:: requestStart(QUrl& url){
|
||||
QNetworkRequest request;
|
||||
request.setUrl( url );
|
||||
QNetworkReply* reply = createRequest(QNetworkAccessManager::GetOperation,request,NULL);
|
||||
// QNetworkRequest request;
|
||||
// request.setUrl( url );
|
||||
// QNetworkReply* reply = createRequest(QNetworkAccessManager::GetOperation,request,NULL);
|
||||
}
|
||||
|
||||
sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
|
||||
|
@ -542,19 +542,26 @@ void BlockedNetworkReply::finishedSlot()
|
|||
emit finished();
|
||||
}
|
||||
|
||||
MySchemeHandler::MySchemeHandler(){
|
||||
MySchemeHandler::MySchemeHandler(ArticleNetworkAccessManager& articleNetMgr):mManager(articleNetMgr){
|
||||
|
||||
}
|
||||
void MySchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
|
||||
{
|
||||
QUrl url = requestJob->requestUrl();
|
||||
|
||||
// QNetworkRequest* request = new QNetworkRequest(url);
|
||||
|
||||
QNetworkRequest request;
|
||||
request.setUrl( url );
|
||||
|
||||
// Reply segment
|
||||
QNetworkReply* reply=this->mManager.createRequest(QNetworkAccessManager::GetOperation,request,NULL);
|
||||
connect(reply,&QNetworkReply::finished,[=](){
|
||||
//QNetworkReply *reply1=qobject_cast<QNetworkReply*>(sender());
|
||||
requestJob->reply("text/html",reply);
|
||||
});
|
||||
|
||||
// // Reply segment
|
||||
// requestJob->reply("text/html", reply);
|
||||
|
||||
emit requestStart(url);
|
||||
// emit requestStart(url);
|
||||
}
|
||||
|
||||
|
|
|
@ -211,12 +211,15 @@ class MySchemeHandler : public QWebEngineUrlSchemeHandler
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MySchemeHandler();
|
||||
MySchemeHandler(ArticleNetworkAccessManager &articleNetMgr);
|
||||
void requestStarted(QWebEngineUrlRequestJob *requestJob);
|
||||
|
||||
protected:
|
||||
|
||||
signals:
|
||||
void requestStart(QUrl& url);
|
||||
|
||||
private:
|
||||
ArticleNetworkAccessManager& mManager;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -146,7 +146,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
#endif
|
||||
|
||||
|
||||
MySchemeHandler *handler = new MySchemeHandler();
|
||||
MySchemeHandler *handler = new MySchemeHandler(articleNetMgr);
|
||||
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("gdlookup", handler);
|
||||
|
||||
QStringList localSchemes={"gdau","gico","qrcx","bres"};
|
||||
|
@ -1302,7 +1302,8 @@ void MainWindow::applyWebSettings()
|
|||
QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings();
|
||||
defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins);
|
||||
defaultSettings->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, false);
|
||||
//defaultSettings->setAttribute( QWebEngineSettings::DeveloperExtrasEnabled, true );
|
||||
defaultSettings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true );
|
||||
defaultSettings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true );
|
||||
}
|
||||
|
||||
void MainWindow::setupNetworkCache( int maxSize )
|
||||
|
|
Loading…
Reference in a new issue