fix: icon not updated on taskbar if icon name in desktop changed - #1700
fix: icon not updated on taskbar if icon name in desktop changed#1700BLumia wants to merge 1 commit into
Conversation
修复 desktop 文件中 Icon 字段的值变化后,任务栏上对应图标不会更新的问题 Log:
Reviewer's GuideThis PR fixes taskbar icon updates by correctly propagating dataChanged signals from the apps/desktop models through DockGlobalElementModel and RoleCombineModel, and strengthens tests to cover multiple-window-to-app mappings and proper dataChanged emission. Sequence diagram for taskbar icon update propagationsequenceDiagram
participant DesktopModel as DesktopModel_m_appsModel
participant DockModel as DockGlobalElementModel
participant TaskbarView as TaskbarView
DesktopModel->>DockModel: dataChanged(topLeft,bottomRight,roles)
loop each row i in [topLeft.row..bottomRight.row]
DockModel->>DesktopModel: index(i,0).data(DesktopIdRole)
DockModel->>DockModel: find id in m_data
alt id found
DockModel->>TaskbarView: dataChanged(index(pos,0), index(pos,0), roles)
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 针对 rolecombinemodel.cpp 的性能优化建议(当前实现已足够,此为可选优化)
// 若 m_indexMap 数据量增大,可维护反向映射
// 在类定义中添加:QMultiHash<QPair<int,int>, QPair<int,int>> m_reverseIndexMap;
// 修改后的 dataChanged 槽函数:
connect(m_minor, &QAbstractItemModel::dataChanged, this,
[this, majorRoles, func](const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList<int> &roles){
Q_UNUSED(roles)
QPair<int,int> minorPair;
for (int i = topLeft.row(); i <= bottomRight.row(); i++) {
for (int j = topLeft.column(); j <= bottomRight.column(); j++) {
minorPair = qMakePair(i, j);
// 使用 QMultiHash 的 values() 方法获取所有映射到该 minor 的 major 位置
QList<QPair<int,int>> majorPositions = m_reverseIndexMap.values(minorPair);
for (const auto &majorPos : majorPositions) {
auto majorIndex = sourceModel()->index(majorPos.first, majorPos.second);
if (!majorIndex.isValid())
continue;
auto minorIndex = func(majorIndex.data(majorRoles), m_minor);
if (!minorIndex.isValid())
continue;
// 更新映射关系
m_reverseIndexMap.remove(minorPair, majorPos);
auto newMinorPair = qMakePair(minorIndex.row(), minorIndex.column());
m_indexMap[majorPos] = newMinorPair;
m_reverseIndexMap.insert(newMinorPair, majorPos);
Q_EMIT dataChanged(majorIndex, majorIndex, m_minorRolesMap.values());
}
}
}
}); |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
修复 desktop 文件中 Icon 字段的值变化后,任务栏上对应图标不会更新的问题
根因(3 个问题)
注:如果在使用目前【最新】的 dde-application-manager 的话,可以使用
dde-dconfig set -a org.deepin.dde.application-manager -r org.deepin.dde.am.appoverride -s /dde-file-manager/wayland -k Icon -v 'deepin-music'来测试,dde-file-manager为要修改图标的 appid,wayland可以为 x11 或 wayland。这种测试方式不需要实际修改 desktop 文件。Log:
Summary by Sourcery
Ensure taskbar dock icons and combined role models correctly propagate dataChanged signals when underlying app or desktop entries change, especially for multiple windows mapped to the same application.
Bug Fixes:
Enhancements:
Tests: