2021-06-14 19:09:53 +02:00
|
|
|
// SPDX-License-Identifier: Unlicense
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: control
|
|
|
|
|
2021-09-01 17:13:51 +02:00
|
|
|
property var model
|
2021-06-14 19:09:53 +02:00
|
|
|
property alias value: control.text
|
|
|
|
|
|
|
|
Keys.onPressed: {
|
2021-09-01 17:13:51 +02:00
|
|
|
if (event.text === model.key) {
|
2021-06-14 19:09:53 +02:00
|
|
|
popup.open()
|
|
|
|
event.accepted = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function set(val) { value = val || '' }
|
|
|
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
|
|
|
Popup {
|
|
|
|
id: popup
|
|
|
|
|
2021-09-01 17:13:51 +02:00
|
|
|
width: parent.width
|
2021-06-14 19:09:53 +02:00
|
|
|
padding: 0
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
input.text = value
|
|
|
|
input.forceActiveFocus()
|
|
|
|
}
|
|
|
|
|
|
|
|
TextInput {
|
|
|
|
id: input
|
|
|
|
|
2021-09-05 16:23:41 +02:00
|
|
|
anchors { fill: parent; leftMargin: 2; rightMargin: 2 }
|
|
|
|
padding: 0
|
2021-06-14 19:09:53 +02:00
|
|
|
clip: true
|
|
|
|
|
|
|
|
onAccepted: {
|
|
|
|
value = input.text.trim()
|
|
|
|
popup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|