Skip to content

Commit

Permalink
Store: Update details page
Browse files Browse the repository at this point in the history
  • Loading branch information
loathingKernel committed Feb 25, 2024
1 parent 9ec349e commit 7a2a645
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 206 deletions.
56 changes: 28 additions & 28 deletions rare/components/tabs/store/api/models/diesel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@dataclass
class DieselSystemDetailItem:
p_type: Optional[str] = None
_type: Optional[str] = None
minimum: Optional[str] = None
recommended: Optional[str] = None
title: Optional[str] = None
Expand All @@ -20,7 +20,7 @@ class DieselSystemDetailItem:
def from_dict(cls: Type["DieselSystemDetailItem"], src: Dict[str, Any]) -> "DieselSystemDetailItem":
d = src.copy()
tmp = cls(
p_type=d.pop("_type", ""),
_type=d.pop("_type", ""),
minimum=d.pop("minimum", ""),
recommended=d.pop("recommended", ""),
title=d.pop("title", ""),
Expand All @@ -31,7 +31,7 @@ def from_dict(cls: Type["DieselSystemDetailItem"], src: Dict[str, Any]) -> "Dies

@dataclass
class DieselSystemDetail:
p_type: Optional[str] = None
_type: Optional[str] = None
details: Optional[List[DieselSystemDetailItem]] = None
systemType: Optional[str] = None
unmapped: Dict[str, Any] = field(default_factory=dict)
Expand All @@ -45,7 +45,7 @@ def from_dict(cls: Type["DieselSystemDetail"], src: Dict[str, Any]) -> "DieselSy
detail = DieselSystemDetailItem.from_dict(item)
details.append(detail)
tmp = cls(
p_type=d.pop("_type", ""),
_type=d.pop("_type", ""),
details=details,
systemType=d.pop("systemType", ""),
)
Expand All @@ -55,7 +55,7 @@ def from_dict(cls: Type["DieselSystemDetail"], src: Dict[str, Any]) -> "DieselSy

@dataclass
class DieselSystemDetails:
p_type: Optional[str] = None
_type: Optional[str] = None
languages: Optional[List[str]] = None
rating: Optional[Dict] = None
systems: Optional[List[DieselSystemDetail]] = None
Expand All @@ -70,7 +70,7 @@ def from_dict(cls: Type["DieselSystemDetails"], src: Dict[str, Any]) -> "DieselS
system = DieselSystemDetail.from_dict(item)
systems.append(system)
tmp = cls(
p_type=d.pop("_type", ""),
_type=d.pop("_type", ""),
languages=d.pop("languages", []),
rating=d.pop("rating", {}),
systems=systems,
Expand All @@ -81,30 +81,30 @@ def from_dict(cls: Type["DieselSystemDetails"], src: Dict[str, Any]) -> "DieselS

@dataclass
class DieselProductAbout:
p_type: Optional[str] = None
_type: Optional[str] = None
desciption: Optional[str] = None
developer_attribution: Optional[str] = None
publisher_attribution: Optional[str] = None
short_description: Optional[str] = None
developerAttribution: Optional[str] = None
publisherAttribution: Optional[str] = None
shortDescription: Optional[str] = None
unmapped: Dict[str, Any] = field(default_factory=dict)

@classmethod
def from_dict(cls: Type["DieselProductAbout"], src: Dict[str, Any]) -> "DieselProductAbout":
d = src.copy()
tmp = cls(
p_type=d.pop("_type", ""),
_type=d.pop("_type", ""),
desciption=d.pop("description", ""),
developer_attribution=d.pop("developerAttribution", ""),
publisher_attribution=d.pop("publisherAttribution", ""),
short_description=d.pop("shortDescription", ""),
developerAttribution=d.pop("developerAttribution", ""),
publisherAttribution=d.pop("publisherAttribution", ""),
shortDescription=d.pop("shortDescription", ""),
)
tmp.unmapped = d
return tmp


@dataclass
class DieselProductDetail:
p_type: Optional[str] = None
_type: Optional[str] = None
about: Optional[DieselProductAbout] = None
requirements: Optional[DieselSystemDetails] = None
socialLinks: Optional[DieselSocialLinks] = None
Expand All @@ -116,7 +116,7 @@ def from_dict(cls: Type["DieselProductDetail"], src: Dict[str, Any]) -> "DieselP
about = DieselProductAbout.from_dict(x) if (x := d.pop("about"), {}) else None
requirements = DieselSystemDetails.from_dict(x) if (x := d.pop("requirements", {})) else None
tmp = cls(
p_type=d.pop("_type", ""),
_type=d.pop("_type", ""),
about=about,
requirements=requirements,
socialLinks=d.pop("socialLinks", {}),
Expand All @@ -127,12 +127,12 @@ def from_dict(cls: Type["DieselProductDetail"], src: Dict[str, Any]) -> "DieselP

@dataclass
class DieselProduct:
p_id: Optional[str] = None
p_images_: Optional[List[str]] = None
p_locale: Optional[str] = None
p_slug: Optional[str] = None
p_title: Optional[str] = None
p_url_pattern: Optional[str] = None
_id: Optional[str] = None
_images_: Optional[List[str]] = None
_locale: Optional[str] = None
_slug: Optional[str] = None
_title: Optional[str] = None
_urlPattern: Optional[str] = None
namespace: Optional[str] = None
pages: Optional[List["DieselProduct"]] = None
data: Optional[DieselProductDetail] = None
Expand All @@ -149,12 +149,12 @@ def from_dict(cls: Type["DieselProduct"], src: Dict[str, Any]) -> "DieselProduct
pages.append(page)
data = DieselProductDetail.from_dict(x) if (x := d.pop("data", {})) else None
tmp = cls(
p_id=d.pop("_id", ""),
p_images_=d.pop("_images_", []),
p_locale=d.pop("_locale", ""),
p_slug=d.pop("_slug", ""),
p_title=d.pop("_title", ""),
p_url_pattern=d.pop("_urlPattern", ""),
_id=d.pop("_id", ""),
_images_=d.pop("_images_", []),
_locale=d.pop("_locale", ""),
_slug=d.pop("_slug", ""),
_title=d.pop("_title", ""),
_urlPattern=d.pop("_urlPattern", ""),
namespace=d.pop("namespace", ""),
pages=pages,
data=data,
Expand Down
34 changes: 18 additions & 16 deletions rare/components/tabs/store/widgets/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, installed: List, store_api: StoreAPI, parent=None):
self.ui.left_layout.setAlignment(Qt.AlignTop)

self.ui.wishlist_button.clicked.connect(self.add_to_wishlist)
self.ui.open_store_button.clicked.connect(self.button_clicked)
self.ui.store_button.clicked.connect(self.button_clicked)
self.ui.wishlist_button.setVisible(True)
self.in_wishlist = False
self.wishlist = []
Expand Down Expand Up @@ -99,13 +99,13 @@ def update_game(self, offer: CatalogOfferModel):
self.slug = slug

if offer.namespace in self.installed:
self.ui.open_store_button.setText(self.tr("Show Game on Epic Page"))
self.ui.owned_label.setVisible(True)
self.ui.store_button.setText(self.tr("Show Game on Epic Page"))
self.ui.status.setVisible(True)
else:
self.ui.open_store_button.setText(self.tr("Buy Game in Epic Games Store"))
self.ui.owned_label.setVisible(False)
self.ui.store_button.setText(self.tr("Buy Game in Epic Games Store"))
self.ui.status.setVisible(False)

self.ui.price.setText(self.tr("Loading"))
self.ui.original_price.setText(self.tr("Loading"))
# self.title.setText(self.tr("Loading"))
# self.image.setPixmap(QPixmap())
is_bundle = False
Expand Down Expand Up @@ -148,17 +148,17 @@ def data_received(self, product: DieselProduct):
raise e
logger.error(str(e))

self.ui.price.setFont(self.font())
self.ui.original_price.setFont(self.font())
price = self.catalog_offer.price.totalPrice.fmtPrice["originalPrice"]
discount_price = self.catalog_offer.price.totalPrice.fmtPrice["discountPrice"]
if price == "0" or price == 0:
self.ui.price.setText(self.tr("Free"))
self.ui.original_price.setText(self.tr("Free"))
else:
self.ui.price.setText(price)
self.ui.original_price.setText(price)
if price != discount_price:
font = self.font()
font.setStrikeOut(True)
self.ui.price.setFont(font)
self.ui.original_price.setFont(font)
self.ui.discount_price.setText(
discount_price
if discount_price != "0"
Expand All @@ -173,6 +173,7 @@ def data_received(self, product: DieselProduct):
for system in requirements.systems:
req_widget = RequirementsWidget(system, self.requirements_tabs)
self.requirements_tabs.addTab(req_widget, system.systemType)
self.ui.requirements_frame.setVisible(True)
else:
self.ui.requirements_frame.setVisible(False)

Expand All @@ -183,7 +184,7 @@ def data_received(self, product: DieselProduct):
# self.image_stack.setCurrentIndex(0)
about = product_data.about
self.ui.description_label.setMarkdown(about.desciption)
self.ui.dev.setText(about.developer_attribution)
self.ui.developer.setText(about.developerAttribution)
# try:
# if isinstance(aboudeveloper, list):
# self.ui.dev.setText(", ".join(self.game.developer))
Expand All @@ -195,8 +196,8 @@ def data_received(self, product: DieselProduct):
self.ui.tags.setText(", ".join(tags))

# clear Layout
for b in self.ui.social_group.findChildren(SocialButton, options=Qt.FindDirectChildrenOnly):
self.ui.social_layout.removeWidget(b)
for b in self.ui.social_links.findChildren(SocialButton, options=Qt.FindDirectChildrenOnly):
self.ui.social_links_layout.removeWidget(b)
b.deleteLater()

links = product_data.socialLinks
Expand All @@ -214,11 +215,11 @@ def data_received(self, product: DieselProduct):
logger.error(str(e))
continue

button = SocialButton(icn, url, parent=self.ui.social_group)
self.ui.social_layout.addWidget(button)
button = SocialButton(icn, url, parent=self.ui.social_links)
self.ui.social_links_layout.addWidget(button)
link_count += 1

self.ui.social_group.setEnabled(bool(link_count))
self.ui.social_links.setEnabled(bool(link_count))

self.setEnabled(True)

Expand All @@ -238,6 +239,7 @@ def keyPressEvent(self, a0: QKeyEvent):
class SocialButton(QPushButton):
def __init__(self, icn, url, parent=None):
super(SocialButton, self).__init__(icn, "", parent=parent)
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.url = url
self.clicked.connect(lambda: QDesktopServices.openUrl(QUrl(url)))
self.setToolTip(url)
Expand Down
1 change: 0 additions & 1 deletion rare/components/tabs/store/widgets/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def __init__(self, manager: QtRequests, catalog_game: CatalogOfferModel, parent=


class WishlistItemWidget(ItemWidget):
show_details = pyqtSignal(CatalogOfferModel)
delete_from_wishlist = pyqtSignal(CatalogOfferModel)

def __init__(self, manager: QtRequests, catalog_game: CatalogOfferModel, parent=None):
Expand Down
Loading

0 comments on commit 7a2a645

Please sign in to comment.