| 1 |
import QtQuick 2.4 |
| 2 |
import FlightGear.Launcher 1.0 |
| 3 |
import FlightGear 1.0 |
| 4 |
|
| 5 |
Rectangle { |
| 6 |
id: editFrame |
| 7 |
|
| 8 |
property bool enabled: true |
| 9 |
property alias placeholder: placeholderText.text |
| 10 |
property alias text: edit.text |
| 11 |
|
| 12 |
implicitHeight: edit.height + Style.margin |
| 13 |
border.color: edit.activeFocus ? Style.frameColor : Style.minorFrameColor |
| 14 |
border.width: 1 |
| 15 |
color: Style.panelBackground |
| 16 |
|
| 17 |
signal editingFinished(); |
| 18 |
|
| 19 |
TextEdit { |
| 20 |
id: edit |
| 21 |
enabled: editFrame.enabled |
| 22 |
anchors.verticalCenter: parent.verticalCenter |
| 23 |
anchors.left: parent.left |
| 24 |
anchors.right: parent.right |
| 25 |
anchors.margins: Style.margin |
| 26 |
height: Math.max(Style.strutSize * 2, implicitHeight) |
| 27 |
textFormat: TextEdit.PlainText |
| 28 |
font.family: "Courier" |
| 29 |
selectByMouse: true |
| 30 |
wrapMode: TextEdit.WordWrap |
| 31 |
font.pixelSize: Style.baseFontPixelSize |
| 32 |
color: Style.baseTextColor |
| 33 |
|
| 34 |
StyledText { |
| 35 |
id: placeholderText |
| 36 |
visible: (edit.text.length == 0) && !edit.activeFocus |
| 37 |
font.family: "Courier" |
| 38 |
color: Style.disabledTextColor |
| 39 |
} |
| 40 |
|
| 41 |
onActiveFocusChanged: { |
| 42 |
if (!activeFocus) { |
| 43 |
editFrame.editingFinished() |
| 44 |
} |
| 45 |
} |
| 46 |
} |
| 47 |
} |