mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 03:18:07 +00:00
82 lines
2.1 KiB
QML
82 lines
2.1 KiB
QML
import QtQuick
|
|
import QtQuick.Controls.Basic as Control
|
|
import QtQuick.Layouts
|
|
import Linphone
|
|
import UtilsCpp
|
|
|
|
TextEdit {
|
|
id: mainItem
|
|
|
|
property string placeholderText
|
|
property real placeholderPixelSize: Typography.p1.pixelSize
|
|
property real placeholderWeight: Typography.p1.weight
|
|
property color placeholderTextColor: color
|
|
property alias background: background.data
|
|
property bool hoverEnabled: true
|
|
property bool hovered: mouseArea.hoverEnabled && mouseArea.containsMouse
|
|
topPadding: Math.round(5 * DefaultStyle.dp)
|
|
bottomPadding: Math.round(5 * DefaultStyle.dp)
|
|
activeFocusOnTab: true
|
|
|
|
property bool displayAsRichText: false
|
|
property string richFormatText: UtilsCpp.encodeTextToQmlRichFormat(text)
|
|
property color textAreaColor
|
|
|
|
|
|
Component.onCompleted: {
|
|
mainItem.textAreaColor = mainItem.color // backup original color
|
|
if (displayAsRichText)
|
|
mainItem.color = 'transparent'
|
|
}
|
|
|
|
onTextChanged: {
|
|
richFormatText = UtilsCpp.encodeTextToQmlRichFormat(text)
|
|
}
|
|
|
|
MouseArea {
|
|
id: mouseArea
|
|
anchors.fill: parent
|
|
enabled: mainItem.hoverEnabled
|
|
hoverEnabled: mainItem.hoverEnabled
|
|
acceptedButtons: Qt.NoButton
|
|
cursorShape: mainItem.hovered ? Qt.IBeamCursor : Qt.ArrowCursor
|
|
}
|
|
|
|
Item {
|
|
id: background
|
|
anchors.fill: parent
|
|
z: -1
|
|
}
|
|
|
|
Text {
|
|
anchors.verticalCenter: mainItem.verticalCenter
|
|
text: mainItem.placeholderText
|
|
color: mainItem.placeholderTextColor
|
|
visible: mainItem.text.length == 0 && !mainItem.activeFocus
|
|
x: mainItem.leftPadding
|
|
font {
|
|
pixelSize: mainItem.placeholderPixelSize
|
|
weight: mainItem.placeholderWeight
|
|
}
|
|
}
|
|
Text {
|
|
id: formattedText
|
|
visible: mainItem.displayAsRichText && mainItem.richFormatText !== ""
|
|
text: mainItem.richFormatText
|
|
textFormat: Text.RichText
|
|
wrapMode: mainItem.wrapMode
|
|
font: mainItem.font
|
|
color: mainItem.textAreaColor
|
|
anchors.fill: parent
|
|
focus: false
|
|
onHoveredLinkChanged: {
|
|
mainItem.hovered = mainItem.displayAsRichText && hoveredLink !== ""
|
|
}
|
|
onLinkActivated: {
|
|
if (link.startsWith('sip'))
|
|
UtilsCpp.createCall(link)
|
|
else
|
|
Qt.openUrlExternally(link)
|
|
}
|
|
}
|
|
}
|