From 5cf342305237c42afd3de498d998afe9322ba870 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Mon, 22 Feb 2021 20:30:06 +0800 Subject: [PATCH 1/2] feat(frontend): Add web searching & web engine settings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 添加网页搜索功能和引擎设置功能 Log: 添加网页搜索功能和引擎设置功能 --- debian/control | 3 +- libsearch/global-settings.h | 1 + src/content-widget.cpp | 29 +++++++++++- src/content-widget.h | 2 + src/control/search-detail-view.cpp | 75 ++++++++++++++++++++++++------ src/control/search-detail-view.h | 20 +++++++- src/control/search-list-view.cpp | 2 + src/control/search-list-view.h | 3 +- src/model/search-item.h | 3 +- src/settings-widget.cpp | 56 +++++++++++++++++++--- src/settings-widget.h | 2 + src/src.pro | 2 +- translations/ukui-search/bo.ts | 57 ++++++++++++----------- translations/ukui-search/tr.ts | 57 ++++++++++++----------- translations/ukui-search/zh_CN.ts | 57 ++++++++++++----------- 15 files changed, 264 insertions(+), 105 deletions(-) diff --git a/debian/control b/debian/control index e6c099e..21acacd 100644 --- a/debian/control +++ b/debian/control @@ -16,7 +16,8 @@ Build-Depends: debhelper (>=9.0.0), libkf5windowsystem-dev, libgsettings-qt-dev, libqt5x11extras5-dev, - libuchardet-dev + libuchardet-dev, + qtwebengine5-dev Standards-Version: 4.5.0 Homepage: https://www.ukui.org/ Vcs-Git: https://github.com/ukui/ukui-search.git diff --git a/libsearch/global-settings.h b/libsearch/global-settings.h index 772c283..0a8523e 100644 --- a/libsearch/global-settings.h +++ b/libsearch/global-settings.h @@ -38,6 +38,7 @@ #define CONTENT_INDEX_DATABASE_STATE "content_index_database_state" #define INDEX_GENERATOR_NORMAL_EXIT "index_generator_normal_exit" #define INOTIFY_NORMAL_EXIT "inotify_normal_exit" +#define WEB_ENGINE "web_engine" #define PATH_EMPTY 1; #define PATH_NOT_IN_HOME 2; #define PATH_PARENT_BLOCKED 3; diff --git a/src/content-widget.cpp b/src/content-widget.cpp index 74f547b..f21628a 100644 --- a/src/content-widget.cpp +++ b/src/content-widget.cpp @@ -105,12 +105,14 @@ void ContentWidget::initListView() m_settingListView = new SearchListView(m_resultList, QStringList(), SearchItem::SearchType::Settings); m_appListView = new SearchListView(m_resultList, QStringList(), SearchItem::SearchType::Apps); m_bestListView = new SearchListView(m_resultList, QStringList(), SearchItem::SearchType::Best); + m_webListView = new SearchListView(m_resultList, QStringList(), SearchItem::SearchType::Web); setupConnect(m_fileListView); setupConnect(m_dirListView); setupConnect(m_contentListView); setupConnect(m_settingListView); setupConnect(m_appListView); setupConnect(m_bestListView); + setupConnect(m_webListView); m_fileTitleLabel = new TitleLabel(m_resultList); m_fileTitleLabel->setText(getTitleName(SearchItem::SearchType::Files)); @@ -124,6 +126,8 @@ void ContentWidget::initListView() m_settingTitleLabel->setText(getTitleName(SearchItem::SearchType::Settings)); m_bestTitleLabel = new TitleLabel(m_resultList); m_bestTitleLabel->setText(getTitleName(SearchItem::SearchType::Best)); + m_webTitleLabel = new TitleLabel(m_resultList); + m_webTitleLabel->setText(getTitleName(SearchItem::SearchType::Web)); m_appShowMoreLabel = new ShowMoreLabel(m_resultList); m_settingShowMoreLabel = new ShowMoreLabel(m_resultList); @@ -148,6 +152,8 @@ void ContentWidget::initListView() m_listLyt->addWidget(m_contentTitleLabel); m_listLyt->addWidget(m_contentListView); m_listLyt->addWidget(m_contentShowMoreLabel); + m_listLyt->addWidget(m_webTitleLabel); + m_listLyt->addWidget(m_webListView); this->hideListView(); m_resultList->setFixedHeight(0); @@ -226,6 +232,8 @@ void ContentWidget::hideListView() m_contentTitleLabel->hide(); m_contentListView->hide(); m_contentShowMoreLabel->hide(); + m_webTitleLabel->hide(); + m_webListView->hide(); } /** @@ -248,8 +256,11 @@ void ContentWidget::setupConnect(SearchListView * listview) { } else { m_detailView->isContent = false; } - m_detailView->setupWidget(type, path); -// m_detailView->setWebWidget(this->m_keyword); + if (type == SearchItem::SearchType::Web) { + m_detailView->setWebWidget(this->m_keyword); + } else { + m_detailView->setupWidget(type, path); + } listview->is_current_list = true; Q_EMIT this->currentItemChanged(); listview->is_current_list = false; @@ -308,6 +319,10 @@ void ContentWidget::resetListHeight() height += m_contentShowMoreLabel->height(); } } + if (! m_webListView->isHidden) { + height += m_webTitleLabel->height(); + height += m_webListView->height(); + } m_resultList->setFixedHeight(height); } @@ -447,6 +462,13 @@ void ContentWidget::refreshSearchList(const QVector& lists) { m_bestListView->isHidden = true; m_bestListView->clear(); } + if (m_webListView) { + m_webListView->clear(); + m_webListView->appendItem(m_keyword); + m_webTitleLabel->show(); + m_webListView->show(); + m_webListView->isHidden = false; + } m_resultList->setFixedHeight(0); m_detailView->clearLayout(); m_contentDetailList.clear(); @@ -639,6 +661,8 @@ QString ContentWidget::getTitleName(const int& type) { return tr("File Contents"); case SearchItem::SearchType::Best : return tr("Best Matches"); + case SearchItem::SearchType::Web : + return tr("Web Pages"); default : return tr("Unknown"); } @@ -684,6 +708,7 @@ void ContentWidget::setKeyword(QString keyword) m_settingListView->setKeyword(keyword); m_appListView->setKeyword(keyword); m_bestListView->setKeyword(keyword); + m_webListView->setKeyword(keyword); } /** diff --git a/src/content-widget.h b/src/content-widget.h index 8cb7853..05aa168 100644 --- a/src/content-widget.h +++ b/src/content-widget.h @@ -72,12 +72,14 @@ private: SearchListView * m_settingListView = nullptr; SearchListView * m_appListView = nullptr; SearchListView * m_bestListView = nullptr; + SearchListView * m_webListView = nullptr; TitleLabel * m_fileTitleLabel = nullptr; TitleLabel * m_dirTitleLabel = nullptr; TitleLabel * m_contentTitleLabel = nullptr; TitleLabel * m_appTitleLabel = nullptr; TitleLabel * m_settingTitleLabel = nullptr; TitleLabel * m_bestTitleLabel = nullptr; + TitleLabel * m_webTitleLabel = nullptr; ShowMoreLabel * m_appShowMoreLabel = nullptr; ShowMoreLabel * m_settingShowMoreLabel = nullptr; ShowMoreLabel * m_dirShowMoreLabel = nullptr; diff --git a/src/control/search-detail-view.cpp b/src/control/search-detail-view.cpp index 635781b..18b1e4c 100644 --- a/src/control/search-detail-view.cpp +++ b/src/control/search-detail-view.cpp @@ -77,6 +77,11 @@ void SearchDetailView::clearLayout() { m_hLine_2->hide(); m_optionView->hide(); m_isEmpty = true; + if (m_webView) { + m_webView->close(); + m_webView = NULL; + } +// m_reload = false; } /** @@ -111,18 +116,53 @@ int SearchDetailView::getType() * @brief SearchDetailView::setWebWidget 显示为网页 * @param keyword 关键词 */ -//void SearchDetailView::setWebWidget(const QString& keyword) -//{ -// QWebEngineView * m_webView = new QWebEngineView(this); -// m_webView->move(0, 0); -// m_webView->setFixedSize(360, 522); -// m_isEmpty = false; -// clearLayout(); +void SearchDetailView::setWebWidget(const QString& keyword) +{ + clearLayout(); + m_isEmpty = false; + m_reload = false; + m_webView = new QWebEngineView(this); + //如果使用非手机版百度跳转,请使用RequestInterceptor类 +// RequestInterceptor * interceptor = new RequestInterceptor(m_webView); +// QWebEngineProfile * profile = new QWebEngineProfile(m_webView); +// profile->setRequestInterceptor(interceptor); +// QWebEnginePage * page = new QWebEnginePage(profile, m_webView); +// m_webView->setPage(page); + m_webView->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); + m_webView->setAttribute(Qt::WA_DeleteOnClose); + m_webView->move(0, 0); + m_webView->setFixedSize(360, 522); -// QString str = "http://m.baidu.com/s?word=" + keyword; -// m_webView->load(str); -// m_webView->show(); -//} + connect(m_webView,&QWebEngineView::loadFinished, this, [ = ](){ + m_reload = true; + }); + connect(m_webView, &QWebEngineView::urlChanged, this, [ = ](const QUrl& url) { + if (m_reload) { + m_webView->close(); + m_webView = NULL; + QDesktopServices::openUrl(url); + } + }); + QString address; + QString engine = GlobalSettings::getInstance()->getValue(WEB_ENGINE).toString(); + if (!engine.isEmpty()) { + if (engine == "360") { + address = "https://m.so.com/s?q=" + keyword; //360 + } else if (engine == "sougou") { + address = "https://wap.sogou.com/web/searchList.jsp?&keyword=" + keyword; //搜狗 + } else { + address = "http://m.baidu.com/s?word=" + keyword; //百度 + } + } else { //默认值 + address = "http://m.baidu.com/s?word=" + keyword; //百度 + } +// QString str = "http://m.baidu.com/s?word=" + keyword; //百度 +// QString str = "https://m.so.com/s?q=" + keyword; //360 +// QString str = "https://wap.sogou.com/web/searchList.jsp?&keyword=" + keyword; //搜狗 + + m_webView->load(address); + m_webView->show(); +} QString SearchDetailView::getHtmlText(const QString & text, const QString & keyword) { QString htmlString; @@ -430,8 +470,6 @@ void SearchDetailView::initUI() m_layout->addStretch(); - - this->clearLayout(); //初始化时隐藏所有控件 } @@ -513,3 +551,14 @@ void SearchDetailView::paintEvent(QPaintEvent *event) { p.drawRoundedRect(rect, 4, 4); return QWidget::paintEvent(event); } + +/** + * @brief RequestInterceptor::interceptRequest 拦截qwebengineview的Url请求 + * @param info + */ +//void RequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info) +//{ +//当使用PC版搜索引擎时,可以使用此方法获取用户点击的链接的url +// QUrl url = info.requestUrl(); +// qDebug() <<"Request URL:" < -//#include +#include +#include +//#include +//#include +#include #include "option-view.h" +#include "global-settings.h" class SearchDetailView : public QWidget { @@ -38,7 +43,7 @@ public: bool isEmpty(); int getType(); bool isContent = false; -// void setWebWidget(const QString&); + void setWebWidget(const QString&); protected: void paintEvent(QPaintEvent *); @@ -80,10 +85,21 @@ private: QFrame * m_hLine_2 = nullptr; OptionView * m_optionView = nullptr; + QWebEngineView * m_webView = nullptr; + bool m_reload = false; + Q_SIGNALS: void configFileChanged(); private Q_SLOTS: void execActions(const int&, const int&, const QString&); }; +//此类用于url拦截 +//class RequestInterceptor : public QWebEngineUrlRequestInterceptor +//{ +//public: +// explicit RequestInterceptor(QObject * parent = nullptr) : QWebEngineUrlRequestInterceptor(parent) {} +// virtual void interceptRequest(QWebEngineUrlRequestInfo & info) Q_DECL_OVERRIDE; +//}; + #endif // SEARCHDETAILVIEW_H diff --git a/src/control/search-list-view.cpp b/src/control/search-list-view.cpp index 6885243..4f82f6c 100644 --- a/src/control/search-list-view.cpp +++ b/src/control/search-list-view.cpp @@ -149,6 +149,8 @@ int SearchListView::getCurrentType() { case SearchItem::SearchType::Contents: // qDebug()<<"qDebug: One row selected, its type is content."; return ResType::Content; + case SearchItem::SearchType::Web: + return ResType::Web; default: //All或者Best的情况,需要自己判断文件类型 return getResType(m_item->m_pathlist.at(this->currentIndex().row())); break; diff --git a/src/control/search-list-view.h b/src/control/search-list-view.h index fc0c953..50e7df2 100644 --- a/src/control/search-list-view.h +++ b/src/control/search-list-view.h @@ -40,7 +40,8 @@ public: Setting, Dir, File, - Content + Content, + Web }; int getCurrentType(); diff --git a/src/model/search-item.h b/src/model/search-item.h index a04f9e3..2cd48c2 100644 --- a/src/model/search-item.h +++ b/src/model/search-item.h @@ -41,7 +41,8 @@ public: Settings, Dirs, Files, - Contents + Contents, + Web }; void setSearchList(const int&, const QStringList&); diff --git a/src/settings-widget.cpp b/src/settings-widget.cpp index 69624a3..601aa1b 100644 --- a/src/settings-widget.cpp +++ b/src/settings-widget.cpp @@ -40,6 +40,7 @@ SettingsWidget::SettingsWidget(QWidget *parent) : QDialog(parent) initUi(); refreshIndexState(); setupBlackList(GlobalSettings::getInstance()->getBlockDirs()); + resetWebEngine(); } SettingsWidget::~SettingsWidget() @@ -170,12 +171,25 @@ void SettingsWidget::initUi() { m_engineBtnGroup->addButton(m_baiduBtn); m_engineBtnGroup->addButton(m_sougouBtn); m_engineBtnGroup->addButton(m_360Btn); +// m_engineBtnGroup->setId(m_baiduBtn, WebEngine::Baidu); +// m_engineBtnGroup->setId(m_sougouBtn, WebEngine::Sougou); +// m_engineBtnGroup->setId(m_360Btn, WebEngine::_360); +// connect(m_engineBtnGroup, QOverload::of(&QButtonGroup::buttonClicked), [ = ] (int id) { +// setWebEngine(id); +// }); + connect(m_baiduBtn, &QRadioButton::clicked, [ = ] (bool checked) { + if (checked) setWebEngine("baidu"); + }); + connect(m_sougouBtn, &QRadioButton::clicked, [ = ] (bool checked) { + if (checked) setWebEngine("sougou"); + }); + connect(m_360Btn, &QRadioButton::clicked, [ = ] (bool checked) { + if (checked) setWebEngine("360"); + }); + m_mainLyt->addWidget(m_searchEngineLabel); m_mainLyt->addWidget(m_engineDescLabel); m_mainLyt->addWidget(m_radioBtnFrame); - m_searchEngineLabel->hide(); - m_engineDescLabel->hide(); - m_radioBtnFrame->hide(); //取消与确认按钮 (隐藏) // m_bottomBtnFrame = new QFrame(this); @@ -289,6 +303,36 @@ void SettingsWidget::onBtnDelClicked(const QString& path) { } } +/** + * @brief SettingsWidget::resetWebEngine 获取当前的搜索引擎并反应在UI控件上 + */ +void SettingsWidget::resetWebEngine() +{ + QString engine = GlobalSettings::getInstance()->getValue(WEB_ENGINE).toString(); + m_engineBtnGroup->blockSignals(true); + if (!engine.isEmpty()) { + if (engine == "360") { + m_360Btn->setChecked(true); + } else if (engine == "sougou") { + m_sougouBtn->setChecked(true); + } else { + m_baiduBtn->setChecked(true); + } + } else { + m_baiduBtn->setChecked(true); + } + m_engineBtnGroup->blockSignals(false); +} + +/** + * @brief SettingsWidget::setWebEngine + * @param engine 选择的搜索引擎 + */ +void SettingsWidget::setWebEngine(const QString& engine) +{ + GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine); +} + /** * @brief setIndexState 设置当前索引状态 * @param isCreatingIndex 是否正在创建索引 @@ -432,13 +476,13 @@ void SettingsWidget::resize() // this->setFixedSize(528, 515); // } if (m_blockdirs <= 4) { - m_dirListArea->setFixedHeight(32 * m_blockdirs + 5); + m_dirListArea->setFixedHeight(32 * m_blockdirs); m_dirListWidget->setFixedHeight(32 * m_blockdirs); } else { - m_dirListWidget->setFixedHeight(32 * m_blockdirs + 5); + m_dirListWidget->setFixedHeight(32 * m_blockdirs); m_dirListArea->setFixedHeight(32 * 4); } - this->setFixedSize(528, 455); + this->setFixedSize(528, 410 + m_dirListArea->height()); } /** diff --git a/src/settings-widget.h b/src/settings-widget.h index bab5124..1c29e87 100644 --- a/src/settings-widget.h +++ b/src/settings-widget.h @@ -52,6 +52,7 @@ private: void paintEvent(QPaintEvent *); void resize(); void showWarningDialog(const int&); + void resetWebEngine(); //标题栏 QVBoxLayout * m_mainLyt = nullptr; QFrame * m_titleFrame = nullptr; @@ -107,6 +108,7 @@ private Q_SLOTS: // void onBtnCancelClicked(); void onBtnAddClicked(); void onBtnDelClicked(const QString&); + void setWebEngine(const QString&); }; #endif // SETTINGSWIDGET_H diff --git a/src/src.pro b/src/src.pro index aae6a6a..3c463b9 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,4 +1,4 @@ -QT += core gui dbus KWindowSystem xml x11extras +QT += core gui dbus KWindowSystem xml x11extras webenginewidgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets diff --git a/translations/ukui-search/bo.ts b/translations/ukui-search/bo.ts index 0fc759c..bf83c5a 100644 --- a/translations/ukui-search/bo.ts +++ b/translations/ukui-search/bo.ts @@ -4,52 +4,57 @@ ContentWidget - + Recently Opened - + Open Quickly - + Commonly Used - + Apps - + Settings - + Files - + Dirs - + File Contents - + Best Matches - + + Web Pages + + + + Unknown @@ -83,27 +88,27 @@ OptionView - + Open - + Add Shortcut to Desktop - + Add Shortcut to Panel - + Open path - + Copy path @@ -127,22 +132,22 @@ SearchDetailView - + Path - + Last time modified - + Application - + Document @@ -307,33 +312,33 @@ ShowMoreLabel - - + + Show More... - + Retract - + Loading - + Loading. - + Loading.. - + Loading... diff --git a/translations/ukui-search/tr.ts b/translations/ukui-search/tr.ts index ed315ca..e37d96b 100644 --- a/translations/ukui-search/tr.ts +++ b/translations/ukui-search/tr.ts @@ -4,52 +4,57 @@ ContentWidget - + Recently Opened Yeni Açılan - + Open Quickly Hızlı Aç - + Commonly Used Genel olarak kullanılan - + Apps Uygulamalar - + Settings Ayarlar - + Files Dosyalar - + Dirs Dizinler - + File Contents Dosya İçeriği - + Best Matches En İyi Eşleşen - + + Web Pages + + + + Unknown Bilinmeyen @@ -83,27 +88,27 @@ OptionView - + Open - + Add Shortcut to Desktop Masaüstüne Kısayol Ekle - + Add Shortcut to Panel Panele Kısayol Ekle - + Open path Yolu aç - + Copy path Yolu kopyala @@ -127,22 +132,22 @@ SearchDetailView - + Path Yol - + Last time modified Son değiştirilme zamanı - + Application Uygulama - + Document Belge @@ -307,33 +312,33 @@ ShowMoreLabel - - + + Show More... Daha Fazla Göster... - + Retract Geri çek - + Loading Yükleniyor - + Loading. Yükleniyor. - + Loading.. Yükleniyor.. - + Loading... Yükleniyor... diff --git a/translations/ukui-search/zh_CN.ts b/translations/ukui-search/zh_CN.ts index b8f85eb..21cb8c7 100644 --- a/translations/ukui-search/zh_CN.ts +++ b/translations/ukui-search/zh_CN.ts @@ -4,52 +4,57 @@ ContentWidget - + Recently Opened 最近 - + Open Quickly 快速 - + Commonly Used 常用 - + Apps 应用 - + Settings 配置项 - + Files 文件 - + Dirs 文件夹 - + File Contents 文件内容 - + Best Matches 最佳匹配 - + + Web Pages + 网页 + + + Unknown 未知 @@ -83,27 +88,27 @@ OptionView - + Open 打开 - + Add Shortcut to Desktop 添加到桌面快捷方式 - + Add Shortcut to Panel 添加到任务栏快捷方式 - + Open path 打开文件所在路径 - + Copy path 复制文件路径 @@ -127,22 +132,22 @@ SearchDetailView - + Path 路径 - + Last time modified 上次修改时间 - + Application 应用 - + Document 文件 @@ -307,33 +312,33 @@ ShowMoreLabel - - + + Show More... 显示更多... - + Retract 收起 - + Loading 加载中 - + Loading. 加载中. - + Loading.. 加载中.. - + Loading... 加载中... From 812daf056d6e74dd903f09b996d417ac2c533a34 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Tue, 23 Feb 2021 10:16:41 +0800 Subject: [PATCH 2/2] fix(frontend): Close webview when mainwindow focused out. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 主界面失焦消失时关闭网页搜索详情页 Log: 主界面失焦消失时关闭网页搜索详情页 --- src/content-widget.cpp | 8 ++++++++ src/content-widget.h | 1 + src/control/search-detail-view.cpp | 16 ++++++++++------ src/control/search-detail-view.h | 1 + src/mainwindow.cpp | 2 ++ 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/content-widget.cpp b/src/content-widget.cpp index f21628a..72e7566 100644 --- a/src/content-widget.cpp +++ b/src/content-widget.cpp @@ -719,3 +719,11 @@ void ContentWidget::setQuicklyOpenList(const QStringList & list) { m_quicklyOpenList = list; } + +/** + * @brief ContentWidget::closeWebView 在主界面失焦消失的时候调用,(若webview未关闭)关闭网页搜索界面 + */ +void ContentWidget::closeWebView() +{ + m_detailView->closeWebWidget(); +} diff --git a/src/content-widget.h b/src/content-widget.h index 05aa168..83390df 100644 --- a/src/content-widget.h +++ b/src/content-widget.h @@ -45,6 +45,7 @@ public: void setContentList(const QStringList&); void setKeyword(QString); void setQuicklyOpenList(const QStringList &); + void closeWebView(); private: void initUI(); void initListView(); diff --git a/src/control/search-detail-view.cpp b/src/control/search-detail-view.cpp index 18b1e4c..a56be27 100644 --- a/src/control/search-detail-view.cpp +++ b/src/control/search-detail-view.cpp @@ -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; diff --git a/src/control/search-detail-view.h b/src/control/search-detail-view.h index 1f159c9..480e7a4 100644 --- a/src/control/search-detail-view.h +++ b/src/control/search-detail-view.h @@ -44,6 +44,7 @@ public: int getType(); bool isContent = false; void setWebWidget(const QString&); + void closeWebWidget(); protected: void paintEvent(QPaintEvent *); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b20e349..474ea3f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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(); }