fix(frontend): Close webview when mainwindow focused out.
Description: 主界面失焦消失时关闭网页搜索详情页 Log: 主界面失焦消失时关闭网页搜索详情页
This commit is contained in:
parent
5cf3423052
commit
812daf056d
|
@ -719,3 +719,11 @@ void ContentWidget::setQuicklyOpenList(const QStringList & list)
|
||||||
{
|
{
|
||||||
m_quicklyOpenList = list;
|
m_quicklyOpenList = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ContentWidget::closeWebView 在主界面失焦消失的时候调用,(若webview未关闭)关闭网页搜索界面
|
||||||
|
*/
|
||||||
|
void ContentWidget::closeWebView()
|
||||||
|
{
|
||||||
|
m_detailView->closeWebWidget();
|
||||||
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
void setContentList(const QStringList&);
|
void setContentList(const QStringList&);
|
||||||
void setKeyword(QString);
|
void setKeyword(QString);
|
||||||
void setQuicklyOpenList(const QStringList &);
|
void setQuicklyOpenList(const QStringList &);
|
||||||
|
void closeWebView();
|
||||||
private:
|
private:
|
||||||
void initUI();
|
void initUI();
|
||||||
void initListView();
|
void initListView();
|
||||||
|
|
|
@ -77,10 +77,7 @@ void SearchDetailView::clearLayout() {
|
||||||
m_hLine_2->hide();
|
m_hLine_2->hide();
|
||||||
m_optionView->hide();
|
m_optionView->hide();
|
||||||
m_isEmpty = true;
|
m_isEmpty = true;
|
||||||
if (m_webView) {
|
closeWebWidget();
|
||||||
m_webView->close();
|
|
||||||
m_webView = NULL;
|
|
||||||
}
|
|
||||||
// m_reload = false;
|
// m_reload = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,8 +135,7 @@ void SearchDetailView::setWebWidget(const QString& keyword)
|
||||||
});
|
});
|
||||||
connect(m_webView, &QWebEngineView::urlChanged, this, [ = ](const QUrl& url) {
|
connect(m_webView, &QWebEngineView::urlChanged, this, [ = ](const QUrl& url) {
|
||||||
if (m_reload) {
|
if (m_reload) {
|
||||||
m_webView->close();
|
closeWebWidget();
|
||||||
m_webView = NULL;
|
|
||||||
QDesktopServices::openUrl(url);
|
QDesktopServices::openUrl(url);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -164,6 +160,14 @@ void SearchDetailView::setWebWidget(const QString& keyword)
|
||||||
m_webView->show();
|
m_webView->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchDetailView::closeWebWidget()
|
||||||
|
{
|
||||||
|
if (m_webView) {
|
||||||
|
m_webView->close();
|
||||||
|
m_webView = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString SearchDetailView::getHtmlText(const QString & text, const QString & keyword) {
|
QString SearchDetailView::getHtmlText(const QString & text, const QString & keyword) {
|
||||||
QString htmlString;
|
QString htmlString;
|
||||||
bool boldOpenned = false;
|
bool boldOpenned = false;
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
int getType();
|
int getType();
|
||||||
bool isContent = false;
|
bool isContent = false;
|
||||||
void setWebWidget(const QString&);
|
void setWebWidget(const QString&);
|
||||||
|
void closeWebWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
|
|
|
@ -382,6 +382,7 @@ bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *r
|
||||||
switch (event->response_type & ~0x80) {
|
switch (event->response_type & ~0x80) {
|
||||||
case XCB_FOCUS_OUT:
|
case XCB_FOCUS_OUT:
|
||||||
this->hide();
|
this->hide();
|
||||||
|
m_contentFrame->closeWebView();
|
||||||
m_search_result_thread->requestInterruption();
|
m_search_result_thread->requestInterruption();
|
||||||
m_search_result_thread->quit();
|
m_search_result_thread->quit();
|
||||||
break;
|
break;
|
||||||
|
@ -394,6 +395,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if (event->key() == Qt::Key_Escape) {
|
if (event->key() == Qt::Key_Escape) {
|
||||||
this->hide();
|
this->hide();
|
||||||
|
m_contentFrame->closeWebView();
|
||||||
m_search_result_thread->requestInterruption();
|
m_search_result_thread->requestInterruption();
|
||||||
m_search_result_thread->quit();
|
m_search_result_thread->quit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue