#!/usr/bin/env python3
-# TODO: add QScrollArea
+# TODO: disable start() when one is running
from sys import argv, exit
from enum import IntFlag
self.game = game
self.coverSize = coverSize if (coverSize > 0) else 48
- self.pixmap=QPixmap(self.game["Icon"] if ("Icon" in self.game) else "")
+
+ if (self.game.icon):
+ self.pixmap = QPixmap(self.game.get_icon("icon").as_posix())
+ else:
+ self.pixmap = QPixmap("")
self.initUI()
makeMouseAware(self, [self, self.cover])
self.game = game
self.coverSize = coverSize if (coverSize > 0) else 200
self.fixed = fixed
- self.pixmap=QPixmap(self.game["Icon"] if ("Icon" in self.game) else "")
+
+ if (self.game.icon):
+ self.pixmap = QPixmap(self.game.get_icon("square").as_posix())
+ else:
+ self.pixmap = QPixmap("")
self.initUI()
makeMouseAware(self, [self, self.cover])
self.initUI()
def initUI(self):
- layout = QVBoxLayout()
- #layout.setSpacing(0)
+ area = QWidget()
+ layout = QVBoxLayout(area)
+ layout.setContentsMargins(0, 0, 0, 0)
for game in self.games:
cover = ListItem(game, self.icon_size)
cover.onClick.connect(lambda game: self.onClick.emit(game))
layout.addWidget(cover)
-
layout.addStretch()
- self.setLayout(layout)
+ self._setScrollLayout(area)
-class Grid(QWidget):
- onClick = pyqtSignal(Game)
+ def _setScrollLayout(self, area):
+ layout = QVBoxLayout()
+ layout.setContentsMargins(0, 0, 0, 0)
- def __init__(self, games: list[Game], icon_size: int = 0):
- super().__init__()
-
- self.games = games
- self.icon_size = icon_size
-
- self.initUI()
-
+ scroll = QScrollArea(self)
+ scroll.setWidgetResizable(True)
+ scroll.setWidget(area)
+
+ layout.addWidget(scroll)
+
+ self.setLayout(layout)
+
+class Grid(List):
def initUI(self):
- layout = FlowLayout()
+ area = QWidget()
+ layout = FlowLayout(area)
for game in self.games:
cover = GridItem(game, self.icon_size, True)
cover.onClick.connect(lambda game: self.onClick.emit(game))
layout.addWidget(cover)
- self.setLayout(layout)
+ self._setScrollLayout(area)
if __name__ == '__main__':
app = QApplication(argv)