Kirigami2

PasswordField.qml
1 /*
2  * SPDX-FileCopyrightText: 2019 Carl-Lucien Schwan <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.15
8 import org.kde.kirigami 2.20 as Kirigami
9 
10 /**
11  * @brief This is a standard password text field.
12  *
13  * Example usage:
14  * @code{.qml}
15  * import org.kde.kirigami 2.20 as Kirigami
16  *
17  * Kirigami.PasswordField {
18  * id: passwordField
19  * onAccepted: {
20  * // check if passwordField.text is valid
21  * }
22  * }
23  * @endcode
24  *
25  * @inherit org::kde::kirgami::ActionTextField
26  * @since 5.57
27  * @author Carl Schwan <[email protected]>
28  */
29 Kirigami.ActionTextField {
30  id: root
31 
32  /**
33  * @brief This property tells whether the password will be displayed in cleartext rather than obfuscated.
34  *
35  * default: ``false``
36  *
37  * @since 5.57
38  */
39  property bool showPassword: false
40 
41  echoMode: root.showPassword ? TextInput.Normal : TextInput.Password
42  placeholderText: qsTr("Password")
43  inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText | Qt.ImhSensitiveData
44  rightActions: Kirigami.Action {
45  text: root.showPassword ? i18n("Hide Password") : i18n("Show Password")
46  icon.name: root.showPassword ? "password-show-off" : "password-show-on"
47  onTriggered: root.showPassword = !root.showPassword
48  }
49 
50  Keys.onPressed: event => {
51  if (event.matches(StandardKey.Undo)) {
52  // Disable undo action for security reasons
53  // See QTBUG-103934
54  event.accepted = true
55  }
56  }
57 }
QString i18n(const char *text, const TYPE &arg...)
An item that represents an abstract Action.
Definition: Action.qml:14
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:14:23 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.