Kirigami-addons
10import org.kde.kirigami as Kirigami
53 required property string label
58 property alias maximumLength: textField.maximumLength
63 property alias fieldActiveFocus: textField.activeFocus
68 property alias readOnly: textField.readOnly
78 property alias echoMode: textField.echoMode
90 property alias inputMethodHints: textField.inputMethodHints
99 property alias placeholderText: textField.placeholderText
104 property alias validator: textField.validator
109 property alias acceptableInput: textField.acceptableInput
131 property var status: Kirigami.MessageType.Information
139 property string statusMessage: ""
147 property bool showPasswordQuality: false
167 signal editingFinished();
182 function clear(): void {
189 function insert(position: int, text: string): void {
190 textField.insert(position, text);
197 function selectAll(): void {
198 textField.selectAll();
205 function select(start: int, end: int): void {
206 textField.select(start, end);
209 onActiveFocusChanged: {
211 textField.forceActiveFocus();
215 onClicked: textField.forceActiveFocus()
217 Accessible.role: Accessible.EditableText
219 contentItem: ColumnLayout {
220 spacing: Kirigami.Units.smallSpacing
222 spacing: Kirigami.Units.largeSpacing
224 Layout.fillWidth: true
226 elide: Text.ElideRight
227 color: root.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
234 text: label(root.maximumLength, root.maximumLength)
235 font: Kirigami.Theme.smallFont
237 function label(current: int, maximum: int): string {
238 return i18ndc("kirigami-addons6
", "@
label %1 is current text length, %2 is maximum length of text field
", "%1/%2
", current, maximum)
241 // 32767 is the default value for TextField.maximumLength
242 visible: root.maximumLength < 32767
243 text: metrics.label(textField.text.length, root.maximumLength)
244 font: Kirigami.Theme.smallFont
245 color: textField.text.length === root.maximumLength
246 ? Kirigami.Theme.neutralTextColor
247 : Kirigami.Theme.textColor
248 horizontalAlignment: Text.AlignRight
250 Layout.margins: Kirigami.Units.smallSpacing
251 Layout.preferredWidth: metrics.advanceWidth
255 Kirigami.PasswordField {
257 Accessible.description: label
258 Layout.fillWidth: true
259 placeholderText: root.placeholderText
261 onTextChanged: root.text = text
262 onAccepted: root.accepted()
263 onEditingFinished: root.editingFinished()
264 onTextEdited: root.textEdited()
265 activeFocusOnTab: false
269 active: root.showPasswordQuality
270 Layout.fillWidth: true
271 sourceComponent: RowLayout {
276 password: textField.text
285 required property int index
287 height: Kirigami.Units.smallSpacing
291 color: switch (passwordHealth.quality) {
292 case PasswordHealth.Bad:
293 case PasswordHealth.Poor:
294 return Kirigami.Theme.negativeBackgroundColor;
295 case PasswordHealth.Weak:
296 return Kirigami.Theme.neutralBackgroundColor;
297 case PasswordHealth.Good:
298 case PasswordHealth.Excellent:
299 return Kirigami.Theme.positiveBackgroundColor;
302 Layout.fillWidth: true
305 height: Kirigami.Units.smallSpacing
307 const entropy = Math.min(passwordHealth.entropy, 200);
308 if (entropy > (index + 1) * 50) {
310 } else if (entropy < (index) * 50) {
313 const percent = entropy / 200;
314 return Math.max(0, parent.width * (percent * 4 - index))
319 color: switch (passwordHealth.quality) {
320 case PasswordHealth.Bad:
321 case PasswordHealth.Poor:
322 return Kirigami.Theme.negativeTextColor;
323 case PasswordHealth.Weak:
324 return Kirigami.Theme.neutralTextColor;
325 case PasswordHealth.Good:
326 case PasswordHealth.Excellent:
327 return Kirigami.Theme.positiveTextColor;
335 Kirigami.InlineMessage {
337 visible: root.statusMessage.length > 0
338 Layout.topMargin: visible ? Kirigami.Units.smallSpacing : 0
339 Layout.fillWidth: true
340 text: root.statusMessage
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Feb 21 2025 11:53:19 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.