GameInfo: Use ui
member instead of double inheritance for the UI module
Signed-off-by: loathingKernel <142770+loathingKernel@users.noreply.github.com>
This commit is contained in:
parent
7b6a3e181a
commit
b73fc328d2
|
@ -42,13 +42,14 @@ from .move_game import CopyGameInstallation, MoveGamePopUp, is_game_dir
|
||||||
logger = getLogger("GameInfo")
|
logger = getLogger("GameInfo")
|
||||||
|
|
||||||
|
|
||||||
class GameInfo(QWidget, Ui_GameInfo):
|
class GameInfo(QWidget):
|
||||||
verification_finished = pyqtSignal(InstalledGame)
|
verification_finished = pyqtSignal(InstalledGame)
|
||||||
uninstalled = pyqtSignal(str)
|
uninstalled = pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, game_utils, parent=None):
|
def __init__(self, game_utils, parent=None):
|
||||||
super(GameInfo, self).__init__(parent=parent)
|
super(GameInfo, self).__init__(parent=parent)
|
||||||
self.setupUi(self)
|
self.ui = Ui_GameInfo()
|
||||||
|
self.ui.setupUi(self)
|
||||||
self.core = LegendaryCoreSingleton()
|
self.core = LegendaryCoreSingleton()
|
||||||
self.signals = GlobalSignalsSingleton()
|
self.signals = GlobalSignalsSingleton()
|
||||||
self.args = ArgumentsSingleton()
|
self.args = ArgumentsSingleton()
|
||||||
|
@ -62,36 +63,36 @@ class GameInfo(QWidget, Ui_GameInfo):
|
||||||
|
|
||||||
self.image = ImageWidget(self)
|
self.image = ImageWidget(self)
|
||||||
self.image.setFixedSize(ImageSize.Display)
|
self.image.setFixedSize(ImageSize.Display)
|
||||||
self.layout_game_info.insertWidget(0, self.image, alignment=Qt.AlignTop)
|
self.ui.layout_game_info.insertWidget(0, self.image, alignment=Qt.AlignTop)
|
||||||
|
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
self.lbl_grade.setVisible(False)
|
self.ui.lbl_grade.setVisible(False)
|
||||||
self.grade.setVisible(False)
|
self.ui.grade.setVisible(False)
|
||||||
else:
|
else:
|
||||||
self.steam_worker: SteamWorker = SteamWorker(self.core)
|
self.steam_worker: SteamWorker = SteamWorker(self.core)
|
||||||
self.steam_worker.signals.rating.connect(self.grade.setText)
|
self.steam_worker.signals.rating.connect(self.ui.grade.setText)
|
||||||
self.steam_worker.setAutoDelete(False)
|
self.steam_worker.setAutoDelete(False)
|
||||||
|
|
||||||
self.game_actions_stack.setCurrentIndex(0)
|
self.ui.game_actions_stack.setCurrentIndex(0)
|
||||||
self.game_actions_stack.resize(self.game_actions_stack.minimumSize())
|
self.ui.game_actions_stack.resize(self.ui.game_actions_stack.minimumSize())
|
||||||
|
|
||||||
self.uninstall_button.clicked.connect(self.uninstall)
|
self.ui.uninstall_button.clicked.connect(self.uninstall)
|
||||||
self.verify_button.clicked.connect(self.verify)
|
self.ui.verify_button.clicked.connect(self.verify)
|
||||||
|
|
||||||
self.verify_pool = QThreadPool()
|
self.verify_pool = QThreadPool()
|
||||||
self.verify_pool.setMaxThreadCount(2)
|
self.verify_pool.setMaxThreadCount(2)
|
||||||
if self.args.offline:
|
if self.args.offline:
|
||||||
self.repair_button.setDisabled(True)
|
self.ui.repair_button.setDisabled(True)
|
||||||
else:
|
else:
|
||||||
self.repair_button.clicked.connect(self.repair)
|
self.ui.repair_button.clicked.connect(self.repair)
|
||||||
|
|
||||||
self.install_button.clicked.connect(self.install)
|
self.ui.install_button.clicked.connect(self.install)
|
||||||
|
|
||||||
self.move_game_pop_up = MoveGamePopUp()
|
self.move_game_pop_up = MoveGamePopUp()
|
||||||
self.move_action = QWidgetAction(self)
|
self.move_action = QWidgetAction(self)
|
||||||
self.move_action.setDefaultWidget(self.move_game_pop_up)
|
self.move_action.setDefaultWidget(self.move_game_pop_up)
|
||||||
self.move_button.setMenu(QMenu())
|
self.ui.move_button.setMenu(QMenu())
|
||||||
self.move_button.menu().addAction(self.move_action)
|
self.ui.move_button.menu().addAction(self.move_action)
|
||||||
|
|
||||||
self.progress_of_moving = QProgressBar()
|
self.progress_of_moving = QProgressBar()
|
||||||
self.existing_game_dir = False
|
self.existing_game_dir = False
|
||||||
|
@ -102,12 +103,12 @@ class GameInfo(QWidget, Ui_GameInfo):
|
||||||
self.widget_container = QWidget()
|
self.widget_container = QWidget()
|
||||||
box_layout = QHBoxLayout()
|
box_layout = QHBoxLayout()
|
||||||
box_layout.setContentsMargins(0, 0, 0, 0)
|
box_layout.setContentsMargins(0, 0, 0, 0)
|
||||||
box_layout.addWidget(self.move_button)
|
box_layout.addWidget(self.ui.move_button)
|
||||||
self.widget_container.setLayout(box_layout)
|
self.widget_container.setLayout(box_layout)
|
||||||
index = self.move_stack.addWidget(self.widget_container)
|
index = self.ui.move_stack.addWidget(self.widget_container)
|
||||||
self.move_stack.setCurrentIndex(index)
|
self.ui.move_stack.setCurrentIndex(index)
|
||||||
self.move_game_pop_up.browse_done.connect(self.show_menu_after_browse)
|
self.move_game_pop_up.browse_done.connect(self.show_menu_after_browse)
|
||||||
self.move_game_pop_up.move_clicked.connect(self.move_button.menu().close)
|
self.move_game_pop_up.move_clicked.connect(self.ui.move_button.menu().close)
|
||||||
self.move_game_pop_up.move_clicked.connect(self.move_game)
|
self.move_game_pop_up.move_clicked.connect(self.move_game)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
@ -170,21 +171,21 @@ class GameInfo(QWidget, Ui_GameInfo):
|
||||||
self.verify_game(self.igame)
|
self.verify_game(self.igame)
|
||||||
|
|
||||||
def verify_game(self, igame: InstalledGame):
|
def verify_game(self, igame: InstalledGame):
|
||||||
self.verify_widget.setCurrentIndex(1)
|
self.ui.verify_widget.setCurrentIndex(1)
|
||||||
verify_worker = VerifyWorker(igame.app_name)
|
verify_worker = VerifyWorker(igame.app_name)
|
||||||
verify_worker.signals.status.connect(self.verify_status)
|
verify_worker.signals.status.connect(self.verify_status)
|
||||||
verify_worker.signals.result.connect(self.verify_result)
|
verify_worker.signals.result.connect(self.verify_result)
|
||||||
verify_worker.signals.error.connect(self.verify_error)
|
verify_worker.signals.error.connect(self.verify_error)
|
||||||
self.verify_progress.setValue(0)
|
self.ui.verify_progress.setValue(0)
|
||||||
self.verify_threads[igame.app_name] = verify_worker
|
self.verify_threads[igame.app_name] = verify_worker
|
||||||
self.verify_pool.start(verify_worker)
|
self.verify_pool.start(verify_worker)
|
||||||
self.move_button.setEnabled(False)
|
self.ui.move_button.setEnabled(False)
|
||||||
|
|
||||||
def verify_cleanup(self, app_name: str):
|
def verify_cleanup(self, app_name: str):
|
||||||
self.verify_widget.setCurrentIndex(0)
|
self.ui.verify_widget.setCurrentIndex(0)
|
||||||
self.verify_threads.pop(app_name)
|
self.verify_threads.pop(app_name)
|
||||||
self.move_button.setEnabled(True)
|
self.ui.move_button.setEnabled(True)
|
||||||
self.verify_button.setEnabled(True)
|
self.ui.verify_button.setEnabled(True)
|
||||||
|
|
||||||
@pyqtSlot(str, str)
|
@pyqtSlot(str, str)
|
||||||
def verify_error(self, app_name, message):
|
def verify_error(self, app_name, message):
|
||||||
|
@ -200,12 +201,12 @@ class GameInfo(QWidget, Ui_GameInfo):
|
||||||
def verify_status(self, app_name, num, total, percentage, speed):
|
def verify_status(self, app_name, num, total, percentage, speed):
|
||||||
# checked, max, app_name
|
# checked, max, app_name
|
||||||
if app_name == self.game.app_name:
|
if app_name == self.game.app_name:
|
||||||
self.verify_progress.setValue(num * 100 // total)
|
self.ui.verify_progress.setValue(num * 100 // total)
|
||||||
|
|
||||||
@pyqtSlot(str, bool, int, int)
|
@pyqtSlot(str, bool, int, int)
|
||||||
def verify_result(self, app_name, success, failed, missing):
|
def verify_result(self, app_name, success, failed, missing):
|
||||||
self.verify_cleanup(app_name)
|
self.verify_cleanup(app_name)
|
||||||
self.repair_button.setDisabled(success)
|
self.ui.repair_button.setDisabled(success)
|
||||||
igame = self.core.get_installed_game(app_name)
|
igame = self.core.get_installed_game(app_name)
|
||||||
if success:
|
if success:
|
||||||
QMessageBox.information(
|
QMessageBox.information(
|
||||||
|
@ -262,13 +263,13 @@ class GameInfo(QWidget, Ui_GameInfo):
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.move_stack.addWidget(self.progress_of_moving)
|
self.ui.move_stack.addWidget(self.progress_of_moving)
|
||||||
self.move_stack.setCurrentWidget(self.progress_of_moving)
|
self.ui.move_stack.setCurrentWidget(self.progress_of_moving)
|
||||||
|
|
||||||
self.game_moving = self.igame.app_name
|
self.game_moving = self.igame.app_name
|
||||||
self.is_moving = True
|
self.is_moving = True
|
||||||
|
|
||||||
self.verify_button.setEnabled(False)
|
self.ui.verify_button.setEnabled(False)
|
||||||
|
|
||||||
if self.move_game_pop_up.is_different_drive(str(dest_path), str(install_path)):
|
if self.move_game_pop_up.is_different_drive(str(dest_path), str(install_path)):
|
||||||
# Destination dir on different drive
|
# Destination dir on different drive
|
||||||
|
@ -295,12 +296,12 @@ class GameInfo(QWidget, Ui_GameInfo):
|
||||||
QThreadPool.globalInstance().start(copy_worker)
|
QThreadPool.globalInstance().start(copy_worker)
|
||||||
|
|
||||||
def move_helper_clean_up(self):
|
def move_helper_clean_up(self):
|
||||||
self.move_stack.setCurrentWidget(self.move_button)
|
self.ui.move_stack.setCurrentWidget(self.ui.move_button)
|
||||||
self.move_game_pop_up.refresh_indicator()
|
self.move_game_pop_up.refresh_indicator()
|
||||||
self.is_moving = False
|
self.is_moving = False
|
||||||
self.game_moving = None
|
self.game_moving = None
|
||||||
self.verify_button.setEnabled(True)
|
self.ui.verify_button.setEnabled(True)
|
||||||
self.move_button.setEnabled(True)
|
self.ui.move_button.setEnabled(True)
|
||||||
|
|
||||||
# This func does the needed UI changes, e.g. changing back to the initial move tool button and other stuff
|
# This func does the needed UI changes, e.g. changing back to the initial move tool button and other stuff
|
||||||
def warn_no_space_left(self):
|
def warn_no_space_left(self):
|
||||||
|
@ -311,7 +312,7 @@ class GameInfo(QWidget, Ui_GameInfo):
|
||||||
|
|
||||||
# Sets all needed variables to the new path.
|
# Sets all needed variables to the new path.
|
||||||
def set_new_game(self, dest_path_with_suffix):
|
def set_new_game(self, dest_path_with_suffix):
|
||||||
self.install_path.setText(str(dest_path_with_suffix))
|
self.ui.install_path.setText(str(dest_path_with_suffix))
|
||||||
self.igame.install_path = str(dest_path_with_suffix)
|
self.igame.install_path = str(dest_path_with_suffix)
|
||||||
self.core.lgd.set_installed_game(self.igame.app_name, self.igame)
|
self.core.lgd.set_installed_game(self.igame.app_name, self.igame)
|
||||||
self.move_game_pop_up.install_path = self.igame.install_path
|
self.move_game_pop_up.install_path = self.igame.install_path
|
||||||
|
@ -321,7 +322,7 @@ class GameInfo(QWidget, Ui_GameInfo):
|
||||||
# We need to re-show the menu, as after clicking on browse, the whole menu gets closed.
|
# We need to re-show the menu, as after clicking on browse, the whole menu gets closed.
|
||||||
# Otherwise, the user would need to click on the move button again to open it again.
|
# Otherwise, the user would need to click on the move button again to open it again.
|
||||||
def show_menu_after_browse(self):
|
def show_menu_after_browse(self):
|
||||||
self.move_button.showMenu()
|
self.ui.move_button.showMenu()
|
||||||
|
|
||||||
def update_game(self, rgame: RareGame):
|
def update_game(self, rgame: RareGame):
|
||||||
# FIXME: Use RareGame for the rest of the code
|
# FIXME: Use RareGame for the rest of the code
|
||||||
|
@ -332,64 +333,64 @@ class GameInfo(QWidget, Ui_GameInfo):
|
||||||
|
|
||||||
self.image.setPixmap(rgame.pixmap)
|
self.image.setPixmap(rgame.pixmap)
|
||||||
|
|
||||||
self.app_name.setText(self.game.app_name)
|
self.ui.app_name.setText(self.game.app_name)
|
||||||
if self.igame:
|
if self.igame:
|
||||||
self.version.setText(self.igame.version)
|
self.ui.version.setText(self.igame.version)
|
||||||
else:
|
else:
|
||||||
self.version.setText(self.game.app_version(self.igame.platform if self.igame else "Windows"))
|
self.ui.version.setText(self.game.app_version(self.igame.platform if self.igame else "Windows"))
|
||||||
self.dev.setText(self.game.metadata["developer"])
|
self.ui.dev.setText(self.game.metadata["developer"])
|
||||||
|
|
||||||
if self.igame:
|
if self.igame:
|
||||||
self.install_size.setText(get_size(self.igame.install_size))
|
self.ui.install_size.setText(get_size(self.igame.install_size))
|
||||||
self.install_path.setText(self.igame.install_path)
|
self.ui.install_path.setText(self.igame.install_path)
|
||||||
self.platform.setText(self.igame.platform)
|
self.ui.platform.setText(self.igame.platform)
|
||||||
else:
|
else:
|
||||||
self.install_size.setText("N/A")
|
self.ui.install_size.setText("N/A")
|
||||||
self.install_path.setText("N/A")
|
self.ui.install_path.setText("N/A")
|
||||||
self.platform.setText("Windows")
|
self.ui.platform.setText("Windows")
|
||||||
|
|
||||||
self.install_size.setEnabled(bool(self.igame))
|
self.ui.install_size.setEnabled(bool(self.igame))
|
||||||
self.lbl_install_size.setEnabled(bool(self.igame))
|
self.ui.lbl_install_size.setEnabled(bool(self.igame))
|
||||||
self.install_path.setEnabled(bool(self.igame))
|
self.ui.install_path.setEnabled(bool(self.igame))
|
||||||
self.lbl_install_path.setEnabled(bool(self.igame))
|
self.ui.lbl_install_path.setEnabled(bool(self.igame))
|
||||||
|
|
||||||
self.uninstall_button.setEnabled(bool(self.igame))
|
self.ui.uninstall_button.setEnabled(bool(self.igame))
|
||||||
self.verify_button.setEnabled(bool(self.igame))
|
self.ui.verify_button.setEnabled(bool(self.igame))
|
||||||
self.repair_button.setEnabled(bool(self.igame))
|
self.ui.repair_button.setEnabled(bool(self.igame))
|
||||||
|
|
||||||
if not self.igame:
|
if not self.igame:
|
||||||
self.game_actions_stack.setCurrentIndex(1)
|
self.ui.game_actions_stack.setCurrentIndex(1)
|
||||||
if self.game.metadata.get("customAttributes", {}).get("ThirdPartyManagedApp", {}).get("value") == "Origin":
|
if self.game.metadata.get("customAttributes", {}).get("ThirdPartyManagedApp", {}).get("value") == "Origin":
|
||||||
self.version.setText("N/A")
|
self.ui.version.setText("N/A")
|
||||||
self.version.setEnabled(False)
|
self.ui.version.setEnabled(False)
|
||||||
self.install_button.setText(self.tr("Link to Origin/Launch"))
|
self.ui.install_button.setText(self.tr("Link to Origin/Launch"))
|
||||||
else:
|
else:
|
||||||
self.install_button.setText(self.tr("Install"))
|
self.ui.install_button.setText(self.tr("Install"))
|
||||||
else:
|
else:
|
||||||
if not self.args.offline:
|
if not self.args.offline:
|
||||||
self.repair_button.setDisabled(
|
self.ui.repair_button.setDisabled(
|
||||||
not os.path.exists(os.path.join(self.core.lgd.get_tmp_path(), f"{self.igame.app_name}.repair"))
|
not os.path.exists(os.path.join(self.core.lgd.get_tmp_path(), f"{self.igame.app_name}.repair"))
|
||||||
)
|
)
|
||||||
self.game_actions_stack.setCurrentIndex(0)
|
self.ui.game_actions_stack.setCurrentIndex(0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
is_ue = self.core.get_asset(rgame.app_name).namespace == "ue"
|
is_ue = self.core.get_asset(rgame.app_name).namespace == "ue"
|
||||||
except ValueError:
|
except ValueError:
|
||||||
is_ue = False
|
is_ue = False
|
||||||
grade_visible = not is_ue and platform.system() != "Windows"
|
grade_visible = not is_ue and platform.system() != "Windows"
|
||||||
self.grade.setVisible(grade_visible)
|
self.ui.grade.setVisible(grade_visible)
|
||||||
self.lbl_grade.setVisible(grade_visible)
|
self.ui.lbl_grade.setVisible(grade_visible)
|
||||||
|
|
||||||
if platform.system() != "Windows" and not is_ue:
|
if platform.system() != "Windows" and not is_ue:
|
||||||
self.grade.setText(self.tr("Loading"))
|
self.ui.grade.setText(self.tr("Loading"))
|
||||||
self.steam_worker.set_app_name(self.game.app_name)
|
self.steam_worker.set_app_name(self.game.app_name)
|
||||||
QThreadPool.globalInstance().start(self.steam_worker)
|
QThreadPool.globalInstance().start(self.steam_worker)
|
||||||
|
|
||||||
if len(self.verify_threads.keys()) == 0 or not self.verify_threads.get(self.game.app_name):
|
if len(self.verify_threads.keys()) == 0 or not self.verify_threads.get(self.game.app_name):
|
||||||
self.verify_widget.setCurrentIndex(0)
|
self.ui.verify_widget.setCurrentIndex(0)
|
||||||
elif self.verify_threads.get(self.game.app_name):
|
elif self.verify_threads.get(self.game.app_name):
|
||||||
self.verify_widget.setCurrentIndex(1)
|
self.ui.verify_widget.setCurrentIndex(1)
|
||||||
self.verify_progress.setValue(
|
self.ui.verify_progress.setValue(
|
||||||
int(
|
int(
|
||||||
self.verify_threads[self.game.app_name].num
|
self.verify_threads[self.game.app_name].num
|
||||||
/ self.verify_threads[self.game.app_name].total
|
/ self.verify_threads[self.game.app_name].total
|
||||||
|
@ -401,19 +402,19 @@ class GameInfo(QWidget, Ui_GameInfo):
|
||||||
# Otherwhise, we show the move tool button.
|
# Otherwhise, we show the move tool button.
|
||||||
if self.igame is not None:
|
if self.igame is not None:
|
||||||
if self.game_moving == self.igame.app_name:
|
if self.game_moving == self.igame.app_name:
|
||||||
index = self.move_stack.addWidget(self.progress_of_moving)
|
index = self.ui.move_stack.addWidget(self.progress_of_moving)
|
||||||
self.move_stack.setCurrentIndex(index)
|
self.ui.move_stack.setCurrentIndex(index)
|
||||||
else:
|
else:
|
||||||
index = self.move_stack.addWidget(self.move_button)
|
index = self.ui.move_stack.addWidget(self.ui.move_button)
|
||||||
self.move_stack.setCurrentIndex(index)
|
self.ui.move_stack.setCurrentIndex(index)
|
||||||
|
|
||||||
# If a game is verifying or moving, disable both verify and moving buttons.
|
# If a game is verifying or moving, disable both verify and moving buttons.
|
||||||
if len(self.verify_threads):
|
if len(self.verify_threads):
|
||||||
self.verify_button.setEnabled(False)
|
self.ui.verify_button.setEnabled(False)
|
||||||
self.move_button.setEnabled(False)
|
self.ui.move_button.setEnabled(False)
|
||||||
if self.is_moving:
|
if self.is_moving:
|
||||||
self.move_button.setEnabled(False)
|
self.ui.move_button.setEnabled(False)
|
||||||
self.verify_button.setEnabled(False)
|
self.ui.verify_button.setEnabled(False)
|
||||||
|
|
||||||
self.move_game_pop_up.update_game(rgame.app_name)
|
self.move_game_pop_up.update_game(rgame.app_name)
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class GameSettings(DefaultGameSettings):
|
||||||
igame: InstalledGame
|
igame: InstalledGame
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(GameSettings, self).__init__(False, parent)
|
super(GameSettings, self).__init__(False, parent=parent)
|
||||||
self.pre_launch_settings = PreLaunchSettings()
|
self.pre_launch_settings = PreLaunchSettings()
|
||||||
self.launch_settings_group.layout().addRow(
|
self.launch_settings_group.layout().addRow(
|
||||||
QLabel(self.tr("Pre-launch command")), self.pre_launch_settings
|
QLabel(self.tr("Pre-launch command")), self.pre_launch_settings
|
||||||
|
|
|
@ -19,8 +19,8 @@ class MoveGamePopUp(QWidget):
|
||||||
move_clicked = pyqtSignal(str)
|
move_clicked = pyqtSignal(str)
|
||||||
browse_done = pyqtSignal()
|
browse_done = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, parent=None):
|
||||||
super(MoveGamePopUp, self).__init__()
|
super(MoveGamePopUp, self).__init__(parent=parent)
|
||||||
layout: QVBoxLayout = QVBoxLayout()
|
layout: QVBoxLayout = QVBoxLayout()
|
||||||
self.install_path = str()
|
self.install_path = str()
|
||||||
self.core = LegendaryCoreSingleton()
|
self.core = LegendaryCoreSingleton()
|
||||||
|
|
|
@ -5,3 +5,4 @@ toml
|
||||||
nuitka
|
nuitka
|
||||||
ordered-set
|
ordered-set
|
||||||
PyQt5-stubs
|
PyQt5-stubs
|
||||||
|
qstylizer
|
Loading…
Reference in a new issue