-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): warn user if FFmpeg not installed (#441)
* feat: Warn user if FFmpeg is not installed Creates a Warning dialog on startup if the program cannot find FFmpeg or FFprobe in the PATH. Other interactions with the program are blocked until the issue is either ignore or resolved. * docs: Add FFmpeg installation guide * ruff formatting * chore: Cleanup missing logic and warning message * chore: Remove custom icon Per QT docs, handling custom iconPixmap requires multiple icons per platform. Easier to just use universal, default warning icon (yellow triangle) * fix: Ignore dialog with X button * fix: Move startup checks after CI * chore: Unreverse install check logic * doc: Improve docs formatting * docs: Point help url to new docs sites * Remove ffmpeg docs page * Use which from python stdlib
- Loading branch information
1 parent
6490cc9
commit b2dbc57
Showing
3 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import logging | ||
import math | ||
from pathlib import Path | ||
from shutil import which | ||
import subprocess | ||
|
||
from PIL import Image, ImageQt | ||
from PySide6.QtCore import Signal, Qt, QUrl | ||
from PySide6.QtGui import QPixmap, QDesktopServices | ||
from PySide6.QtWidgets import QMessageBox | ||
|
||
|
||
class FfmpegChecker(QMessageBox): | ||
"""A warning dialog for if FFmpeg is missing.""" | ||
|
||
HELP_URL = "https://docs.tagstud.io/help/ffmpeg/" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
self.setWindowTitle("Warning: Missing dependency") | ||
self.setText("Warning: Could not find FFmpeg installation") | ||
self.setIcon(QMessageBox.Warning) | ||
# Blocks other application interactions until resolved | ||
self.setWindowModality(Qt.ApplicationModal) | ||
|
||
self.setStandardButtons( | ||
QMessageBox.Help | QMessageBox.Ignore | QMessageBox.Cancel | ||
) | ||
self.setDefaultButton(QMessageBox.Ignore) | ||
# Enables the cancel button but hides it to allow for click X to close dialog | ||
self.button(QMessageBox.Cancel).hide() | ||
|
||
self.ffmpeg = False | ||
self.ffprobe = False | ||
|
||
def installed(self): | ||
"""Checks if both FFmpeg and FFprobe are installed and in the PATH.""" | ||
if which("ffmpeg"): | ||
self.ffmpeg = True | ||
if which("ffprobe"): | ||
self.ffprobe = True | ||
|
||
logging.info( | ||
f"[FFmpegChecker] FFmpeg found: {self.ffmpeg}, FFprobe found: {self.ffprobe}" | ||
) | ||
return self.ffmpeg and self.ffprobe | ||
|
||
def show_warning(self): | ||
"""Displays the warning to the user and awaits respone.""" | ||
missing = "FFmpeg" | ||
# If ffmpeg is installed but not ffprobe | ||
if not self.ffprobe and self.ffmpeg: | ||
missing = "FFprobe" | ||
|
||
self.setText(f"Warning: Could not find {missing} installation") | ||
self.setInformativeText( | ||
f"{missing} is required for multimedia thumbnails and playback" | ||
) | ||
# Shows the dialog | ||
selection = self.exec() | ||
|
||
# Selection will either be QMessageBox.Help or (QMessageBox.Ignore | QMessageBox.Cancel) which can be ignored | ||
if selection == QMessageBox.Help: | ||
QDesktopServices.openUrl(QUrl(self.HELP_URL)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters