Desktop: Unify save file handling and add file dialog for export (#3008)

* Prepare save file unification

* Desktop add save file dialog
This commit is contained in:
Timon
2025-08-06 16:07:53 +00:00
committed by GitHub
parent 5f2432cacf
commit 96a1b12a05
8 changed files with 47 additions and 30 deletions
@@ -68,18 +68,18 @@ pub enum FrontendMessage {
document_id: DocumentId,
name: String,
path: Option<PathBuf>,
document: String,
content: Vec<u8>,
},
TriggerDownloadImage {
TriggerSaveFile {
name: String,
content: Vec<u8>,
},
TriggerExportImage {
svg: String,
name: String,
mime: String,
size: (f64, f64),
},
TriggerDownloadTextFile {
document: String,
name: String,
},
TriggerFetchAndOpenDocument {
name: String,
filename: String,
@@ -1005,7 +1005,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
document_id,
name,
path: self.path.clone(),
document: self.serialize_document(),
content: self.serialize_document().into_bytes(),
})
}
DocumentMessage::SavedDocument { path } => {
+2 -2
View File
@@ -234,11 +234,11 @@ impl NodeGraphExecutor {
};
if file_type == FileType::Svg {
responses.add(FrontendMessage::TriggerDownloadTextFile { document: svg, name });
responses.add(FrontendMessage::TriggerSaveFile { name, content: svg.into_bytes() });
} else {
let mime = file_type.to_mime().to_string();
let size = (size * scale_factor).into();
responses.add(FrontendMessage::TriggerDownloadImage { svg, name, mime, size });
responses.add(FrontendMessage::TriggerExportImage { svg, name, mime, size });
}
Ok(())
}