Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save dialogs don't automatically add extensions #421

Closed
wxl opened this issue May 7, 2019 · 12 comments · Fixed by #425
Closed

save dialogs don't automatically add extensions #421

wxl opened this issue May 7, 2019 · 12 comments · Fixed by #425
Assignees

Comments

@wxl
Copy link
Member

wxl commented May 7, 2019

Save dialogs in don't provide an option to automatically add extensions, so even where some application understands one particular extension, saving a file in it doesn't result in an extension being added.

Expected Behavior

Save dialogs should at least have a checkbox providing an option to automatically add an extension.

Current Behavior

Save dialogs have no options regarding extensions and files get saved without them unless manually added.

Possible Solution

To be fair, I'm not sure. I know it's not reasonable to imagine that LXQt is going to provide every single app-specific option known to man (e.g. LibreOffice's encrypt with a password), but I would imagine that having the option to automatically add a file extension seems pretty universally applicable.

Steps to Reproduce (for bugs)

I originally noticed this in k3b, so:

  1. Open k3b
  2. Click "Create a New Data Project"
  3. Click "Save"
  4. Note that the file name does not have the ".k3b" extension
  5. Click ok to use the default file name
  6. Open the file manager to the save location and note the file does not have the extension
Context

@agaida suggested I file this here.

System Information
  • Distribution & Version: Lubuntu 19.10
  • Kernel: 5.0.0-13-generic
  • Qt Version: 5.12.2
  • libqtxdg Version: 3.3.1-0ubuntu2
  • lxqt-build-tools Version: 0.6.0-2ubuntu1
  • Package version: 0.14.1-0ubuntu2

Downstream bug

@tsujan
Copy link
Member

tsujan commented May 7, 2019

@wxl That's the app's job.

Our dialog supports everything that a file dialog needs -- including QFileDialog::setDefaultSuffix(), which can be used by codes -- plus functionalities that aren't found in Qt file dialog.

For example, ScreenGrab, lximage-qt, Falkon and many other Qt apps add a default extension with "Save As" when no extension is given.

I think what you see with K3b is K3b's fault but I'll look into it.

@tsujan
Copy link
Member

tsujan commented May 7, 2019

OK, I investigated it.

Unlike other apps, K3b doesn't set a default suffix — and so, we have no responsibility — but the KDE file dialog adds it when the current name filter starts with a usable extension. That isn't a Qt standard.

However, I patched libfm-qt to do the same thing, i.e if (1) there is no default suffix, (2) the dialog is in the save mode, and (3) the file name doesn't end with an extension, LXQt file dialog could extract the first extension in the current name filter and add it to the file name.

It worked with K3b and I don't think it could have any side effect. But I should try it for a while before making a PR.

@tsujan tsujan self-assigned this May 7, 2019
@tsujan
Copy link
Member

tsujan commented May 7, 2019

This needs some discussion. I tell my opinion to see who dares to disagree ;)

When there isn't a default suffix (bad code like K3b's?) but there is a name filter (like Image Files (*.png *.jpg)), LXQt save-dialog adds the first extension when the name typed by the user doesn't have one.

If the user doesn't want an extension for whatever reason (?), he/she could choose All Files(*) in the File Type combo. If the app doesn't provide All Files(*), it means that an extension is important to it and so, the file will be always saved with an extension.

Now, this looks logical to me and, I think, it's better than cluttering the GUI with a checkbox that says, "Save with extension" (saying nothing about the extra codes the latter would need). KDE GUI's are all cluttered but I don't think we want that for LXQt when we can avoid it reasonably.

Any objection?

@wxl
Copy link
Member Author

wxl commented May 7, 2019

Thanks for the further investigation. I didn't think this was an LXQt problem, per se, but I think this will be a nice feature that will provide a consistent experience for users despite the fallibility of other software.

Totally agree that KDE is cluttered. I mean they like to pitch how configurable their software is and while I agree, my common retort is: if you can find where to change the setting you want 😉

That said, I think what you're saying makes sense. The idea of not having an extension seems, as you implied, like a pretty strange edge case. That person will get annoyed by the behavior, I'm sure, but in the effort of serving the vast majority of users in the best possible way (KISS), I think what you suggest is a good idea.

