1
0
Fork 0
mirror of synced 2024-06-02 02:34:40 +12:00

ImportGame: Pass app_name through the signal to resolve some information

Not working particularly well, since setting the path tries to auto-detect
the `app_name`, but it doesn't break anything either.
This commit is contained in:
loathingKernel 2023-04-16 23:01:09 +03:00
parent 4a96224dd3
commit 184be66662
No known key found for this signature in database
GPG key ID: CE0C72D0B53821FD
3 changed files with 26 additions and 16 deletions

View file

@ -47,7 +47,7 @@ class GamesTab(QStackedWidget):
self.game_info_page = GameInfoTabs(self)
self.game_info_page.back_clicked.connect(lambda: self.setCurrentWidget(self.games_page))
self.game_info_page.import_clicked.connect(lambda: self.show_import())
self.game_info_page.import_clicked.connect(self.show_import)
self.addWidget(self.game_info_page)
self.integrations_page = IntegrationsTabs(self)
@ -118,9 +118,10 @@ class GamesTab(QStackedWidget):
)
@pyqtSlot()
def show_import(self):
@pyqtSlot(str)
def show_import(self, app_name: str = None):
self.setCurrentWidget(self.integrations_page)
self.integrations_page.show_import()
self.integrations_page.show_import(app_name)
@pyqtSlot()
def show_egl_sync(self):

View file

@ -13,15 +13,17 @@ from .ubisoft_group import UbisoftGroup
class IntegrationsTabs(SideTabWidget):
def __init__(self, parent=None):
super(IntegrationsTabs, self).__init__(show_back=True, parent=parent)
self.import_group = ImportGroup(self)
self.import_widget = IntegrationsWidget(
ImportGroup(self),
self.import_group,
self.tr("To import games from Epic Games Store, please enable EGL Sync."),
self,
)
self.import_index = self.addTab(self.import_widget, self.tr("Import Games"))
self.egl_sync_group = EGLSyncGroup(self)
self.egl_sync_widget = IntegrationsWidget(
EGLSyncGroup(self),
self.egl_sync_group,
self.tr("To import EGL games from directories, please use Import Game."),
self,
)
@ -32,14 +34,17 @@ class IntegrationsTabs(SideTabWidget):
self.tr(""),
self,
)
self.eos_ubisoft.addWidget(UbisoftGroup(self.eos_ubisoft))
self.eos_ubisoft.addWidget(EOSGroup(self.eos_ubisoft))
self.ubisoft_group = UbisoftGroup(self.eos_ubisoft)
self.eos_group = EOSGroup(self.eos_ubisoft)
self.eos_ubisoft.addWidget(self.ubisoft_group)
self.eos_ubisoft.addWidget(self.eos_group)
self.eos_ubisoft_index = self.addTab(self.eos_ubisoft, self.tr("Epic Overlay and Ubisoft"))
self.setCurrentIndex(self.import_index)
def show_import(self):
def show_import(self, app_name: str = None):
self.setCurrentIndex(self.import_index)
self.import_group.set_game(app_name)
def show_egl_sync(self):
self.setCurrentIndex(self.egl_sync_index)
@ -53,13 +58,11 @@ class IntegrationsWidget(QWidget):
super(IntegrationsWidget, self).__init__(parent=parent)
self.info = QLabel(f"<b>{info}</b>")
layout = QVBoxLayout(self)
self.__layout = QVBoxLayout(self)
if widget is not None:
layout.addWidget(widget)
layout.addWidget(self.info)
layout.addItem(
QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
)
self.__layout.addWidget(widget)
self.__layout.addWidget(self.info)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
def addWidget(self, widget: QWidget, stretch: int = 0, alignment: Qt.AlignmentFlag = Qt.Alignment()):
self.layout().insertWidget(self.layout().count() - 2, widget, stretch, alignment)
self.__layout.insertWidget(self.layout().count() - 1, widget, stretch, alignment)

View file

@ -217,6 +217,12 @@ class ImportGroup(QGroupBox):
self.threadpool = QThreadPool.globalInstance()
def set_game(self, app_name: str):
if app_name:
folder = self.rcore.get_game(app_name).folder_name
self.path_edit.setText(os.path.join(self.core.get_default_install_dir(), folder))
self.app_name_edit.setText(app_name)
def path_edit_callback(self, path) -> Tuple[bool, str, int]:
if os.path.exists(path):
if os.path.exists(os.path.join(path, ".egstore")):
@ -252,7 +258,7 @@ class ImportGroup(QGroupBox):
self.ui.import_dlcs_check.setEnabled(
bool(self.core.get_dlc_for_game(app_name))
)
self.ui.import_button.setEnabled(True)
self.ui.import_button.setEnabled(self.path_edit.is_valid)
else:
self.ui.import_dlcs_check.setEnabled(False)
self.ui.import_button.setEnabled(False)