Merge branch '0615-newfrontend' into 'new-frontend'

Add web search detail page; Change selection rules; Fix translation bug; Add...

See merge request kylin-desktop/ukui-search!177
This commit is contained in:
PengfeiZhang 2021-10-27 06:25:34 +00:00
commit 52f8bb042f
24 changed files with 348 additions and 105 deletions

View File

@ -42,6 +42,7 @@ void TitleLabel::initUi() {
this->setLayout(m_titleLyt);
m_showMoreLabel = new ShowMoreLabel(this);
m_showMoreLabel->setFixedHeight(UNFOLD_LABEL_HEIGHT);
m_showMoreLabel->adjustSize();
m_showMoreLabel->hide();
m_titleLyt->addStretch();
m_titleLyt->addWidget(m_showMoreLabel);

View File

@ -51,15 +51,12 @@ ResultArea::ResultArea(QWidget *parent) : QScrollArea(parent)
void ResultArea::appendWidet(ResultWidget *widget)
{
//NEW_TODO
m_mainLyt->removeWidget(m_webSearchWidget);
m_mainLyt->addWidget(widget);
setupConnectionsForWidget(widget);
widget->clearResult();
m_widget_list.append(widget);
int spacing_height = m_widget_list.length() > 1 ? m_mainLyt->spacing() : 0;
m_widget->setFixedHeight(m_widget->height() + widget->height() + spacing_height);
m_mainLyt->addWidget(m_webSearchWidget);
}
/**
@ -82,8 +79,15 @@ void ResultArea::pressEnter()
if (false == m_is_selected) {//未选中时默认选取bestlist第一项
int resultNum = m_bestListWidget->getResultNum();
if (0 == resultNum) {//无搜索结果时默认选中websearch
m_webSearchWidget->LaunchBrowser();//默认已选中websearch
for (ResultWidget * i : m_widget_list) {
if (m_selectedPluginID == m_widget_list.back()->pluginId()) {
QModelIndex index = i->getModlIndex(0, 0);
i->setResultSelection(index);
m_selectedPluginID = i->pluginId();
m_is_selected = true;
break;
}
}
} else {//选取bestlist第一项
QModelIndex index = m_bestListWidget->getModlIndex(0, 0);
m_bestListWidget->setResultSelection(index);
@ -91,9 +95,6 @@ void ResultArea::pressEnter()
m_is_selected = true;
}
} else {//选中状态时默认启动action首项
if (m_selectedPluginID == m_webSearchWidget->getWidgetName()) {//选中网页搜索则启动搜索
m_webSearchWidget->LaunchBrowser();
} else {
//先判断详情页是否打开
if (m_detail_open_state) {
if (m_selectedPluginID == m_bestListWidget->getWidgetName()) {//最佳匹配
@ -112,11 +113,10 @@ void ResultArea::pressEnter()
}
}
}
}
void ResultArea::pressDown()
{
if (m_selectedPluginID == m_webSearchWidget->getWidgetName()) {//当前为web search暂不处理
if (m_selectedPluginID == m_widget_list.back()->pluginId()) {//当前为web search暂不处理
return;
} else if (m_selectedPluginID == m_bestListWidget->getWidgetName()) {
QModelIndex index = m_bestListWidget->getCurrentSelection();
@ -169,13 +169,6 @@ void ResultArea::pressDown()
break;
}
}
if (indexNum >= m_widget_list.size()) {//下一项是web search
QModelIndex index = m_webSearchWidget->getModlIndex(0, 0);
m_webSearchWidget->setResultSelection(index);
m_selectedPluginID = m_webSearchWidget->getWidgetName();
m_is_selected = true;
this->ensureWidgetVisible(m_webSearchWidget);
}
if (findNextWidget){
break;
}
@ -192,29 +185,7 @@ void ResultArea::pressUp()
if (!m_is_selected) {
return;
}
if (m_selectedPluginID == m_webSearchWidget->getWidgetName()) {//当前为web search
if (m_bestListWidget->getResultNum() == 0) {
return;
}
m_webSearchWidget->clearResultSelection();
for (int i = 0; i < m_widget_list.size(); i++) {
ResultWidget * plugin = m_widget_list[m_widget_list.size() - (i + 1)];
bool findNextWidget = false;
if (0 != plugin->getResultNum()) {
int maxNum = plugin->getExpandState() ?
plugin->getResultNum() : (plugin->getResultNum() < NUM_LIMIT_SHOWN_DEFAULT ?
plugin->getResultNum() : NUM_LIMIT_SHOWN_DEFAULT);
QModelIndex resultIndex = plugin->getModlIndex(maxNum - 1, 0);
plugin->setResultSelection(resultIndex);
m_selectedPluginID = plugin->pluginId();
findNextWidget = true;
sendKeyPressSignal(m_selectedPluginID);
}
if (findNextWidget) {
break;
}
}
} else if (m_selectedPluginID == m_bestListWidget->getWidgetName()) {
if (m_selectedPluginID == m_bestListWidget->getWidgetName()) {
QModelIndex index = m_bestListWidget->getCurrentSelection();
int maxNum = m_bestListWidget->getExpandState() ?
m_bestListWidget->getResultNum() : (m_bestListWidget->getResultNum() < NUM_LIMIT_SHOWN_DEFAULT ?
@ -329,8 +300,6 @@ void ResultArea::onWidgetSizeChanged()
whole_height += widget->height();
}
whole_height += m_bestListWidget->height();
//TODO 网页高度
whole_height += m_webSearchWidget->height();
int spacing_height = m_widget_list.length() > 1 ? m_mainLyt->spacing() : 0;
m_widget->setFixedHeight(whole_height + spacing_height * (m_widget_list.length() - 1));
@ -345,9 +314,6 @@ void ResultArea::setSelectionInfo(QString &pluginID)
if (m_selectedPluginID != m_bestListWidget->getWidgetName()) {
m_bestListWidget->clearResultSelection();
}
if (m_selectedPluginID != m_webSearchWidget->getWidgetName()) {
m_webSearchWidget->clearResultSelection();
}
}
void ResultArea::mousePressEvent(QMouseEvent *event)
@ -422,8 +388,6 @@ void ResultArea::initUi()
m_bestListWidget->clearResult();
m_mainLyt->addWidget(m_bestListWidget);
m_webSearchWidget = new WebSearchWidget(this);
m_mainLyt->addWidget(m_webSearchWidget);
m_mainLyt->setContentsMargins(RESULT_LAYOUT_MARGINS);
this->widget()->setContentsMargins(0,0,0,0);
m_mainLyt->setSpacing(0);
@ -435,21 +399,25 @@ void ResultArea::initUi()
void ResultArea::initConnections()
{
connect(this, &ResultArea::startSearch, m_bestListWidget, &BestListWidget::startSearch);
connect(this, &ResultArea::startSearch, m_webSearchWidget, &WebSearchWidget::startSearch);
connect(this, &ResultArea::startSearch, this, [=] () {
m_detail_open_state = false;
m_is_selected = false;
QModelIndex index = m_webSearchWidget->getModlIndex(0, 0);//每次启动搜索则选中web搜索待bestlist收到结果后清空选中
m_webSearchWidget->setResultSelection(index);
m_selectedPluginID = "";
});
connect(m_bestListWidget, &BestListWidget::sizeChanged, this, &ResultArea::onWidgetSizeChanged);
connect(m_bestListWidget, &BestListWidget::sizeChanged, this, [=] () {
if (!m_is_selected) {
m_webSearchWidget->clearResultSelection();//每次启动搜索则选中web搜索待bestlist收到结果后清空选中
QModelIndex index = m_bestListWidget->getModlIndex(0, 0);
if (index.isValid()) {
m_bestListWidget->setResultSelection(index);
m_selectedPluginID = m_bestListWidget->getWidgetName();
m_is_selected = true;
for (ResultWidget * i : m_widget_list) {
if (i->pluginId() == m_widget_list.back()->pluginId()) {
i->clearResultSelection();
break;
}
}
}
});
@ -458,12 +426,10 @@ void ResultArea::initConnections()
m_detail_open_state = true;
m_is_selected = true;
m_selectedPluginID = m_bestListWidget->getWidgetName();
m_webSearchWidget->clearResultSelection();
});
connect(this, &ResultArea::clearSelectedRow, m_bestListWidget, &BestListWidget::clearSelectedRow);
connect(this, &ResultArea::resizeWidth, this, [=] (const int &size) {
m_bestListWidget->setFixedWidth(size);
m_webSearchWidget->setFixedWidth(size);
});
connect(m_bestListWidget, &BestListWidget::rowClicked, this, &ResultArea::rowClicked);
connect(this->verticalScrollBar(), &QScrollBar::valueChanged, this, [=] (int value) {//判断显示和隐藏逻辑
@ -516,6 +482,16 @@ void ResultArea::setupConnectionsForWidget(ResultWidget *widget)
});
connect(this, &ResultArea::stopSearch, widget, &ResultWidget::stopSearch);
connect(widget, &ResultWidget::sizeChanged, this, &ResultArea::onWidgetSizeChanged);
connect(widget, &ResultWidget::sizeChanged, this, [=] () {
if (widget->pluginId() == m_widget_list.back()->pluginId() and m_selectedPluginID != m_bestListWidget->getWidgetName()) {//每次搜索默认选中websearch由bestlist取消
QModelIndex index = widget->getModlIndex(0, 0);
if (index.isValid()) {
widget->setResultSelection(index);
m_is_selected = true;
m_selectedPluginID = widget->pluginId();
}
}
});
connect(widget, &ResultWidget::showMoreClicked, this, [=] () {//点击展开搜索结果后 显示悬浮窗
this->verticalScrollBar()->setValue(widget->pos().ry() + TITLE_HEIGHT); //置顶当前类型搜索结果
if (widget->height() > FRAME_HEIGHT) {//当前widget高度大于搜索结果界面高度则显示悬浮窗
@ -649,6 +625,7 @@ void DetailWidget::updateDetailPage(const QString &plugin_name, const SearchPlug
m_mainLyt->addWidget(m_detailPage);
// m_mainLyt->insertWidget(0, m_detailPage, 0);
}
m_currentPluginId = plugin_name;
}
void DetailWidget::clear()

View File

@ -66,7 +66,6 @@ private:
QVBoxLayout * m_mainLyt = nullptr;
BestListWidget * m_bestListWidget = nullptr;
QList<ResultWidget *> m_widget_list;
WebSearchWidget * m_webSearchWidget = nullptr;
TitleLabel * m_titleLable = nullptr;
bool m_detail_open_state = false;

View File

@ -105,11 +105,11 @@ QString BestListModel::getKey(const QModelIndex &index)
void BestListModel::appendInfo(const QString &pluginId, const SearchPluginIface::ResultInfo &info)
{
if (pluginId == "File Search" && m_fileActionKey_tmp != info.actionKey) {//临时保存文件搜索结果的actionKey
m_fileActionKey_tmp = info.actionKey;
}
if (pluginId == "File Content Search" && info.actionKey == m_fileActionKey_tmp) {//文本搜索判断是否和保存的actionKey相同
if (m_plugin_action_key_list.contains(info.actionKey)) {
qDebug() << "plugin ID:" << pluginId << "name:" << info.name << "action key:" << info.actionKey << "is same with pre-result!";
return;
} else {
m_plugin_action_key_list.append(info.actionKey);
}
if (m_plugin_id_list.contains(pluginId)) {
if (info.name == m_item->m_result_info_list.at(m_plugin_id_list.lastIndexOf(pluginId)).name) {
@ -148,6 +148,7 @@ void BestListModel::startSearch(const QString &keyword)
if (!m_item->m_result_info_list.isEmpty()) {
this->beginResetModel();
m_plugin_id_list.clear();
m_plugin_action_key_list.clear();
m_item->m_result_info_list.clear();
this->endResetModel();
Q_EMIT this->itemListChanged(m_item->m_result_info_list.length());

View File

@ -43,8 +43,8 @@ private:
void initConnections();
SearchResultItem * m_item = nullptr;
QVector<QString> m_plugin_id_list;
QVector<QString> m_plugin_action_key_list;
bool m_isExpanded = false;
QString m_fileActionKey_tmp;
};
}
#endif // BESTLISTMODEL_H

View File

@ -81,8 +81,10 @@ void SearchResultModel::appendInfo(const SearchPluginIface::ResultInfo &info)
m_item->m_result_info_list.append(info);
this->endResetModel();
Q_EMIT this->itemListChanged(m_item->m_result_info_list.length());
if (m_plugin_id != "Web Page") {
Q_EMIT this->sendBestListData(m_plugin_id, m_item->m_result_info_list.at(0));
}
}
void SearchResultModel::startSearch(const QString &keyword)
{

View File

@ -119,7 +119,7 @@ void ResultWidget::initUi()
m_mainLyt->setSpacing(MAIN_SPACING);
m_titleLabel = new TitleLabel(this);
m_titleLabel->setText(m_plugin_id);
m_titleLabel->setText(SearchPluginManager::getInstance()->getPlugin(m_plugin_id)->getPluginName());
m_titleLabel->setFixedHeight(TITLE_HEIGHT);
m_resultView = new ResultView(m_plugin_id, this);

View File

@ -22,7 +22,7 @@ AppSearchPlugin::AppSearchPlugin(QObject *parent) : QObject(parent)
const QString AppSearchPlugin::name()
{
return tr("Applications Search");
return "Applications Search";
}
const QString AppSearchPlugin::description()

View File

@ -19,7 +19,7 @@ FileSearchPlugin::FileSearchPlugin(QObject *parent) : QObject(parent)
const QString FileSearchPlugin::name()
{
return tr("File Search");
return "File Search";
}
const QString FileSearchPlugin::description()
@ -226,7 +226,7 @@ DirSearchPlugin::DirSearchPlugin(QObject *parent) : QObject(parent)
const QString DirSearchPlugin::name()
{
return tr("Dir Search");
return "Dir Search";
}
const QString DirSearchPlugin::description()
@ -406,7 +406,7 @@ FileContengSearchPlugin::FileContengSearchPlugin(QObject *parent) : QObject(pare
const QString FileContengSearchPlugin::name()
{
return tr("File Content Search");
return "File Content Search";
}
const QString FileContengSearchPlugin::description()

View File

@ -31,6 +31,7 @@ include(parser/parser.pri)
include(appsearch/appsearch.pri)
include(notesearch/notesearch.pri)
include(settingsearch/settingsearch.pri)
include(websearch/websearch.pri)
LIBS += -L$$OUT_PWD/../libchinese-segmentation/ -lchinese-segmentation
LIBS += -lxapian -lquazip5 -luchardet -lQt5Xdg#-L/usr/local/lib/libjemalloc -ljemalloc
@ -67,7 +68,7 @@ unix {
INSTALLS += target
header.path = /usr/include/ukui-search
header.files += *.h index/*.h appsearch/*.h settingsearch/*.h plugininterface/*.h
header.files += *.h index/*.h appsearch/*.h settingsearch/*.h plugininterface/*.h websearch/*.h
INSTALLS += header
}
INCLUDEPATH += $$PWD/../libchinese-segmentation

View File

@ -18,7 +18,7 @@ NoteSearchPlugin::NoteSearchPlugin(QObject *parent)
const QString NoteSearchPlugin::name()
{
return tr("Note Search");
return "Note Search";
}
const QString NoteSearchPlugin::description()

View File

@ -4,6 +4,7 @@
#include "app-search-plugin.h"
#include "settings-search-plugin.h"
#include "note-search-plugin.h"
#include "web-search-plugin.h"
using namespace Zeeker;
@ -16,7 +17,7 @@ SearchPluginManager::SearchPluginManager(QObject *parent)
registerPlugin(new DirSearchPlugin(this));
registerPlugin(new FileSearchPlugin(this));
registerPlugin(new FileContengSearchPlugin(this));
registerPlugin(new WebSearchPlugin(this));
}
bool SearchPluginManager::registerPlugin(Zeeker::SearchPluginIface *plugin)

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="100px" height="96px" viewBox="0 0 100 96" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title> Search-web-深色模式</title>
<g id="综合搜索SP2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.100000001">
<g id="搜索-网页-预览" transform="translate(-1404.000000, -393.000000)">
<g id="-Search-web-深色模式" transform="translate(1404.000000, 393.000000)">
<rect id="矩形" fill="#FFFFFF" transform="translate(85.000000, 85.000000) rotate(45.000000) translate(-85.000000, -85.000000) " x="74" y="81" width="22" height="8" rx="4"></rect>
<circle id="椭圆形" stroke="#FFFFFF" stroke-width="8" cx="62.5" cy="62.5" r="23.5"></circle>
<path d="M92,0 C96.418278,-8.11624501e-16 100,3.581722 100,8 L100,19 L0,19 L0,8 C-5.41083001e-16,3.581722 3.581722,8.11624501e-16 8,0 L92,0 Z M90.5,6 C88.5670034,6 87,7.56700338 87,9.5 C87,11.4329966 88.5670034,13 90.5,13 C92.4329966,13 94,11.4329966 94,9.5 C94,7.56700338 92.4329966,6 90.5,6 Z M78.5,6 C76.5670034,6 75,7.56700338 75,9.5 C75,11.4329966 76.5670034,13 78.5,13 C80.4329966,13 82,11.4329966 82,9.5 C82,7.56700338 80.4329966,6 78.5,6 Z M66.5,6 C64.5670034,6 63,7.56700338 63,9.5 C63,11.4329966 64.5670034,13 66.5,13 C68.4329966,13 70,11.4329966 70,9.5 C70,7.56700338 68.4329966,6 66.5,6 Z" id="形状结合" fill="#FFFFFF"></path>
<path d="M92,19 L100,19 L100,39 C100,41.209139 98.209139,43 96,43 C93.790861,43 92,41.209139 92,39 L92,19 L92,19 Z" id="矩形备份" fill="#FFFFFF"></path>
<path d="M4,19 L4,79 C4,83.418278 7.581722,87 12,87 L31,87 L31,87" id="路径-2" stroke="#FFFFFF" stroke-width="8" stroke-linecap="round"></path>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="100px" height="96px" viewBox="0 0 100 96" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title> Search-web-浅色模式</title>
<g id="综合搜索SP2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.100000001">
<g id="搜索-网页-预览" transform="translate(-1058.000000, -393.000000)">
<g id="编组" transform="translate(620.000000, 161.000000)">
<g id="编组-12备份-2" transform="translate(8.000000, 66.000000)">
<g id="-Search-web-浅色模式" transform="translate(430.000000, 166.000000)">
<rect id="矩形" fill="#262626" transform="translate(85.000000, 85.000000) rotate(45.000000) translate(-85.000000, -85.000000) " x="74" y="81" width="22" height="8" rx="4"></rect>
<circle id="椭圆形" stroke="#262626" stroke-width="8" cx="62.5" cy="62.5" r="23.5"></circle>
<path d="M92,0 C96.418278,-8.11624501e-16 100,3.581722 100,8 L100,19 L0,19 L0,8 C-5.41083001e-16,3.581722 3.581722,8.11624501e-16 8,0 L92,0 Z M90.5,6 C88.5670034,6 87,7.56700338 87,9.5 C87,11.4329966 88.5670034,13 90.5,13 C92.4329966,13 94,11.4329966 94,9.5 C94,7.56700338 92.4329966,6 90.5,6 Z M78.5,6 C76.5670034,6 75,7.56700338 75,9.5 C75,11.4329966 76.5670034,13 78.5,13 C80.4329966,13 82,11.4329966 82,9.5 C82,7.56700338 80.4329966,6 78.5,6 Z M66.5,6 C64.5670034,6 63,7.56700338 63,9.5 C63,11.4329966 64.5670034,13 66.5,13 C68.4329966,13 70,11.4329966 70,9.5 C70,7.56700338 68.4329966,6 66.5,6 Z" id="形状结合" fill="#262626"></path>
<path d="M92,19 L100,19 L100,39 C100,41.209139 98.209139,43 96,43 C93.790861,43 92,41.209139 92,39 L92,19 L92,19 Z" id="矩形备份" fill="#262626"></path>
<path d="M4,19 L4,79 C4,83.418278 7.581722,87 12,87 L31,87 L31,87" id="路径-2" stroke="#262626" stroke-width="8" stroke-linecap="round"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="28px" height="28px" viewBox="0 0 28 28" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>搜索</title>
<defs>
<filter x="-10.4%" y="-10.4%" width="120.8%" height="120.8%" filterUnits="objectBoundingBox" id="filter-1">
<feOffset dx="0" dy="0" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset>
<feGaussianBlur stdDeviation="0.5" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur>
<feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.304021662 0" type="matrix" in="shadowBlurOuter1" result="shadowMatrixOuter1"></feColorMatrix>
<feMerge>
<feMergeNode in="shadowMatrixOuter1"></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
<linearGradient x1="50%" y1="0%" x2="50%" y2="99.4562097%" id="linearGradient-2">
<stop stop-color="#F4F5F8" offset="0%"></stop>
<stop stop-color="#D7DAE3" offset="100%"></stop>
</linearGradient>
<path d="M2.81753333,1.07293333 C1.71513333,1.70993333 0.926466667,2.73693333 0.597133333,3.96673333 L0.597133333,3.96673333 C0.266933333,5.19566667 0.435933333,6.48093333 1.07206667,7.58246667 L1.07206667,7.58246667 C1.9214,9.0532 3.5048,9.96666667 5.20433333,9.96666667 L5.20433333,9.96666667 C6.03633333,9.96666667 6.85793333,9.74566667 7.58246667,9.32706667 L7.58246667,9.32706667 C8.68573333,8.69006667 9.4744,7.66306667 9.80373333,6.43326667 L9.80373333,6.43326667 C10.1322,5.20433333 9.96406667,3.91906667 9.32793333,2.81753333 L9.32793333,2.81753333 C8.4786,1.3468 6.8952,0.433333333 5.19566667,0.433333333 L5.19566667,0.433333333 C4.36366667,0.433333333 3.54206667,0.654333333 2.81753333,1.07293333" id="path-3"></path>
<linearGradient x1="67.6564459%" y1="76.5684866%" x2="29.1508454%" y2="18.6250777%" id="linearGradient-5">
<stop stop-color="#3D8AFD" offset="0%"></stop>
<stop stop-color="#75A8FF" offset="100%"></stop>
</linearGradient>
</defs>
<g id="组件" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="搜索" transform="translate(2.000000, 2.000000)" filter="url(#filter-1)">
<rect id="矩形" x="0" y="0" width="24" height="24"></rect>
<rect id="矩形" fill="url(#linearGradient-2)" x="2" y="2" width="20" height="20" rx="7"></rect>
<rect id="矩形" fill="#7299FF" opacity="0.5" x="5" y="5" width="14" height="2" rx="1"></rect>
<rect id="矩形备份" fill="#7299FF" opacity="0.5" x="5" y="9" width="12" height="2" rx="1"></rect>
<rect id="矩形备份-2" fill="#7299FF" opacity="0.5" x="5" y="13" width="9" height="2" rx="1"></rect>
<rect id="矩形备份-3" fill="#7299FF" opacity="0.5" x="5" y="17" width="9" height="2" rx="1"></rect>
<g id="编组-9" transform="translate(14.200000, 13.500000) scale(-1, 1) translate(-14.200000, -13.500000) translate(9.000000, 7.000000)">
<polygon id="Fill-13" fill="#E5E5E5" points="2.18694667 11.0043267 1.65134667 10.6949267 2.88981333 8.54992667 3.42541333 8.86019333"></polygon>
<path d="M1.04442,12.48884 L0.936953333,12.4273067 C0.52182,12.18724 0.379686667,11.6577067 0.619753333,11.24344 L1.30095333,10.0639067 C1.53928667,9.64964 2.07055333,9.50750667 2.48482,9.74670667 L2.59142,9.80824 C3.00655333,10.04744 3.14868667,10.57784 2.90862,10.9921067 L2.22742,12.17164 C1.98908667,12.5859067 1.45868667,12.72804 1.04442,12.48884" id="Fill-14" fill="#FF6438"></path>
<g id="编组">
<mask id="mask-4" fill="white">
<use xlink:href="#path-3"></use>
</mask>
<g id="Clip-16"></g>
<path d="M2.81753333,1.07293333 C1.71513333,1.70993333 0.926466667,2.73693333 0.597133333,3.96673333 L0.597133333,3.96673333 C0.266933333,5.19566667 0.435933333,6.48093333 1.07206667,7.58246667 L1.07206667,7.58246667 C1.9214,9.0532 3.5048,9.96666667 5.20433333,9.96666667 L5.20433333,9.96666667 C6.03633333,9.96666667 6.85793333,9.74566667 7.58246667,9.32706667 L7.58246667,9.32706667 C8.68573333,8.69006667 9.4744,7.66306667 9.80373333,6.43326667 L9.80373333,6.43326667 C10.1322,5.20433333 9.96406667,3.91906667 9.32793333,2.81753333 L9.32793333,2.81753333 C8.4786,1.3468 6.8952,0.433333333 5.19566667,0.433333333 L5.19566667,0.433333333 C4.36366667,0.433333333 3.54206667,0.654333333 2.81753333,1.07293333" id="Fill-15" fill="url(#linearGradient-5)" mask="url(#mask-4)"></path>
</g>
<path d="M5.19488667,0 C4.31262,0 3.41908667,0.224466667 2.60095333,0.697666667 C0.11362,2.13286667 -0.738313333,5.31266667 0.697753333,7.8 C1.66062,9.46746667 3.40782,10.4 5.20528667,10.4 C6.08668667,10.4 6.98108667,10.1755333 7.79922,9.70233333 C10.2865533,8.26713333 11.13762,5.08733333 9.70242,2.6 C8.73955333,0.932533333 6.99148667,0 5.19488667,0 M5.19575333,0.866666667 L5.19575333,0.866666667 C6.74102,0.866666667 8.17968667,1.69693333 8.95188667,3.03333333 C10.1461533,5.10293333 9.43548667,7.75753333 7.36588667,8.9518 C6.70722,9.33226667 5.96015333,9.53333333 5.20528667,9.53333333 C3.66002,9.53333333 2.21962,8.70306667 1.44828667,7.36666667 C0.25402,5.29706667 0.964686667,2.64246667 3.03428667,1.4482 C3.69295333,1.06773333 4.44002,0.866666667 5.19575333,0.866666667" id="Fill-17" fill="#EDFFFE"></path>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -7,5 +7,8 @@
<file>res/icons/edit-find-symbolic.svg</file>
<file>res/icons/net-disconnected.svg</file>
<file>res/icons/system-search.symbolic.png</file>
<file>res/icons/search-web-icon.svg</file>
<file>res/icons/search-web-dark.svg</file>
<file>res/icons/search-web-default.svg</file>
</qresource>
</RCC>

View File

@ -18,7 +18,7 @@ SettingsSearchPlugin::SettingsSearchPlugin(QObject *parent) : QObject(parent)
const QString SettingsSearchPlugin::name()
{
return tr("Settings Search");
return "Settings Search";
}
const QString SettingsSearchPlugin::description()

View File

@ -0,0 +1,110 @@
#include "web-search-plugin.h"
#include "global-settings.h"
using namespace Zeeker;
WebSearchPlugin::WebSearchPlugin(QObject *parent) : QObject(parent)
{
SearchPluginIface::Actioninfo open { 0, tr("Start browser search")};
m_actionInfo << open;
initDetailPage();
}
const QString Zeeker::WebSearchPlugin::name()
{
return "Web Page";
}
const QString Zeeker::WebSearchPlugin::description()
{
return tr("Web Page");
}
QString Zeeker::WebSearchPlugin::getPluginName()
{
return tr("Web Page");
}
void Zeeker::WebSearchPlugin::KeywordSearch(QString keyword, DataQueue<Zeeker::SearchPluginIface::ResultInfo> *searchResult)
{
m_keyWord = keyword;
ResultInfo resultInfo;
resultInfo.name = m_keyWord;
resultInfo.type = 0;
resultInfo.icon = QIcon(":/res/icons/search-web-icon.svg");
resultInfo.actionKey = m_keyWord;
searchResult->enqueue(resultInfo);
}
QList<Zeeker::SearchPluginIface::Actioninfo> Zeeker::WebSearchPlugin::getActioninfo(int type)
{
return m_actionInfo;
}
void Zeeker::WebSearchPlugin::openAction(int actionkey, QString key, int type)
{
QString address;
QString engine = GlobalSettings::getInstance()->getValue("web_engine").toString();
if(!engine.isEmpty()) {
if(engine == "360") {
address = "https://so.com/s?q=" + m_keyWord; //360
} else if(engine == "sougou") {
address = "https://www.sogou.com/web?query=" + m_keyWord; //搜狗
} else {
address = "http://baidu.com/s?word=" + m_keyWord; //百度
}
} else { //默认值
address = "http://baidu.com/s?word=" + m_keyWord ; //百度
}
QDesktopServices::openUrl(address);
}
QWidget *Zeeker::WebSearchPlugin::detailPage(const Zeeker::SearchPluginIface::ResultInfo &ri)
{
return m_detailPage;
}
void Zeeker::WebSearchPlugin::initDetailPage()
{
m_detailPage = new QWidget();
m_detailPage->setFixedWidth(360);
m_detailPage->setAttribute(Qt::WA_TranslucentBackground);
m_detailLyt = new QVBoxLayout(m_detailPage);
m_detailLyt->setContentsMargins(8, 0, 16, 0);
m_iconLabel = new QLabel(m_detailPage);
m_iconLabel->setAlignment(Qt::AlignCenter);
QString type = GlobalSettings::getInstance()->getValue(STYLE_NAME_KEY).toString();
if (type == "ukui-dark") {
m_iconLabel->setPixmap(QIcon(":/res/icons/search-web-dark.svg").pixmap(100, 96));
} else {
m_iconLabel->setPixmap(QIcon(":/res/icons/search-web-default.svg").pixmap(100, 96));
}
connect(qApp, &QApplication::paletteChanged, this, [=] () {
QString type = GlobalSettings::getInstance()->getValue(STYLE_NAME_KEY).toString();
if (type == "ukui-dark") {
m_iconLabel->setPixmap(QIcon(":/res/icons/search-web-dark.svg").pixmap(100, 96));
} else {
m_iconLabel->setPixmap(QIcon(":/res/icons/search-web-default.svg").pixmap(100, 96));
}
});
m_actionFrame = new QFrame(m_detailPage);
m_actionFrameLyt = new QVBoxLayout(m_actionFrame);
m_actionFrameLyt->setContentsMargins(0, 0, 0, 0);
m_actionFrameLyt->setAlignment(Qt::AlignCenter);
m_actionLabel1 = new ActionLabel(tr("Start browser search"), m_currentActionKey, m_actionFrame);
m_actionLabel1->adjustSize();
m_actionFrameLyt->addWidget(m_actionLabel1);;
m_actionFrame->setLayout(m_actionFrameLyt);
m_detailLyt->addSpacing(166);
m_detailLyt->addWidget(m_iconLabel);
m_detailLyt->addSpacing(6);
m_detailLyt->addWidget(m_actionFrame);
m_detailPage->setLayout(m_detailLyt);
m_detailLyt->addStretch();
connect(m_actionLabel1, &ActionLabel::actionTriggered, [ & ](){
openAction(0, m_currentActionKey, 0);
});
}

View File

@ -0,0 +1,52 @@
#ifndef WEBSEARCHPLUGIN_H
#define WEBSEARCHPLUGIN_H
#include <QObject>
#include <QObject>
#include <QThreadPool>
#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFrame>
#include <QLabel>
#include <QAction>
#include "action-label.h"
#include "search-plugin-iface.h"
namespace Zeeker {
class LIBSEARCH_EXPORT WebSearchPlugin : public QObject, public SearchPluginIface
{
Q_OBJECT
public:
explicit WebSearchPlugin(QObject *parent = nullptr);
PluginType pluginType() {return PluginType::SearchPlugin;}
const QString name();
const QString description();
const QIcon icon() {return QIcon::fromTheme("folder");}
void setEnable(bool enable) {m_enable = enable;}
bool isEnable() {return m_enable;}
QString getPluginName();
void KeywordSearch(QString keyword,DataQueue<ResultInfo> *searchResult);
QList<SearchPluginIface::Actioninfo> getActioninfo(int type);
void openAction(int actionkey, QString key, int type);
QWidget *detailPage(const ResultInfo &ri);
private:
void initDetailPage();
QString m_keyWord;
QString m_currentActionKey;
QWidget *m_detailPage = nullptr;
QVBoxLayout *m_detailLyt = nullptr;
QLabel *m_iconLabel = nullptr;
QFrame *m_actionFrame = nullptr;
QVBoxLayout *m_actionFrameLyt = nullptr;
ActionLabel *m_actionLabel1 = nullptr;
QVBoxLayout * m_actionLyt = nullptr;
bool m_enable = true;
QList<WebSearchPlugin::Actioninfo> m_actionInfo;
};
}
#endif // WEBSEARCHPLUGIN_H

View File

@ -0,0 +1,7 @@
INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/web-search-plugin.h
SOURCES += \
$$PWD/web-search-plugin.cpp

View File

@ -4,7 +4,7 @@
<context>
<name>Zeeker::AppMatch</name>
<message>
<location filename="../../libsearch/appsearch/app-match.cpp" line="258"/>
<location filename="../../libsearch/appsearch/app-match.cpp" line="262"/>
<source>Application Description:</source>
<translation></translation>
</message>
@ -43,7 +43,6 @@
<translation></translation>
</message>
<message>
<location filename="../../libsearch/appsearch/app-search-plugin.cpp" line="25"/>
<location filename="../../libsearch/appsearch/app-search-plugin.cpp" line="30"/>
<location filename="../../libsearch/appsearch/app-search-plugin.cpp" line="35"/>
<source>Applications Search</source>
@ -79,7 +78,6 @@
<translation></translation>
</message>
<message>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="229"/>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="239"/>
<source>Dir Search</source>
<translation></translation>
@ -114,13 +112,13 @@
<name>Zeeker::FileContengSearchPlugin</name>
<message>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="398"/>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="597"/>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="596"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="399"/>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="598"/>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="597"/>
<source>Open path</source>
<translation></translation>
</message>
@ -130,9 +128,8 @@
<translation></translation>
</message>
<message>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="409"/>
<source>File Content Search</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="414"/>
@ -150,17 +147,17 @@
<translation></translation>
</message>
<message>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="572"/>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="571"/>
<source>Path</source>
<translation></translation>
</message>
<message>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="584"/>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="583"/>
<source>Last time modified</source>
<translation></translation>
</message>
<message>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="599"/>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="598"/>
<source>Copy path</source>
<translation></translation>
</message>
@ -185,7 +182,6 @@
<translation></translation>
</message>
<message>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="22"/>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="32"/>
<source>File Search</source>
<translation></translation>
@ -205,7 +201,7 @@
<location filename="../../libsearch/index/file-search-plugin.cpp" line="69"/>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="185"/>
<source>Can not get a default application for opening %1.</source>
<translation type="unfinished">%1</translation>
<translation>%1</translation>
</message>
<message>
<location filename="../../libsearch/index/file-search-plugin.cpp" line="93"/>
@ -247,7 +243,6 @@
<translation></translation>
</message>
<message>
<location filename="../../libsearch/notesearch/note-search-plugin.cpp" line="21"/>
<location filename="../../libsearch/notesearch/note-search-plugin.cpp" line="31"/>
<location filename="../../libsearch/notesearch/note-search-plugin.cpp" line="97"/>
<source>Note Search</source>
@ -284,12 +279,11 @@
<name>Zeeker::SettingsSearchPlugin</name>
<message>
<location filename="../../libsearch/settingsearch/settings-search-plugin.cpp" line="11"/>
<location filename="../../libsearch/settingsearch/settings-search-plugin.cpp" line="364"/>
<location filename="../../libsearch/settingsearch/settings-search-plugin.cpp" line="405"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="../../libsearch/settingsearch/settings-search-plugin.cpp" line="21"/>
<location filename="../../libsearch/settingsearch/settings-search-plugin.cpp" line="31"/>
<source>Settings Search</source>
<translation></translation>
@ -300,9 +294,24 @@
<translation></translation>
</message>
<message>
<location filename="../../libsearch/settingsearch/settings-search-plugin.cpp" line="350"/>
<location filename="../../libsearch/settingsearch/settings-search-plugin.cpp" line="391"/>
<source>Settings</source>
<translation></translation>
</message>
</context>
<context>
<name>Zeeker::WebSearchPlugin</name>
<message>
<location filename="../../libsearch/websearch/web-search-plugin.cpp" line="7"/>
<location filename="../../libsearch/websearch/web-search-plugin.cpp" line="94"/>
<source>Start browser search</source>
<translation></translation>
</message>
<message>
<location filename="../../libsearch/websearch/web-search-plugin.cpp" line="19"/>
<location filename="../../libsearch/websearch/web-search-plugin.cpp" line="24"/>
<source>Web Page</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -12,7 +12,7 @@
<context>
<name>Zeeker::BestListWidget</name>
<message>
<location filename="../../frontend/view/best-list-view.cpp" line="305"/>
<location filename="../../frontend/view/best-list-view.cpp" line="309"/>
<source>Best Matches</source>
<translation type="unfinished"></translation>
</message>
@ -243,7 +243,7 @@
<context>
<name>Zeeker::WebSearchWidget</name>
<message>
<location filename="../../frontend/view/web-search-view.cpp" line="149"/>
<location filename="../../frontend/view/web-search-view.cpp" line="150"/>
<source>Web Page</source>
<translation type="unfinished"></translation>
</message>

View File

@ -247,7 +247,7 @@
<context>
<name>Zeeker::BestListWidget</name>
<message>
<location filename="../../frontend/view/best-list-view.cpp" line="305"/>
<location filename="../../frontend/view/best-list-view.cpp" line="309"/>
<source>Best Matches</source>
<translation type="unfinished">En İyi Eşleşen</translation>
</message>
@ -616,7 +616,7 @@
<context>
<name>Zeeker::WebSearchWidget</name>
<message>
<location filename="../../frontend/view/web-search-view.cpp" line="149"/>
<location filename="../../frontend/view/web-search-view.cpp" line="150"/>
<source>Web Page</source>
<translation type="unfinished"></translation>
</message>

View File

@ -12,7 +12,7 @@
<context>
<name>Zeeker::BestListWidget</name>
<message>
<location filename="../../frontend/view/best-list-view.cpp" line="305"/>
<location filename="../../frontend/view/best-list-view.cpp" line="309"/>
<source>Best Matches</source>
<translation></translation>
</message>
@ -397,7 +397,7 @@
<context>
<name>Zeeker::WebSearchWidget</name>
<message>
<location filename="../../frontend/view/web-search-view.cpp" line="149"/>
<location filename="../../frontend/view/web-search-view.cpp" line="150"/>
<source>Web Page</source>
<translation type="unfinished"></translation>
</message>