Fix video export resolution scaling and post-export UI hang
- Scale the document to the selected output resolution. It was rendered at document size regardless of the export dimensions, so picking a different resolution didn't scale the stage. - Run the audio+video mux on a background thread instead of the UI thread, keeping the app responsive (showing "Finalizing") during the re-mux pass. - Send desktop notifications fire-and-forget. notify_rust's show() is a synchronous D-Bus call that blocked the UI for the full service activation timeout (~25s) when no notification daemon is running.
This commit is contained in:
@@ -3,52 +3,52 @@
|
||||
use notify_rust::Notification;
|
||||
use std::path::Path;
|
||||
|
||||
/// Send a desktop notification for successful export
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `output_path` - Path to the exported file
|
||||
///
|
||||
/// # Returns
|
||||
/// Ok(()) if notification sent successfully, Err with log message if failed
|
||||
pub fn notify_export_complete(output_path: &Path) -> Result<(), String> {
|
||||
// `notify_rust`'s `Notification::show()` is a SYNCHRONOUS D-Bus call. When no
|
||||
// notification daemon is running it can block for the service-activation timeout
|
||||
// (~25s) before failing, so these are fire-and-forget on a detached thread — the
|
||||
// UI must never wait on them (e.g. they're triggered from the export-complete
|
||||
// handler on the UI thread).
|
||||
|
||||
/// Show a desktop notification for a successful export (fire-and-forget).
|
||||
pub fn notify_export_complete(output_path: &Path) {
|
||||
let filename = output_path
|
||||
.file_name()
|
||||
.and_then(|n| n.to_str())
|
||||
.unwrap_or("unknown");
|
||||
.unwrap_or("unknown")
|
||||
.to_string();
|
||||
|
||||
Notification::new()
|
||||
.summary("Export Complete")
|
||||
.body(&format!("Successfully exported: {}", filename))
|
||||
.icon("dialog-information") // Standard icon name (freedesktop.org)
|
||||
.timeout(5000) // 5 seconds
|
||||
.show()
|
||||
.map_err(|e| format!("Failed to show notification: {}", e))?;
|
||||
|
||||
Ok(())
|
||||
std::thread::spawn(move || {
|
||||
if let Err(e) = Notification::new()
|
||||
.summary("Export Complete")
|
||||
.body(&format!("Successfully exported: {}", filename))
|
||||
.icon("dialog-information") // Standard icon name (freedesktop.org)
|
||||
.timeout(5000) // 5 seconds
|
||||
.show()
|
||||
{
|
||||
eprintln!("⚠️ Could not send desktop notification: {}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Send a desktop notification for export error
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `error_message` - The error message to display
|
||||
///
|
||||
/// # Returns
|
||||
/// Ok(()) if notification sent successfully, Err with log message if failed
|
||||
pub fn notify_export_error(error_message: &str) -> Result<(), String> {
|
||||
// Truncate very long error messages
|
||||
let truncated = if error_message.len() > 100 {
|
||||
format!("{}...", &error_message[..97])
|
||||
/// Show a desktop notification for an export error (fire-and-forget).
|
||||
pub fn notify_export_error(error_message: &str) {
|
||||
// Truncate very long error messages (on a char boundary).
|
||||
let truncated = if error_message.chars().count() > 100 {
|
||||
let prefix: String = error_message.chars().take(97).collect();
|
||||
format!("{}...", prefix)
|
||||
} else {
|
||||
error_message.to_string()
|
||||
};
|
||||
|
||||
Notification::new()
|
||||
.summary("Export Failed")
|
||||
.body(&truncated)
|
||||
.icon("dialog-error") // Standard error icon
|
||||
.timeout(10000) // 10 seconds for errors (longer to read)
|
||||
.show()
|
||||
.map_err(|e| format!("Failed to show notification: {}", e))?;
|
||||
|
||||
Ok(())
|
||||
std::thread::spawn(move || {
|
||||
if let Err(e) = Notification::new()
|
||||
.summary("Export Failed")
|
||||
.body(&truncated)
|
||||
.icon("dialog-error") // Standard error icon
|
||||
.timeout(10000) // 10 seconds for errors (longer to read)
|
||||
.show()
|
||||
{
|
||||
eprintln!("⚠️ Could not send desktop notification: {}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user