Skip to content

KFileWidget: use a QDialogButtonBox for the accept and reject buttons

Currently the file widget uses a rather dated and nonstandard arrangement of buttons with the OK and Cancel buttons arranged vertically, to the right of the filename and filter text fields.

However, these buttons are hidden by default, and the dialog that includes a KFileWidget is responsible for showing them. In plasma-integration where the dialog is constructed, the buttons are actually not shown; instead they are used to populate a new QDialogButtonBox widget which is then injected into the dialog under everything else.

This is done to give the file dialog a standard arrangement of buttons that respects the platform's button ordering settings. But doing it in plasma-integration makes the dialog a mishmash of UI elements from multiple places, overcomplicating the implementation in general and tab focus handling in particular.

We can improve this situation by uplifting the nicer and more standard QDialogButtonBox-based UI into kfilewidget itself without breaking backwards-compatibility with anything. There are no visual or functional changes to the open/save dialogs run through plasma-integration with this commit, so it it safely backportable to KF5.

As a result of this change, a few setTabFocus() function calls become either unnecessary or harmful, and are deleted. Tab focus in general is still not ideal, and will be improved in follow-up commits building on this work.

cc @sitter for historical knowledge about why we do it this way because maybe I'm barking up the wrong tree.

Merge request reports

Loading