diff --git a/Rare/FlowLayout.py b/Rare/FlowLayout.py deleted file mode 100644 index 66441fce..00000000 --- a/Rare/FlowLayout.py +++ /dev/null @@ -1,92 +0,0 @@ -from PyQt5 import Qt -from PyQt5.QtCore import QRect, QPoint, QSize -from PyQt5.QtWidgets import QSizePolicy, QLayout - - -class FlowLayout(QLayout): - def __init__(self, parent=None, margin=0, spacing=-1): - super(FlowLayout, self).__init__(parent) - - if parent is not None: - self.setContentsMargins(margin, margin, margin, margin) - - self.setSpacing(spacing) - - self.itemList = [] - - def __del__(self): - item = self.takeAt(0) - while item: - item = self.takeAt(0) - - def addItem(self, item): - self.itemList.append(item) - - def count(self): - return len(self.itemList) - - def itemAt(self, index): - if index >= 0 and index < len(self.itemList): - return self.itemList[index] - - return None - - def takeAt(self, index): - if index >= 0 and index < len(self.itemList): - return self.itemList.pop(index) - - return None - - def expandingDirections(self): - return Qt.Orientations(Qt.Orientation(0)) - - def hasHeightForWidth(self): - return True - - def heightForWidth(self, width): - height = self.doLayout(QRect(0, 0, width, 0), True) - return height - - def setGeometry(self, rect): - super(FlowLayout, self).setGeometry(rect) - self.doLayout(rect, False) - - def sizeHint(self): - return self.minimumSize() - - def minimumSize(self): - size = QSize() - - for item in self.itemList: - size = size.expandedTo(item.minimumSize()) - - margin, _, _, _ = self.getContentsMargins() - - size += QSize(2 * margin, 2 * margin) - return size - - def doLayout(self, rect, testOnly): - x = rect.x() - y = rect.y() - lineHeight = 0 - - for item in self.itemList: - wid = item.widget() - spaceX = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, QSizePolicy.PushButton, - Qt.Horizontal) - spaceY = self.spacing() + wid.style().layoutSpacing(QSizePolicy.PushButton, QSizePolicy.PushButton, - Qt.Vertical) - nextX = x + item.sizeHint().width() + spaceX - if nextX - spaceX > rect.right() and lineHeight > 0: - x = rect.x() - y = y + lineHeight + spaceY - nextX = x + item.sizeHint().width() + spaceX - lineHeight = 0 - - if not testOnly: - item.setGeometry(QRect(QPoint(x, y), item.sizeHint())) - - x = nextX - lineHeight = max(lineHeight, item.sizeHint().height()) - - return y + lineHeight - rect.y() diff --git a/Rare/GameWidget.py b/Rare/GameWidget.py index 52b810a5..fab48c11 100644 --- a/Rare/GameWidget.py +++ b/Rare/GameWidget.py @@ -10,14 +10,14 @@ class GameWidget(QWidget): self.title = game.title self.version = game.version + self.size = game.install_size self.layout = QHBoxLayout() - - self.pixmap = QPixmap(f"../images/{game.app_name}/FinalArt.png") - self.pixmap = self.pixmap.scaled(240, 320) + pixmap = QPixmap(f"../images/{game.app_name}/FinalArt.png") + pixmap = pixmap.scaled(240, 320) self.image = QLabel() - self.image.setPixmap(self.pixmap) + self.image.setPixmap(pixmap) self.layout.addWidget(self.image) ##Layout on the right @@ -28,12 +28,16 @@ class GameWidget(QWidget): self.launch_button = QPushButton(play_icon, "Launch") self.launch_button.clicked.connect(self.launch) - self.wine_rating = QLabel("Wine Rating: Comming Soon") + self.wine_rating = QLabel("Wine Rating: " + self.get_rating()) self.version_label = QLabel("Version: " + str(self.version)) + self.size_label = QLabel(f"Installed size: {round(self.size / (1024 ** 3), 2)} GB") + self.settings = QPushButton(qta.icon("fa5s.cogs"), " Settings") self.childLayout.addWidget(self.launch_button) self.childLayout.addWidget(self.wine_rating) self.childLayout.addWidget(self.version_label) + self.childLayout.addWidget(self.size_label) + self.childLayout.addWidget(self.settings) self.childLayout.addStretch(1) # self.layout.addWidget(QLabel(game.title)) @@ -42,3 +46,23 @@ class GameWidget(QWidget): def launch(self): print(f"launch {self.title}") + # TODO + + def get_rating(self) -> str: + return "gold" # TODO + + +class UninstalledGameWidget(QWidget): + def __init__(self, game): + super(UninstalledGameWidget, self).__init__() + self.title = game.app_title + self.layout = QHBoxLayout() + + pixmap = QPixmap(f"../images/{game.app_name}/UninstalledArt.png") + pixmap = pixmap.scaled(240, 320) + self.image = QLabel() + self.image.setPixmap(pixmap) + self.layout.addWidget(self.image) + + self.layout.addWidget(QLabel(f"