From eb520ac3f8927ce70927310753c0e13922ae2331 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Mon, 3 Aug 2026 08:31:17 +1200 Subject: [PATCH] Pre-fill SVG export filename with the element's own name Suggests the element's filename (without its .elmt extension) as the default save name when exporting to SVG, instead of only defaulting to the customElementsDir with no filename. Addresses plc-user's review suggestion on PR #637. --- sources/editor/ui/qetelementeditor.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sources/editor/ui/qetelementeditor.cpp b/sources/editor/ui/qetelementeditor.cpp index 04ffa60b6..9a4eb2ffb 100644 --- a/sources/editor/ui/qetelementeditor.cpp +++ b/sources/editor/ui/qetelementeditor.cpp @@ -1397,10 +1397,20 @@ bool QETElementEditor::on_m_save_as_file_action_triggered() */ bool QETElementEditor::on_m_export_svg_action_triggered() { + //Suggest the element's own filename (without its .elmt extension) as + //the default export name, per plc-user's review on #637 -- the + //directory-only default below is unchanged for an element that has + //never been saved, since there is no filename to derive one from. + QString suggested_path = QETApp::customElementsDir(); + if (!m_file_name.isEmpty()) { + QFileInfo file_info(m_file_name); + suggested_path = QDir(file_info.absolutePath()).filePath(file_info.completeBaseName()); + } + QString fn = QFileDialog::getSaveFileName( this, tr("Exporter en SVG", "dialog title"), - m_file_name.isEmpty() ? QETApp::customElementsDir() : QDir(m_file_name).absolutePath(), + suggested_path, tr("Image SVG (*.svg)", "filetypes allowed when exporting an element to SVG")); if (fn.isEmpty()) {