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){
|
void ArticleNetworkAccessManager:: requestStart(QUrl& url){
|
||||||
QNetworkRequest request;
|
// QNetworkRequest request;
|
||||||
request.setUrl( url );
|
// request.setUrl( url );
|
||||||
QNetworkReply* reply = createRequest(QNetworkAccessManager::GetOperation,request,NULL);
|
// QNetworkReply* reply = createRequest(QNetworkAccessManager::GetOperation,request,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
|
sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
|
||||||
|
@ -542,19 +542,26 @@ void BlockedNetworkReply::finishedSlot()
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
MySchemeHandler::MySchemeHandler(){
|
MySchemeHandler::MySchemeHandler(ArticleNetworkAccessManager& articleNetMgr):mManager(articleNetMgr){
|
||||||
|
|
||||||
}
|
}
|
||||||
void MySchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
|
void MySchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob)
|
||||||
{
|
{
|
||||||
QUrl url = requestJob->requestUrl();
|
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);
|
||||||
// requestJob->reply("text/html", reply);
|
connect(reply,&QNetworkReply::finished,[=](){
|
||||||
|
//QNetworkReply *reply1=qobject_cast<QNetworkReply*>(sender());
|
||||||
|
requestJob->reply("text/html",reply);
|
||||||
|
});
|
||||||
|
|
||||||
emit requestStart(url);
|
// // Reply segment
|
||||||
|
// requestJob->reply("text/html", reply);
|
||||||
|
|
||||||
|
// emit requestStart(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,12 +211,15 @@ class MySchemeHandler : public QWebEngineUrlSchemeHandler
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MySchemeHandler();
|
MySchemeHandler(ArticleNetworkAccessManager &articleNetMgr);
|
||||||
void requestStarted(QWebEngineUrlRequestJob *requestJob);
|
void requestStarted(QWebEngineUrlRequestJob *requestJob);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void requestStart(QUrl& url);
|
void requestStart(QUrl& url);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ArticleNetworkAccessManager& mManager;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -146,7 +146,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
MySchemeHandler *handler = new MySchemeHandler();
|
MySchemeHandler *handler = new MySchemeHandler(articleNetMgr);
|
||||||
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("gdlookup", handler);
|
QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("gdlookup", handler);
|
||||||
|
|
||||||
QStringList localSchemes={"gdau","gico","qrcx","bres"};
|
QStringList localSchemes={"gdau","gico","qrcx","bres"};
|
||||||
|
@ -1302,7 +1302,8 @@ void MainWindow::applyWebSettings()
|
||||||
QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings();
|
QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings();
|
||||||
defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins);
|
defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins);
|
||||||
defaultSettings->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, false);
|
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 )
|
void MainWindow::setupNetworkCache( int maxSize )
|
||||||
|
|
Loading…
Reference in a new issue