mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-05 12:14:12 +02:00
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.
This commit is contained in:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user