From 50bbea2b75ffc660472d2d00a484a4d495384f0a Mon Sep 17 00:00:00 2001 From: Dummerle Date: Wed, 6 Jan 2021 21:41:26 +0100 Subject: [PATCH] Some nice dialogs --- Rare/Tabs/GamesInstalled/GameSettingsDialog.py | 12 ++++++++---- Rare/Tabs/GamesInstalled/InstalledList.py | 15 ++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Rare/Tabs/GamesInstalled/GameSettingsDialog.py b/Rare/Tabs/GamesInstalled/GameSettingsDialog.py index 8ff84c92..e072a118 100644 --- a/Rare/Tabs/GamesInstalled/GameSettingsDialog.py +++ b/Rare/Tabs/GamesInstalled/GameSettingsDialog.py @@ -38,12 +38,16 @@ class GameSettingsDialog(QDialog): return self.action def uninstall(self): - dia = AcceptDialog(f"Do you really want to delete {self.game.title}") - if dia.get_accept(): + msg = QMessageBox() + msg.setIcon(QMessageBox.Warning) + msg.setText(f"Do you really want to delete {self.game.title}") + msg.setWindowTitle("Uninstall Game") + msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + ret = msg.exec_() + + if ret == QMessageBox.Ok: self.action = "uninstall" self.close() - - def exit_settings(self): self.close() diff --git a/Rare/Tabs/GamesInstalled/InstalledList.py b/Rare/Tabs/GamesInstalled/InstalledList.py index d3516f6a..836d97d1 100644 --- a/Rare/Tabs/GamesInstalled/InstalledList.py +++ b/Rare/Tabs/GamesInstalled/InstalledList.py @@ -53,26 +53,29 @@ class GameListInstalled(QScrollArea): def import_games_prepare(self): # Automatically import from windows + imported = 0 if os.name == "nt": available_drives = ['%s:' % d for d in string.ascii_uppercase if os.path.exists('%s:' % d)] for drive in available_drives: path = f"{drive}/Program Files/Epic Games/" if os.path.exists(path): - self.auto_import_games(path) + imported += self.auto_import_games(path) else: possible_wineprefixes = [os.path.expanduser("~/.wine/"), os.path.expanduser("~/Games/epic-games-store/")] for wine_prefix in possible_wineprefixes: - self.auto_import_games(f"{wine_prefix}drive_c/Program Files/Epic Games/") + imported += self.auto_import_games(f"{wine_prefix}drive_c/Program Files/Epic Games/") + QMessageBox.information(self, "Imported Games", f"Successfully imported {imported} Games") logger.info("Restarting app to import games") def auto_import_games(self, game_path): + imported = 0 if not os.path.exists(game_path): - return + return 0 if os.listdir(game_path) == 0: logger.info(f"No Games found in {game_path}") - return + return 0 for path in os.listdir(game_path): json_path = game_path + path + "/.egstore" print(json_path) @@ -83,4 +86,6 @@ class GameListInstalled(QScrollArea): for file in os.listdir(json_path): if file.endswith(".mancpn"): app_name = json.load(open(os.path.join(json_path, file)))["AppName"] - legendaryUtils.import_game(self.core, app_name, game_path + path) + if legendaryUtils.import_game(self.core, app_name, game_path + path): + imported +=1 + return imported