KFileDialog::selectedFile's behaviour

David Jarvie djarvie at kde.org
Thu May 28 14:28:12 BST 2009


On Wed, May 27, 2009 10:00 pm, Ingo Klöcker wrote:
> On Wednesday 27 May 2009, David Jarvie wrote:
>> On Wed, May 27, 2009 3:53 pm, Raphael Kubo da Costa wrote:
>> > 2009/5/23 Raphael Kubo da Costa <kubito at gmail.com>:
>> >> Hi there,
>> >>
>> >> When using KFileDialog with setMode(KFile::File),
>> >> setOperationMode(KFileDialog::Saving) and passing a default
>> >> mimetype to setMimeFilter, the dialog only returns a filename with
>> >> extension if the name typed in the input box doesn't correspond to
>> >> an existing file.
>> >>
>> >> So if you have foo and bar in your directory and pass
>> >> "application/x-compressed-tar" to setMimeFilter's default
>> >> parameter, entering "foobar" in the file name input box will make
>> >> selectedFile() return "/path/to/foobar.tar.gz", whereas entering
>> >> "foo" will return "/path/to/foo" and completely ignore the default
>> >> extension passed, possibly because foo already exists.
>> >>
>> >> Is this behaviour a feature or a bug? ;)
>> >
>> > Please don't consider I'm trying to make any kind of pressure here,
>> > but I can start working on a fix if it's indeed a bug.
>>
>> Having encountered this issue already, I'd say it's a bug.
>
> I suppose it's a problem of expectation. Maybe the default filename
> extension should be "appended" (in light grey) to the filename the user
> enters (similar to the automatic (?) completion mode). Then it would be
> obvious to the user what happens if he enters just "foo". The extension
> should vanish when the user enters a dot or when he explicitly requests
> its removal by pressing Delete.
>
> I noticed that very often I'm unsure whether the application will really
> append the extension. Giving visual feedback like described above would
> help me (and probably others) tremendously. Obviously, this would also
> fix the above bug (?) while on the same time making it possible to
> still get "foo" instead of "foo.tar.gz" if one does not want an
> extension.

That sounds like the best solution.

-- 
David Jarvie.
KAlarm author & maintainer.
http://www.astrojar.org.uk/kalarm





More information about the kde-core-devel mailing list