2020-10-19 13:20:02 +03:00
|
|
|
/*
|
2021-01-19 02:02:37 +03:00
|
|
|
Copyright (C) 2020-21 Sebastian J. Wolf and other contributors
|
2020-10-19 13:20:02 +03:00
|
|
|
|
|
|
|
This file is part of Fernschreiber.
|
|
|
|
|
|
|
|
Fernschreiber is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Fernschreiber is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-01-19 02:02:37 +03:00
|
|
|
|
2020-10-19 13:20:02 +03:00
|
|
|
import QtQuick 2.6
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
|
2021-01-19 02:02:37 +03:00
|
|
|
import "../js/twemoji.js" as Emoji
|
|
|
|
import "../js/functions.js" as Functions
|
2020-10-19 13:20:02 +03:00
|
|
|
|
|
|
|
Column {
|
|
|
|
id: textItem
|
|
|
|
property alias headerText: headerItem.text
|
|
|
|
property string text
|
|
|
|
property bool isLinkedLabel // for telephone number
|
|
|
|
width: parent.width
|
|
|
|
visible: !!text
|
|
|
|
SectionHeader {
|
|
|
|
id: headerItem
|
|
|
|
visible: text !== "" && labelLoader.status === Loader.Ready && labelLoader.item.text !== ""
|
|
|
|
height: visible ? Theme.itemSizeSmall : 0
|
|
|
|
x: 0
|
|
|
|
}
|
|
|
|
Loader {
|
|
|
|
id: labelLoader
|
|
|
|
active: true
|
|
|
|
asynchronous: true
|
|
|
|
sourceComponent: textItem.isLinkedLabel ? linkedLabelComponent : labelComponent
|
|
|
|
width: textItem.width
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: labelComponent
|
|
|
|
Label {
|
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
2021-01-25 01:46:30 +03:00
|
|
|
font.pixelSize: Theme.fontSizeMedium
|
2020-10-19 13:20:02 +03:00
|
|
|
textFormat: Text.StyledText
|
2020-11-03 01:19:50 +03:00
|
|
|
color: Theme.primaryColor
|
2020-11-22 01:56:03 +03:00
|
|
|
text: Emoji.emojify( Functions.replaceUrlsWithLinks(textItem.text).replace(/\n/g, "<br>"), Theme.fontSizeExtraSmall)
|
2020-11-03 01:19:50 +03:00
|
|
|
linkColor: Theme.highlightColor
|
2020-10-19 13:20:02 +03:00
|
|
|
visible: text !== ""
|
|
|
|
onLinkActivated: {
|
|
|
|
Functions.handleLink(link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component {
|
|
|
|
id: linkedLabelComponent
|
|
|
|
LinkedLabel {
|
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
2020-11-03 01:19:50 +03:00
|
|
|
font.pixelSize: Theme.fontSizeSmall
|
2020-10-19 13:20:02 +03:00
|
|
|
textFormat: Text.StyledText
|
2020-11-03 01:19:50 +03:00
|
|
|
color: Theme.highlightColor
|
2020-10-19 13:20:02 +03:00
|
|
|
plainText: textItem.text
|
|
|
|
visible: textItem.text !== ""
|
|
|
|
onLinkActivated: {
|
|
|
|
Functions.handleLink(link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|