MauiKit Controls

PasswordField.qml
1/*
2 * Copyright 2018 Camilo Higuita <milo.h@aol.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20import QtQuick
21import QtQuick.Controls
22
23/**
24 * @inherit QtQuick.Controls.TextField
25 * @brief A text field meant to enter passwords.
26 *
27 * <a href="https://doc.qt.io/qt-6/qml-qtquick-controls-textfield.html">This control inherits from QQC2 TextField, to checkout its inherited properties refer to the Qt Docs.</a>
28 *
29 * This control allows to mask the password as it is typed, and also includes a button action to toggle between unmask and masking the password.
30 *
31 * @note Some extra properties inherited from the TextField style, have been obscured, and can be discovered on the SearchField documentation.
32 * @see SearchField
33 */
34TextField
35{
36 id: control
37 echoMode: TextInput.Password
38 passwordMaskDelay: 300
39 inputMethodHints: Qt.ImhNoAutoUppercase
40
41 /**
42 * @private
43 */
44 property int previousEchoMode
45
46 icon.source: "lock"
47
48 actions: Action
49 {
50 icon.name: control.echoMode === TextInput.Normal ? "view-hidden" : "view-visible"
51 icon.color: control.color
52 onTriggered:
53 {
54 if(control.echoMode === TextInput.Normal)
55 {
56 control.echoMode = control.previousEchoMode
57 }else
58 {
59 control.echoMode = TextInput.Normal
60 }
61 }
62 }
63
64 Component.onCompleted:
65 {
66 control.previousEchoMode = control.echoMode
67 }
68}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.