Refactor status handling: remove status bar widget and update to use footer subtitle for status messages
This commit is contained in:
parent
4dbf200c5f
commit
1167521355
2 changed files with 5 additions and 37 deletions
|
@ -87,9 +87,6 @@ class HostsManagerApp(App):
|
||||||
yield Input(placeholder="Enter comment (optional)", id="comment-input")
|
yield Input(placeholder="Enter comment (optional)", id="comment-input")
|
||||||
yield Checkbox("Active", id="active-checkbox")
|
yield Checkbox("Active", id="active-checkbox")
|
||||||
|
|
||||||
# Status bar
|
|
||||||
yield Static("", id="status", classes="status-bar")
|
|
||||||
|
|
||||||
def on_ready(self) -> None:
|
def on_ready(self) -> None:
|
||||||
"""Called when the app is ready."""
|
"""Called when the app is ready."""
|
||||||
self.load_hosts_file()
|
self.load_hosts_file()
|
||||||
|
@ -114,30 +111,18 @@ class HostsManagerApp(App):
|
||||||
self.update_status(f"❌ Error loading hosts file: {e}")
|
self.update_status(f"❌ Error loading hosts file: {e}")
|
||||||
|
|
||||||
def update_status(self, message: str = "") -> None:
|
def update_status(self, message: str = "") -> None:
|
||||||
"""Update the status bar."""
|
"""Update the footer subtitle with status information."""
|
||||||
status_widget = self.query_one("#status", Static)
|
|
||||||
|
|
||||||
if message:
|
if message:
|
||||||
# Check if this is an error message (starts with ❌)
|
# Set temporary status message
|
||||||
|
self.sub_title = message
|
||||||
if message.startswith("❌"):
|
if message.startswith("❌"):
|
||||||
# Use error styling for error messages
|
|
||||||
status_widget.remove_class("status-bar")
|
|
||||||
status_widget.add_class("status-error")
|
|
||||||
status_widget.update(message)
|
|
||||||
# Auto-clear error message after 5 seconds
|
# Auto-clear error message after 5 seconds
|
||||||
self.set_timer(5.0, lambda: self.update_status())
|
self.set_timer(5.0, lambda: self.update_status())
|
||||||
else:
|
else:
|
||||||
# Use normal styling for regular messages
|
# Auto-clear regular message after 3 seconds
|
||||||
status_widget.remove_class("status-error")
|
|
||||||
status_widget.add_class("status-bar")
|
|
||||||
status_widget.update(message)
|
|
||||||
# Auto-clear regular message after 3 seconds
|
|
||||||
self.set_timer(3.0, lambda: self.update_status())
|
self.set_timer(3.0, lambda: self.update_status())
|
||||||
else:
|
else:
|
||||||
# Reset to normal status display
|
# Reset to normal status display
|
||||||
status_widget.remove_class("status-error")
|
|
||||||
status_widget.add_class("status-bar")
|
|
||||||
|
|
||||||
mode = "Edit mode" if self.edit_mode else "Read-only mode"
|
mode = "Edit mode" if self.edit_mode else "Read-only mode"
|
||||||
entry_count = len(self.hosts_file.entries)
|
entry_count = len(self.hosts_file.entries)
|
||||||
active_count = len(self.hosts_file.get_active_entries())
|
active_count = len(self.hosts_file.get_active_entries())
|
||||||
|
@ -149,7 +134,7 @@ class HostsManagerApp(App):
|
||||||
if file_info["exists"]:
|
if file_info["exists"]:
|
||||||
status_text += f" | {file_info['path']}"
|
status_text += f" | {file_info['path']}"
|
||||||
|
|
||||||
status_widget.update(status_text)
|
self.sub_title = status_text
|
||||||
|
|
||||||
# Event handlers
|
# Event handlers
|
||||||
def on_data_table_row_highlighted(self, event: DataTable.RowHighlighted) -> None:
|
def on_data_table_row_highlighted(self, event: DataTable.RowHighlighted) -> None:
|
||||||
|
|
|
@ -34,23 +34,6 @@ HOSTS_MANAGER_CSS = """
|
||||||
text-style: italic;
|
text-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-bar {
|
|
||||||
background: $surface;
|
|
||||||
color: $text;
|
|
||||||
height: 1;
|
|
||||||
padding: 0 1;
|
|
||||||
dock: bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-error {
|
|
||||||
background: $error;
|
|
||||||
color: $text;
|
|
||||||
height: 1;
|
|
||||||
padding: 0 1;
|
|
||||||
text-style: bold;
|
|
||||||
dock: bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* DataTable styling to match background */
|
/* DataTable styling to match background */
|
||||||
#entries-table {
|
#entries-table {
|
||||||
background: $background;
|
background: $background;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue