Skip to content

Commit

Permalink
Include the URI in the launcher's window title
Browse files Browse the repository at this point in the history
  • Loading branch information
MHendricks committed May 14, 2024
1 parent 13dd962 commit eb02401
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion hab_gui/windows/alias_launch_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class AliasLaunchWindow(QtWidgets.QMainWindow):
parent (Qt.QtWidgets.QWidget, optional): Define a parent for this widget.
"""

window_title = "Hab Launch - {uri}"
"""The title of this window. Use a `str.format` style string with the kwarg
`uri` to include the currently selected URI.
"""

def __init__(
self,
settings,
Expand All @@ -45,7 +50,6 @@ def __init__(
self.init_gui(uri)

# Window properties
self.setWindowTitle("Hab Launch Aliases")
self.setFixedWidth(400)
self.center_window_position()

Expand All @@ -62,6 +66,12 @@ def __init__(
logger.debug(f"Setting auto-refresh interval to {refresh_time} seconds")
self.refresh_timer.start(refresh_time * 1000)

def _update_window_title(self, uri):
"""Updates the window title with a `str.format` style string with the
kwarg `uri` to include the currently selected URI.
"""
self.setWindowTitle(self.window_title.format(uri=uri))

def apply_layout(self):
"""Configures the layout of all widgets in this interface."""
column_uri_widget = 1 if self.prefs_enabled else 0
Expand Down Expand Up @@ -175,6 +185,10 @@ def init_gui(self, uri=None):
# Ensure the URI widget has focus by default
self.uri_widget.setFocus()

# Ensure the window title always shows the currently selected URI
self.settings.uri_changed.connect(self._update_window_title)
self._update_window_title(uri)

@utils.cursor_override()
def refresh_cache(self, reset_timer=True):
"""Refresh the resolved hab and re-display.
Expand Down

0 comments on commit eb02401

Please sign in to comment.