Skip to content

refactor(icons): centralize icon resolution into Paths.resolveIconPath/resolveIconUrl#1880

Merged
Purian23 merged 1 commit intoAvengeMedia:masterfrom
odtgit:refactor/centralize-icon-resolution
Mar 1, 2026
Merged

refactor(icons): centralize icon resolution into Paths.resolveIconPath/resolveIconUrl#1880
Purian23 merged 1 commit intoAvengeMedia:masterfrom
odtgit:refactor/centralize-icon-resolution

Conversation

@odtgit
Copy link
Contributor

@odtgit odtgit commented Mar 1, 2026

Summary

Supersedes #1878. An audit of all icon resolution paths found 8 components that resolve icons via Quickshell.iconPath() or image://icon/ URLs without checking appIdSubstitutions. Rather than adding the same 8-line inline pattern to each file (#1878), this PR centralizes the logic into two new functions in Paths.qml:

  • resolveIconPath(iconName) — for Quickshell.iconPath() callsites, handles substitution + file path detection + DesktopService.resolveIconPath() fallback
  • resolveIconUrl(iconName) — for image://icon/ URL callsites, same substitution logic

All consumer files now use one-line calls instead of duplicated inline blocks.

Why substitutions are needed

Qt6's QIcon::fromTheme() has a limitation where it silently resolves some icon names (e.g. PWA icons like chrome-xxx-Default) to the generic browser icon instead of the actual icon installed in ~/.local/share/icons/hicolor/. This was confirmed via pixel-level comparison. Icons bundled in the active system theme (e.g. Qogir ships YouTube) work; others don't. This is a Qt upstream issue. The appIdSubstitutions feature lets users map broken icon names to direct file paths, bypassing Qt's theme lookup.

Zero cost for non-users

When no substitutions match, moddedAppId() returns the original icon name unchanged (identity), so the existing Quickshell.iconPath() / image://icon/ path executes exactly as before.

Files changed (9)

File Change
Common/Paths.qml Add resolveIconPath(), resolveIconUrl(), simplify getAppIcon()
Widgets/AppIconRenderer.qml 8 lines inline → Paths.resolveIconPath()
Notifications/Center/NotificationCard.qml (×2) Quickshell.iconPath(appIcon, true)Paths.resolveIconPath(appIcon)
Notifications/Popup/NotificationPopup.qml Same
Notifications/Center/HistoryNotificationCard.qml Same
Dock/DockContextMenu.qml Same
DankBar/Widgets/AppsDockContextMenu.qml Same
Modals/DankLauncherV2/LauncherContent.qml "image://icon/" + iconPaths.resolveIconUrl()
Modules/Settings/LauncherTab.qml (×3) Same

Test plan

  • Configure regex appIdSubstitutions mapping PWA app_ids to file paths
  • Verify PWA icons display correctly in: taskbar, launcher, dock right-click menus, launcher settings
  • Verify non-PWA apps are unaffected (no substitution → original path unchanged)
  • Verify fallback icons still work for apps with no icon

…h/resolveIconUrl

Supersedes AvengeMedia#1878. Rather than duplicating the moddedAppId + file path
substitution pattern inline across 8 files, this introduces two
centralized functions in Paths.qml:

- resolveIconPath(iconName): for Quickshell.iconPath() callsites,
  with DesktopService.resolveIconPath() fallback
- resolveIconUrl(iconName): for image://icon/ URL callsites

All consumer files now use one-line calls. When no substitutions are
configured, moddedAppId() returns the original name unchanged (zero
cost), so this has no impact on users who don't use the feature.

Affected components:
- AppIconRenderer (8 lines → 1)
- NotificationCard, NotificationPopup, HistoryNotificationCard
- DockContextMenu, AppsDockContextMenu
- LauncherContent, LauncherTab (×3)
@Purian23 Purian23 merged commit 0f8e0bc into AvengeMedia:master Mar 1, 2026
1 check passed
Purian23 added a commit that referenced this pull request Mar 1, 2026
- Consistent with the
appIcon PR changes in #1880.
@Purian23
Copy link
Collaborator

Purian23 commented Mar 1, 2026

Thanks!

@odtgit odtgit deleted the refactor/centralize-icon-resolution branch March 3, 2026 16:11
bbedward pushed a commit that referenced this pull request Mar 10, 2026
…h/resolveIconUrl (#1880)

Supersedes #1878. Rather than duplicating the moddedAppId + file path
substitution pattern inline across 8 files, this introduces two
centralized functions in Paths.qml:

- resolveIconPath(iconName): for Quickshell.iconPath() callsites,
  with DesktopService.resolveIconPath() fallback
- resolveIconUrl(iconName): for image://icon/ URL callsites

All consumer files now use one-line calls. When no substitutions are
configured, moddedAppId() returns the original name unchanged (zero
cost), so this has no impact on users who don't use the feature.

Affected components:
- AppIconRenderer (8 lines → 1)
- NotificationCard, NotificationPopup, HistoryNotificationCard
- DockContextMenu, AppsDockContextMenu
- LauncherContent, LauncherTab (×3)

Co-authored-by: odtgit <odtgit@taliops.com>
bbedward pushed a commit that referenced this pull request Mar 10, 2026
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

Successfully merging this pull request may close these issues.

2 participants