Fix PDF export truncating project filenames at the first dot

Forum report (qelectrotech.org/forum, topic 3005, reporter oc67): a
project named e.g. "Mon_projet.avec_un_point.qet" exported to PDF as
"Mon_projet.pdf" - everything after the first "." in the filename was
silently dropped.

Root cause: ProjectPrintWindow::docName() used QFileInfo::baseName(),
which returns the filename up to the FIRST "." rather than stripping
only the final suffix. docName() feeds both the PDF print job's
setOutputFileName() and the QFileDialog::getSaveFileName default in
exportToPDF(), so the truncation showed up as the actual exported
file's name, not just a dialog suggestion.

sources/exportdialog.cpp's SVG/PNG/DXF export path already uses the
correct QFileInfo::completeBaseName() (strips only the last suffix) -
this fix brings the PDF/print path in line with that existing,
correct pattern rather than introducing a new approach.

Verified the exact before/after behavior with a standalone QFileInfo
test: baseName() on "Mon_projet.avec_un_point.qet" returns
"Mon_projet" (the bug); completeBaseName() returns
"Mon_projet.avec_un_point" (correct). Also did a clean incremental
build with no new warnings/errors.
This commit is contained in:
ispyisail
2026-08-12 10:31:04 +12:00
parent 10cc162c4e
commit 162d43e1c9
+1 -1
View File
@@ -108,7 +108,7 @@ QString ProjectPrintWindow::docName(QETProject *project)
{ {
QString doc_name; QString doc_name;
if (!project->filePath().isEmpty()) { if (!project->filePath().isEmpty()) {
doc_name = QFileInfo(project->filePath()).baseName(); doc_name = QFileInfo(project->filePath()).completeBaseName();
} else if (!project->title().isEmpty()) { } else if (!project->title().isEmpty()) {
doc_name = project->title(); doc_name = project->title();
doc_name = QET::stringToFileName(doc_name); doc_name = QET::stringToFileName(doc_name);