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