Cura/resources/qml/Preferences/ReadOnlyTextArea.qml
Arjen Hiemstra 898c621b6f Recreate editingFinished signal behaviour without using TextArea::editingFinished
Apparently, editingFinished was only added in Qt 5.6, so we cannot use
it. So we have to manually recreate the behaviour.

Contributes to CURA-342
2016-07-11 11:36:21 +02:00

62 lines
1.1 KiB
QML

// Copyright (c) 2016 Ultimaker B.V.
// Uranium is released under the terms of the AGPLv3 or higher.
import QtQuick 2.1
import QtQuick.Controls 1.1
Item
{
id: base
property alias text: textArea.text
property alias wrapMode: textArea.wrapMode
signal editingFinished();
property bool readOnly: false
width: textArea.width
height: textArea.height
TextArea
{
id: textArea
enabled: !base.readOnly
opacity: base.readOnly ? 0.5 : 1.0
anchors.fill: parent
Keys.onReturnPressed:
{
base.editingFinished()
}
Keys.onEnterPressed:
{
base.editingFinished()
}
onActiveFocusChanged:
{
if(!activeFocus)
{
base.editingFinished()
}
}
}
Label
{
visible: base.readOnly
text: textArea.text
anchors.fill: parent
anchors.margins: textArea.__style ? textArea.__style.textMargin : 4
color: palette.buttonText
}
SystemPalette { id: palette }
}