saves: show the save's ICON0.PNG in the table
The Save column now displays a small (40x32, letterboxed) icon from the save folder's ICON0.PNG when present, using the first location (PSP, PPSSPP, cloud) that has one.
This commit is contained in:
+18
@@ -3376,12 +3376,25 @@ class SavesPage(QWidget):
|
||||
self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
||||
self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
self.table.setSortingEnabled(True)
|
||||
self.table.setIconSize(QSize(40, 32))
|
||||
self.table.horizontalHeader().setSortIndicator(0, Qt.AscendingOrder)
|
||||
layout.addWidget(self.table)
|
||||
|
||||
self.status = QLabel("")
|
||||
layout.addWidget(self.status)
|
||||
|
||||
def _save_icon(self, folder):
|
||||
"""Return a small QIcon from a save folder's ICON0.PNG, or None."""
|
||||
if not folder:
|
||||
return None
|
||||
p = Path(folder) / "ICON0.PNG"
|
||||
if not p.is_file():
|
||||
return None
|
||||
pm = QPixmap(str(p))
|
||||
if pm.isNull():
|
||||
return None
|
||||
return QIcon(_fit_pixmap(pm, 40, 32))
|
||||
|
||||
def set_locations(self, psp_dir, ppsspp_dir, cloud_dir):
|
||||
self._psp_dir = psp_dir or ""
|
||||
self._ppsspp_dir = ppsspp_dir or ""
|
||||
@@ -3406,6 +3419,7 @@ class SavesPage(QWidget):
|
||||
self.table.insertRow(row)
|
||||
title = sid
|
||||
enc = False
|
||||
icon = None
|
||||
for loc in ("psp", "ppsspp", "cloud"):
|
||||
s = data[loc].get(sid)
|
||||
if s is None:
|
||||
@@ -3414,10 +3428,14 @@ class SavesPage(QWidget):
|
||||
title = s["title"]
|
||||
if s.get("encrypted"):
|
||||
enc = True
|
||||
if icon is None:
|
||||
icon = self._save_icon(s.get("path"))
|
||||
if enc:
|
||||
title += " \u26a0"
|
||||
t = QTableWidgetItem(title)
|
||||
t.setToolTip(sid)
|
||||
if icon is not None:
|
||||
t.setIcon(icon)
|
||||
self.table.setItem(row, 0, t)
|
||||
self.table.setItem(row, 1, QTableWidgetItem(sid))
|
||||
for col, loc in enumerate(("psp", "ppsspp", "cloud"), start=2):
|
||||
|
||||
Reference in New Issue
Block a user