Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the Store page #388

Merged
merged 21 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6b15c0f
Store: Clean up store UI by using library widgets
loathingKernel Jan 29, 2023
d3b5919
Store: Use ElideLabel for requirements
loathingKernel Mar 12, 2023
b812e38
Wishlist: Remove embedded title
loathingKernel Mar 30, 2023
2db3432
ShopWidget: Cleanup shop layout
loathingKernel Mar 30, 2023
d76fc2b
ShopWidget: Fix layouting again
loathingKernel Mar 30, 2023
b6458b1
SearchResultItem: Use ShopImageWidget as a base
loathingKernel Mar 30, 2023
247b2c9
ShopImageWidget: Design it to me similar to IconGameWidget
loathingKernel Mar 30, 2023
7246078
ShopGameInfo: Design it to me similar to GameInfo
loathingKernel Mar 30, 2023
f6396f4
Store: Exploratory changes to the store page
loathingKernel Apr 4, 2023
91af16b
Store: Exploratory changes for GraphQL API
loathingKernel Apr 10, 2023
fda82b1
Shop: Use a single QGridLayout instead of left and right VBoxLayouts
loathingKernel Apr 12, 2023
b4a26b5
Store: Finalize store design
loathingKernel Sep 23, 2023
816c5f3
Store: adapt image sized
loathingKernel Dec 14, 2023
2a2458b
Store: Update details page
loathingKernel Feb 3, 2024
9ec349e
WIP
loathingKernel Feb 12, 2024
7a2a645
Store: Update details page
loathingKernel Feb 20, 2024
1fab13f
Store: Fix rebase errors
loathingKernel Feb 21, 2024
7665579
Store: Unset autoFillBackground for some scrollareas
loathingKernel Feb 24, 2024
fb0d5bb
Store: Fix various wishlist issues.
loathingKernel Feb 25, 2024
89340f3
StoreAPI: comment unused and erroneous code
loathingKernel Feb 25, 2024
14bde0a
WishlistWidget: re-order comboboxes to match the order in the library
loathingKernel Feb 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rare/components/tabs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .games import GamesTab
from .settings import SettingsTab
from .settings.debug import DebugSettings
from .store import Shop
from .store import StoreTab
from .tab_widgets import MainTabBar, TabButtonWidget


Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(self, parent):
self.setTabEnabled(self.downloads_index, not self.args.offline)

if not self.args.offline:
self.store_tab = Shop(self.core)
self.store_tab = StoreTab(self.core, parent=self)
self.store_index = self.addTab(self.store_tab, self.tr("Store (Beta)"))
self.setTabEnabled(self.store_index, not self.args.offline)

Expand Down
72 changes: 21 additions & 51 deletions rare/components/tabs/store/__init__.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,42 @@
from PyQt5.QtGui import QShowEvent, QHideEvent
from PyQt5.QtWidgets import QStackedWidget, QTabWidget
from legendary.core import LegendaryCore

from rare.shared.rare_core import RareCore
from rare.utils.paths import cache_dir
from .game_info import ShopGameInfo
from .search_results import SearchResults
from .shop_api_core import ShopApiCore
from .shop_widget import ShopWidget
from .wishlist import WishlistWidget, Wishlist
from rare.widgets.side_tab import SideTabWidget
from .api.models.response import CatalogOfferModel
from .landing import LandingWidget, LandingPage
from .search import SearchPage
from .store_api import StoreAPI
from .widgets.details import DetailsWidget
from .wishlist import WishlistPage


class Shop(QStackedWidget):
init = False
class StoreTab(SideTabWidget):

def __init__(self, core: LegendaryCore, parent=None):
super(StoreTab, self).__init__(parent=parent)
self.init = False

def __init__(self, core: LegendaryCore):
super(Shop, self).__init__()
self.core = core
self.rcore = RareCore.instance()
self.api_core = ShopApiCore(
# self.rcore = RareCore.instance()
self.api = StoreAPI(
self.core.egs.session.headers["Authorization"],
self.core.language_code,
self.core.country_code,
[] # [i.asset_infos["Windows"].namespace for i in self.rcore.game_list if bool(i.asset_infos)]
)

self.shop = ShopWidget(cache_dir(), self.core, self.api_core)
self.wishlist_widget = Wishlist(self.api_core)

self.store_tabs = QTabWidget(parent=self)
self.store_tabs.addTab(self.shop, self.tr("Games"))
self.store_tabs.addTab(self.wishlist_widget, self.tr("Wishlist"))

self.addWidget(self.store_tabs)

self.search_results = SearchResults(self.api_core)
self.addWidget(self.search_results)
self.search_results.show_info.connect(self.show_game_info)
self.info = ShopGameInfo(
[i.asset_infos["Windows"].namespace for i in self.rcore.game_list if bool(i.asset_infos)],
self.api_core,
)
self.addWidget(self.info)
self.info.back_button.clicked.connect(lambda: self.setCurrentIndex(0))
self.landing = LandingPage(self.api, parent=self)
self.landing_index = self.addTab(self.landing, self.tr("Store"))

self.search_results.back_button.clicked.connect(lambda: self.setCurrentIndex(0))
self.shop.show_info.connect(self.show_search_results)
self.search = SearchPage(self.api, parent=self)
self.search_index = self.addTab(self.search, self.tr("Search"))

self.wishlist_widget.show_game_info.connect(self.show_game_info)
self.shop.show_game.connect(self.show_game_info)
self.api_core.update_wishlist.connect(self.update_wishlist)
self.wishlist_widget.update_wishlist_signal.connect(self.update_wishlist)
self.wishlist = WishlistPage(self.api, parent=self)
self.wishlist_index = self.addTab(self.wishlist, self.tr("Wishlist"))

def showEvent(self, a0: QShowEvent) -> None:
if a0.spontaneous() or self.init:
return super().showEvent(a0)
self.shop.load()
self.wishlist_widget.update_wishlist()
self.init = True
return super().showEvent(a0)

Expand All @@ -64,14 +45,3 @@ def hideEvent(self, a0: QHideEvent) -> None:
return super().hideEvent(a0)
# TODO: Implement store unloading
return super().hideEvent(a0)

def update_wishlist(self):
self.shop.update_wishlist()

def show_game_info(self, data):
self.info.update_game(data)
self.setCurrentIndex(2)

def show_search_results(self, text: str):
self.search_results.load_results(text)
self.setCurrentIndex(1)
39 changes: 39 additions & 0 deletions rare/components/tabs/store/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import sys

from PyQt5.QtCore import QSize
from PyQt5.QtWidgets import QDialog, QApplication, QVBoxLayout
from legendary.core import LegendaryCore

from . import StoreTab


class StoreWindow(QDialog):
def __init__(self):
super().__init__()

self.core = LegendaryCore()
self.core.login()
self.store_tab = StoreTab(self.core, self)

layout = QVBoxLayout(self)
layout.addWidget(self.store_tab)

self.store_tab.show()


if __name__ == "__main__":
import rare.resources.static_css
# import rare.resources.stylesheets.RareStyle
from rare.utils.misc import set_style_sheet

app = QApplication(sys.argv)
app.setApplicationName("Rare")
app.setOrganizationName("Rare")

set_style_sheet("")
set_style_sheet("RareStyle")
window = StoreWindow()
window.setWindowTitle(f"{app.applicationName()} - Store")
window.resize(QSize(1280, 800))
window.show()
app.exec()
Empty file.
Empty file.
Loading
Loading