pcb-rnd knowledge pool

 

'Save as' dialog format guessing

save_as_guess by Tibor 'Igor2' Palinkas on 2019-05-23

Tags: announcement, save, save as, saveas, file, format, guess

node source

 

 

Abstract: I've finished implementing a long requested feature: automatic format detection (from file name) in the 'save as' dialog. It is available from r25653.

 

Imported from the mailing list archives.

I generally do not like when software is too smart and make guesses, so I made it optional and added some logics so that it doesn't outsmart the user:

  1. it has a checkbox so it can be disabled
  2. the initial/default value of this checkbox is coming from config (plugins/dialogs/file_select_dialog/save_as_format_guess); it's on by default but can be disabled e.g. from the user config. THe config is not automatically updated from the 'save as' dialog, so changing the checkbox there has temporary effect (intentionally). The default config value is on, for enabling the new feature.
  3. it triggers only if you change the file name; it does _not_ automatically select a format when the dialog is open. This is to avoid a corner case: when load a file from a format that mismatches the file name and do a 'save as', it doesn't go and try to fix the format for you but preserves the format that was learned during load. If you edit the relevant part of the file, it will make a guess
  4. if you ever manually select a file format (from the combo box), it is automatically disabled so changing the file name will not override your manually selected format
  5. when it does a guess, it picks the highest priority format if multiple formats match the file name; the file formats in the format selection combo box are ordered by priority, from top (most preferred) to bottom, so you can see what it would pick.
  6. if it is not enabled and you click on it to enable it, it automatically makes a guess shortly after the click
  7. there is an explicit warning that appears right to the checkbox if guessing fails. This is important becuse if you have a typo on the file name, the format will be left in its last state. This label obviously can show up temporarily if you type in some longish name, like "foo.kicad_pcb", but once you finish typing and you have a file name that is recognized, the warning is gone
  8. whenever the guess suceeds it does update the combo box, so you always see what it picked for you