From 3507434a9b1f89b25bc7ae7e919dfef6ab2b34f7 Mon Sep 17 00:00:00 2001 From: mrkmntal Date: Tue, 27 Oct 2026 14:05:56 -0400 Subject: [PATCH] Implemented the About modal on a, replacing the old c controls action. --- README.md | 2 +- mpvremote/app.py | 3 +- mpvremote/config.py | 3 +- mpvremote/views.py | 67 +++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 66 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1ffa271..878dd28 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ directory defaults to `~/Videos` and can be changed in the app's Settings view | `e` | Playlist view | | `o` | Queue view | | `x` | Settings (media directory) | -| `c` | Show controls help | +| `a` | About page and controls | | `q` | Quit | ### Playlist view diff --git a/mpvremote/app.py b/mpvremote/app.py index 912fc5e..30d4c08 100644 --- a/mpvremote/app.py +++ b/mpvremote/app.py @@ -3,7 +3,7 @@ import threading from pathlib import Path from mpvremote import config from mpvremote.mpv_client import MpvClient -from mpvremote.views import MainView, PlaylistView, QueueView, SettingsView +from mpvremote.views import AboutView, MainView, PlaylistView, QueueView, SettingsView class App: @@ -29,6 +29,7 @@ class App: 'playlist': PlaylistView(self), 'queue': QueueView(self), 'settings': SettingsView(self), + 'about': AboutView(self), } self.current_view = self.views['main'] self.messages = [] diff --git a/mpvremote/config.py b/mpvremote/config.py index bf14d49..4aced54 100644 --- a/mpvremote/config.py +++ b/mpvremote/config.py @@ -2,6 +2,7 @@ import os from pathlib import Path SOCKET = "/tmp/mpv-socket" +APP_VERSION = "0.1.0" DEFAULT_MEDIA_DIR = os.path.expanduser("~/Videos") MEDIA_DIR_FILE = Path.home() / ".config" / "mpvremotemedia" @@ -40,9 +41,9 @@ KEY_NEXT = ord('n') KEY_PREV = ord('p') KEY_LOOP_FILE = ord('r') KEY_LOOP_PLIST = ord('R') -KEY_CONTROLS = ord('c') KEY_QUEUE = ord('o') KEY_PLAYLIST = ord('e') KEY_QUIT = ord('q') KEY_DELETE_PLAYLIST = ord('d') KEY_SETTINGS = ord('x') +KEY_ABOUT = ord('a') diff --git a/mpvremote/views.py b/mpvremote/views.py index 1aca35e..0f680a0 100644 --- a/mpvremote/views.py +++ b/mpvremote/views.py @@ -58,7 +58,7 @@ class MainView: self.app.draw_messages() def _draw_help(self): - text = " [Space]Pause [KLeft/KRight]Seek [KUp/KDown/j/k]Vol [s]Sub [e]Plist [o]Queue [x]Settings [r/R]Loop [q]Quit" + text = " [a]About [Space]Pause [KLeft/KRight]Seek [KUp/KDown]Vol [e]List [o]Queue [x]Settings [q]Quit" self.app.draw_help_bar(text) def handle_key(self, key): @@ -112,11 +112,6 @@ class MainView: else: self.app.client.command("set_property", "loop-playlist", "no") self.app.add_message(">> Loop Current Playlist: no") - elif key == config.KEY_CONTROLS: - self.app.add_message("=== Controls ===") - self.app.add_message("[Space] Pause | [KLeft/KRight] Seek -10s/+10s | [KUp/KDown/j/k] Vol -/+") - self.app.add_message("[s] Subtitle | [o] Queue | [e] Playlist | [x] Settings | [n/p] Next/Prev") - self.app.add_message("[r/R] Loop File/Playlist (state shown in status bar) | [q] Quit") elif key == config.KEY_PLAYLIST: self.app.switch_view('playlist') elif key == config.KEY_QUEUE: @@ -125,6 +120,8 @@ class MainView: elif key == config.KEY_SETTINGS: self.app.views['settings'].open() self.app.switch_view('settings') + elif key == config.KEY_ABOUT: + self.app.switch_view('about') return True @@ -465,3 +462,61 @@ class SettingsView: self.cursor += 1 self.error = "" return True + + +class AboutView: + def __init__(self, app): + self.app = app + self.lines = [ + f"mpvremote {config.APP_VERSION}", + "", + "A curses-based remote for controlling a running mpv player.", + "Control playback, manage playlists, and queue files from your library.", + "", + "Playback", + " Space Pause / resume", + " KLeft/KRight Seek -10s / +10s (h/l)", + " KUp/KDown Volume -5 / +5 (j/k)", + " s Cycle subtitles", + " n/p Next / previous track", + " r/R Loop file / playlist", + "", + "Views", + " e Playlist | o Queue | x Settings | a About | q Quit", + " Playlist: Up/Down navigate, Enter play, Del/d remove", + " Queue: type to search, Up/Down navigate, Enter queue", + " Backspace edits search; Esc clears search or goes back", + ] + + def _put(self, row, col, text, attrs=0): + if row < 0 or row >= self.app.height or col >= self.app.width: + return + try: + self.app.stdscr.addstr(row, col, text[:max(0, self.app.width - col)], attrs) + except curses.error: + pass + + def draw(self): + self.app.draw_status_bar(f" About | mpvremote {config.APP_VERSION}") + panel_width = max(1, min(76, self.app.width - 4)) + panel_height = min(len(self.lines) + 2, max(3, self.app.height - 3)) + left = max(0, (self.app.width - panel_width) // 2) + top = max(1, (self.app.height - panel_height) // 2) + inner_width = max(1, panel_width - 2) + + self._put(top, left, "+" + "-" * max(0, panel_width - 2) + "+") + for row in range(top + 1, min(top + panel_height - 1, self.app.height - 1)): + self._put(row, left, "|" + " " * max(0, panel_width - 2) + "|") + self._put(top + panel_height - 1, left, "+" + "-" * max(0, panel_width - 2) + "+") + + visible_lines = self.lines[:max(0, panel_height - 2)] + for index, line in enumerate(visible_lines): + attrs = curses.A_BOLD if line in (self.lines[0], "Playback", "Views") else 0 + self._put(top + 1 + index, left + 2, line[:inner_width], attrs) + + self.app.draw_help_bar(" [Esc/q]Close") + + def handle_key(self, key): + if key in (27, config.KEY_QUIT): + self.app.switch_view('main') + return True