[KNewFileMenu] Add extension to proposed filename

Authored by ahmadsamir on Thu, Mar 26, 11:09 AM.



Using "create new" text or html file, add the extension to the proposed
filename, this makes those plain text files work for other OS's e.g.
Windows (with Linux plain text files (.txt) don't usually have a extension
relying on mimetype detection); as for but HTML filenames they do have
extensions even on Linux.

Adapt the knewfilemenutest to the changes.

BUG: 61669

Test Plan

make && ctest; and using the create name text/html file menu in dolphin

Diff Detail

R241 KIO
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
ahmadsamir created this revision.Thu, Mar 26, 11:09 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptThu, Mar 26, 11:09 AM
ahmadsamir requested review of this revision.Thu, Mar 26, 11:09 AM
dfaure requested changes to this revision.Sat, Mar 28, 9:49 AM

Thanks for all your work, I'm impressed!


typo: extenstion -> extension


The old code was using a translated string as suggested file name.
You're using a filename that it going to be always in English.

How about appending the extension from templatePath to the translated text?

This revision now requires changes to proceed.Sat, Mar 28, 9:49 AM
  • Change it as suggested by dfaure to use the translated text from Name= entry
  • Fix typos
dfaure added inline comments.Sat, Mar 28, 11:22 AM

"use the translation" is done before that comment, so it's a bit of a confusing place for it.


text += fileName.midRef(....);

This also assumes all those files always have an extension.... mid(-1) returns the whole string.
Since users can create additional templates, maybe this is worth a >=0 check?

ahmadsamir updated this revision to Diff 78731.Sat, Mar 28, 3:16 PM
ahmadsamir edited the summary of this revision. (Show Details)
  • Fix unit test
  • Handle the case that a templatePath is a file with no extension
dfaure accepted this revision.Sat, Mar 28, 4:49 PM
This revision is now accepted and ready to land.Sat, Mar 28, 4:49 PM
This revision was automatically updated to reflect the committed changes.