Changeset View
Changeset View
Standalone View
Standalone View
src/declarativeimports/plasmacomponents/qml/TextField.qml
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 31 | QtControls.TextField { | |||
---|---|---|---|---|---|
43 | * This only makes sense if the echoMode is set to Password. | 43 | * This only makes sense if the echoMode is set to Password. | ||
44 | * @since 5.26 | 44 | * @since 5.26 | ||
45 | */ | 45 | */ | ||
46 | property bool revealPasswordButtonShown: false | 46 | property bool revealPasswordButtonShown: false | ||
47 | 47 | | |||
48 | // this takes into account kiosk restriction | 48 | // this takes into account kiosk restriction | ||
49 | readonly property bool __effectiveRevealPasswordButtonShown: revealPasswordButtonShown | 49 | readonly property bool __effectiveRevealPasswordButtonShown: revealPasswordButtonShown | ||
50 | && KAuthorized.authorize("lineedit_reveal_password") | 50 | && KAuthorized.authorize("lineedit_reveal_password") | ||
51 | && textField.length > 0 | ||||
51 | 52 | | |||
52 | //Deprecated/unsupported api | 53 | //Deprecated/unsupported api | ||
53 | /** | 54 | /** | ||
54 | * type: string | 55 | * type: string | ||
55 | * | 56 | * | ||
56 | * Allows to set a custom character for password fields | 57 | * Allows to set a custom character for password fields | ||
57 | * @warning Not implemented in Plasma components. | 58 | * @warning Not implemented in Plasma components. | ||
58 | */ | 59 | */ | ||
Show All 28 Lines | 87 | Row { | |||
87 | anchors { | 88 | anchors { | ||
88 | right: textField.right | 89 | right: textField.right | ||
89 | rightMargin: 6 | 90 | rightMargin: 6 | ||
90 | verticalCenter: textField.verticalCenter | 91 | verticalCenter: textField.verticalCenter | ||
91 | } | 92 | } | ||
92 | 93 | | |||
93 | PlasmaCore.IconItem { | 94 | PlasmaCore.IconItem { | ||
94 | id: showPasswordButton | 95 | id: showPasswordButton | ||
95 | source: __effectiveRevealPasswordButtonShown ? (textField.echoMode === TextInput.Normal ? "hint" : "visibility") : "" | 96 | source: __effectiveRevealPasswordButtonShown ? (textField.echoMode === TextInput.Normal ? "visibility": "hint") : "" | ||
96 | height: Math.max(textField.height * 0.8, units.iconSizes.small) | 97 | height: Math.max(textField.height * 0.8, units.iconSizes.small) | ||
97 | width: height | 98 | width: height | ||
98 | opacity: (__effectiveRevealPasswordButtonShown && textField.enabled) ? 1 : 0 | 99 | opacity: (__effectiveRevealPasswordButtonShown && textField.enabled) ? 1 : 0 | ||
99 | visible: opacity > 0 | 100 | visible: opacity > 0 | ||
100 | Behavior on opacity { | 101 | Behavior on opacity { | ||
101 | NumberAnimation { | 102 | NumberAnimation { | ||
102 | duration: units.longDuration | 103 | duration: units.longDuration | ||
103 | easing.type: Easing.InOutQuad | 104 | easing.type: Easing.InOutQuad | ||
104 | } | 105 | } | ||
105 | } | 106 | } | ||
106 | MouseArea { | 107 | MouseArea { | ||
107 | anchors.fill: parent | 108 | anchors.fill: parent | ||
109 | enabled: __effectiveRevealPasswordButtonShown | ||||
108 | onClicked: { | 110 | onClicked: { | ||
109 | textField.echoMode = (textField.echoMode == TextInput.Normal ? TextInput.Password : TextInput.Normal) | 111 | textField.echoMode = (textField.echoMode == TextInput.Normal ? TextInput.Password : TextInput.Normal) | ||
110 | textField.forceActiveFocus() | 112 | textField.forceActiveFocus() | ||
111 | } | 113 | } | ||
112 | } | 114 | } | ||
113 | } | 115 | } | ||
114 | 116 | | |||
115 | PlasmaCore.IconItem { | 117 | PlasmaCore.IconItem { | ||
Show All 14 Lines | 131 | MouseArea { | |||
130 | anchors.fill: parent | 132 | anchors.fill: parent | ||
131 | onClicked: { | 133 | onClicked: { | ||
132 | textField.text = "" | 134 | textField.text = "" | ||
133 | textField.forceActiveFocus() | 135 | textField.forceActiveFocus() | ||
134 | } | 136 | } | ||
135 | } | 137 | } | ||
136 | } | 138 | } | ||
137 | } | 139 | } | ||
140 | | ||||
141 | on__EffectiveRevealPasswordButtonShownChanged: { | ||||
142 | if (revealPasswordButtonShown && length === 0) { | ||||
143 | textField.echoMode = TextInput.Password | ||||
144 | } | ||||
145 | } | ||||
138 | } | 146 | } |