From 4491e1c46c987c697d54b94b5548e2fff783eeea Mon Sep 17 00:00:00 2001 From: Nucanot Date: Fri, 29 Mar 2024 11:19:41 +0100 Subject: [PATCH 1/2] Prepend Current Fit's Ship and Name to the Window's Title MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit prepends the current fit's ship name and fit name to the main frame's title. Format is "" — is the title, either "pyfa" or "pyfa v1.2.3 - Python Fitting Assistant" The title is update when the active fit changes (via the tab switcher) or the current fit is renamed. --- gui/mainFrame.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 44bfc5c49..e1cea9a97 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -234,6 +234,9 @@ def __init__(self, title="pyfa"): self.Bind(GE.EVT_SSO_LOGIN, self.onSSOLogin) + self.Bind(GE.FIT_CHANGED, self.onFitChanged) + self.Bind(GE.FIT_RENAMED, self.onFitRenamed) + @property def command(self) -> wx.CommandProcessor: return Fit.getCommandProcessor(self.getActiveFit()) @@ -996,3 +999,37 @@ def openWXInspectTool(self, event): if not wnd: wnd = self InspectionTool().Show(wnd, True) + + def onFitChanged(self, event): + """ + Triggered by a FIT_CHANGED event (which is posted when the active fit changes) + This method updates the windows's title via `_updateTitle()`. + """ + activeFitID = self.getActiveFit() + if activeFitID is not None and activeFitID not in event.fitIDs: + return + self._updateTitle(fitID=activeFitID) + + def onFitRenamed(self, event): + """ + Triggered by a FIT_RENAMED event. + This method updates the windows's title via `_updateTitle()` if the current fit is renamed. + """ + if self.getActiveFit() != event.fitID: + return + self._updateTitle(fitID=event.fitID) + + def _updateTitle(self, fitID): + """ + This method updates the frame's title with information from the fit with ID `fitID`. + """ + fit = Fit.getInstance().getFit(fitID) + fitName = fit and fit.name or None + shipName = fit and fit.ship.name or None + + newTitle = "" + if fitName is not None and shipName is not None: + newTitle = f'{shipName} "{fitName}" — {self.title}' + else: + newTitle = self.title + self.SetTitle(newTitle) From 484c165e0c942da06abf5e85f41ddae755645ef5 Mon Sep 17 00:00:00 2001 From: Nucanot Date: Fri, 29 Mar 2024 13:48:06 +0100 Subject: [PATCH 2/2] Add Missing Skip() Calls --- gui/mainFrame.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gui/mainFrame.py b/gui/mainFrame.py index e1cea9a97..864ff2936 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -1005,6 +1005,7 @@ def onFitChanged(self, event): Triggered by a FIT_CHANGED event (which is posted when the active fit changes) This method updates the windows's title via `_updateTitle()`. """ + event.Skip() activeFitID = self.getActiveFit() if activeFitID is not None and activeFitID not in event.fitIDs: return @@ -1015,6 +1016,7 @@ def onFitRenamed(self, event): Triggered by a FIT_RENAMED event. This method updates the windows's title via `_updateTitle()` if the current fit is renamed. """ + event.Skip() if self.getActiveFit() != event.fitID: return self._updateTitle(fitID=event.fitID)