Bug 381561 - getsavefilename broken due to port to QFileDialog
Summary: getsavefilename broken due to port to QFileDialog
Status: RESOLVED FIXED
Alias: None
Product: kdialog
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR major
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-23 08:49 UTC by Kai Uwe Broulik
Modified: 2017-12-21 04:11 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Kdialog save as filter: unknown (56.28 KB, image/png)
2017-07-18 04:13 UTC, ahxcker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Uwe Broulik 2017-06-23 08:49:27 UTC
When I "Save As" a file in Google Chrome, the resulting file dialog starts in / and defaults to ".bin" "Unknown" file format. In master I correctly get it starting in ~/Downloads and correct file format, however it is missing some porting commits in 17.04.

For instance right click on the KDE logo on the KDE website and chosing "Save As" results in the following kdialog call:

kdialog --attach=106954753 --title="Datei speichern" --getsavefilename /home/broulik/Downloads/index.html "application/octet-stream text/html"
Comment 1 David Faure 2017-06-23 12:26:16 UTC
Wow that was fast ;)

What do you call "correct" ?
If application/octet-stream is the first mimetype, then it's selected as the first mimetype, I'm not sure what's incorrect there.
Comment 2 Kai Uwe Broulik 2017-06-23 12:33:15 UTC
Even if I save an html page which, from what I can tell only sends along text/html, I get "HTML document" as first entry and then an empty mimetype as second. In all cases it never pre-fills the file name, nor does it deduce the save location, ie. if it says --getsavefilename ~/foo/bar it used to open in ~/foo and pre-fill "bar" as file name. It no longer does that. And then if it pre-filled "foo.png" it would (should) know that it's "PNG image" I want and not application/octet-stream.
Comment 3 David Faure 2017-06-23 21:03:53 UTC
Git commit 04706f321c3fb3660d9a1a8ec960229ea7ab11f9 by David Faure.
Committed on 23/06/2017 at 21:03.
Pushed by dfaure into branch 'Applications/17.04'.

Trim filter string to be a bit tolerant and avoid empty mimetype entries

Testcase: kdialog  --getsavefilename . "text/html "

M  +1    -1    src/kdialog.cpp

https://commits.kde.org/kdialog/04706f321c3fb3660d9a1a8ec960229ea7ab11f9
Comment 4 David Faure 2017-06-23 21:43:00 UTC
Git commit e9a26eb0d11d9edea7e4bdb585ede494310b9be0 by David Faure.
Committed on 23/06/2017 at 21:41.
Pushed by dfaure into branch 'Applications/17.04'.

When startDir is a file, preselect it.

Works fine for local files, but not for remote dirs, unless we use StatJob.

M  +32   -3    src/kdialog.cpp

https://commits.kde.org/kdialog/e9a26eb0d11d9edea7e4bdb585ede494310b9be0
Comment 5 David Faure 2017-06-23 21:43:18 UTC
I was wondering about using QFileDialog::selectUrl rather than QFileDialog::setDirectoryUrl, but the argument is documented as [startDir], it was never supposed to be a preselected filename....

But OK, fixed, at least for local files.
Comment 6 Kai Uwe Broulik 2017-06-26 08:35:10 UTC
When I try to save an image now, it defaults to ".bin" extension for that file, instead of "webP" or "jpeg" despite the fact that chrome suggests .webp or .jpg extension.

Chrome's source code has the following code:

// Add the *.* filter, but only if we have added other filters (otherwise it
// is implied).
if (file_types_.include_all_files && !file_types_.extensions.empty())
  filter_set.insert("application/octet-stream");
// Create the final output string.
filter_string.clear();
for (std::set<std::string>::iterator it = filter_set.begin();
     it != filter_set.end(); ++it) {
  filter_string.append(*it + " ");
}

So they deliberately add it as "All files" filter. With QFileDialog I get a ComboBox with "Unknown" (selected) and "JPEG image", before the port I got an editable ComboBox with just JPEG image in it. It doesn't always have an "Unknown", though, for text/html Chrome doesn't add application/octet-stream for some reason.

Any particular reason this went into 17.04 bugfix branch and not master as file dialog stuff tends to break severly whenever someone touches it :/
Comment 7 Kai Uwe Broulik 2017-06-26 09:44:42 UTC
getopenfilename also seems to be borked, when I try to upload a patch to Phab, while it gets the name in the file input form, uploading just fails. I don't see a difference in output from getopenfilename, however. (Also, dialog size restoration is broken)
Comment 8 David Faure 2017-07-01 12:27:46 UTC
So the "unknown" (as I get with plasma-integration enabled) is expected.
The *.bin can be a bit surprising, I agree --> https://bugs.freedesktop.org/show_bug.cgi?id=101667

What's the kdialog command that's broken, for your last comment?
With the Qt or the KDE implementation?
Comment 9 Christoph Feck 2017-07-10 02:16:26 UTC
Kai, please check comment #8 and review the current state of the 17.04 branch. Does it still have regressions?
Comment 10 Kai Uwe Broulik 2017-07-10 08:20:43 UTC
I tried it with master. When I try to upload a Diff to Phabricator, Chrome just uploads forever. The commandline of the kdialog call was:

kdialog --attach=109051905 --title="Datei öffnen" --getopenfilename /home/broulik/Projekte/kf5/plasma-workspace/../plasma-desktop

I don't se anything suspicious with it besides the fact that it does not resolve the ../ path and shows that in the address bar.

Also it no longer remembers the dialog's size (the QFileDialog is *not* the actual window it opens. The same reason I cannot make QML dialogs modal to it since I cannot access the underlying platform helper window)
Comment 11 ahxcker 2017-07-18 04:13:48 UTC
Created attachment 106689 [details]
Kdialog save as filter: unknown

Same problem here.

I find 
Associations -> applications -> octet-stream

changed description's will effect kdialog filter:unkown

I don't know if this is useful or not!
Comment 12 anomaly256 2017-10-19 01:03:47 UTC
Hi, any workaround for this?
Comment 13 anomaly256 2017-10-19 01:04:57 UTC
I see it's marked as 'resolved fixed' but I seem to be hitting it still in 17.08.2
Comment 14 anomaly256 2017-10-19 01:07:11 UTC
Actually, I suspect I've only /started/ hitting it since my system upgraded from 17.04 to 17.08 of kdialog
Comment 15 Aleksey Kontsevich 2017-10-30 08:25:45 UTC
Bug still exists in latest KDE when downloading file in FF or Chromium. Why you've marked it as resolved?!
Comment 16 Aleksey Kontsevich 2017-10-30 08:29:36 UTC
I get .bin extension for all files instead of jpg, mp3, pdf, etc.
Comment 17 Patrick Silva 2017-11-03 19:59:08 UTC
report about the regression related here
https://bugs.kde.org/show_bug.cgi?id=382437
Comment 18 Aleksey Kontsevich 2017-12-21 04:11:19 UTC
Another bug here: if I download and save some file to directory named ../C#/ or ../C#/../..  it renamed to C and stored in parent ../C#/ directory.