Plasma-framework

PasswordField.qml
1// SPDX-FileCopyrightText: 2019 Carl-Lucien Schwan <carl@carlschwan.eu>
2// SPDX-License-Identifier: LGPL-2.0-or-later
3
4import QtQuick
5import QtQuick.Controls as QQC2
6import org.kde.plasma.extras as PlasmaExtras
7import org.kde.config as KConfig
8import org.kde.kirigami as Kirigami
9
10/**
11 * This is a standard password text field.
12 *
13 * Example usage for the password field component:
14 *
15 * @code{.qml}
16 * import org.kde.plasma.extras as PlasmaExtras
17 *
18 * PlasmaExtras.PasswordField {
19 * id: passwordField
20 * onAccepted: {
21 * // check if passwordField.text is valid
22 * }
23 * }
24 * @endcode
25 *
26 * @since 5.93
27 * @inherit org::kde::plasma::extras::ActionTextField
28 * @author Carl Schwan <carl@carlschwan.eu>
29 */
30PlasmaExtras.ActionTextField {
31 id: root
32
33 /**
34 * This property holds whether we show the clear text password.
35 *
36 * By default, it's false.
37 * @since 5.93
38 */
39 property bool showPassword: false
40
41 Shortcut {
42 // Let's consider this shortcut a standard, it's also supported at least by su and sudo
43 sequence: "Ctrl+Shift+U"
44 enabled: root.activeFocus
45 onActivated: root.clear();
46 }
47
48 echoMode: root.showPassword ? TextInput.Normal : TextInput.Password
49 placeholderText: i18nd("libplasma6", "Password")
50 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText | Qt.ImhSensitiveData
51
52 rightActions: Kirigami.Action {
53 enabled: KConfig.KAuthorized.authorize("lineedit_reveal_password")
54 visible: enabled
55 icon.name: root.showPassword ? "password-show-off" : "password-show-on"
56 onTriggered: root.showPassword = !root.showPassword
57 }
58
59 Keys.onPressed: event => {
60 if (event.matches(StandardKey.Undo)) {
61 // Disable undo action for security reasons
62 // See QTBUG-103934
63 event.accepted = true
64 }
65 }
66}
QString name() const
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:54:11 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.