1
0
Fork 0
mirror of synced 2024-07-03 05:31:23 +12:00
Rare/rare/components/tab_widget.py

57 lines
2.5 KiB
Python
Raw Normal View History

2021-03-09 03:07:07 +13:00
from PyQt5.QtCore import QSize
2021-03-25 05:01:12 +13:00
from PyQt5.QtWidgets import QTabWidget, QWidget
2021-03-09 08:36:42 +13:00
from qtawesome import icon
2021-02-18 05:46:03 +13:00
2021-04-08 08:39:23 +12:00
from rare.components.TabUtils import TabBar, TabButtonWidget
from rare.components.tabs.CloudSaves import SyncSaves
from rare.components.tabs.Downloads.__init__ import DownloadTab
from rare.components.tabs.Games import GameTab
from rare.components.tabs.Settings import SettingsTab
from rare.utils.models import InstallOptions
2021-03-19 00:45:59 +13:00
from custom_legendary.core import LegendaryCore
2021-02-10 23:48:25 +13:00
class TabWidget(QTabWidget):
2021-02-20 00:57:55 +13:00
def __init__(self, core: LegendaryCore):
2021-02-10 23:48:25 +13:00
super(TabWidget, self).__init__()
2021-03-16 23:03:55 +13:00
disabled_tab = 3
self.setTabBar(TabBar(disabled_tab))
2021-02-20 00:57:55 +13:00
self.settings = SettingsTab(core)
2021-02-23 06:50:00 +13:00
self.game_list = GameTab(core)
2021-03-09 05:20:28 +13:00
self.game_list.default_widget.game_list.update_game.connect(lambda: self.setCurrentIndex(1))
updates = self.game_list.default_widget.game_list.updates
2021-02-10 23:48:25 +13:00
self.addTab(self.game_list, self.tr("Games"))
self.downloadTab = DownloadTab(core, updates)
self.addTab(self.downloadTab, "Downloads" + (" (" + str(len(updates)) + ")" if len(updates) != 0 else ""))
self.downloadTab.finished.connect(self.dl_finished)
2021-02-23 06:50:00 +13:00
self.game_list.default_widget.game_list.install_game.connect(lambda x: self.downloadTab.install_game(x))
2021-02-28 05:20:56 +13:00
2021-03-12 01:11:15 +13:00
self.game_list.game_info.info.verify_game.connect(lambda app_name: self.downloadTab.install_game(
InstallOptions(app_name, core.get_installed_game(app_name).install_path, repair=True)))
2021-03-12 01:11:15 +13:00
self.tabBarClicked.connect(lambda x: self.game_list.layout.setCurrentIndex(0) if x == 0 else None)
2021-03-16 23:03:55 +13:00
self.cloud_saves = SyncSaves(core)
self.addTab(self.cloud_saves, "Cloud Saves")
2021-02-10 23:48:25 +13:00
# Space Tab
self.addTab(QWidget(), "")
self.setTabEnabled(disabled_tab, False)
2021-02-10 23:48:25 +13:00
self.account = QWidget()
self.addTab(self.account, "")
2021-03-09 03:07:07 +13:00
self.setTabEnabled(disabled_tab + 1, False)
2021-02-10 23:48:25 +13:00
# self.settings = SettingsTab(core)
self.addTab(self.settings, icon("fa.gear", color='white'), "(!)" if self.settings.about.update_available else "")
2021-03-09 03:07:07 +13:00
self.setIconSize(QSize(25, 25))
2021-02-10 23:48:25 +13:00
self.tabBar().setTabButton(3, self.tabBar().RightSide, TabButtonWidget(core))
def dl_finished(self):
self.game_list.default_widget.game_list.update_list()
self.setTabText(1, "Downloads")
2021-02-10 23:48:25 +13:00
def resizeEvent(self, event):
self.tabBar().setMinimumWidth(self.width())
super(TabWidget, self).resizeEvent(event)