fix(dock): prioritize theme icon over cached window icon in preview#1451
Open
Ivy233 wants to merge 1 commit intolinuxdeepin:masterfrom
Open
fix(dock): prioritize theme icon over cached window icon in preview#1451Ivy233 wants to merge 1 commit intolinuxdeepin:masterfrom
Ivy233 wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
When switching icon themes, the window preview icons were not updating because the code prioritized WinIconRole (Base64-encoded cached window icon data from X11 properties) over IconNameRole (theme icon name from desktop files). This change reverses the priority to use IconNameRole first, which loads icons dynamically from the current theme via QIcon::fromTheme(). Only when IconNameRole is empty does it fall back to WinIconRole. This ensures preview icons follow theme changes immediately, fixing the issue where old and new theme icons appeared mixed after switching themes. Influence: 1. Window preview icons now update immediately when switching icon themes 2. All preview icons display consistently in the current theme style 3. Fallback to cached window icons still works for windows without desktop files 4. No impact on preview functionality or performance fix(dock): 预览窗口优先使用主题图标而非缓存的窗口图标 切换图标主题时,窗口预览图标未更新,因为代码优先使用 WinIconRole (从 X11 属性获取的 Base64 编码缓存窗口图标数据)而非 IconNameRole (从 desktop 文件获取的主题图标名称)。 此更改反转了优先级,优先使用 IconNameRole,通过 QIcon::fromTheme() 从当前主题动态加载图标。仅当 IconNameRole 为空时才回退到 WinIconRole。 这确保预览图标立即跟随主题变化,修复了切换主题后新旧主题图标混合 显示的问题。 Influence: 1. 切换图标主题时窗口预览图标立即更新 2. 所有预览图标以当前主题样式一致显示 3. 对于没有 desktop 文件的窗口,仍可回退到缓存的窗口图标 4. 不影响预览功能和性能 PMS: BUG-341117
Reviewer's guide (collapsed on small PRs)Reviewer's GuideReorders icon selection priority in the X11 dock window preview so that theme-based icons (IconNameRole) are used first and cached window icons (WinIconRole) are only used as a fallback, ensuring preview icons reflect current theme changes immediately while preserving a safe fallback path; also updates the SPDX copyright years. Sequence diagram for updated icon selection in X11 window previewsequenceDiagram
actor User
participant Dock as DockPanel
participant TaskModel as TaskManagerModel
participant Preview as X11WindowPreviewContainer
User->>Dock: Hover window item
Dock->>Preview: previewWindow(winId)
Preview->>TaskModel: data(index, IconNameRole)
TaskModel-->>Preview: iconName
alt iconName is not empty
Preview->>Preview: updatePreviewIconFromString(iconName)
else iconName is empty
Preview->>TaskModel: data(index, WinIconRole)
TaskModel-->>Preview: winIconData
Preview->>Preview: updatePreviewIconFromString(winIconData)
end
Preview->>TaskModel: data(index, WinTitleRole)
TaskModel-->>Preview: winTitle
Preview->>Preview: updatePreviewTitle(winTitle)
Preview-->>Dock: Preview updated with theme-aware icon
Dock-->>User: Show window preview with correct theme icon
Class diagram for X11WindowPreviewContainer icon selection changesclassDiagram
class X11WindowPreviewContainer {
- X11WindowMonitor* m_monitor
+ X11WindowPreviewContainer(X11WindowMonitor* monitor, QWidget* parent)
+ void showPreviewWithModel(QAbstractItemModel* sourceModel)
+ void updatePreviewIconFromString(QString iconData)
+ void updatePreviewTitle(QString title)
}
class X11WindowMonitor {
+ void previewWindow(int winId)
}
class QAbstractItemModel {
+ int rowCount(QModelIndex parent)
+ QModelIndex index(int row, int column, QModelIndex parent)
+ QVariant data(QModelIndex index, int role)
}
class QModelIndex {
+ int row()
+ int column()
+ bool isValid()
}
class QVariant {
+ QString toString()
+ int toInt()
}
class TaskManagerRoles {
<<enumeration>>
WinIdRole
WinIconRole
IconNameRole
WinTitleRole
}
X11WindowPreviewContainer --> X11WindowMonitor : uses
X11WindowPreviewContainer --> QAbstractItemModel : reads preview data
QAbstractItemModel --> QModelIndex : creates
X11WindowPreviewContainer --> QModelIndex : selects item
X11WindowPreviewContainer --> QVariant : handles role data
X11WindowPreviewContainer ..> TaskManagerRoles : accesses roles
%% Icon selection logic (new priority)
class IconSelectionPolicy {
+ QString selectIcon(QAbstractItemModel* model, QModelIndex index)
}
X11WindowPreviewContainer ..> IconSelectionPolicy : uses
%% Conceptual behavior of IconSelectionPolicy:
%% 1. Try IconNameRole (theme icon name, follows theme changes)
%% 2. If empty, fall back to WinIconRole (cached window icon)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When switching icon themes, the window preview icons were not updating because the code prioritized WinIconRole (Base64-encoded cached window icon data from X11 properties) over IconNameRole (theme icon name from desktop files).
This change reverses the priority to use IconNameRole first, which loads icons dynamically from the current theme via QIcon::fromTheme(). Only when IconNameRole is empty does it fall back to WinIconRole.
This ensures preview icons follow theme changes immediately, fixing the issue where old and new theme icons appeared mixed after switching themes.
Influence:
fix(dock): 预览窗口优先使用主题图标而非缓存的窗口图标
切换图标主题时,窗口预览图标未更新,因为代码优先使用 WinIconRole
(从 X11 属性获取的 Base64 编码缓存窗口图标数据)而非 IconNameRole
(从 desktop 文件获取的主题图标名称)。
此更改反转了优先级,优先使用 IconNameRole,通过 QIcon::fromTheme()
从当前主题动态加载图标。仅当 IconNameRole 为空时才回退到 WinIconRole。
这确保预览图标立即跟随主题变化,修复了切换主题后新旧主题图标混合
显示的问题。
Influence:
PMS: BUG-341117
Summary by Sourcery
Bug Fixes: