From 7808da118a887c8145b0fb37f3ce9ee8dd5739e8 Mon Sep 17 00:00:00 2001 From: Chris Seagraves <47610393+nosv1@users.noreply.github.com> Date: Sun, 20 Jun 2021 15:33:27 -0500 Subject: [PATCH] Include the save name in the window title. --- qt_ui/windows/QLiberationWindow.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/qt_ui/windows/QLiberationWindow.py b/qt_ui/windows/QLiberationWindow.py index c2a96a4d..a79755c3 100644 --- a/qt_ui/windows/QLiberationWindow.py +++ b/qt_ui/windows/QLiberationWindow.py @@ -50,7 +50,7 @@ class QLiberationWindow(QMainWindow): self.liberation_map = QLiberationMap(self.game_model, self) self.setGeometry(300, 100, 270, 100) - self.setWindowTitle(f"DCS Liberation - v{VERSION}") + self.updateWindowTitle() self.setWindowIcon(QIcon("./resources/icon.png")) self.statusBar().showMessage("Ready") @@ -71,6 +71,7 @@ class QLiberationWindow(QMainWindow): logging.info("Loading last saved game : " + str(last_save_file)) game = persistency.load_game(last_save_file) self.onGameGenerated(game) + self.updateWindowTitle(last_save_file) except: logging.info("Error loading latest save game") else: @@ -243,6 +244,8 @@ class QLiberationWindow(QMainWindow): game = persistency.load_game(file[0]) GameUpdateSignal.get_instance().game_loaded.emit(game) + self.updateWindowTitle(file[0]) + def saveGame(self): logging.info("Saving game") @@ -266,6 +269,18 @@ class QLiberationWindow(QMainWindow): liberation_install.setup_last_save_file(self.game.savepath) liberation_install.save_config() + self.updateWindowTitle(file[0]) + + def updateWindowTitle(self, save_path: Optional[str] = None) -> None: + """ + to DCS Liberation - vX.X.X - file_name + """ + window_title = f"DCS Liberation - v{VERSION}" + if save_path: # appending the file name to title as it is updated + file_name = save_path.split("/")[-1].split(".liberation")[0] + window_title = f"{window_title} - {file_name}" + self.setWindowTitle(window_title) + def onGameGenerated(self, game: Game): logging.info("On Game generated") self.game = game