2018-08-05 10:06:57 +00:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Controls.Material 2.2
|
|
|
|
import QtQuick.Layouts 1.3
|
2018-08-24 05:25:41 +00:00
|
|
|
import Matrique.Settings 0.1
|
2018-08-05 10:06:57 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
property bool flat: false
|
|
|
|
property bool highlighted: false
|
2018-08-09 11:58:19 +00:00
|
|
|
property string displayText: ""
|
2018-08-05 10:06:57 +00:00
|
|
|
property alias timeLabelVisible: timeText.visible
|
2018-08-13 14:44:32 +00:00
|
|
|
property alias authorLabelVisible: authorText.visible
|
2018-08-05 10:06:57 +00:00
|
|
|
|
|
|
|
property int maximumWidth
|
|
|
|
|
|
|
|
readonly property bool darkBackground: highlighted && !flat
|
|
|
|
|
|
|
|
id: messageRect
|
|
|
|
|
2018-08-13 14:44:32 +00:00
|
|
|
width: Math.min(Math.max(messageText.implicitWidth, (timeText.visible ? timeText.implicitWidth : 0), (authorLabelVisible ? authorText.implicitWidth : 0)) + 24, maximumWidth)
|
|
|
|
height: (authorText.visible ? authorText.implicitHeight : 0) + messageText.implicitHeight + (timeText.visible ? timeText.implicitHeight : 0) + 24
|
2018-08-05 10:06:57 +00:00
|
|
|
|
|
|
|
color: flat ? "transparent" : highlighted ? Material.accent : background
|
|
|
|
border.color: Material.accent
|
|
|
|
border.width: flat ? 2 : 0
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: messageColumn
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 12
|
|
|
|
spacing: 0
|
|
|
|
|
2018-08-13 14:44:32 +00:00
|
|
|
Label {
|
|
|
|
id: authorText
|
|
|
|
text: author.displayName
|
|
|
|
color: darkBackground ? "white" : Material.accent
|
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
|
2018-08-05 10:06:57 +00:00
|
|
|
Label {
|
|
|
|
id: messageText
|
|
|
|
Layout.maximumWidth: parent.width
|
|
|
|
text: displayText
|
|
|
|
color: darkBackground ? "white": Material.foreground
|
|
|
|
|
|
|
|
wrapMode: Label.Wrap
|
|
|
|
linkColor: darkBackground ? "white" : Material.accent
|
2018-08-24 05:25:41 +00:00
|
|
|
textFormat: MSettings.richText ? Text.RichText : Text.StyledText
|
2018-08-05 10:06:57 +00:00
|
|
|
onLinkActivated: Qt.openUrlExternally(link)
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: timeText
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: Qt.formatTime(time, "hh:mm")
|
|
|
|
color: darkBackground ? "white" : "grey"
|
|
|
|
font.pointSize: 8
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|