1
1
// Copyright © SixtyFPS GmbH <[email protected] >
2
2
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
3
4
- import { LineEditBase , LineEditClearIcon } from "../common/lineedit-base.slint" ;
4
+ import { LineEditBase , LineEditClearIcon , LineEditPasswordIcon } from "../common/lineedit-base.slint" ;
5
5
6
6
export component LineEdit {
7
7
in property <length > font-size <=> inner.font-size;
8
8
in property <string > placeholder-text <=> inner.placeholder-text;
9
- in property input-type <=> inner. input-type;
9
+ in property < InputType > input-type ;
10
10
in property horizontal-alignment <=> inner.horizontal-alignment;
11
11
in property read-only <=> inner.read-only;
12
12
in property <bool > enabled : true ;
@@ -68,6 +68,7 @@ export component LineEdit {
68
68
padding-bottom : native.native-padding-bottom;
69
69
70
70
inner := LineEditBase {
71
+ input-type : root .input-type;
71
72
placeholder-color : self .enabled ? NativeStyleMetrics.placeholder-color : NativeStyleMetrics.placeholder-color-disabled;
72
73
text-color : self .enabled ? NativeStyleMetrics.textedit-text-color : NativeStyleMetrics.textedit-text-color-disabled;
73
74
enabled : root .enabled;
@@ -90,5 +91,19 @@ export component LineEdit {
90
91
}
91
92
}
92
93
94
+ if root .input-type == InputType.password: LineEditPasswordIcon {
95
+ width : self .source.width * 1px ;
96
+ show-password-image : @image-url ("_visibility.svg" ) ;
97
+ hide-password-image : @image-url ("_visibility_off.svg" ) ;
98
+ colorize : inner.text-color;
99
+ height : inner.min-height;
100
+ image-fit : preserve;
101
+ show-password-changed (show) => {
102
+ inner.input-type = show ? InputType.text : root .input-type;
103
+ inner.focus ();
104
+ }
105
+ }
106
+
107
+
93
108
}
94
109
}
0 commit comments