fix: paste cursor position, expanded buttons, footer hints, and back navigation
This commit is contained in:
parent
a099e944c2
commit
3d4b541fde
1 changed files with 21 additions and 15 deletions
|
|
@ -23,14 +23,21 @@ from textual.widgets import (
|
||||||
Select,
|
Select,
|
||||||
Static,
|
Static,
|
||||||
)
|
)
|
||||||
from textual.events import Key
|
from textual import events
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
|
|
||||||
class PathInput(Input):
|
class PathInput(Input):
|
||||||
"""Custom input for bash-like path tab completion."""
|
"""Custom input for bash-like path tab completion."""
|
||||||
|
|
||||||
def on_key(self, event: Key) -> None:
|
def on_paste(self, event: events.Paste) -> None:
|
||||||
|
# Schedule moving cursor to the end after the default paste handler runs
|
||||||
|
self.call_after_refresh(self._move_cursor_to_end)
|
||||||
|
|
||||||
|
def _move_cursor_to_end(self) -> None:
|
||||||
|
self.cursor_position = len(self.value)
|
||||||
|
|
||||||
|
def on_key(self, event: events.Key) -> None:
|
||||||
if event.key == "tab":
|
if event.key == "tab":
|
||||||
current = self.value
|
current = self.value
|
||||||
if not current:
|
if not current:
|
||||||
|
|
@ -68,16 +75,6 @@ class PathInput(Input):
|
||||||
event.stop()
|
event.stop()
|
||||||
|
|
||||||
|
|
||||||
LOGO = r"""
|
|
||||||
____ _____ ____ _
|
|
||||||
| _ \ _ _| ___|_ _ ___ __| _ \| |_ _ _ __
|
|
||||||
| |_) | | | | |_ / _` |/ __/ _ \ |_) | | | | | '__|
|
|
||||||
| __/| |_| | _| (_| | (_| __/ _ <| | |_| | |
|
|
||||||
|_| \__, |_| \__,_|\___\___|_| \_\_|\__,_|_|
|
|
||||||
|___/
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class WelcomeScreen(Screen):
|
class WelcomeScreen(Screen):
|
||||||
"""Welcome screen with video path input and settings."""
|
"""Welcome screen with video path input and settings."""
|
||||||
|
|
||||||
|
|
@ -141,6 +138,7 @@ class WelcomeScreen(Screen):
|
||||||
|
|
||||||
yield Label("", id="error-label")
|
yield Label("", id="error-label")
|
||||||
yield Button("Start Processing", id="start-btn", variant="primary")
|
yield Button("Start Processing", id="start-btn", variant="primary")
|
||||||
|
yield Footer()
|
||||||
|
|
||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||||
if event.button.id == "start-btn":
|
if event.button.id == "start-btn":
|
||||||
|
|
@ -225,6 +223,7 @@ class ProcessingScreen(Screen):
|
||||||
yield Label("[1/3] Preparing...", id="phase-label")
|
yield Label("[1/3] Preparing...", id="phase-label")
|
||||||
yield ProgressBar(total=100, id="progress-bar")
|
yield ProgressBar(total=100, id="progress-bar")
|
||||||
yield Label("", id="status-label")
|
yield Label("", id="status-label")
|
||||||
|
yield Footer()
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
self.run_worker(self._process, thread=True)
|
self.run_worker(self._process, thread=True)
|
||||||
|
|
@ -410,10 +409,11 @@ class FaceSelectionScreen(Screen):
|
||||||
#buttons-row {
|
#buttons-row {
|
||||||
margin-top: 1;
|
margin-top: 1;
|
||||||
height: 3;
|
height: 3;
|
||||||
align: center middle;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#buttons-row Button {
|
#buttons-row Button {
|
||||||
|
width: 1fr;
|
||||||
margin: 0 1;
|
margin: 0 1;
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
@ -493,10 +493,11 @@ class FaceSelectionScreen(Screen):
|
||||||
id="blur-btn",
|
id="blur-btn",
|
||||||
variant="primary",
|
variant="primary",
|
||||||
)
|
)
|
||||||
|
yield Footer()
|
||||||
|
|
||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||||
if event.button.id == "back-btn":
|
if event.button.id == "back-btn":
|
||||||
self.app.pop_screen()
|
self.app.switch_screen("welcome")
|
||||||
elif event.button.id == "blur-btn":
|
elif event.button.id == "blur-btn":
|
||||||
self._start_encoding()
|
self._start_encoding()
|
||||||
elif event.button.id and event.button.id.startswith("view-"):
|
elif event.button.id and event.button.id.startswith("view-"):
|
||||||
|
|
@ -622,6 +623,7 @@ class EncodingScreen(Screen):
|
||||||
yield Label("", id="encoding-status")
|
yield Label("", id="encoding-status")
|
||||||
yield Label(f"Output: {self.output_path.name}", id="output-label")
|
yield Label(f"Output: {self.output_path.name}", id="output-label")
|
||||||
yield Button("Done — Exit", id="done-btn", variant="success")
|
yield Button("Done — Exit", id="done-btn", variant="success")
|
||||||
|
yield Footer()
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
self.run_worker(self._encode, thread=True)
|
self.run_worker(self._encode, thread=True)
|
||||||
|
|
@ -688,11 +690,15 @@ class PyFaceBlurApp(App):
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
BINDINGS = [
|
BINDINGS = [
|
||||||
|
Binding("tab", "focus_next", "Focus Next", show=True),
|
||||||
|
Binding("shift+tab", "focus_previous", "Focus Prev", show=True),
|
||||||
Binding("q", "quit", "Quit", show=True),
|
Binding("q", "quit", "Quit", show=True),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
SCREENS = {"welcome": WelcomeScreen}
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
self.push_screen(WelcomeScreen())
|
self.push_screen("welcome")
|
||||||
|
|
||||||
|
|
||||||
def run() -> None:
|
def run() -> None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue