Review Request: Fix keyboard navigation into folders in KFileDialog

Will Stephenson wstephenson at
Mon Mar 29 18:05:34 BST 2010

This is an automatically generated e-mail. To reply, visit:

(Updated 2010-03-29 17:05:34.481519)

Review request for kdelibs, Andreas Pakulat and Rafael Fernández López.


Add more testing done.


This patch solves the problem that the Enter/Return keys cannot be used when saving files to navigate into a folder in KFileDialog.  What happens is that the navigation in KDirOperator works, but the key event is also caught by the KFileDialog itself and passed to KDialog, oking the dialog.  Cursoring over a file in the KDirOperator populates the location widget, so a filename is provided and the dialog is valid.

This patch consumes the Enter/Return key event in a new KDirOperator::keyPressEvent(QKeyEvent*).  This change should be sufficient to solve the problem, but past changes to the code have made the control flow complex and different when loading and when saving files.  Without the Enter/Return key press event reaching KDialog, the user cannot save a file by selecting it and pressing Enter.

This is for 2 reasons: 

1) r891277 by ereslibre in KFileWidget::_k_fileSelected() prevents the KDirOperator::fileSelected() signal from invoking slotOk(), to "give the user a chance to amend the filename after selecting a file".

2) r895027 by ereslibre suppresses the KDirOperator::fileSelected() signal from being emitted when the isSaving flag is set on KDirOperator, when an item is activated, in order to respect KDE's double-click/single-click activate policy.  This is redundant because QAbstractItemView::activated() is controlled by KStyle according to KDE click policy ( 

Since the behaviour change in 2) to KDirOperator::fileSelected() was masked by the propagated Enter/Return, is redundant for its goal, and was undocumented, the patch removes it.

The additional chance to amend the filename behaviour is inconsistent with single click policy and gives different behaviour in between load and save mode, but is useful since no select/deselect buttons appear on hover in KDirOperator's views yet, so I have kept that and improved it by focusing the location widget after a file item is activated.

This addresses bug 205781.


  trunk/KDE/kdelibs/kfile/kdiroperator.h 1107918 
  trunk/KDE/kdelibs/kfile/kdiroperator.cpp 1107918 
  trunk/KDE/kdelibs/kfile/kfilewidget.cpp 1107918 


Testing (updated)

kfiledialogtest run with single click mouse, double click mouse, and keyboard navigation

make test in kdelibs/kfile and kdelibs/kio/kfile

Reviewed KDE SVN in for users of KDirOperator that expect Enter/Return keyPressEvents from KDirOperator or that listen to fileSelected after setIsSaving(true) - there are none.



More information about the kde-core-devel mailing list