Oh, and this is totally tangential, but I also note that Featherpad doesn't seem to have a default extension. I guess it shouldn't necessarily have one, but there should be a whole variety of different text file types, no? I mean, Kate behaves similar, so maybe not.

@tsujan
Copy link
Member

tsujan commented May 7, 2019

The idea of not having an extension seems, as you implied, like a pretty strange edge case.

Yes, but it's still possible if the filter is All Files(*).

The more I use it, the more reasonable it seems to me. Why should we save a file without extension when the File Type combo has one? IMO, KDE's way makes sense.

Featherpad doesn't seem to have a default extension.

That's intentional. Text documents aren't just simple texts. They can be C/C++/Python/Bash... codes or markdown, config, etc. There's a huge number of them and apps may add to them. So, adding a filter doesn't make sense — multiple screens would be needed for showing it ;) FeatherPad only adds a proper extension when a suffixed file is opened and the save-as dialog is called. I made it so for security reasons (it has a story) before the first version of FeatherPad.

@wxl
Copy link
Member Author

wxl commented May 7, 2019

Sounds good to me!

@tsujan
Copy link
Member

tsujan commented May 7, 2019

Thanks for the feedback!

@wxl
Copy link
Member Author

wxl commented May 7, 2019

Actually I noticed Falkon defaults to saving pages as MIME HTML archives, but provides options for HTML pages, both single and complete. The default filename ends in .mhtml. If you toggle the file type, the extension does not change. That said, would you be adding anything to allow one to change different extensions?

@tsujan
Copy link
Member

tsujan commented May 7, 2019

The default filename ends in .mhtml

I use it a lot with Falkon. With the patch, it'll be the default extension when the user doesn't type it.

Apart from that, no file dialog can change which extensions an app provides or prefers.

@wxl
Copy link
Member Author

wxl commented May 7, 2019 via email

@tsujan
Copy link
Member

tsujan commented May 7, 2019

Please open another issue for that! I agree that it should be as you said. I may make the patch more complete to cover it too because both issues/features are about extensions and I'm lazy. But opening a separate issue for it would show its importance.

tsujan added a commit that referenced this issue May 9, 2019
Closes #421 and closes #423

This is how extensions are handled in the save mode:

 * If the file name has no extension and there isn't a default suffix but there is a filter in "File type" combo — like `Image Files (*.png *.jpg)` — the first extension provided by the filter will be added to the saved file name.
 * If the file name has an extension and the contents of "File type" combo is changed by the user, the extension will be updated accordingly.

Overwrite prompts are also handled appropriately.
@tsujan
Copy link
Member

tsujan commented May 9, 2019

The patch is here: #425

It doesn't need recompilation of pcmanfm-qt but a previous patch (1baee3e) does. So, recompilation of pcmanfm-qt (and other libfm-qt based apps) is really recommended.

tsujan added a commit that referenced this issue May 13, 2019
Closes #421 and closes #423 and fixes lxqt/lxqt-archiver#29

This is how extensions are handled in the save mode:

 * If the file name has no extension and there isn't a default suffix but there is a filter in "File type" combo — like `Image Files (*.png *.jpg)` — the first extension provided by the filter will be added to the saved file name.
 * If the file name has an extension and the contents of "File type" combo is changed by the user, the extension will be updated accordingly.
 * Filters like `NAME (DESCRIPTION) (*.X *.Y)` are covered.

Overwrite prompts are also handled appropriately.

NOTE: Recompile libfm-qt based apps after this.
agaida pushed a commit that referenced this issue Jun 1, 2019
Closes #421 and closes #423 and fixes lxqt/lxqt-archiver#29

This is how extensions are handled in the save mode:

 * If the file name has no extension and there isn't a default suffix but there is a filter in "File type" combo — like `Image Files (*.png *.jpg)` — the first extension provided by the filter will be added to the saved file name.
 * If the file name has an extension and the contents of "File type" combo is changed by the user, the extension will be updated accordingly.
 * Filters like `NAME (DESCRIPTION) (*.X *.Y)` are covered.

Overwrite prompts are also handled appropriately.

NOTE: Recompile libfm-qt based apps after this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants