Skip to content

Commit

Permalink
Store: Use ElideLabel for requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
loathingKernel committed Mar 16, 2023
1 parent 4dd01d0 commit 32a1774
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
20 changes: 11 additions & 9 deletions rare/components/tabs/store/game_info.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from PyQt5.QtCore import Qt, QUrl
from PyQt5.QtGui import QFont, QDesktopServices
from PyQt5.QtGui import QFont, QDesktopServices, QFontMetrics
from PyQt5.QtWidgets import (
QWidget,
QLabel,
Expand All @@ -15,13 +15,14 @@
from rare.shared.image_manager import ImageSize
from rare.ui.components.tabs.store.shop_game_info import Ui_ShopGameInfo
from rare.utils.misc import icon
from rare.widgets.side_tab import SideTabWidget
from rare.widgets.side_tab import SideTabWidget, SideTabContents
from rare.widgets.elide_label import ElideLabel
from .image_widget import ShopImageWidget

logger = logging.getLogger("ShopInfo")


class ShopGameInfo(QWidget, Ui_ShopGameInfo):
class ShopGameInfo(QWidget, Ui_ShopGameInfo, SideTabContents):

# TODO Design
def __init__(self, installed_titles: list, api_core, parent=None):
Expand Down Expand Up @@ -61,6 +62,7 @@ def handle_wishlist_update(self, data):
self.wishlist_button.setVisible(False)

def update_game(self, data: dict):
self.set_title.emit(data["title"])
self.title.setText(data["title"])
self.title_str = data["title"]
self.id_str = data["id"]
Expand Down Expand Up @@ -144,7 +146,7 @@ def data_received(self, game):
self.tags.setText("")
self.dev.setText(self.data.get("seller", {}).get("name", ""))
return
self.title.setText(self.game.title)
# self.title.setText(self.game.title)

self.price.setFont(QFont())
if self.game.price == "0" or self.game.price == 0:
Expand All @@ -167,11 +169,11 @@ def data_received(self, game):
bold_font = QFont()
bold_font.setBold(True)

fm = QFontMetrics(self.font())
if self.game.reqs:
for system in self.game.reqs:
req_widget = QWidget(self.requirements_tabs)
req_layout = QGridLayout(req_widget)
req_layout.setSizeConstraint(QGridLayout.SetFixedSize)
req_widget.layout().setAlignment(Qt.AlignTop)
req_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
min_label = QLabel(self.tr("Minimum"), parent=req_widget)
Expand All @@ -180,13 +182,13 @@ def data_received(self, game):
rec_label.setFont(bold_font)
req_layout.addWidget(min_label, 0, 1)
req_layout.addWidget(rec_label, 0, 2)
req_layout.setColumnStretch(1, 2)
req_layout.setColumnStretch(2, 2)
for i, (key, value) in enumerate(self.game.reqs.get(system, {}).items()):
req_layout.addWidget(QLabel(key, parent=req_widget), i + 1, 0)
min_label = QLabel(value[0], parent=req_widget)
min_label.setWordWrap(False)
min_label = ElideLabel(value[0], parent=req_widget)
req_layout.addWidget(min_label, i + 1, 1)
rec_label = QLabel(value[1], parent=req_widget)
rec_label.setWordWrap(False)
rec_label = ElideLabel(value[1], parent=req_widget)
req_layout.addWidget(rec_label, i + 1, 2)
self.requirements_tabs.addTab(req_widget, system)
# self.req_group_box.layout().addWidget(req_tabs)
Expand Down
2 changes: 1 addition & 1 deletion rare/components/tabs/store/search_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from rare.shared.image_manager import ImageSize
from rare.widgets.flow_layout import FlowLayout
from widgets.elide_label import ElideLabel
from rare.widgets.elide_label import ElideLabel
from .image_widget import ShopImageWidget


Expand Down
4 changes: 3 additions & 1 deletion rare/components/tabs/store/wishlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

from rare.ui.components.tabs.store.wishlist import Ui_Wishlist
from rare.utils.misc import icon
from rare.widgets.side_tab import SideTabContents
from .shop_api_core import ShopApiCore
from .game_widgets import WishlistWidget


class Wishlist(QWidget, Ui_Wishlist):
class Wishlist(QWidget, Ui_Wishlist, SideTabContents):
show_game_info = pyqtSignal(dict)
update_wishlist_signal = pyqtSignal()

Expand All @@ -32,6 +33,7 @@ def __init__(self, api_core: ShopApiCore, parent=None):

def update_wishlist(self):
self.setEnabled(False)
self.set_title.emit("Wishlist")
self.api_core.get_wishlist(self.set_wishlist)

def delete_from_wishlist(self, game):
Expand Down

0 comments on commit 32a1774

Please sign in to comment.