[Share Experiences] 图标的使用逻辑是什么?
Tofloor
poster avatar
thepoy
deepin
2022-02-06 05:40
Author

我当前使用的图标是 bloom

image.png

安装了sublime-merge后,使用的图标是:

image.png

bloom中没有此软件的图标,所以会fallback到哪里?

我从 /中查找了全部 sublime-merge.*,也不曾找到上图中显示的 sublime-merge图标样式,只有 sublime-text才是上图所示的图标。

可以确认的是,sublime-merge 的图标名没有问题:

[Desktop Entry]
...
Icon=sublime-merge
...

而且我在 ~/.local/share/icons/hicolor中也添加了 sublime-merge的图标:

image.png

可是其显示的图标仍然是sublime-text的图标,这让我感觉很疑惑。

Reply Favorite View the author
All Replies
deepin-superuser
deepin
2022-02-06 06:38
#1

你用的是bloom主题 应该有限吧图标放到bloom主题文件夹里边吧

Reply View the author
神末shenmo
deepin
Spark-App
Q&A Team
2022-02-06 07:09
#2

有时候确实有这个问题,之前一个Windows主题里面的某个spark相关图标优先级居然比星火的图标高

说明这样的错误匹配不是个例

@WangYaohua

Reply View the author
andktan
deepin
2022-02-06 17:50
#3

我用了个笨办法,把 /icons/下的有关这个浏览器的图标名都改完了,也不能去了这个logo,。

Reply View the author
Hibanaw
deepin
2022-02-07 03:08
#4
andktan

我用了个笨办法,把 /icons/下的有关这个浏览器的图标名都改完了,也不能去了这个logo,。

注销过吗?

Reply View the author
thepoy
deepin
2022-02-07 03:30
#5

画了一个 sublime-merge 的图标放到bloom中,已解决此问题

image.png

Reply View the author
andktan
deepin
2022-02-07 16:33
#6
Hibanaw

注销过吗?

没有,这样会不会弄错了影响系统呢

Reply View the author
andktan
deepin
2022-02-07 16:34
#7
Hibanaw

注销过吗?

没有,这样会不会弄错了影响系统呢

Reply View the author
忘记、过去
deepin
2022-02-07 18:01
#8
神末shenmo

有时候确实有这个问题,之前一个Windows主题里面的某个spark相关图标优先级居然比星火的图标高

说明这样的错误匹配不是个例

@WangYaohua

老问题了,edge 浏览器之前的图标匹配就没对过,被系统里 micorsoft 开头的图标替代了。desktop-entry-editor 也会被 desktop.svg 顶掉。

Reply View the author
HualetWang
deepin
2022-02-08 02:07
#9

DDE现在查找图标的逻辑应该是 https://github.com/lxqt/libqtxdg 的实现,按照 XDG Icon Spec 实现的,先在当前主题里面匹配 sublime-merge ,匹配不上的话会在当前主题匹配 sublime ,而不是去 hicolor 里面匹配 sublime-merge ,我也觉得奇怪,但是据 @zccrs 说标准是这么定的,快出来解释一下~

Reply View the author
zccrs
deepin
2022-02-08 21:24
#10

原因是因为图标名称中的 "-" 中划线有个特殊的规定,具体的标准在这里:https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html:
“The dash - character is used to separate levels of specificity in icon names, for all contexts other than MimeTypes. For instance, we use input-mouse as the generic item for all mouse devices, and we use input-mouse-usb for a USB mouse device. However, if the more specific item does not exist in the current theme, and does exist in a parent theme, the generic icon from the current theme is preferred, in order to keep consistent style.”

大概翻译一下意思是:“除了 Mimetypes 这一类图标,图标名中的中划线是用来进行图标分级的(注意是分级不是分类),比如 input-mouse-usb,如果当前主题中没有完全匹配的 input-mouse-usb 图标,只有通用的 input-mouse 图标,且它的父主题中有 input-mouse-usb,这时候也应该优先使用当前主题的 input-mouse 图标,而不是父主题中的 input-mouse-usb,目的是为了更严格的保持图标样式的统一性,也就是说尽可能的都用一个主题里的图标文件”。

这个规范藏的比较深,所以有些开发者没注意到就把它忽略了,再加上大家都习惯性的用 "AAA-BBB" 这种形式做图标分类用,chrome 安装 PWA 应用也有这样的问题,它给 PWA 程序创建的图标名叫 chrome-xxxxxxx,这就导致所有的 PWA 应用的图标都会使用到当前主题的 chrome.svg。也就是说,如果图标名中包含 "-",那就相当于是这个图标即便回退到通用图标也没有明显的影响,还有个例子就是类似于 cd-rom-dvd 和 cd-rom-vcd,在有这个规则的前提下,实现图标主题的这一方,可以偷懒不做这么多的特例图标,统一为 DVD 和 VCD 画一个 cd-rom 的图标就可以了,这样自己的图标主题即扩大覆盖范围,又节约了工作量。

对于楼主提到的 sublime-merge 应该是找到了 bloom 的父主题 Papirus 的 sublime.svg,但是这个算是个未定义行为,因为规范中也只提到了说优先使用当前主题里的通用图标,当前主题是 bloom,但是通用图标却是在 Papirus 里,标准中倒是没有特别说明通用图标是否应该继承,不过目前 qtxdg 的确是这样实现的。其实正常来说,对于 sublime-xxxx chrome-xxxx 这种命名需求,应该避免使用 "-",因为无论在什么情况下,都不应该让它回退到使用 sublime 图标(这样就无法通过图标区分了),可以改成用 "_" 下划线避免这样的问题。

Reply View the author
zccrs
deepin
2022-02-08 21:26
#11
忘记、过去

老问题了,edge 浏览器之前的图标匹配就没对过,被系统里 micorsoft 开头的图标替代了。desktop-entry-editor 也会被 desktop.svg 顶掉。

这个问题已经给 chrome 报了 bug,不过貌似他们没理解是啥情况,我得录个视频解释一下。

Reply View the author
zccrs
deepin
2022-02-08 22:22
#12

另外给 qtxdg 提了个 PR,看会不会被接受吧 https://github.com/lxqt/libqtxdg/pull/273。如果能合,我们就在 DDE 里默认关闭这个 fallback 行为。

Reply View the author
忘记、过去
deepin
2022-02-09 01:33
#13
zccrs

另外给 qtxdg 提了个 PR,看会不会被接受吧 https://github.com/lxqt/libqtxdg/pull/273。如果能合,我们就在 DDE 里默认关闭这个 fallback 行为。

感谢解答,大佬辛苦啦~tail

Reply View the author