forked from openkylin/ukui-search
Merge branch '0330-dev' into 'main'
[Fix] There still will be rounder corner when kwin effect disabled. See merge request kylin-desktop/ukui-search!4
This commit is contained in:
commit
46086349d5
|
@ -16,8 +16,7 @@ Build-Depends: debhelper (>=9.0.0),
|
|||
libkf5windowsystem-dev,
|
||||
libgsettings-qt-dev,
|
||||
libqt5x11extras5-dev,
|
||||
libuchardet-dev,
|
||||
qtwebengine5-dev
|
||||
libuchardet-dev
|
||||
Standards-Version: 4.5.0
|
||||
Homepage: https://www.ukui.org/
|
||||
Vcs-Git: https://github.com/ukui/ukui-search.git
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <QFileInfo>
|
||||
#include <QDateTime>
|
||||
#include <QDBusMetaType>
|
||||
#include <QWebEngineCookieStore>
|
||||
//#include <QWebEngineCookieStore>
|
||||
#include "config-file.h"
|
||||
|
||||
SearchDetailView::SearchDetailView(QWidget *parent) : QWidget(parent)
|
||||
|
@ -81,9 +81,9 @@ void SearchDetailView::clearLayout() {
|
|||
m_optionView->hide();
|
||||
m_isEmpty = true;
|
||||
// closeWebWidget();
|
||||
if (m_webView) {
|
||||
m_webView->hide();
|
||||
}
|
||||
// if (m_webView) {
|
||||
// m_webView->hide();
|
||||
// }
|
||||
// m_reload = false;
|
||||
}
|
||||
|
||||
|
@ -124,42 +124,42 @@ void SearchDetailView::setWebWidget(const QString& keyword)
|
|||
clearLayout();
|
||||
m_isEmpty = false;
|
||||
m_reload = false;
|
||||
if (m_webView) {
|
||||
if (QString::compare(keyword, m_currentKeyword) == 0 && m_net_enable) { //关键词没有发生变化,只把原来的网页show出来
|
||||
m_webView->show();
|
||||
return;
|
||||
}
|
||||
} 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);
|
||||
m_webView->setFixedSize(378, 522);
|
||||
// if (m_webView) {
|
||||
// if (QString::compare(keyword, m_currentKeyword) == 0 && m_net_enable) { //关键词没有发生变化,只把原来的网页show出来
|
||||
// m_webView->show();
|
||||
// return;
|
||||
// }
|
||||
// } 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);
|
||||
// m_webView->setFixedSize(378, 522);
|
||||
|
||||
connect(m_webView,&QWebEngineView::loadFinished, this, [ = ](bool is_successful){
|
||||
m_reload = true;
|
||||
if (m_engineProfile){
|
||||
m_engineProfile->clearHttpCache(); // 清理缓存
|
||||
m_engineProfile->clearAllVisitedLinks(); // 清理浏览记录
|
||||
m_engineProfile->cookieStore()->deleteAllCookies(); // 清理cookie
|
||||
m_engineProfile->cookieStore()->deleteSessionCookies(); // 清理会话cookie
|
||||
}
|
||||
if (is_successful) {
|
||||
m_webView->show();
|
||||
m_net_enable = true;
|
||||
} else {
|
||||
m_noNetFrame->show();
|
||||
m_net_enable = false;
|
||||
}
|
||||
});
|
||||
connect(m_webView, &QWebEngineView::urlChanged, this, [ = ](const QUrl& url) {
|
||||
if (m_reload) {
|
||||
QDesktopServices::openUrl(url);
|
||||
closeWebWidget();
|
||||
}
|
||||
});
|
||||
}
|
||||
// connect(m_webView,&QWebEngineView::loadFinished, this, [ = ](bool is_successful){
|
||||
// m_reload = true;
|
||||
// if (m_engineProfile){
|
||||
// m_engineProfile->clearHttpCache(); // 清理缓存
|
||||
// m_engineProfile->clearAllVisitedLinks(); // 清理浏览记录
|
||||
// m_engineProfile->cookieStore()->deleteAllCookies(); // 清理cookie
|
||||
// m_engineProfile->cookieStore()->deleteSessionCookies(); // 清理会话cookie
|
||||
// }
|
||||
// if (is_successful) {
|
||||
// m_webView->show();
|
||||
// m_net_enable = true;
|
||||
// } else {
|
||||
// m_noNetFrame->show();
|
||||
// m_net_enable = false;
|
||||
// }
|
||||
// });
|
||||
// connect(m_webView, &QWebEngineView::urlChanged, this, [ = ](const QUrl& url) {
|
||||
// if (m_reload) {
|
||||
// QDesktopServices::openUrl(url);
|
||||
// closeWebWidget();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//如果使用非手机版百度跳转,请使用RequestInterceptor类
|
||||
// RequestInterceptor * interceptor = new RequestInterceptor(m_webView);
|
||||
// QWebEngineProfile * profile = new QWebEngineProfile(m_webView);
|
||||
|
@ -173,20 +173,21 @@ void SearchDetailView::setWebWidget(const QString& keyword)
|
|||
QString engine = GlobalSettings::getInstance()->getValue(WEB_ENGINE).toString();
|
||||
if (!engine.isEmpty()) {
|
||||
if (engine == "360") {
|
||||
address = "https://m.so.com/s?q=" + keyword; //360
|
||||
address = "https://so.com/s?q=" + keyword; //360
|
||||
} else if (engine == "sougou") {
|
||||
address = "https://wap.sogou.com/web/searchList.jsp?&keyword=" + keyword; //搜狗
|
||||
address = "https://www.sogou.com/web?query=" + keyword; //搜狗
|
||||
} else {
|
||||
address = "http://m.baidu.com/s?word=" + keyword; //百度
|
||||
address = "http://baidu.com/s?word=" + keyword; //百度
|
||||
}
|
||||
} else { //默认值
|
||||
address = "http://m.baidu.com/s?word=" + keyword; //百度
|
||||
address = "http://baidu.com/s?word=" + keyword; //百度
|
||||
}
|
||||
QDesktopServices::openUrl(address);
|
||||
// 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->load(address);
|
||||
// m_webView->show();
|
||||
}
|
||||
|
||||
|
@ -236,10 +237,10 @@ void SearchDetailView::setAppWidget(const QString &appname, const QString &path,
|
|||
|
||||
void SearchDetailView::closeWebWidget()
|
||||
{
|
||||
if (m_webView) {
|
||||
m_webView->close();
|
||||
m_webView = NULL;
|
||||
}
|
||||
// if (m_webView) {
|
||||
// m_webView->close();
|
||||
// m_webView = NULL;
|
||||
// }
|
||||
}
|
||||
|
||||
QString SearchDetailView::getHtmlText(const QString & text, const QString & keyword) {
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
#define SEARCHDETAILVIEW_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QWebEngineView>
|
||||
#include <QWebEngineSettings>
|
||||
#include <QWebEngineProfile>
|
||||
//#include <QWebEngineView>
|
||||
//#include <QWebEngineSettings>
|
||||
//#include <QWebEngineProfile>
|
||||
//#include <QWebEngineUrlRequestInterceptor>
|
||||
#include <QDesktopServices>
|
||||
#include "option-view.h"
|
||||
|
@ -94,8 +94,8 @@ private:
|
|||
QLabel * m_noNetIconLabel = nullptr;
|
||||
QLabel * m_noNetTipsLabel = nullptr;
|
||||
|
||||
QWebEngineView * m_webView = nullptr;
|
||||
QWebEngineProfile * m_engineProfile = nullptr;
|
||||
// QWebEngineView * m_webView = nullptr;
|
||||
// QWebEngineProfile * m_engineProfile = nullptr;
|
||||
bool m_reload = false;
|
||||
bool m_net_enable = true;
|
||||
QString m_currentKeyword;
|
||||
|
|
|
@ -85,7 +85,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
QPainterPath path;
|
||||
auto rect = this->rect();
|
||||
rect.adjust(1, 1, -1, -1);
|
||||
path.addRoundedRect(rect, 6, 6);
|
||||
// path.addRoundedRect(rect, 0, 0);
|
||||
path.addRect(rect);
|
||||
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
|
||||
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
|
||||
|
||||
|
@ -484,7 +485,8 @@ void MainWindow::paintEvent(QPaintEvent *event) {
|
|||
p.setBrush(opt.palette.color(QPalette::Base));
|
||||
p.setOpacity(trans);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRoundedRect(rect, 6, 6);
|
||||
// p.drawRoundedRect(rect, 6, 6);
|
||||
p.drawRect(rect);
|
||||
return QWidget::paintEvent(event);
|
||||
|
||||
}
|
||||
|
|
|
@ -439,7 +439,8 @@ void SettingsWidget::paintEvent(QPaintEvent *event) {
|
|||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
QPainterPath rectPath;
|
||||
rectPath.addRoundedRect(this->rect(), 6, 6);
|
||||
// rectPath.addRoundedRect(this->rect(), 6, 6);
|
||||
rectPath.addRect(this->rect());
|
||||
|
||||
// // 画一个黑底
|
||||
// QPixmap pixmap(this->rect().size());
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
QT += core gui dbus KWindowSystem xml x11extras webenginewidgets
|
||||
QT += core gui dbus KWindowSystem xml x11extras
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
|
|
Loading…
Reference in New Issue