Skip to content

Commit 79cb36c

Browse files
macevhiczMHendricks
authored andcommitted
Show hab env in windowTitle, if available
1 parent 9a559c8 commit 79cb36c

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

preditor/gui/logger_window_plugin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class LoggerWindowPlugin:
1313
def __init__(self, parent):
1414
self.parent = parent
1515

16+
def updateWindowTitle(self, title):
17+
return title
18+
1619
def record_prefs(self, name):
1720
"""Returns any prefs to save with the PrEditor's preferences.
1821

preditor/gui/loggerwindow.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,9 @@ def __init__(self, parent, name=None, run_workbox=False, standalone=False):
266266

267267
self.dont_ask_again = []
268268

269-
# Load any plugins that modify the LoggerWindow
270-
self.plugins = {}
271-
for name, plugin in plugins.loggerwindow():
272-
self.plugins[name] = plugin(self)
269+
# Load any plugins, and set window title
270+
self.loadPlugins()
271+
self.setWindowTitle(self.defineWindowTitle())
273272

274273
self.restorePrefs()
275274

@@ -282,17 +281,6 @@ def __init__(self, parent, name=None, run_workbox=False, standalone=False):
282281
action.triggered.connect(partial(self.setStyleSheet, style_name))
283282

284283
self.uiConsoleTOOLBAR.show()
285-
loggerName = QApplication.instance().translate(
286-
'PrEditorWindow', DEFAULT_CORE_NAME
287-
)
288-
self.setWindowTitle(
289-
'{} - {} - {} {}-bit'.format(
290-
loggerName,
291-
self.name,
292-
'{}.{}.{}'.format(*sys.version_info[:3]),
293-
osystem.getPointerSize(),
294-
)
295-
)
296284

297285
self.setWorkboxFontBasedOnConsole()
298286
self.setEditorChooserFontBasedOnConsole()
@@ -333,6 +321,29 @@ def apply_options(self):
333321

334322
self.update_workbox_stack()
335323

324+
def loadPlugins(self):
325+
"""Load any plugins that modify the LoggerWindow."""
326+
self.plugins = {}
327+
for name, plugin in plugins.loggerwindow():
328+
if name not in self.plugins:
329+
self.plugins[name] = plugin(self)
330+
331+
def defineWindowTitle(self):
332+
"""Define the window title, including and info plugins may add."""
333+
334+
# Define the title
335+
loggerName = QApplication.instance().translate(
336+
'PrEditorWindow', DEFAULT_CORE_NAME
337+
)
338+
pyVersion = '{}.{}.{}'.format(*sys.version_info[:3])
339+
size = osystem.getPointerSize()
340+
title = f"{loggerName} - {self.name} - {pyVersion} {size}-bit"
341+
342+
# Add any info plugins may add to title
343+
for _name, plugin in self.plugins.items():
344+
title = plugin.updateWindowTitle(title)
345+
return title
346+
336347
def comment_toggle(self):
337348
self.current_workbox().__comment_toggle__()
338349

0 commit comments

Comments
 (0)