|
1 | 1 | from typing import Optional |
2 | 2 |
|
3 | 3 | from PySide6.QtCore import QModelIndex, QRect, QSize, Qt |
4 | | -from PySide6.QtGui import QColor, QFontMetrics, QPainter, QPixmap |
| 4 | +from PySide6.QtGui import QColor, QFontMetrics, QPainter |
5 | 5 | from PySide6.QtWidgets import QListView, QStyle, QStyleOptionViewItem |
6 | 6 | from qfluentwidgets import FluentIcon, ListItemDelegate, drawIcon, isDarkTheme |
7 | 7 | from qfluentwidgets.common.color import autoFallbackThemeColor, themeColor |
8 | 8 | from qfluentwidgets.common.font import getFont |
9 | 9 |
|
10 | | -from app_blocker.appBlockerBackend import AppKind |
| 10 | +from app_blocker.appBlockerBackend import AppKind, InstalledApp |
11 | 11 | from models.appPickerListModel import AppPickerListModel, AppPickerModelItem |
12 | 12 |
|
13 | 13 |
|
@@ -97,10 +97,12 @@ def _paintCheckbox(self, painter: QPainter, option: QStyleOptionViewItem, item: |
97 | 97 |
|
98 | 98 | painter.restore() |
99 | 99 |
|
100 | | - def _paintIcon(self, painter: QPainter, icon_rect: QRect, pixmap: Optional[QPixmap]) -> None: |
| 100 | + def _paintIcon(self, painter: QPainter, icon_rect: QRect, app: InstalledApp) -> None: |
101 | 101 | painter.save() |
102 | | - if pixmap is not None and not pixmap.isNull(): |
103 | | - painter.drawPixmap(icon_rect, pixmap) |
| 102 | + # app_icon validates the file decodes (and warms the engine's base pixmap), the icon is then |
| 103 | + # painted through its engine so dpr scaling and pixmap caching (QPixmapCache) are Qt's job |
| 104 | + if app.app_icon is not None: |
| 105 | + app.app_qicon.paint(painter, icon_rect) |
104 | 106 | else: |
105 | 107 | # draw a rounded placeholder with an application icon when the app has no icon |
106 | 108 | c = 255 if isDarkTheme() else 0 |
@@ -196,7 +198,7 @@ def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIn |
196 | 198 | self._paintBackgroundAndIndicator(painter, option, index) |
197 | 199 | self._paintCheckbox(painter, option, item) |
198 | 200 |
|
199 | | - self._paintIcon(painter, self._getIconRect(option), item.app.app_icon) |
| 201 | + self._paintIcon(painter, self._getIconRect(option), item.app) |
200 | 202 |
|
201 | 203 | badge_word = "Blocked" if item.already_blocked else item.app.kind.value.capitalize() |
202 | 204 | text_rect = self._getTextRect(option) |
|
0 commit comments