Warning, /frameworks/kirigami/src/controls/PasswordField.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *  SPDX-FileCopyrightText: 2019 Carl-Lucien Schwan <carl@carlschwan.eu>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick 2.15
0008 import org.kde.kirigami 2.20 as Kirigami
0009 
0010 /**
0011  * @brief This is a standard password text field.
0012  *
0013  * Example usage:
0014  * @code{.qml}
0015  * import org.kde.kirigami 2.20 as Kirigami
0016  *
0017  * Kirigami.PasswordField {
0018  *     id: passwordField
0019  *     onAccepted: {
0020  *         // check if passwordField.text is valid
0021  *     }
0022  * }
0023  * @endcode
0024  * @author Carl Schwan <carl@carlschwan.eu>
0025  * @since KDE Frameworks 5.57
0026  * @inherit kirigami::ActionTextField
0027  */
0028 Kirigami.ActionTextField {
0029     id: root
0030 
0031     /**
0032      * @brief This property specifies whether the password will be displayed in cleartext rather than obfuscated.
0033      *
0034      * default: ``false``
0035      *
0036      * @since KDE Frameworks 5.57
0037      */
0038     property bool showPassword: false
0039 
0040     echoMode: root.showPassword ? TextInput.Normal : TextInput.Password
0041     placeholderText: qsTr("Password")
0042     inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText | Qt.ImhSensitiveData
0043     rightActions: Kirigami.Action {
0044         text: root.showPassword ? qsTr("Hide Password") : qsTr("Show Password")
0045         icon.name: root.showPassword ? "password-show-off" : "password-show-on"
0046         onTriggered: root.showPassword = !root.showPassword
0047     }
0048 
0049     Keys.onPressed: event => {
0050         if (event.matches(StandardKey.Undo)) {
0051             // Disable undo action for security reasons
0052             // See QTBUG-103934
0053             event.accepted = true
0054         }
0055     }
0056 }