Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SystemTrayIcon 设置 icon.name 无效 #212

Open
rb-union opened this issue Dec 9, 2024 · 1 comment
Open

SystemTrayIcon 设置 icon.name 无效 #212

rb-union opened this issue Dec 9, 2024 · 1 comment

Comments

@rb-union
Copy link

rb-union commented Dec 9, 2024

SUMMARY | 问题概要

SystemTrayIcon 设置 icon.name 图标查找失败,显示为齿轮图标。
/qquicklabsplatformiconloader.cpp#L35 未查找到图标。

QIcon QQuickLabsPlatformIconLoader::toQIcon() const
{
    QIcon fallback = QPixmap::fromImage(image());
    QIcon icon = QIcon::fromTheme(m_icon.name(), fallback);
    icon.setIsMask(m_icon.isMask());
    return icon;
}

icon的查找中 availableSizes() 为空则直接使用 fallback (qicon.cpp#L1415

QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
{
    QIcon icon = fromTheme(name);

    if (icon.isNull() || icon.availableSizes().isEmpty())
        return fallback;

    return icon;
}

和 dtkgui 这笔提交 chore: add proxyiconengine 有关,后续的 svg 图片默认 IconEngine 变成了 DDciIconEngine;
这笔提交处理了部分问题 fix: wrong availableSizes for DIconProxyEngine, 但 DDciIconEngine 没有处理 availableSizes()

DTK and OS VERSIONS | DTK&系统版本信息

Distribution: deepin V23
Package:

  • dde-qt6introduction: 6.0.24
  • libdtk6gui: 6.0.24

Minimal Reproducible Case Code | 最小复现案例代码

  1. 使用 SystemTrayIcon 组件
SystemTrayIcon {
    icon.name: "dde-file-manager"
}
  1. 在 Qt6 对 QIcon 单独测试
    qWarning() << "Icon exist: " << QIcon::fromTheme("dde-file-manager");
    qWarning() << "Icon is null: " << QIcon::fromTheme("dde-file-manager", QIcon());

OBSERVED RESULT | 观察到的结果

  1. 托盘显示齿轮图标,无对应的图标。

  2. 输出如下,查找到的图标中 availableSizes 也为空。

Icon exist:  QIcon("dde-file-manager",availableSizes[normal,Off]=QList(),cacheKey=0x200000000)
Icon is null:  QIcon(null)

EXPECTED RESULT | 期望的结果

图标显示和查找正常。

ADDITIONAL INFORMATION | 额外补充

No response

@rb-union
Copy link
Author

rb-union commented Dec 9, 2024

已有PR linuxdeepin/dtkgui#255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant