Password visibility in KPasswordDialog
With the upcoming 5.14 release of the KDE Frameworks, KPasswordDialog
gets the ability to change the visibility of the password being typed by the user. This is a common and useful feature, especially when the password is hard to type and error prone. Screenshots follow:
If you use a KPasswordDialog
in your application, you will get this feature for free and none of the existing code has to be updated.
The two eye-shaped icons have been recently added to the Breeze theme, so they will only be available starting from Plasma 5.5. However, for Plasma 5.4 and earlier versions, the KWidgetAddons
framework will fallback to the very same icons, hardcoded through the QRC system. This will also make them available on non-Plasma systems where Breeze is not installed at all. The only drawback is that those icons will not be themeable anymore.
The visibility feature is automatically hidden if you manually set a password using KPasswordDialog::setPassword()
. This prevents possible leaks because the user might not be supposed to know the password, but only to use it.
If for some reason you don’t preset a password buy you do want to disable this feature, just call setPassword()
with an empty string as argument.