Skip to content

Commit

Permalink
Shop: Use a single QGridLayout instead of left and right VBoxLayouts
Browse files Browse the repository at this point in the history
  • Loading branch information
loathingKernel committed Jun 11, 2023
1 parent a3c398b commit cbcdc78
Show file tree
Hide file tree
Showing 3 changed files with 304 additions and 323 deletions.
20 changes: 8 additions & 12 deletions rare/components/tabs/store/shop_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from .image_widget import WaitingSpinner
from .shop_api_core import ShopApiCore

from .api.models.utils import parse_date

logger = logging.getLogger("Shop")


Expand Down Expand Up @@ -77,7 +79,7 @@ def __init__(self, cache_dir, core: LegendaryCore, shop_api: ShopApiCore, parent
self.search_bar = ButtonLineEdit(
"fa.search", placeholder_text=self.tr("Search Games")
)
self.ui.left_layout.insertWidget(0, self.search_bar)
self.ui.main_layout.addWidget(self.search_bar, 0, 0)

# self.search_bar.textChanged.connect(self.search_games)

Expand Down Expand Up @@ -165,7 +167,7 @@ def add_free_games(self, free_games: List[CatalogOfferModel]):
self.free_games_next.setLayout(free_games_next_layout)
self.ui.free_container.layout().addWidget(self.free_games_next)

date = datetime.datetime.now()
date = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
free_games_now = []
coming_free_games = []
for game in free_games:
Expand All @@ -187,19 +189,13 @@ def add_free_games(self, free_games: List[CatalogOfferModel]):
try:
# parse datetime to check if game is next week or now
try:
start_date = datetime.datetime.strptime(
game.promotions["upcomingPromotionalOffers"][0][
"promotionalOffers"
][0]["startDate"],
"%Y-%m-%dT%H:%M:%S.%fZ",
start_date = parse_date(
game.promotions["upcomingPromotionalOffers"][0]["promotionalOffers"][0]["startDate"]
)
except Exception:
try:
start_date = datetime.datetime.strptime(
game.promotions["promotionalOffers"][0][
"promotionalOffers"
][0]["startDate"],
"%Y-%m-%dT%H:%M:%S.%fZ",
start_date = parse_date(
game.promotions["promotionalOffers"][0]["promotionalOffers"][0]["startDate"]
)
except Exception as e:

Expand Down
115 changes: 54 additions & 61 deletions rare/ui/components/tabs/store/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,10 @@
class Ui_ShopWidget(object):
def setupUi(self, ShopWidget):
ShopWidget.setObjectName("ShopWidget")
ShopWidget.resize(350, 382)
ShopWidget.resize(788, 662)
ShopWidget.setWindowTitle("Store")
self.shop_layout = QtWidgets.QHBoxLayout(ShopWidget)
self.shop_layout.setObjectName("shop_layout")
self.left_layout = QtWidgets.QVBoxLayout()
self.left_layout.setObjectName("left_layout")
self.games_scrollarea = QtWidgets.QScrollArea(ShopWidget)
self.games_scrollarea.setFrameShape(QtWidgets.QFrame.NoFrame)
self.games_scrollarea.setFrameShadow(QtWidgets.QFrame.Plain)
self.games_scrollarea.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
self.games_scrollarea.setWidgetResizable(True)
self.games_scrollarea.setObjectName("games_scrollarea")
self.games_container = QtWidgets.QWidget()
self.games_container.setGeometry(QtCore.QRect(0, 0, 186, 368))
self.games_container.setObjectName("games_container")
self.games_container_layout = QtWidgets.QVBoxLayout(self.games_container)
self.games_container_layout.setContentsMargins(0, 0, 3, 0)
self.games_container_layout.setObjectName("games_container_layout")
self.free_scrollarea = QtWidgets.QScrollArea(self.games_container)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.free_scrollarea.sizePolicy().hasHeightForWidth())
self.free_scrollarea.setSizePolicy(sizePolicy)
self.free_scrollarea.setFrameShape(QtWidgets.QFrame.NoFrame)
self.free_scrollarea.setFrameShadow(QtWidgets.QFrame.Plain)
self.free_scrollarea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.free_scrollarea.setWidgetResizable(True)
self.free_scrollarea.setObjectName("free_scrollarea")
self.free_container = QtWidgets.QWidget()
self.free_container.setGeometry(QtCore.QRect(0, 0, 16, 16))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.free_container.sizePolicy().hasHeightForWidth())
self.free_container.setSizePolicy(sizePolicy)
self.free_container.setObjectName("free_container")
self.free_container_layout = QtWidgets.QHBoxLayout(self.free_container)
self.free_container_layout.setContentsMargins(0, 0, 0, 3)
self.free_container_layout.setObjectName("free_container_layout")
self.free_scrollarea.setWidget(self.free_container)
self.games_container_layout.addWidget(self.free_scrollarea)
self.discounts_group = QtWidgets.QGroupBox(self.games_container)
self.discounts_group.setObjectName("discounts_group")
self.games_container_layout.addWidget(self.discounts_group)
self.games_group = QtWidgets.QGroupBox(self.games_container)
self.games_group.setObjectName("games_group")
self.games_container_layout.addWidget(self.games_group)
self.games_scrollarea.setWidget(self.games_container)
self.left_layout.addWidget(self.games_scrollarea)
self.shop_layout.addLayout(self.left_layout)
self.right_layout = QtWidgets.QVBoxLayout()
self.right_layout.setObjectName("right_layout")
self.reset_button = QtWidgets.QPushButton(ShopWidget)
self.reset_button.setObjectName("reset_button")
self.right_layout.addWidget(self.reset_button)
self.main_layout = QtWidgets.QGridLayout(ShopWidget)
self.main_layout.setObjectName("main_layout")
self.filter_scrollarea = QtWidgets.QScrollArea(ShopWidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
Expand Down Expand Up @@ -141,17 +89,59 @@ def setupUi(self, ShopWidget):
self.others_layout.setObjectName("others_layout")
self.filter_container_layout.addWidget(self.others_group)
self.filter_scrollarea.setWidget(self.filter_container)
self.right_layout.addWidget(self.filter_scrollarea)
self.shop_layout.addLayout(self.right_layout)
self.shop_layout.setStretch(0, 1)
self.main_layout.addWidget(self.filter_scrollarea, 1, 1, 1, 1)
self.reset_button = QtWidgets.QPushButton(ShopWidget)
self.reset_button.setObjectName("reset_button")
self.main_layout.addWidget(self.reset_button, 0, 1, 1, 1)
self.games_scrollarea = QtWidgets.QScrollArea(ShopWidget)
self.games_scrollarea.setFrameShape(QtWidgets.QFrame.NoFrame)
self.games_scrollarea.setFrameShadow(QtWidgets.QFrame.Plain)
self.games_scrollarea.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
self.games_scrollarea.setWidgetResizable(True)
self.games_scrollarea.setObjectName("games_scrollarea")
self.games_container = QtWidgets.QWidget()
self.games_container.setGeometry(QtCore.QRect(0, 0, 628, 618))
self.games_container.setObjectName("games_container")
self.games_container_layout = QtWidgets.QVBoxLayout(self.games_container)
self.games_container_layout.setContentsMargins(0, 0, 3, 0)
self.games_container_layout.setObjectName("games_container_layout")
self.free_scrollarea = QtWidgets.QScrollArea(self.games_container)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.free_scrollarea.sizePolicy().hasHeightForWidth())
self.free_scrollarea.setSizePolicy(sizePolicy)
self.free_scrollarea.setFrameShape(QtWidgets.QFrame.NoFrame)
self.free_scrollarea.setFrameShadow(QtWidgets.QFrame.Plain)
self.free_scrollarea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.free_scrollarea.setWidgetResizable(True)
self.free_scrollarea.setObjectName("free_scrollarea")
self.free_container = QtWidgets.QWidget()
self.free_container.setGeometry(QtCore.QRect(0, 0, 16, 16))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.free_container.sizePolicy().hasHeightForWidth())
self.free_container.setSizePolicy(sizePolicy)
self.free_container.setObjectName("free_container")
self.free_container_layout = QtWidgets.QHBoxLayout(self.free_container)
self.free_container_layout.setContentsMargins(0, 0, 0, 3)
self.free_container_layout.setObjectName("free_container_layout")
self.free_scrollarea.setWidget(self.free_container)
self.games_container_layout.addWidget(self.free_scrollarea)
self.discounts_group = QtWidgets.QGroupBox(self.games_container)
self.discounts_group.setObjectName("discounts_group")
self.games_container_layout.addWidget(self.discounts_group)
self.games_group = QtWidgets.QGroupBox(self.games_container)
self.games_group.setObjectName("games_group")
self.games_container_layout.addWidget(self.games_group)
self.games_scrollarea.setWidget(self.games_container)
self.main_layout.addWidget(self.games_scrollarea, 1, 0, 1, 1)

self.retranslateUi(ShopWidget)

def retranslateUi(self, ShopWidget):
_translate = QtCore.QCoreApplication.translate
self.discounts_group.setTitle(_translate("ShopWidget", "Discounts from your wishlist"))
self.games_group.setTitle(_translate("ShopWidget", "Games"))
self.reset_button.setText(_translate("ShopWidget", "Reset filters"))
self.price_group.setTitle(_translate("ShopWidget", "Price"))
self.none_price.setText(_translate("ShopWidget", "None"))
self.free_button.setText(_translate("ShopWidget", "Free"))
Expand All @@ -164,6 +154,9 @@ def retranslateUi(self, ShopWidget):
self.genre_group.setTitle(_translate("ShopWidget", "Genre"))
self.type_group.setTitle(_translate("ShopWidget", "Type"))
self.others_group.setTitle(_translate("ShopWidget", "Other tags"))
self.reset_button.setText(_translate("ShopWidget", "Reset filters"))
self.discounts_group.setTitle(_translate("ShopWidget", "Discounts from your wishlist"))
self.games_group.setTitle(_translate("ShopWidget", "Games"))


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit cbcdc78

Please sign in to comment.