72 lines
2.0 KiB
QML
72 lines
2.0 KiB
QML
import QtQuick 2.5
|
|
import "../Shared"
|
|
|
|
// Champ de saisie avec libellé. Haut/Bas ne sont pas consommés par le TextInput
|
|
// et remontent donc jusqu'au KeyNavigation posé sur ce composant.
|
|
FocusScope {
|
|
id: root
|
|
|
|
property alias label: labelText.text
|
|
property alias text: input.text
|
|
property alias placeholder: placeholderText.text
|
|
property bool password: false
|
|
signal accepted()
|
|
|
|
implicitWidth: 400
|
|
implicitHeight: column.implicitHeight
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: input.forceActiveFocus()
|
|
}
|
|
|
|
Column {
|
|
id: column
|
|
width: parent.width
|
|
spacing: Theme.spacingS
|
|
|
|
Text {
|
|
id: labelText
|
|
visible: text !== ""
|
|
color: root.activeFocus ? Theme.text : Theme.textMuted
|
|
font.pixelSize: Theme.fontSmall
|
|
}
|
|
|
|
Rectangle {
|
|
width: parent.width
|
|
height: Theme.controlHeight
|
|
radius: Theme.radius
|
|
color: Theme.surface
|
|
border.width: 2
|
|
border.color: root.activeFocus ? Theme.accent : Theme.border
|
|
|
|
TextInput {
|
|
id: input
|
|
anchors {
|
|
fill: parent
|
|
leftMargin: Theme.spacingM
|
|
rightMargin: Theme.spacingM
|
|
}
|
|
focus: true
|
|
clip: true
|
|
verticalAlignment: TextInput.AlignVCenter
|
|
color: Theme.text
|
|
selectionColor: Theme.accent
|
|
font.pixelSize: Theme.fontBody
|
|
echoMode: root.password ? TextInput.Password : TextInput.Normal
|
|
onAccepted: root.accepted()
|
|
}
|
|
|
|
Text {
|
|
id: placeholderText
|
|
anchors.fill: input
|
|
visible: input.text === ""
|
|
verticalAlignment: Text.AlignVCenter
|
|
color: Theme.textMuted
|
|
font: input.font
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
}
|
|
}
|