self.cover_size = size
else:
self.cover_size = 48 if (CoverMode.LIST in self.cover_mode) else 200
+
+ self.pixmap=QPixmap(self.game["Icon"] if ("Icon" in self.game) else "")
self.initUI()
makeMouseAware(self, [self, self.cover])
self.line2.setAlignment(Qt.AlignRight)
self._resetMinMax()
+
+ def _resetPixmap(self):
+ crop = self.pixmap
+
+ w = self.pixmap.width()
+ h = self.pixmap.height()
+ crop = self.pixmap.copy(
+ int((w - h) / 2) if w > h else 0,
+ int((h - w) / 2) if h > w else 0,
+ min(w, h), min(w, h)
+ )
+
+ self.cover.setPixmap(crop)
def initUI(self):
self._initUI_text()
-
- pixmap = QPixmap(self.game["Icon"] if ("Icon" in self.game) else "")
-
+
self.cover = QLabel()
- self.cover.setPixmap(pixmap)
self.cover.setScaledContents(True)
self.cover.setMinimumSize(self.cover_size, self.cover_size)
self.cover.setMaximumSize(self.cover_size, self.cover_size)
+ self._resetPixmap()
line1sub = QWidget()
hlay = QHBoxLayout()
cover.onClick.connect(lambda game: self.onClick.emit(game))
covers.append(cover)
return covers
-
- def _on_click(self, game):
- print(repr(game))
class Grid(List):
def __init__(self, games: list[Game], icon_size: int = 0):
app = QApplication(argv)
game1 = Game(None, PurePath(""))
- game1["Name"] = "Super Buba"
- game1["Icon"] = "./buba.jpg"
+ game1["Name"] = "Super Sheep"
+ game1["Icon"] = "./super-sheep.jpg"
game1._init()
game2 = Game(None, PurePath(""))
game2["Name"] = "Super Buba II: le retour de la nouvelle bĂȘte"