Caching icon loaded from disk

This commit is contained in:
Vinícius Moreira
2019-07-11 17:02:44 -03:00
committed by GitHub
parent 4d3abfcf89
commit 2f4fc0335d
2 changed files with 8 additions and 4 deletions

View File

@@ -81,9 +81,7 @@ class FlatpakAsyncDataLoader(Thread):
break
else:
self.log_msg(
"Could not retrieve app data for id '{}'. Server response: {}. Body: {}".format(
app.base_data.id, res.status_code, res.content.decode()), Fore.RED)
self.log_msg("Could not retrieve app data for id '{}'. Server response: {}. Body: {}".format(app.base_data.id, res.status_code, res.content.decode()), Fore.RED)
except:
self.log_msg("Could not retrieve app data for id '{}'".format(app.base_data.id), Fore.YELLOW)
traceback.print_exc()

View File

@@ -237,7 +237,13 @@ class AppsTable(QTableWidget):
col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
if app_v.model.supports_disk_cache() and os.path.exists(app_v.model.get_disk_icon_path()):
icon = QIcon(app_v.model.get_disk_icon_path())
with open (app_v.model.get_disk_icon_path(), 'rb') as f:
icon_bytes = f.read()
pixmap = QPixmap()
pixmap.loadFromData(icon_bytes)
icon = QIcon(pixmap)
self.icon_cache.add_non_existing(app_v.model.base_data.icon_url, {'icon': icon, 'bytes': icon_bytes})
elif not app_v.model.base_data.icon_url:
icon = QIcon(app_v.model.get_default_icon_path())
else: