83 lines
1.8 KiB
QML
83 lines
1.8 KiB
QML
|
import QtQuick 2.0
|
||
|
import QtQuick.Controls 2.9
|
||
|
import QtQuick.Controls.Material 2.0
|
||
|
|
||
|
ItemDelegate {
|
||
|
id: control
|
||
|
|
||
|
property string value: ""
|
||
|
property bool required: false
|
||
|
property color textColor: control.required && value === "" ? "red":control.Material.foreground
|
||
|
property string placeholderText: ""
|
||
|
|
||
|
onClicked: {
|
||
|
textField.text = value
|
||
|
textEditDialog.open()
|
||
|
}
|
||
|
|
||
|
Text {
|
||
|
anchors {
|
||
|
right: nextPageIconText.left
|
||
|
verticalCenter: parent.verticalCenter
|
||
|
rightMargin: control.padding
|
||
|
}
|
||
|
|
||
|
width: parent.width * 0.6
|
||
|
elide: Text.ElideRight
|
||
|
font.pixelSize: parent.font.pixelSize
|
||
|
|
||
|
horizontalAlignment: Text.AlignRight
|
||
|
|
||
|
color: control.textColor
|
||
|
|
||
|
text: value === "" ? "Not set": value + ""
|
||
|
}
|
||
|
|
||
|
Text {
|
||
|
id: nextPageIconText
|
||
|
|
||
|
anchors {
|
||
|
right: parent.right
|
||
|
verticalCenter: parent.verticalCenter
|
||
|
rightMargin: control.padding
|
||
|
}
|
||
|
|
||
|
font.pixelSize: parent.height * 0.5
|
||
|
|
||
|
verticalAlignment: Text.AlignVCenter
|
||
|
|
||
|
color: control.textColor
|
||
|
|
||
|
text: ">"
|
||
|
}
|
||
|
|
||
|
Dialog {
|
||
|
id: textEditDialog
|
||
|
parent: Overlay.overlay
|
||
|
|
||
|
x: (parent.width - width) / 2
|
||
|
y: (parent.height - height) / 2
|
||
|
|
||
|
width: parent.width * 0.9
|
||
|
|
||
|
Material.theme: control.Material.theme
|
||
|
Material.accent: control.Material.accent
|
||
|
modal: true
|
||
|
|
||
|
title: control.text
|
||
|
|
||
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
||
|
|
||
|
contentItem: TextField {
|
||
|
id: textField
|
||
|
|
||
|
placeholderText: control.placeholderText
|
||
|
text: control.value
|
||
|
}
|
||
|
|
||
|
onAccepted: {
|
||
|
control.value = textField.text
|
||
|
}
|
||
|
}
|
||
|
}
|