Kirigami-addons
7import QtQuick.Controls 2.15
8import QtQuick.Layouts 1.15
10import org.kde.kirigami 2.19 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: ""
159 signal editingFinished();
181 function insert(position: int, text: string) {
182 textField.insert(position, text);
185 onActiveFocusChanged: {
187 textField.forceActiveFocus();
191 onClicked: textField.forceActiveFocus()
193 Accessible.role: Accessible.EditableText
195 contentItem: ColumnLayout {
196 spacing: Kirigami.Units.smallSpacing
198 spacing: Kirigami.Units.largeSpacing
200 Layout.fillWidth: true
202 elide: Text.ElideRight
203 color: root.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor
210 text: label(root.maximumLength, root.maximumLength)
211 font: Kirigami.Theme.smallFont
213 function label(current: int, maximum: int): string {
214 return i18nc("@label %1 is current text length, %2 is maximum length of text field
", "%1/%2
", current, maximum)
217 // 32767 is the default value for TextField.maximumLength
218 visible: root.maximumLength < 32767
219 text: metrics.label(textField.text.length, root.maximumLength)
220 font: Kirigami.Theme.smallFont
221 color: textField.text.length === root.maximumLength
222 ? Kirigami.Theme.neutralTextColor
223 : Kirigami.Theme.textColor
224 horizontalAlignment: Text.AlignRight
226 Layout.margins: Kirigami.Units.smallSpacing
227 Layout.preferredWidth: metrics.advanceWidth
230 Kirigami.PasswordField {
232 Accessible.description: label
233 Layout.fillWidth: true
234 placeholderText: root.placeholderText
236 onTextChanged: root.text = text
237 onAccepted: root.accepted()
238 onEditingFinished: root.editingFinished()
239 onTextEdited: root.textEdited()
240 activeFocusOnTab: false
243 Kirigami.InlineMessage {
245 visible: root.statusMessage.length > 0
246 Layout.topMargin: visible ? Kirigami.Units.smallSpacing : 0
247 Layout.fillWidth: true
248 text: root.statusMessage
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:46:57 by
doxygen 1.10.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.