Add tags in shop_info.py
This commit is contained in:
parent
7cf4f15122
commit
c0f4577870
5 changed files with 22 additions and 6 deletions
|
@ -11,6 +11,8 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel
|
||||||
from rare.utils.extra_widgets import ImageLabel
|
from rare.utils.extra_widgets import ImageLabel
|
||||||
from rare.utils.utils import get_lang
|
from rare.utils.utils import get_lang
|
||||||
|
|
||||||
|
logger = logging.getLogger("GameWidgets")
|
||||||
|
|
||||||
|
|
||||||
class GameWidget(QWidget):
|
class GameWidget(QWidget):
|
||||||
show_info = pyqtSignal(dict)
|
show_info = pyqtSignal(dict)
|
||||||
|
@ -38,7 +40,8 @@ class GameWidget(QWidget):
|
||||||
self.image.update_image(img["url"], json_info["title"], (self.width, int(self.width * 9 / 16)))
|
self.image.update_image(img["url"], json_info["title"], (self.width, int(self.width * 9 / 16)))
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print(json_info["keyImages"])
|
logger.info(", ".join([img["type"] for img in json_info["keyImages"]]))
|
||||||
|
# print(json_info["keyImages"])
|
||||||
|
|
||||||
save = QSettings().value("cache_images", True, bool)
|
save = QSettings().value("cache_images", True, bool)
|
||||||
if os.path.exists(p := os.path.join(self.path, f"{json_info['title']}_wide.png")) and save:
|
if os.path.exists(p := os.path.join(self.path, f"{json_info['title']}_wide.png")) and save:
|
||||||
|
@ -54,7 +57,7 @@ class GameWidget(QWidget):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
# No image found
|
# No image found
|
||||||
logging.error(f"No image found for {self.title}")
|
logger.error(f"No image found for {self.title}")
|
||||||
|
|
||||||
self.layout.addWidget(self.image)
|
self.layout.addWidget(self.image)
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ class ShopGameInfo(QWidget, Ui_shop_info):
|
||||||
self.dev.setText(self.game.developer)
|
self.dev.setText(self.game.developer)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
self.tags.setText(", ".join(self.game.tags))
|
||||||
# self.price.setText(self.game.price)
|
# self.price.setText(self.game.price)
|
||||||
|
|
||||||
self.request.deleteLater()
|
self.request.deleteLater()
|
||||||
|
|
|
@ -25,7 +25,7 @@ class ShopGame:
|
||||||
# TODO: Copyrights etc
|
# TODO: Copyrights etc
|
||||||
def __init__(self, title: str = "", image_urls: _ImageUrlModel = None, social_links: dict = None,
|
def __init__(self, title: str = "", image_urls: _ImageUrlModel = None, social_links: dict = None,
|
||||||
langs: list = None, reqs: dict = None, publisher: str = "", developer: str = "",
|
langs: list = None, reqs: dict = None, publisher: str = "", developer: str = "",
|
||||||
original_price: str = "", discount_price: str = ""):
|
original_price: str = "", discount_price: str = "", tags: list = None):
|
||||||
self.title = title
|
self.title = title
|
||||||
self.image_urls = image_urls
|
self.image_urls = image_urls
|
||||||
self.links = []
|
self.links = []
|
||||||
|
@ -41,6 +41,7 @@ class ShopGame:
|
||||||
self.developer = developer
|
self.developer = developer
|
||||||
self.price = original_price
|
self.price = original_price
|
||||||
self.discount_price = discount_price
|
self.discount_price = discount_price
|
||||||
|
self.tags = tags
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, api_data: dict, search_data: dict):
|
def from_json(cls, api_data: dict, search_data: dict):
|
||||||
|
@ -80,5 +81,6 @@ class ShopGame:
|
||||||
tmp.developer = i["value"]
|
tmp.developer = i["value"]
|
||||||
tmp.price = search_data['price']['totalPrice']['fmtPrice']['originalPrice']
|
tmp.price = search_data['price']['totalPrice']['fmtPrice']['originalPrice']
|
||||||
tmp.discount_price = search_data['price']['totalPrice']['fmtPrice']['discountPrice']
|
tmp.discount_price = search_data['price']['totalPrice']['fmtPrice']['discountPrice']
|
||||||
|
tmp.tags = [i.replace("_", " ").capitalize() for i in api_data["data"]["meta"].get("tags", [])]
|
||||||
|
|
||||||
return tmp
|
return tmp
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# run again. Do not edit this file unless you know what you are doing.
|
# run again. Do not edit this file unless you know what you are doing.
|
||||||
|
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtWidgets
|
||||||
|
|
||||||
|
|
||||||
class Ui_shop_info(object):
|
class Ui_shop_info(object):
|
||||||
|
@ -45,6 +45,9 @@ class Ui_shop_info(object):
|
||||||
self.discount_price = QtWidgets.QLabel(shop_info)
|
self.discount_price = QtWidgets.QLabel(shop_info)
|
||||||
self.discount_price.setObjectName("discount_price")
|
self.discount_price.setObjectName("discount_price")
|
||||||
self.verticalLayout_2.addWidget(self.discount_price)
|
self.verticalLayout_2.addWidget(self.discount_price)
|
||||||
|
self.tags = QtWidgets.QLabel(shop_info)
|
||||||
|
self.tags.setObjectName("tags")
|
||||||
|
self.verticalLayout_2.addWidget(self.tags)
|
||||||
self.open_store_button = QtWidgets.QPushButton(shop_info)
|
self.open_store_button = QtWidgets.QPushButton(shop_info)
|
||||||
self.open_store_button.setObjectName("open_store_button")
|
self.open_store_button.setObjectName("open_store_button")
|
||||||
self.verticalLayout_2.addWidget(self.open_store_button)
|
self.verticalLayout_2.addWidget(self.open_store_button)
|
||||||
|
@ -75,6 +78,7 @@ class Ui_shop_info(object):
|
||||||
self.owned_label.setText(_translate("shop_info", "You already own this game"))
|
self.owned_label.setText(_translate("shop_info", "You already own this game"))
|
||||||
self.price.setText(_translate("shop_info", "TextLabel"))
|
self.price.setText(_translate("shop_info", "TextLabel"))
|
||||||
self.discount_price.setText(_translate("shop_info", "TextLabel"))
|
self.discount_price.setText(_translate("shop_info", "TextLabel"))
|
||||||
|
self.tags.setText(_translate("shop_info", "TextLabel"))
|
||||||
self.open_store_button.setText(_translate("shop_info", "Buy Game in Epic Games Store"))
|
self.open_store_button.setText(_translate("shop_info", "Buy Game in Epic Games Store"))
|
||||||
self.req_group_box.setTitle(_translate("shop_info", "Requirements"))
|
self.req_group_box.setTitle(_translate("shop_info", "Requirements"))
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="tags">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="open_store_button">
|
<widget class="QPushButton" name="open_store_button">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
Loading…
Reference in a new issue