Fix Save As feature
ClosedPublic

Authored by broulik on Nov 2 2017, 4:40 PM.

Details

Summary

The filter format demanded by QFileDialog is different from KFileDialog.
Also, the filter returned is just the filter combobox text verbatim.

Test Plan

I can now save searches as html files and txt files properly.

Diff Detail

Repository
R228 KFind
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Nov 2 2017, 4:40 PM
broulik updated this revision to Diff 21829.Nov 3 2017, 10:34 AM
  • Fix placeholder (use %1 always)
  • Remove space between label and filter so it doesn't have a trailing space in the filter dropdown

You should prefer mimetype filters, so that more extensions and magic-mimetype-determination works.
text/html and text/plain should do the job just fine, no?

For mime type filters I cannot use getSaveFileUrl, can I? I tried `text/html;;text/plain` as filter` but that doesn't work, so I probably have to create a QFileDialog myself.

broulik updated this revision to Diff 22385.Nov 15 2017, 10:32 AM
broulik added a subscriber: aacid.
  • Use mime type filters

(This requires Qt 5.9, is this safe for Applications master? @aacid )

My definition of KDE Applications is that they can have whatever dependency they want/need.

dfaure added inline comments.Nov 15 2017, 11:00 AM
src/kfindtreeview.cpp
449

Are we 100% sure that selecting a URL and then clicking Cancel will lead to selectedUrls() being empty?

I would test the return value of exec(), to be sure to handle Cancel correctly.

broulik updated this revision to Diff 22386.Nov 15 2017, 11:05 AM
  • Check exec() return value
dfaure accepted this revision.Nov 15 2017, 11:12 AM
This revision is now accepted and ready to land.Nov 15 2017, 11:12 AM
This revision was automatically updated to reflect the committed changes.