fix: 通过第三方插件的pluginName属性从系统加载图标

任务栏的控制中心插件只配置了固定的几个内置插件图标,第三方的插件无法获取图标文件,需要第三方插件根据pluginName属性将图标文件安装到系
统,任务栏插件再根据名称从系统中获取

Log: 优化插件图标获取方法
Task: https://pms.uniontech.com/task-view-122345.html
Influence: 任务栏的控制中心插件能根据插件名称获取插件图标
Change-Id: Ie2b75a26d5dae350fe3f36e635aa65bc2d34ce58
This commit is contained in:
chenjun 2022-05-09 14:44:41 +08:00 committed by wubw
parent 2f12ecc228
commit 47d086405f

View File

@ -334,7 +334,22 @@ void ModuleWidget::initUI()
// 插件图标
auto leftAction = new DViewItemAction(Qt::AlignVCenter, size, size, true);
leftAction->setIcon(QIcon::fromTheme(pluginIconMap.value(m_dockInter->getPluginKey(name), "dcc_dock_plug_in")));
const QString pluginKey = m_dockInter->getPluginKey(name);
QIcon pluginIcon;
// 第三方插件通过pluginKey从系统中读取图标
if (pluginIconMap.contains(pluginKey)) {
pluginIcon = QIcon::fromTheme(pluginIconMap.value(m_dockInter->getPluginKey(name)));
} else {
pluginIcon = QIcon::fromTheme(pluginKey);
}
// 如果获取不到图标则使用默认图标
if (pluginIcon.isNull()) {
pluginIcon = QIcon::fromTheme("dcc_dock_plug_in");
}
leftAction->setIcon(pluginIcon);
item->setActionList(Qt::Edge::LeftEdge, {leftAction});
auto rightAction = new DViewItemAction(Qt::AlignVCenter, size, size, true);