[fix][ui] not displaying the default type icon besides the package when its icon path does not exist

This commit is contained in:
Vinicius Moreira
2020-06-16 15:03:44 -03:00
parent 4a95bd1abb
commit 80de6a9103
2 changed files with 11 additions and 7 deletions

View File

@@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- not calling initial required tasks after enabling a new package type on settings
- not updating the type filters if only type is available after refreshing the table
- displaying the type filters on the search results when there is only one type available and some actions are done
- not displaying the default type icon besides the package when its icon path does not exist (Snap runtimes are not displaying icons)
- minor fixes
- Tray
- update notifications not working on Ubuntu 18.04

View File

@@ -409,13 +409,16 @@ class AppsTable(QTableWidget):
icon_path = pkg.model.get_disk_icon_path()
if pkg.model.installed and pkg.model.supports_disk_cache() and icon_path:
if icon_path.startswith('/') and os.path.isfile(icon_path):
with open(icon_path, 'rb') as f:
icon_bytes = f.read()
pixmap = QPixmap()
pixmap.loadFromData(icon_bytes)
icon = QIcon(pixmap)
self.icon_cache.add_non_existing(pkg.model.icon_url, {'icon': icon, 'bytes': icon_bytes})
if icon_path.startswith('/'):
if os.path.isfile(icon_path):
with open(icon_path, 'rb') as f:
icon_bytes = f.read()
pixmap = QPixmap()
pixmap.loadFromData(icon_bytes)
icon = QIcon(pixmap)
self.icon_cache.add_non_existing(pkg.model.icon_url, {'icon': icon, 'bytes': icon_bytes})
else:
icon = QIcon(pkg.model.get_default_icon_path())
else:
try:
icon = QIcon.fromTheme(icon_path)