特别说明:本人小白,希望一起让deepin更好用,也不知道对大家有没有用,代码改动和以下描述由AI生成,但我在自己电脑上编译测试,以下描述的实测情况部分已核实。
本说明配套补丁文件:dde-grand-search-user-changes.patch(基于官方 main HEAD ee08269,6.1.2,可直接 git apply) 官方最新 main 源码包:dde-grand-search_official-main_6.1.2.zip(HEAD = ee08269,版本 6.1.2)
dde-grand-search-user-changes.patch
ee08269
6.1.2
git apply
dde-grand-search_official-main_6.1.2.zip
DDE 全局搜索(dde-grand-search)日常使用中的几个痛点:
~/.cache/thumbnails
本改动集解决以上问题,并顺带修复两处代码缺陷(预览插件加载器泄漏、openInFileManager 不选中文件)。
openInFileManager
参照 Listary 的全量结果浏览器,与主搜索框互补:
src/grand-search/gui/resultbrowser/resultbrowserwindow.cpp/.h
src/grand-search/gui/resultbrowser/resultbrowserpreview.cpp/.h
src/grand-search/gui/resultbrowser/pdfpreview.cpp/.h
src/grand-search/gui/mainwindow.cpp/.h
mainwindow_p.h
showResultsBrowser()
onShowAllResults()
onBrowserSearchTextChanged()
closeEvent
src/grand-search/main.cpp
--show-results
setQuitOnLastWindowClosed(false)
newInstanceStarted
src/grand-search/gui/entrance/entrancewidget.cpp/.h/_p.h
sigShowAllResults
setSearchText()/searchText()
src/grand-search/dde-grand-search.desktop
NoDisplay=false
Exec=--show-results
X-Deepin-Singleton
src/grand-search/dde-grand-search-results.desktop
src/grand-search/gui/iconbutton.cpp
src/grand-search/CMakeLists.txt
deepin-pdfium
X11
参照 Listary 的搜索语法,支持:多关键字全部命中(AND)、排除词、类型过滤、目录限定、全角空格归一化。
src/dde-grand-search-daemon/searcher/file/filesearchutils.cpp/.h
parseContent
/目录片段
-排除词
doc:
pic:
video:
audio:
zip:
exe:
pdf:
ext:xxx,yyy
\u3000
matchScope()
src/dde-grand-search-daemon/searcher/file/filenameworker.cpp
AND
src/dde-grand-search-daemon/searcher/app/desktopappworker.cpp/.h
src/dde-grand-search-daemon/searcher/web/statictextworker.cpp
src/dde-grand-search-daemon/maincontroller/maincontroller.cpp
src/global/searchhelper.h
DOCUMENT_SUFFIX
uof/uos/uop/uot/uott/uost/uopt/dps/et/ett/dpt/ofd
PICTURE_SUFFIX
webp/ico/heic
searchedit.cpp/.h
entrancewidget
exhibitionwidget
matchwidget
grandsearchlistview
mainwindow
utils.cpp/.h
jumpPathToDialog
org.freedesktop.FileManager1 ShowItems
showFileItem
utils::openInFileManager
jumpPathToDialog 移植自同名已验证工具(savejump)的完整时序:独立后台脚本(QProcess::startDetached,不受浮窗关闭/进程退出影响)→ xclip 写路径并回读验证(失败中止,杜绝粘旧剪贴板)→ xdotool windowactivate --sync + windowfocus 激活目标窗口 → Ctrl+L 连发两次(WPS 首次会丢)→ 全选+粘贴+回车 → Alt+N 兼容确认 → 1s 后剪贴板仍为路径才按原类型恢复(文本/文件 uri-list 均恢复)。
QProcess::startDetached
xclip
xdotool windowactivate --sync
windowfocus
src/dde-grand-search-daemon/searcher/fulltext/fulltextworker.cpp
GRANDSEARCH_GROUP_FILE_FULLTEXT
src/global/builtinsearch.h
src/grand-search/gui/datadefine.h
GroupName_File
GroupName_Fulltext
src/grand-search/gui/exhibition/matchresult/groupwidget.cpp
src/grand-search/gui/exhibition/matchresult/matchwidget.cpp
locateItem()/jumpItem()
src/grand-search/utils/utils.cpp
updateItemsWeight
packageBestMatch
openMatchedItemWithCtrl
src/grand-search/gui/handlevisibility/handlevisibility.cpp
src/grand-search/gui/mainwindow.cpp
activeMainWindow()
XSetInputFocus
XRaiseWindow
src/grand-search/thumbnail/thumbnailcache.cpp/.h
clearDiskCache()
src/grand-search/gui/exhibition/preview/previewpluginmanager.cpp
m_plugins
pPlugin
new QPluginLoader
src/global/framelogmanager.cpp/.h
writeGsDebugLog()
官方 4fac05b → ee08269(6.1.2)只改了 2 个文件:debian/changelog(版本号)和 searchhintwidget.cpp(搜索提示富文本/索引提示,27 行)。本改动集未触及 searchhintwidget.cpp,故不存在"官方已修复、本改动重复"的条目;全部 46 个文件的改动在官方 main 中均为新增或修改,无重叠。
4fac05b → ee08269
debian/changelog
searchhintwidget.cpp
clean_build.sh
src/grand-search/utils/keylistener.cpp/.h
src/grand-search/utils/pathinserter.cpp/.h
CMakeLists.txt
Xtst
以 git apply 应用补丁后,与用户改版源码逐文件 diff,仅 4 个文件存在差异,全部为设计内调整:
diff
其余 42 个文件(含 resultbrowser 6 个新增文件)与用户改版字节级一致。清理的 2 处行尾空白属于"行尾空格误用"(git apply 会发 warning 但不影响应用),为提交上游的整洁性而清理,功能零影响。
XGetInputFocus
xdotool
sudo apt install xdotool xclip
用户实测环境:deepin 25 x86_64(X11)。
ext:
# 基于官方 main(HEAD = ee08269) git apply dde-grand-search-user-changes.patch # 或 git am < dde-grand-search-user-changes.patch # 若需保留提交信息,需先为 patch 补 From/Subject 头
构建依赖:sudo apt install xdotool xclip libdeepin-pdfium-dev
sudo apt install xdotool xclip libdeepin-pdfium-dev
新增的结果筛选界面截图:
patch文件:dde-grand-search-user-changes.zip
amd64.deb(x86_64):dde-grand-search_6.1.2_amd64.zip
简要使用说明:
No replies yet
Featured Collection
Popular Ranking
Popular Events
特别说明:本人小白,希望一起让deepin更好用,也不知道对大家有没有用,代码改动和以下描述由AI生成,但我在自己电脑上编译测试,以下描述的实测情况部分已核实。
dde-grand-search 增强改动集
一、背景与动机
DDE 全局搜索(dde-grand-search)日常使用中的几个痛点:
~/.cache/thumbnails写磁盘缓存,个人使用场景下不必要。本改动集解决以上问题,并顺带修复两处代码缺陷(预览插件加载器泄漏、
openInFileManager不选中文件)。二、功能改动清单
1. 搜索结果浏览面板("全部结果"窗口)— 新增
参照 Listary 的全量结果浏览器,与主搜索框互补:
src/grand-search/gui/resultbrowser/resultbrowserwindow.cpp/.h(新增)src/grand-search/gui/resultbrowser/resultbrowserpreview.cpp/.h(新增)src/grand-search/gui/resultbrowser/pdfpreview.cpp/.h(新增)src/grand-search/gui/mainwindow.cpp/.h、mainwindow_p.hshowResultsBrowser()、onShowAllResults()、onBrowserSearchTextChanged()、面板与主框互斥显示、closeEvent常驻逻辑、析构释放src/grand-search/main.cpp--show-results启动参数;setQuitOnLastWindowClosed(false)进程常驻;newInstanceStarted重复启动分流(面板有会话→恢复面板,否则→弹主搜索框)src/grand-search/gui/entrance/entrancewidget.cpp/.h/_p.hsigShowAllResults信号 +setSearchText()/searchText()src/grand-search/dde-grand-search.desktopNoDisplay=false、Exec=--show-results、移除X-Deepin-Singletonsrc/grand-search/dde-grand-search-results.desktop(新增)src/grand-search/gui/iconbutton.cppsrc/grand-search/CMakeLists.txtdeepin-pdfium、X112. 高级搜索语法 — 文件/应用/全文搜索全面升级
参照 Listary 的搜索语法,支持:多关键字全部命中(AND)、排除词、类型过滤、目录限定、全角空格归一化。
src/dde-grand-search-daemon/searcher/file/filesearchutils.cpp/.hparseContent全面重写:/目录片段限定(路径某级目录需包含该片段);-排除词(条目自身名称不得包含);类型过滤doc:pic:video:audio:zip:exe:pdf:ext:xxx,yyy(自定义扩展名,兼容带点/不带点、逗号分隔);全角空格\u3000归一化为半角;matchScope():统一后置过滤(目录片段/排除词/扩展名),不依赖 dfm-search 库层;src/dde-grand-search-daemon/searcher/file/filenameworker.cppAND(多关键字必须全部命中);matchScope()后置过滤;src/dde-grand-search-daemon/searcher/app/desktopappworker.cpp/.h:多关键字 AND 精筛;/目录片段、-排除词、doc:等类型词不作用于应用搜索(剥离后仅保留包含词,只有类型/排除词时应用不参与);src/dde-grand-search-daemon/searcher/web/statictextworker.cpp:剥离仅对文件搜索生效的语法词,避免污染搜索引擎关键词;src/dde-grand-search-daemon/maincontroller/maincontroller.cpp:检测到冒号即走本地解析分支,保持原文不转 JSON,仅激活文件搜索;src/global/searchhelper.h:DOCUMENT_SUFFIX扩充国产办公格式(uof/uos/uop/uot/uott/uost/uopt/dps/et/ett/dpt/ofd);PICTURE_SUFFIX扩充webp/ico/heic(与pic:类型过滤口径一致)。3. 快捷键增强
searchedit.cpp/.h、entrancewidget、exhibitionwidget、matchwidget、grandsearchlistview、mainwindow(showEvent 记录呼出前 X11 焦点窗口)、utils.cpp/.h(jumpPathToDialog)org.freedesktop.FileManager1 ShowItems,deepin 25 的showFileItem只打开目录不选中,故改用标准接口)utils::openInFileManagerjumpPathToDialog移植自同名已验证工具(savejump)的完整时序:独立后台脚本(QProcess::startDetached,不受浮窗关闭/进程退出影响)→xclip写路径并回读验证(失败中止,杜绝粘旧剪贴板)→xdotool windowactivate --sync+windowfocus激活目标窗口 → Ctrl+L 连发两次(WPS 首次会丢)→ 全选+粘贴+回车 → Alt+N 兼容确认 → 1s 后剪贴板仍为路径才按原类型恢复(文本/文件 uri-list 均恢复)。4. 搜索结果分组与权重优化
src/dde-grand-search-daemon/searcher/fulltext/fulltextworker.cpp:内容命中的结果统一归入新增的"包含该内容的文件"分组(GRANDSEARCH_GROUP_FILE_FULLTEXT),不再按文件类型散落,避免与文件名命中混在一起;src/global/builtinsearch.h:新增GRANDSEARCH_GROUP_FILE_FULLTEXT分组键;src/grand-search/gui/datadefine.h:GroupName_File改为"其他文件"(与"文档/图片/视频/音频"并列语义清晰)、新增GroupName_Fulltext;src/grand-search/gui/exhibition/matchresult/groupwidget.cpp:FULLTEXT 分组显示名映射;src/grand-search/gui/exhibition/matchresult/matchwidget.cpp:分组显示顺序重排(类型区→设置/应用/网页→内容命中区);内容命中区前插入分隔线;locateItem()/jumpItem()实现;src/grand-search/utils/utils.cppupdateItemsWeight:文件名命中额外加权 +2000(仅对文件名搜索项,确保"文件名匹配"优先于"内容匹配");packageBestMatch:文件夹组移出黑名单(文件夹名匹配可进"最佳结果");openMatchedItemWithCtrl:扩展支持全文/语义/OCR 来源的文件定位。5. 模态场景与进程常驻适配
src/grand-search/gui/handlevisibility/handlevisibility.cppsrc/grand-search/gui/mainwindow.cpp:activeMainWindow()增加 X11XSetInputFocus+XRaiseWindow显式抢焦点兜底(绕过模态窗口限制);closeEvent:面板有会话→仅隐藏主窗、进程常驻;无会话→按官方原版退出;src/grand-search/main.cpp:进程常驻 + 重复启动分流(见第 1 节)。6. 其他改进与缺陷修复
src/grand-search/thumbnail/thumbnailcache.cpp/.h~/.cache/thumbnails磁盘缓存读写(不再与文管共用磁盘缓存、不产生缓存文件),删除clearDiskCache()等废弃接口src/grand-search/gui/exhibition/preview/previewpluginmanager.cppm_plugins导致pPlugin赋值丢失、每次预览重复new QPluginLoader且不释放(插件库泄漏)——改为引用遍历src/global/framelogmanager.cpp/.hwriteGsDebugLog()保留空实现兼容既有调用点三、与官方 main 的甄别结论
官方
4fac05b → ee08269(6.1.2)只改了 2 个文件:debian/changelog(版本号)和searchhintwidget.cpp(搜索提示富文本/索引提示,27 行)。本改动集未触及searchhintwidget.cpp,故不存在"官方已修复、本改动重复"的条目;全部 46 个文件的改动在官方 main 中均为新增或修改,无重叠。四、排除项说明(未进 patch)
clean_build.shsrc/grand-search/utils/keylistener.cpp/.hsrc/grand-search/utils/pathinserter.cpp/.hCMakeLists.txt中的Xtst链接五、补丁与改版源码的字节级差异(应用后比对结果)
以
git apply应用补丁后,与用户改版源码逐文件diff,仅 4 个文件存在差异,全部为设计内调整:debian/changelogsrc/grand-search/CMakeLists.txtXtst链接src/grand-search/gui/mainwindow.cppgit apply无警告src/grand-search/main.cpp其余 42 个文件(含 resultbrowser 6 个新增文件)与用户改版字节级一致。清理的 2 处行尾空白属于"行尾空格误用"(git apply 会发 warning 但不影响应用),为提交上游的整洁性而清理,功能零影响。
七、依赖变化
deepin-pdfium(PDF 预览)、X11 库(XSetInputFocus/XGetInputFocus);xdotool、xclip(Alt+Enter 路径插入,deepin 默认未装 xdotool,需sudo apt install xdotool xclip);八、测试情况
用户实测环境:deepin 25 x86_64(X11)。
-排除词、doc:/pic:/video:/audio:/zip:/exe:/pdf:/ext:类型过滤、/目录片段限定、全角空格——通过;九、已知限制与风险
matchScope()就是为了规避库层 "Boolean+fileExtensions" 组合在不同版本上的行为差异(部分版本返回 0 结果),代价是大结果集下过滤在进程内完成,搜索速度略降;setQuitOnLastWindowClosed(false)使主搜索框关闭后进程驻留(供结果面板恢复),内存占用略增,符合"任务栏图标可再次打开面板"的设计意图;十、补丁使用方式
构建依赖:
sudo apt install xdotool xclip libdeepin-pdfium-dev新增的结果筛选界面截图:

patch文件:dde-grand-search-user-changes.zip
amd64.deb(x86_64):dde-grand-search_6.1.2_amd64.zip
简要使用说明: