From f6e6f79a344110e8c5aa397fc12221620c624ddc Mon Sep 17 00:00:00 2001 From: ThePendulum Date: Sun, 26 Jul 2026 01:24:34 +0200 Subject: [PATCH] Add View menu with a toggle to hide/show the ffmpeg log panel --- main.py | 10 ++++++++- scripts/smoke_test_view_menu.py | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 scripts/smoke_test_view_menu.py diff --git a/main.py b/main.py index c48b597..994b187 100644 --- a/main.py +++ b/main.py @@ -3,7 +3,7 @@ from pathlib import Path from typing import Optional from PyQt6.QtCore import Qt, QTimer, QThread, pyqtSignal -from PyQt6.QtGui import QShortcut, QKeySequence +from PyQt6.QtGui import QShortcut, QKeySequence, QAction from PyQt6.QtWidgets import ( QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QSlider, QCheckBox, QDoubleSpinBox, QFileDialog, @@ -55,6 +55,7 @@ class MainWindow(QMainWindow): self.player.setMinimumHeight(400) self._build_ui() + self._build_menu() self._wire_shortcuts() self._position_timer = QTimer(self) @@ -155,6 +156,13 @@ class MainWindow(QMainWindow): self.setCentralWidget(central) + def _build_menu(self): + view_menu = self.menuBar().addMenu("&View") + + self.toggle_log_action = QAction("Show ffmpeg Log", self, checkable=True, checked=True) + self.toggle_log_action.toggled.connect(self.log_view.setVisible) + view_menu.addAction(self.toggle_log_action) + def _wire_shortcuts(self): QShortcut(QKeySequence(","), self, activated=lambda: self._step_frame(-1)) QShortcut(QKeySequence("."), self, activated=lambda: self._step_frame(1)) diff --git a/scripts/smoke_test_view_menu.py b/scripts/smoke_test_view_menu.py new file mode 100644 index 0000000..aa1cbdf --- /dev/null +++ b/scripts/smoke_test_view_menu.py @@ -0,0 +1,39 @@ +import sys +import time +from pathlib import Path + +from PyQt6.QtWidgets import QApplication + +sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) +import main as app_main + +ROOT = Path(__file__).resolve().parent.parent +OUT_DIR = ROOT / "test_media" / "seek_validation" + + +def main(): + OUT_DIR.mkdir(exist_ok=True) + qapp = QApplication(sys.argv) + win = app_main.MainWindow() + win.show() + qapp.processEvents() + + assert win.log_view.isVisible(), "log panel should be visible by default" + assert win.toggle_log_action.isChecked() + win.grab().save(str(OUT_DIR / "view_menu_log_visible.png")) + + win.toggle_log_action.setChecked(False) + qapp.processEvents() + assert not win.log_view.isVisible(), "toggling the menu action should hide the log panel" + win.grab().save(str(OUT_DIR / "view_menu_log_hidden.png")) + + win.toggle_log_action.setChecked(True) + qapp.processEvents() + assert win.log_view.isVisible() + + win.player.shutdown() + print("PASS: View > Show ffmpeg Log toggles the log panel correctly") + + +if __name__ == "__main__": + main()