Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepend Current Fit's Ship and Name to the Window's Title #2601

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions gui/mainFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -996,3 +999,39 @@ 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()`.
"""
event.Skip()
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.
"""
event.Skip()
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)