Feat:Clear cache after web searching.

This commit is contained in:
zhangjiaping 2021-03-13 15:51:03 +08:00
parent 8d54f02e09
commit 47f67ffdd0
2 changed files with 5 additions and 2 deletions

View File

@ -129,6 +129,7 @@ void SearchDetailView::setWebWidget(const QString& keyword)
}
} else {
m_webView = new QWebEngineView(this);
m_engineProfile = m_webView->page()->profile();
m_webView->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
m_webView->setAttribute(Qt::WA_DeleteOnClose);
m_webView->move(0, 0);
@ -136,11 +137,12 @@ void SearchDetailView::setWebWidget(const QString& keyword)
connect(m_webView,&QWebEngineView::loadFinished, this, [ = ](){
m_reload = true;
if (m_engineProfile) m_engineProfile->clearHttpCache();
});
connect(m_webView, &QWebEngineView::urlChanged, this, [ = ](const QUrl& url) {
if (m_reload) {
closeWebWidget();
QDesktopServices::openUrl(url);
closeWebWidget();
}
});
}

View File

@ -24,7 +24,7 @@
#include <QWidget>
#include <QWebEngineView>
#include <QWebEngineSettings>
//#include <QWebEngineProfile>
#include <QWebEngineProfile>
//#include <QWebEngineUrlRequestInterceptor>
#include <QDesktopServices>
#include "option-view.h"
@ -91,6 +91,7 @@ private:
OptionView * m_optionView = nullptr;
QWebEngineView * m_webView = nullptr;
QWebEngineProfile * m_engineProfile = nullptr;
bool m_reload = false;
QString m_currentKeyword;