A new widget called
KNewPasswordWidget has been added to the KWidgetsAddons framework, starting from 5.16. I decided to create this widget because sometimes you cannot just use
KNewPasswordDialog to ask the users for a new password. This is the case when you need to add further options to the same dialog. This widget is meant to be easily embedded in such a custom password dialog, without having to code it from scratch. You get for free:
- Password and verification input fields
- Action to toggle the password visibility
- Strength meter bar (which you can hide)
- A signal to connect to, in order to update the dialog stuff (e.g. enabling/disabling the OK button).
You can also set a background “warning” color, displayed when the verification password does not match (feature borrowed from KeePass).
So the following is a custom password dialog with a
KNewPasswordWidget and a couple of checkboxes:
Code sample is available in the doxygen documentation of the widget.