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